/* GeoGuess: black, square, one orange. */
:root {
  --bg: #0c0c0e; --bar: #111113; --panel: #151517; --cell: #19191c;
  --line: #2a2a2e; --line-2: #3a3a3f; --text: #f4f4f5; --muted: #8a8a92; --dim: #5c5c63;
  --accent: #ff5a14; --accent-2: #ff7a3d; --good: #2fbf71; --bad: #ff4d4d;
  --human: #ff5a14; --topbar: 64px;
  --sans: "Inter Tight", Inter, system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans);
  -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); font-size: 14px; }
svg.i { width: 15px; height: 15px; vertical-align: -2px; flex: none; }

/* ---------- top bar ---------- */
.topbar { position: fixed; inset: 0 0 auto 0; height: var(--topbar); z-index: 40; display: flex; align-items: center;
  justify-content: space-between; background: var(--bar); border-bottom: 1px solid #1e1e21; padding-right: 32px; }
.brand { display: flex; align-items: center; gap: 16px; text-decoration: none; font-size: 22px; font-weight: 500; }
.brand .logo { width: var(--topbar); height: var(--topbar); background: var(--accent); display: grid; place-items: center; }
.brand .logo img { width: 40px; height: 40px; image-rendering: pixelated; }
.topbar nav { display: flex; align-items: center; gap: 26px; font-size: 18px; }
.link { background: none; border: 0; padding: 0; cursor: pointer; text-decoration: none; color: var(--text);
  display: inline-flex; align-items: center; gap: 6px; }
.link:hover { color: var(--accent-2); }
.link.accent { color: var(--accent); }
.nav-user { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); }

.screen { display: none; position: fixed; inset: var(--topbar) 0 0 0; overflow: hidden; }
.screen.active { display: block; }
#lobby, #final { overflow-y: auto; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent;
  border-radius: 0; padding: 16px 22px; font-size: 18px; font-weight: 500; cursor: pointer; text-decoration: none;
  transition: background .12s, border-color .12s, opacity .12s; }
.btn:disabled { cursor: not-allowed; opacity: .55; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:not(:disabled):hover { background: var(--accent-2); }
.btn.dark { background: rgba(17,17,19,.92); color: var(--text); border-color: var(--line); }
.btn.dark:not(:disabled):hover { border-color: var(--line-2); background: #1a1a1d; }
.btn.small { padding: 8px 12px; font-size: 14px; }
.btn.nudge { animation: nudge .5s 2; border-color: var(--accent); }
@keyframes nudge { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ---------- avatars ---------- */
.avatar { --s: 28px; width: var(--s); height: var(--s); flex: none; display: inline-grid; place-items: center;
  background: var(--c, #444); color: #fff; font-weight: 600; font-size: calc(var(--s) * .5); line-height: 1;
  border-radius: 4px; overflow: hidden; }
.avatar.pic { background: #fff; }
.avatar.pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.human { background: var(--human); }
.avatar.sm { --s: 22px; }
.avatar.md { --s: 40px; }
.avatar.lg { --s: 48px; }
.avatar.xl { --s: 88px; }

/* ---------- lobby ---------- */
.lobby-wrap { max-width: 1700px; margin: 0 auto; padding: 0 56px 64px; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; gap: 48px; padding: 22px 56px 28px;
  margin: 0 -56px; border-bottom: 1px solid #1e1e21;
  background-image: linear-gradient(90deg, #1b1b1e 1px, transparent 1px); background-size: 130px 100%; }
.hero p { margin: 0; max-width: 660px; font-size: 15px; line-height: 1.35; color: #d8d8dc; }

.lobby-grid { display: grid; grid-template-columns: minmax(380px, 540px) 1fr; gap: 64px; margin-top: 56px; align-items: start; }
.game-col { display: flex; flex-direction: column; gap: 12px; }

.panel { background: var(--panel); border: 1px solid #202023; }
.panel-head { display: flex; align-items: center; height: 64px; border-bottom: 1px solid #202023; padding-right: 24px; }
.panel-head .ico { width: 64px; height: 64px; background: var(--accent); display: grid; place-items: center; flex: none;
  margin: -1px 0 -1px -1px; }
.panel-head .ico svg { width: 32px; height: 32px; color: #1a0800; }
.panel-head h2 { margin: 0 0 0 30px; font-size: 22px; font-weight: 500; }
.panel-head .count { margin-left: auto; font-size: 18px; }
.panel-body { padding: 40px 40px 28px; }

.player-row { display: flex; align-items: center; gap: 14px; background: var(--cell); border: 1px solid #222226; padding: 18px 20px; }
.player-row input { flex: 1; min-width: 0; background: none; border: 0; font-size: 17px; outline: none; padding: 4px 0;
  border-bottom: 1px solid transparent; }
.player-row input:focus { border-bottom-color: var(--accent); }
.player-row .link { font-size: 16px; }
.player-row .link.muted { color: var(--muted); }
.player-row .link.muted:hover { color: var(--text); }

.panel .label { font-size: 22px; font-weight: 500; margin: 40px 0 12px; }
.segmented { display: flex; gap: 8px; background: var(--cell); border: 1px solid #222226; padding: 12px; }
.segmented button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 16px;
  border: 0; background: none; color: var(--muted); font-size: 21px; cursor: pointer; text-transform: capitalize; }
.segmented .mode-ico { height: 36px; min-width: 36px; padding: 4px; display: inline-grid; place-items: center; }
.segmented .mode-ico img { height: 28px; image-rendering: pixelated; }
.segmented button.on { background: var(--accent); color: #fff; }
.segmented button:not(.on):hover { color: var(--text); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 12px; }
.stat { background: var(--cell); border: 1px solid #222226; padding: 16px 6px 12px; text-align: center; }
.stat b { display: block; font-size: 38px; font-weight: 500; line-height: 1.05; letter-spacing: -.02em; }
.stat small { color: var(--muted); font-size: 15px; }
.note { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); font-size: 14px; line-height: 1.25; margin: 28px 0 0; }
.note .i { margin-top: 1px; }
.cta { display: flex; flex-direction: column; gap: 12px; }
.cta .btn { width: 100%; }

.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.fighter { position: relative; background: #121214; border: 1px solid #222226; padding: 18px 20px 16px; cursor: pointer;
  display: flex; flex-direction: column; align-items: flex-start; min-height: 168px; transition: border-color .12s, background .12s; }
.fighter:hover { border-color: color-mix(in srgb, var(--c) 60%, #222226); }
.fighter.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 7%, #121214); }
.fighter .avatar { margin-bottom: 14px; }
.fighter .fname { font-size: 18px; font-weight: 500; padding-right: 24px; word-break: break-word; }
.fighter .org { color: var(--muted); font-size: 15px; margin-top: 2px; }
.fighter .tag { margin-top: 8px; border: 1px solid #2c2c31; background: #19191c; padding: 3px 7px; font-size: 15px; }
.fighter .mark { position: absolute; top: 18px; right: 18px; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--c); display: grid; place-items: center; }
.fighter .mark svg { width: 13px; height: 13px; color: #111; opacity: 0; }
.fighter.on .mark { background: var(--c); }
.fighter.on .mark svg { opacity: 1; }
.fighter .lock { position: absolute; top: 18px; right: 18px; width: 20px; height: 20px; color: var(--dim); display: none; }
.fighter.locked { background: #151517; border-color: #1c1c1f; }
.fighter.locked .avatar { filter: grayscale(1) brightness(.55); }
.fighter.locked .fname, .fighter.locked .org, .fighter.locked .tag { color: var(--dim); }
.fighter.locked .mark { display: none; }
.fighter.locked .lock { display: block; }
.fighter .keyline { color: var(--accent); font-size: 15px; margin-top: 2px; }
.fighter .paste { margin-top: 8px; border: 1px solid #2c2c31; background: #19191c; padding: 3px 7px; font-size: 15px;
  color: var(--text); cursor: pointer; }
.fighter .paste:hover { border-color: var(--accent); }
.fighter input, .fighter select { width: 100%; margin-top: 8px; padding: 7px 9px; border: 1px solid #2c2c31; border-radius: 0;
  background: #0d0d0f; color: var(--text); font-size: 12.5px; font-family: var(--mono); }
.fighter input:focus, .fighter select:focus { outline: none; border-color: var(--accent); }

/* ---------- play ---------- */
#pano { position: absolute; inset: 0; }
.return { position: absolute; top: 32px; left: 34px; z-index: 5; padding: 14px 20px; font-size: 17px; }
.scoreboard { position: absolute; top: 32px; left: 50%; transform: translateX(-50%); z-index: 5; display: flex; align-items: stretch;
  gap: 12px; background: rgba(17,17,19,.94); padding: 12px; }
.scoreboard .cell { min-width: 104px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px 14px; }
.scoreboard .cell b { font-size: 36px; font-weight: 500; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.scoreboard .cell small { font-size: 15px; text-transform: uppercase; margin-top: 3px; }
.scoreboard .round { background: #505055; color: #e9e9ec; }
.scoreboard .score { background: var(--accent); color: #fff; }
.scoreboard .timer { min-width: 130px; display: grid; place-items: center; font-size: 40px; font-weight: 500;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.scoreboard .timer.warn { color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .45; } }

.rivals { position: absolute; top: 32px; right: 54px; width: 362px; z-index: 5; background: rgba(17,17,19,.95);
  padding: 20px 20px 8px; max-height: calc(100vh - var(--topbar) - 470px); min-height: 120px; overflow-y: auto; }
.rivals-head { display: flex; justify-content: space-between; align-items: center; font-size: 15px; text-transform: uppercase; margin-bottom: 6px; }
.live { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; text-transform: none; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; }
.live i:first-child { animation: pulse 1.4s infinite; }
.rival { padding: 16px 0 14px; }
.rival .row { display: flex; align-items: center; gap: 12px; font-size: 17px; }
.rival .row .avatar { --s: 30px; }
.rival .row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rival .status { margin-left: auto; font-size: 14px; padding: 2px 6px; background: var(--c); color: #fff; white-space: nowrap; }
.rival .status.locked { background: var(--good); color: #04220f; }
.rival .status.out, .rival .status.error { background: var(--bad); color: #fff; }
.bar { height: 5px; background: #4a4a50; margin: 12px 0 10px; }
.bar > i { display: block; height: 100%; background: var(--c); width: 0; transition: width .4s; }
.rival .last { display: flex; gap: 7px; align-items: center; font-size: 14.5px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.rival .last span { overflow: hidden; text-overflow: ellipsis; }
.rival .last.flash span { animation: flash .8s; }
@keyframes flash { from { color: var(--text); } }

/* After the human locks in, the panel widens into a live trace with pictures. */
.rival .feed { display: none; }
.rivals.unlocked { width: 460px; max-height: calc(100vh - var(--topbar) - 64px); }
.rivals.unlocked #live-mode { color: var(--accent); }
.traces-toggle { margin-left: 8px; background: none; border: 1px solid var(--line-2); color: var(--text); padding: 2px 8px;
  font-size: 12px; cursor: pointer; text-transform: uppercase; letter-spacing: .04em; }
.traces-toggle:hover { border-color: var(--accent); }
.rivals.unlocked.compact { width: 362px; max-height: calc(100vh - var(--topbar) - 470px); }
.rivals.unlocked.compact .feed { display: none; }
.rivals.unlocked .live i:nth-of-type(2) { background: var(--accent); }
.rivals.unlocked .feed { display: block; max-height: 380px; overflow-y: auto; margin-top: 4px; padding-left: 12px;
  border-left: 2px solid var(--c); }
.thought { padding: 8px 0; font-size: 13px; line-height: 1.45; border-top: 1px solid #222226; }
.thought:first-child { border-top: 0; }
.thought .tl { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 3px; }
.thought .text { white-space: pre-wrap; }
.thought.tool .text, .thought.start .text { color: var(--muted); font-size: 12px; }
.thought details summary { cursor: pointer; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.thought .thinking { white-space: pre-wrap; color: var(--muted); font-size: 12px; margin: 4px 0; }
.thought img { display: block; width: 100%; margin-top: 6px; cursor: zoom-in; border: 1px solid #2c2c31; }

.guess-box { position: absolute; right: 54px; bottom: 48px; z-index: 6; width: 362px; display: flex; flex-direction: column;
  gap: 12px; transition: width .25s; }
.guess-box:hover, .guess-box.pinned { width: min(640px, 56vw); }
#guess-map { height: 318px; border: 1px solid rgba(255,255,255,.15); transition: height .25s; opacity: .9; }
.guess-box:hover #guess-map, .guess-box.pinned #guess-map { height: min(460px, 52vh); opacity: 1; }
#guess-btn { width: 100%; padding: 16px; font-size: 22px; }
.guess-box.pinned #guess-btn { background: var(--accent); border-color: var(--accent); color: #fff; }

.locked-banner { position: absolute; left: 50%; bottom: 48px; transform: translateX(-50%); z-index: 7;
  background: rgba(17,17,19,.95); border-left: 4px solid var(--accent); padding: 16px 24px; font-size: 17px; white-space: nowrap; }

/* ---------- reveal ---------- */
#reveal-map { position: absolute; left: 0; top: 0; bottom: 0; right: 500px; }
.reveal-panel { position: absolute; right: 0; top: 0; bottom: 0; width: 500px; background: var(--panel);
  border-left: 1px solid #202023; display: flex; flex-direction: column; }
.eyebrow { font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.reveal-head { padding: 28px 28px 18px; border-bottom: 1px solid #202023; }
.reveal-head h2 { font-weight: 500; margin: 10px 0 6px; font-size: 36px; line-height: 1.05; letter-spacing: -.02em; }
.reveal-head h2 em { font-style: normal; color: var(--accent); }
#round-table, #replay { flex: 1; overflow-y: auto; padding: 14px 20px; }
.reveal-actions { padding: 16px 20px 20px; border-top: 1px solid #202023; }
.reveal-actions .btn { width: 100%; }

.lb { width: 100%; border-collapse: separate; border-spacing: 0 8px; font-size: 15px; }
.lb th { text-align: left; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em;
  font-weight: 500; padding: 2px 12px; }
.lb td { padding: 12px; background: var(--cell); border-top: 1px solid #222226; border-bottom: 1px solid #222226; }
.lb td:first-child { border-left: 1px solid #222226; }
.lb td:last-child { border-right: 1px solid #222226; }
.lb tr.clickable { cursor: pointer; }
.lb tr.clickable:hover td { border-color: var(--line-2); background: #1e1e21; }
.lb tr.me td { background: color-mix(in srgb, var(--accent) 10%, var(--cell)); }
.lb tr.me td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.lb .rank { font-size: 20px; color: var(--muted); width: 40px; text-align: center; }
.lb tbody tr:first-child .rank { color: var(--accent); }
.lb .pts { font-size: 20px; text-align: right; font-variant-numeric: tabular-nums; }
.lb .who { display: flex; align-items: center; gap: 10px; }
.lb .sub { font-size: 13px; color: var(--muted); }
.lb .chev { text-align: right; width: 70px; }
.lb .chev span { font-size: 12px; border: 1px solid #2c2c31; padding: 3px 7px; color: var(--muted); white-space: nowrap; }
.lb tr.clickable:hover .chev span { color: var(--text); border-color: var(--accent); }

.replay-head { display: flex; align-items: center; gap: 12px; padding: 4px 0 14px; position: sticky; top: -14px;
  background: var(--panel); z-index: 1; }
.replay-head b { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 17px; }
.step { border-left: 2px solid #2c2c31; margin: 0 0 0 6px; padding: 0 0 18px 18px; position: relative; }
.step::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; background: var(--c, var(--dim)); }
.step .tl { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 4px; }
.step .text { white-space: pre-wrap; font-size: 14px; line-height: 1.5; }
.step details { margin-top: 6px; }
.step summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.step .thinking { white-space: pre-wrap; font-size: 12.5px; color: var(--muted); line-height: 1.5; margin-top: 4px; }
.call { display: inline-block; font-family: var(--mono); font-size: 12px; background: #1e1e21; border: 1px solid #2c2c31;
  padding: 3px 8px; margin: 6px 4px 0 0; word-break: break-all; }
.step img { display: block; width: 100%; margin-top: 8px; cursor: zoom-in; border: 1px solid #2c2c31; }
.verdict { background: var(--cell); border: 1px solid #222226; border-left: 4px solid var(--c, var(--dim)); padding: 16px;
  margin: 0 0 18px; font-size: 15px; }

/* ---------- final ---------- */
.final-wrap { max-width: 820px; margin: 0 auto; padding: 56px 24px; text-align: center; }
.final-wrap h1 { font-weight: 500; font-size: clamp(44px, 7vw, 80px); margin: 14px 0 10px; letter-spacing: -.035em; line-height: 1; }
.final-wrap > p { font-size: 18px; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 12px; margin: 48px 0 28px; }
.podium .place { width: 190px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.podium .nm { font-size: 17px; }
.podium .block { width: 100%; display: flex; flex-direction: column; align-items: center; padding-top: 16px; gap: 4px;
  background: var(--panel); border: 1px solid #222226; border-top: 4px solid var(--c); }
.podium .p1 .block { height: 190px; background: color-mix(in srgb, var(--c) 14%, var(--panel)); }
.podium .p2 .block { height: 140px; }
.podium .p3 .block { height: 105px; }
.podium .block .n { font-size: 48px; line-height: 1; }
.podium .block .pts { color: var(--muted); font-variant-numeric: tabular-nums; }
#final-table { text-align: left; margin-bottom: 32px; }
#again-btn { min-width: 320px; }

/* ---------- overlays ---------- */
.loading { position: fixed; inset: 0; background: rgba(8,8,10,.82); backdrop-filter: blur(4px); z-index: 50; display: flex;
  flex-direction: column; align-items: center; justify-content: center; gap: 18px; font-size: 20px; }
.spinner { width: 46px; height: 46px; border: 4px solid #2a2a2e; border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 60; display: flex; align-items: center;
  justify-content: center; cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 92vh; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 55; display: grid; place-items: center; padding: 20px; }
.modal-card { width: min(640px, 100%); background: var(--panel); border: 1px solid #222226; }
.modal-card .panel-body { padding: 28px 32px; font-size: 16px; line-height: 1.5; color: #d8d8dc; }
.modal-card ul { padding-left: 20px; margin: 0; }
.modal-card li { margin-bottom: 8px; }

/* ---------- small screens ---------- */
@media (max-width: 1100px) {
  .lobby-grid { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .hero { grid-template-columns: minmax(0, 1fr); gap: 14px; }
}
@media (max-width: 1000px) {
  #reveal-map { right: 0; bottom: 55vh; }
  .reveal-panel { width: 100%; top: 45vh; border-left: 0; border-top: 1px solid #202023; }
}
@media (max-width: 760px) {
  :root { --topbar: 56px; }
  .topbar { padding-right: 14px; }
  .brand { font-size: 18px; }
  .topbar nav { gap: 14px; font-size: 15px; }
  #nav-rules, #nav-traces { display: none; }
  .lobby-wrap { padding: 0 16px 40px; }
  .hero { margin: 0 -16px; padding: 18px 16px; }
  .panel-body { padding: 22px 16px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .roster { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .return { top: auto; bottom: 14px; left: 10px; padding: 10px 12px; font-size: 14px; }
  .scoreboard { top: 10px; padding: 6px; gap: 6px; }
  .scoreboard .cell { min-width: 64px; padding: 4px 8px; }
  .scoreboard .cell b { font-size: 22px; }
  .scoreboard .cell small { font-size: 11px; }
  .scoreboard .timer { min-width: 80px; font-size: 26px; }
  .rivals { top: 90px; left: 10px; right: auto; width: 220px; max-height: 32vh; padding: 10px 12px; }
  .rival .last { display: none; }
  .rivals.unlocked { width: calc(100vw - 20px); max-height: 55vh; }
  .rivals.unlocked.compact { width: 220px; max-height: 32vh; }
  .guess-box, .guess-box:hover, .guess-box.pinned { width: calc(100vw - 20px); right: 10px; bottom: 10px; }
  .guess-box:not(.pinned) #guess-map { height: 150px; }
}
