:root {
  --bg: #10141c;
  --bg-2: #1b2230;
  --ink: #f3eee6;
  --muted: #b7ad9f;
  --line: rgba(243, 238, 230, 0.14);
  --copper: #e0924a;
  --copper-ink: #2a1608;
  --teal: #8fd8c8;
  --danger: #ffb4a8;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f4efe6;
  --bg-2: #fffaf3;
  --ink: #1d1914;
  --muted: #5c5348;
  --line: rgba(29, 25, 20, 0.12);
  --copper: #b8611a;
  --copper-ink: #fff8f1;
  --teal: #0e6b5e;
  --danger: #8d2f24;
  --shadow: 0 12px 30px rgba(40, 24, 8, 0.08);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(224, 146, 74, 0.16), transparent 50%),
    var(--bg);
  color: var(--ink);
  font: 16px/1.45 "Segoe UI", system-ui, sans-serif;
}
main { flex: 1; }
a { color: var(--teal); }
img { max-width: 100%; }
h1, h2 { font-family: Georgia, "Iowan Old Style", Palatino, serif; font-weight: 500; letter-spacing: -0.03em; }
h1 { font-size: clamp(2rem, 6vw, 3.6rem); line-height: 0.95; margin: 0 0 12px; }
.top, .foot { display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 14px 18px; }
.top { border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 20; }
.nav { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.nav a { color: var(--ink); text-decoration: none; }
.logo { color: var(--ink); text-decoration: none; font-family: Georgia, serif; font-size: 1.3rem; }
.logo span { color: var(--copper); }
.foot { color: var(--muted); flex-wrap: wrap; }
.hero, .narrow, .panel { width: min(920px, calc(100% - 28px)); margin: 28px auto; }
.lead { font-size: 1.15rem; }
.muted { color: var(--muted); }
.kicker { color: var(--copper); letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.78rem; }
.actions, .filters, .coords { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.btn, button.theme {
  border: 0; border-radius: 999px; padding: 11px 16px; background: var(--copper); color: var(--copper-ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block;
}
.btn.ghost, button.theme { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn:disabled { background: #4c4338; color: #c8bfb2; cursor: not-allowed; }
.stack { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
input, select, textarea {
  background: var(--bg-2); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit;
}
.check { flex-direction: row; align-items: center; color: var(--ink); }
.warn { color: var(--danger); }
.flash { margin: 12px 18px; padding: 10px 12px; border-radius: 10px; background: var(--bg-2); }
.flash-bad { color: var(--danger); }
.copper { color: var(--copper); }
.panel, .dock, .narrow form, .stats article {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 16px;
}
.leaders, .plain, .recap { list-style: none; padding: 0; margin: 0; }
.leaders li, .recap li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.recap img, .thumb { width: 72px; height: 48px; object-fit: cover; border-radius: 8px; background: #000; }
.preview { width: min(100%, 420px); border-radius: 12px; }
.board { display: grid; gap: 12px; padding: 12px; }
.shot { margin: 0; min-height: 240px; height: 42vh; background: #07080c; border-radius: 16px; overflow: hidden; position: relative; display: grid; }
.shot img { width: 100%; height: 100%; object-fit: contain; }
.overlay { position: absolute; right: 8px; bottom: 8px; }
.map-wrap { position: relative; height: 260px; min-width: 0; border-radius: 12px; overflow: hidden; background: #9ecceb; }
.map-wrap.lg { height: 70vh; }
#map, #pick-map { position: relative; width: 100%; min-width: 0; }
#map { height: 100%; min-height: 240px; }
#map .ol-viewport,
#pick-map .ol-viewport {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
}
#map canvas,
#pick-map canvas,
.ol-viewport img { max-width: none !important; max-height: none !important; }
.admin-main { min-width: 0; max-width: 100%; }
/* Wide screen: fields left, map right. Narrow: one column, fields then map. */
form#photo-form.photo-layout {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  gap: 20px !important;
  align-items: start !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
}
form#photo-form .photo-fields,
form#photo-form .photo-map {
  min-width: 0 !important;
  max-width: none !important;
  width: auto !important;
}
form#photo-form .photo-fields { overflow: hidden; }
form#photo-form .photo-fields input,
form#photo-form .photo-fields select,
form#photo-form .photo-fields textarea { width: 100%; max-width: 100%; min-width: 0; }
form#photo-form .photo-fields .coords label { flex: 1 1 8rem; min-width: 0; }
form#photo-form .photo-fields .actions { width: 100%; min-width: 0; }
form#photo-form .photo-fields .actions input { flex: 1 1 8rem; min-width: 0; }
form#photo-form .photo-map { position: sticky; top: 12px; }
form#photo-form #pick-map {
  display: block;
  width: 100% !important;
  height: calc(100vh - 140px) !important;
  min-height: 480px !important;
  border-radius: 12px;
  overflow: hidden;
  background: #9ecceb;
}
.hud, .year-row, .split-line { display: flex; justify-content: space-between; gap: 8px; }
.hud { flex-wrap: wrap; }
.year-row output { font-family: Georgia, serif; font-size: 2rem; color: var(--ink); }
.hint { min-height: 2.6em; color: var(--muted); }
.squares { font-size: 1.4rem; letter-spacing: 0.12em; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stats strong { display: block; font-size: 1.8rem; }
.bars { display: flex; gap: 8px; align-items: end; height: 110px; }
.bar { width: 18px; background: var(--copper); border-radius: 6px 6px 0 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.bad { outline: 1px solid var(--danger); }
.calendar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.day { width: 64px; min-height: 48px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--ink); padding: 4px; display: flex; flex-direction: column; }
.day.on { border-color: var(--copper); }
.pin { background: transparent; border: 0; }
.pin i { display: block; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #1a140c; box-shadow: var(--shadow); }
.admin { display: grid; grid-template-columns: 200px minmax(0, 1fr); width: 100%; max-width: 100%; min-height: 100vh; }
.side { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-right: 1px solid var(--line); min-width: 0; }
.side a { color: var(--ink); text-decoration: none; }
.admin-main { padding: 16px; }
@media (min-width: 900px) {
  .board { grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.9fr); align-items: start; }
  .shot { height: calc(100vh - 120px); min-height: 420px; }
  .map-wrap { height: 300px; }
}
@media (max-width: 800px) {
  .admin { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
  .top { align-items: flex-start; }
}
@media (max-width: 420px) {
  .nav a:not(:nth-child(-n+3)) { font-size: 0.92rem; }
  .shot { height: 38vh; }
}
.wide { width: min(1100px, calc(100% - 28px)); margin: 28px auto; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 18px; }
.choice-grid form { display: flex; }
.choice, button.choice {
  display: flex; flex-direction: column; gap: 8px; align-items: flex-start; text-align: left;
  background: var(--bg-2); color: var(--ink); border: 1px solid var(--line); border-radius: 18px;
  padding: 22px; text-decoration: none; min-height: 150px; width: 100%; font: inherit; cursor: pointer;
}
.choice strong { font-family: Georgia, serif; font-size: 1.7rem; font-weight: 500; color: var(--ink); }
.choice span { color: var(--muted); }
.choice:hover, button.choice:hover { border-color: var(--copper); }
.row-head, .friend-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.gcard { background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.gcard h2 { font-size: 1.35rem; margin: 8px 0; }
.gcard-link { color: var(--ink); text-decoration: none; display: block; }
.gcard.is-closed { opacity: 0.62; border-style: dashed; }
.gcard.is-closed h2, .gcard.is-closed p { color: var(--muted); }
.gcover { width: 100%; aspect-ratio: 16/10; object-fit: cover; border-radius: 12px; background: #07080c; display: block; }
.gcover.tall { aspect-ratio: 16/9; margin-bottom: 12px; }
.gcover.blank { min-height: 120px; }
.badge { display: inline-block; border: 1px solid var(--copper); color: var(--copper); border-radius: 999px; padding: 2px 10px; }
.code-line strong { font-family: ui-monospace, monospace; letter-spacing: 0.08em; }
.created-line { color: var(--copper); letter-spacing: 0.08em; font-size: 0.95rem; margin-bottom: 0; }
.sorts { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.chip { color: var(--ink); text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; }
.chip.on { border-color: var(--copper); color: var(--copper); }
.pack-layout { display: grid; gap: 16px; }
.side-list { display: flex; flex-direction: column; gap: 10px; }
.side-card { display: flex; gap: 10px; color: var(--ink); text-decoration: none; align-items: center; }
.side-card img { width: 84px; height: 56px; object-fit: cover; border-radius: 8px; }
.side-card em { display: block; color: var(--muted); font-style: normal; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-name { color: var(--muted); font-size: 0.85rem; text-align: center; }
.cal-cell { min-height: 84px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); color: var(--ink); text-decoration: none; overflow: hidden; display: flex; flex-direction: column; }
.cal-cell img { width: 100%; height: 58px; object-fit: cover; }
.cal-cell span { padding: 2px 6px; }
.cal-cell.blank { background: transparent; border-color: transparent; }
.cal-cell.has { border-color: var(--copper); min-height: 128px; }
.cal-num { font-weight: 700; padding: 4px 6px 0; }
.cal-events { list-style: none; margin: 0; padding: 2px 6px 4px; display: flex; flex-direction: column; gap: 3px; }
.cal-events li { display: flex; align-items: flex-start; justify-content: space-between; gap: 4px; background: rgba(224, 146, 74, 0.16); border-radius: 6px; padding: 3px 5px; font-size: 0.75rem; line-height: 1.25; }
.cal-events li span { padding: 0; }
.cal-x { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0 2px; font: inherit; line-height: 1; }
.cal-add { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 0.75rem; padding: 0 6px 6px; }
.cal-full { color: var(--muted); font-size: 0.75rem; padding: 0 6px 6px; }
.meta-layout { display: grid; gap: 16px; align-items: start; }
.meta-card { border: 1px solid var(--line); border-radius: 14px; padding: 10px; margin-bottom: 10px; background: var(--bg-2); }
.meta-card.on { border-color: var(--copper); }
.meta-card img { width: 100%; max-height: 180px; object-fit: cover; border-radius: 10px; }
.note { color: var(--copper); }
.meta-map #pick-map { height: min(70vh, 640px); min-height: 360px; border-radius: 12px; overflow: hidden; background: #9ecceb; }
.covers { border: 0; padding: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.cover-pick img { width: 92px; height: 64px; object-fit: cover; border-radius: 8px; display: block; }
.cover-pick input { margin-bottom: 4px; }
.country-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.country { display: flex; gap: 8px; align-items: center; background: var(--bg-2); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font: inherit; cursor: pointer; text-align: left; }
.country.on, .country:hover { border-color: var(--copper); }
.flag { font-size: 1.4rem; }
.ranked { width: min(860px, calc(100% - 28px)); margin: 28px auto; display: flex; flex-direction: column; gap: 14px; }
.rank-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 22px; padding: 22px; }
.division { font-family: Georgia, serif; font-size: clamp(2.4rem, 6vw, 4rem); margin: 0; line-height: 0.95; }
.rating-num { font-size: 2rem; margin: 0; color: var(--copper); }
.flag-line { font-size: 1.2rem; }
.rank-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.rank-actions .btn { min-width: 16rem; text-align: center; }
.searching { font-size: 1.3rem; }
.score-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.score-pair article { background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.score-pair strong { font-size: 2rem; }
#duel-score { color: var(--teal); flex-basis: 100%; }
.hp-board { display: grid; gap: 8px; margin: 4px 0 12px; }
.hp-row { display: grid; grid-template-columns: minmax(4.5rem, 9rem) 1fr auto; gap: 8px; align-items: center; }
.hp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hp-track { height: 12px; background: rgba(255,255,255,.08); border-radius: 99px; overflow: hidden; }
.hp-fill { height: 100%; width: 0; border-radius: 99px; background: #e0924a; }
.hp-row.opp .hp-fill { background: #7ec8c0; }
.hp-num { font-variant-numeric: tabular-nums; min-width: 4.5rem; text-align: right; }
.rev-stage { position: relative; height: 3.4rem; margin: 10px 0 14px; }
.rev-stage .dist, .rev-stage .gap {
  position: absolute;
  top: 0;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-size: 1.55rem;
}
.rev-stage .dist.mine { color: #e7b07a; }
.rev-stage .dist.opp { color: #8fd0c8; }
.rev-stage .gap { font-size: 1.9rem; z-index: 2; }
#duel-clock { font-variant-numeric: tabular-nums; font-size: 1.35rem; min-width: 2.4rem; text-align: center; }
#duel-clock.warn { color: #e7b07a; font-size: 1.85rem; animation: duel-pulse .9s ease-in-out infinite; }
#duel-clock.hot { color: #ff6b4a; font-size: 2.35rem; font-weight: 700; animation: duel-pulse .38s ease-in-out infinite; }
@keyframes duel-pulse { 50% { transform: scale(1.12); } }
.hub { width: min(1180px, calc(100% - 28px)); margin: 22px auto; display: grid; grid-template-columns: 250px minmax(0, 1fr) 230px; gap: 16px; align-items: start; }
.hub-card, .hub-panel { background: var(--bg-2); border: 1px solid var(--line); border-radius: 18px; padding: 16px; min-width: 0; }
.hub .division { font-size: 2.15rem; line-height: 1; overflow-wrap: anywhere; }
.hub-card h2 { font-size: 1.45rem; margin: 0 0 10px; }
.hub-card h3 { font-size: 0.95rem; margin: 14px 0 6px; color: var(--muted); font-family: inherit; font-weight: 600; }
.hub-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.avatar-form { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.avatar { width: 96px; height: 96px; border-radius: 18px; border: 1px dashed var(--copper); background: #141820; display: grid; place-items: center; position: relative; overflow: hidden; cursor: pointer; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-plus { font-size: 2rem; color: var(--copper); line-height: 1; }
.avatar input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.text-btn { background: none; border: 0; color: var(--teal); font: inherit; padding: 0; cursor: pointer; }
.mode-switch { display: flex; gap: 8px; }
.mode-switch a { color: var(--ink); text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; }
.mode-switch a.on { background: var(--copper); color: var(--copper-ink); border-color: var(--copper); }
.week-clock { margin: 0; color: var(--copper); }
.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); }
.tabs a { color: var(--muted); text-decoration: none; padding: 8px 0; }
.tabs a.on { color: var(--ink); box-shadow: inset 0 -2px 0 var(--copper); }
.place-list { list-style: none; margin: 0; padding: 0; }
.place-list li, .history-row { display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.history-row { grid-template-columns: 8.5rem minmax(0, 1fr) auto auto; }
.place-list .me { color: var(--copper); }
.place-list em, .history-row em { color: var(--muted); font-style: normal; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); display: inline-block; }
.dot.off { background: #6d655c; }
.photo-slots { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin: 18px 0; max-width: 720px; }
.slot { grid-column: span 2; aspect-ratio: 1; position: relative; border: 1px dashed var(--line); border-radius: 16px; background: var(--bg-2); display: grid; place-items: center; cursor: pointer; overflow: hidden; min-height: 120px; }
.slot:nth-child(4) { grid-column: 2 / span 2; }
.slot:nth-child(5) { grid-column: 4 / span 2; }
.slot-plus { font-size: 2.4rem; color: var(--copper); line-height: 1; }
.slot-num { position: absolute; top: 8px; left: 10px; color: var(--muted); z-index: 1; }
.slot input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.slot.filled { border-style: solid; border-color: var(--copper); }
.slot.filled .slot-plus { display: none; }
.drop { position: relative; display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center; min-height: 160px; border: 1px dashed var(--line); border-radius: 18px; background: var(--bg-2); cursor: pointer; text-align: center; padding: 18px; }
.drop.over { border-color: var(--copper); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.pool-grid { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.pool-grid img { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; }
.cal-cell input { margin: 4px 6px 6px; }
@media (max-width: 980px) {
  .hub { grid-template-columns: 1fr; }
  .history-row { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 900px) {
  .pack-layout { grid-template-columns: minmax(0, 1.4fr) minmax(240px, 0.8fr); align-items: start; }
  .meta-layout { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); }
  .meta-map { position: sticky; top: 72px; }
}
@media (max-width: 800px) {
  form#photo-form.photo-layout {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  form#photo-form .photo-map { position: static; }
  form#photo-form #pick-map {
    height: 320px !important;
    min-height: 280px !important;
  }
}
