:root {
  --text: #ffffff;
  --muted: #a8a8a8;
  --shadow-text: #3f3f3f;
  --yellow: #ffff55;
  --cz: #3c8dff;
  --rl: #ff9a2e;
  --win: #55c040;
  --lose: #d8443a;
  --ocean: #2b5d93;
  --land: #9a9a9a;
  --land-off: #6c6c6c;
  --border: #3d3d3d;
  --panel: rgba(0, 0, 0, .55);
  --line: rgba(255, 255, 255, .14);
  --dirt: none;   /* textures are generated in app.js */
  --stone: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--text);
  font: 19px/1.4 'Pixelify Sans', ui-monospace, monospace;
  background-color: #3b2a1d;
  background-image: linear-gradient(rgba(0,0,0,.55), rgba(0,0,0,.55)), var(--dirt);
  background-size: auto, 64px 64px;
  image-rendering: pixelated;
  min-height: 100dvh;
  text-shadow: 2px 2px 0 var(--shadow-text);
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
.link { background: none; border: 0; color: inherit; padding: 0; text-decoration: underline; text-shadow: inherit; }
b { font-weight: 600; }

main { width: 100%; max-width: 1180px; margin: 0 auto; padding: 24px 16px 64px; }
.screen.center { display: flex; flex-direction: column; align-items: center; gap: 18px; min-height: calc(100dvh - 88px); justify-content: center; }

/* ---------- block logo + splash */
.logo-wrap { position: relative; width: min(400px, 100%); }
.logo { width: min(400px, 100%); }
.logo svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 6px 0 rgba(0,0,0,.35)); }
.splash {
  position: absolute; right: -2%; bottom: 2%;
  background: none; border: 0; padding: 0; white-space: nowrap;
  color: var(--yellow); text-shadow: 3px 3px 0 #3f3f15;
  font-size: clamp(14px, 3.2vw, 24px); font-weight: 500;
  transform: rotate(-18deg); transform-origin: center;
  animation: splash .55s ease-in-out infinite alternate;
}
@keyframes splash { from { scale: 1; } to { scale: 1.09; } }

.mc-title { margin: 0; font-size: 34px; font-weight: 600; }
.mc-sub { margin: -8px 0 0; color: #dcdcdc; text-align: center; max-width: 520px; }
.tally { color: #e0e0e0; font-size: 18px; text-align: center; min-height: 1.4em; }
.tally .CZ { color: var(--cz); } .tally .RL { color: var(--rl); }

/* ---------- Minecraft buttons */
.menu { display: flex; flex-direction: column; gap: 10px; width: min(420px, 100%); }
.menu-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.mc-btn {
  position: relative; width: 100%; min-height: 46px; padding: 6px 12px;
  border: 2px solid #000; border-radius: 0;
  background-color: #6f6f6f; background-image: var(--stone); background-size: 64px 64px;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,.38), inset -2px -4px 0 rgba(0,0,0,.42);
  color: #e0e0e0; text-shadow: 2px 2px 0 #383838; font-size: 19px;
}
.mc-btn:hover:not(:disabled) { outline: 2px solid #fff; outline-offset: -2px; color: #ffffa0; }
.mc-btn:active:not(:disabled) { box-shadow: inset -2px -2px 0 rgba(255,255,255,.3), inset 2px 3px 0 rgba(0,0,0,.45); }
.mc-btn:disabled { background-color: #2c2c2c; background-image: none; color: #8a8a8a; cursor: default; box-shadow: none; text-shadow: none; }
.mc-btn small { font-size: 14px; opacity: .8; }
.mc-btn.small { width: auto; min-height: 40px; font-size: 17px; padding: 4px 14px; }
.mc-btn.green { background-color: #3d7a2a; }
.hint { color: #c8c8c8; font-size: 15px; text-align: center; margin: 2px 0 6px; }

.mc-panel { background: var(--panel); border: 2px solid #000; box-shadow: inset 0 0 0 2px rgba(255,255,255,.12); padding: 18px; }
.narrow { width: min(380px, 100%); display: flex; flex-direction: column; gap: 10px; }
label { color: #c8c8c8; }
input {
  font: inherit; color: #fff; text-shadow: none;
  background: #000; border: 2px solid #a0a0a0; border-radius: 0; padding: 9px 10px; width: 100%;
}
input:focus { outline: none; border-color: #fff; }
input:disabled { border-color: #555; color: #777; }
.error { color: #ff5555; min-height: 1.3em; margin: 0; }

.corner { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; font-size: 15px; color: #fff; flex-wrap: wrap; }
.presence span { margin-right: 8px; color: #777; }
.presence span.on { color: var(--win); }

/* ---------- player pick */
.pick { display: flex; gap: 20px; }
.player-btn {
  width: 150px; padding: 18px 0 14px; display: flex; flex-direction: column; align-items: center; gap: 10px;
  font-size: 32px; font-weight: 700;
  border: 2px solid #000; background: var(--panel); box-shadow: inset 0 0 0 2px rgba(255,255,255,.12);
}
.player-btn:hover { outline: 2px solid #fff; outline-offset: -2px; }
.player-btn .head { width: 72px; height: 72px; image-rendering: pixelated; background-size: cover; border: 2px solid #000; }

/* ---------- match banner, stats */
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; width: min(560px, 100%); color: var(--yellow); }
.banner .mc-btn { width: auto; }
.scoreboard { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; text-align: center; gap: 8px; width: min(560px, 100%); }
.score { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.score b { font-size: 64px; line-height: 1; }
.score.cz b { color: var(--cz); } .score.rl b { color: var(--rl); }
.score small { color: var(--yellow); min-height: 1.3em; font-size: 15px; }
.tag { color: #fff; font-weight: 600; font-size: 15px; padding: 1px 10px; border: 2px solid #000; display: inline-block; text-align: center; }
.tag.CZ { background: var(--cz); } .tag.RL { background: var(--rl); } .tag.none { background: #555; }
.vs { color: var(--muted); text-transform: uppercase; font-size: 14px; }
.breakdown { grid-column: 1 / -1; color: #d0d0d0; font-size: 16px; border-top: 2px solid var(--line); padding-top: 10px; }
.breakdown.averages { border-top: 0; padding-top: 0; }
.history { width: min(560px, 100%); padding: 4px 0; max-height: 46vh; overflow: auto; }
.history .row { display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; align-items: center; padding: 9px 14px; border-bottom: 2px solid var(--line); }
.history .row:last-child { border-bottom: 0; }
.history .detail { color: var(--muted); font-size: 15px; }
.history time { color: var(--muted); font-size: 14px; white-space: nowrap; }
.history p { padding: 8px 14px; margin: 0; color: var(--muted); }

/* ---------- game */
.screen.game { display: grid; grid-template-columns: 1fr 360px; gap: 18px; align-items: start; }
.globe-wrap { position: relative; aspect-ratio: 1; max-height: calc(100dvh - 80px); width: 100%; }
#globe { width: 100%; height: 100%; touch-action: none; cursor: grab; display: block; image-rendering: auto; }
#globe:active { cursor: grabbing; }
.globe-hint { position: absolute; bottom: 0; left: 0; right: 0; text-align: center; color: #bbb; font-size: 14px; pointer-events: none; }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; font-size: 140px; font-weight: 700; color: var(--yellow); text-shadow: 6px 6px 0 #3f3f15; pointer-events: none; }
.panel { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-head h2 { margin: 0; font-size: 28px; font-weight: 600; }
.status { background: var(--panel); border: 2px solid #000; box-shadow: inset 0 0 0 2px rgba(255,255,255,.12); padding: 12px 14px; }
.status.mine { box-shadow: inset 0 0 0 2px var(--win); color: #b8ff9a; }
.status.won { background: rgba(40, 110, 30, .85); }
.status.lost { background: rgba(130, 30, 25, .85); }
.status .mc-btn { margin-top: 8px; }
.guess { display: flex; gap: 8px; align-items: stretch; }
.ac { position: relative; flex: 1; }
.ac-list {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 2px); margin: 0; padding: 2px; list-style: none;
  background: #100010f0; border: 2px solid #2a0a5e; box-shadow: inset 0 0 0 1px #5000ff55; max-height: 300px; overflow: auto;
}
.ac-list li { padding: 7px 9px; cursor: pointer; }
.ac-list li.active, .ac-list li:hover { background: rgba(255,255,255,.12); color: var(--yellow); }
.ac-list li small { color: var(--muted); margin-left: 8px; font-size: 14px; }
.closest { color: #d0d0d0; font-size: 15px; min-height: 1.2em; }
.guesses { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 44vh; overflow: auto; }
.guesses li { display: grid; grid-template-columns: 18px 1fr auto auto; gap: 10px; align-items: center; padding: 6px 10px; background: var(--panel); border: 2px solid #000; }
.guesses li.latest { border-color: #fff; }
.guesses .sw { width: 18px; height: 18px; border: 2px solid #000; }
.guesses .km { color: #d0d0d0; font-size: 15px; font-variant-numeric: tabular-nums; }
.guesses .by { font-size: 13px; padding: 0 6px; border: 2px solid #000; }
.guesses .by.CZ { background: var(--cz); } .guesses .by.RL { background: var(--rl); }
.opp { font-size: 15px; color: #d0d0d0; }
.opp h3 { font-size: 17px; color: #fff; margin: 6px 0; font-weight: 600; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .mc-btn { flex: 1; width: auto; }
.actions .mc-btn.surrender { flex: 0 0 auto; margin-left: auto; background-color: #6a6a6a; }
.actions .mc-btn.surrender.on { background-color: #8a6d1e; color: #fff; outline: 2px solid var(--yellow); outline-offset: -2px; }
.status .vote { margin-top: 8px; padding-top: 8px; border-top: 2px solid rgba(255, 255, 255, .15); color: var(--yellow); }

/* ---------- running win tally for a game mode */
.mode-tally { text-align: center; font-size: 17px; color: #e2e2e2; }
.mode-tally:empty { display: none; }
.mode-tally b { font-family: Tiny5, 'Pixelify Sans', monospace; font-weight: 400; font-size: 22px; }
.mode-tally .CZ { color: var(--cz); } .mode-tally .RL { color: var(--rl); }
.panel .mode-tally { text-align: left; margin-top: -6px; }

/* ---------- race over */
.race-over {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, 92%);
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
  background: rgba(20, 20, 20, .92); animation: pop .35s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes pop { from { transform: translate(-50%, -50%) scale(.6); opacity: 0; } }
.race-over h3 { margin: 0; font-family: Tiny5, 'Pixelify Sans', monospace; font-weight: 400; font-size: 52px; line-height: 1; color: var(--yellow); text-shadow: 4px 4px 0 #3f3f15; }
.race-over .why { color: var(--muted); }
.race-over .country { font-size: 20px; }
.race-over .times { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.race-over .times div { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; border: 2px solid #000; background: rgba(255, 255, 255, .06); }
.race-over .times b { font-family: Tiny5, 'Pixelify Sans', monospace; font-weight: 400; font-size: 30px; }
.race-over .times .first { border-color: var(--yellow); }
.race-over .actions { width: 100%; }
.race-over .close { position: absolute; top: 4px; right: 8px; background: none; border: 0; color: var(--muted); font-size: 22px; }
@media (max-width: 760px) { .race-over h3 { font-size: 40px; } }

/* ---------- quiz */
.quiz { width: min(640px, 100%); display: flex; flex-direction: column; gap: 14px; }
.quiz p { margin: 0; }
.quiz-score { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.quiz-score b { font-family: Tiny5, 'Pixelify Sans', monospace; font-size: 34px; }
.quiz-score .CZ { color: var(--cz); } .quiz-score .RL { color: var(--rl); }
.quiz-score .to { color: var(--muted); font-size: 16px; text-align: center; }
.quiz-q { font-size: 23px; line-height: 1.35; }
.quiz-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 16px; }
.quiz-bar { height: 8px; background: #000; border: 2px solid #000; }
.quiz-bar span { display: block; height: 100%; background: var(--yellow); }
.quiz-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quiz-choices .mc-btn { min-height: 64px; line-height: 1.25; }
.quiz-choices .mc-btn.right, .quiz-choices .mc-btn.right:disabled { background: #3d7a2a; background-image: none; color: #fff; }
.quiz-choices .mc-btn.wrong, .quiz-choices .mc-btn.wrong:disabled { background: #8a2a22; background-image: none; color: #fff; }
.quiz-choices .mc-btn.picked { outline: 3px solid #fff; outline-offset: -3px; }
.quiz-choices .who { display: block; font-size: 14px; opacity: .9; }
.quiz-note { min-height: 1.4em; color: var(--yellow); text-align: center; }
.quiz-big { font-family: Tiny5, 'Pixelify Sans', monospace; font-size: 90px; text-align: center; color: var(--yellow); text-shadow: 5px 5px 0 #3f3f15; }
.quiz .actions .mc-btn { flex: 1; }
.quiz-topic { display: flex; flex-direction: column; gap: 4px; }
.quiz-blurb { color: var(--muted); font-size: 16px; text-align: center; }
#quiz-nav { width: min(240px, 100%); }
@media (max-width: 760px) { .quiz-choices { grid-template-columns: 1fr; } .quiz-q { font-size: 20px; } }

/* ---------- hard mode checkbox */
.check { display: flex; align-items: center; gap: 10px; color: #e0e0e0; cursor: pointer; user-select: none; }
.check small { color: var(--muted); font-size: 15px; }
.menu .check { justify-content: center; flex-wrap: wrap; margin: 4px 0; }
.check input {
  appearance: none; width: 22px; height: 22px; padding: 0; flex: none; margin: 0;
  background: #000; border: 2px solid #a0a0a0; display: grid; place-items: center; cursor: pointer;
}
.check input:checked::after { content: ''; width: 10px; height: 10px; background: var(--win); }
.check input:focus-visible { border-color: #fff; }

.hard-badge { color: var(--yellow); font-size: 16px; }

/* ---------- chat */
.chat-slot:empty { display: none; }
.screen.center .chat-slot { width: min(560px, 100%); }
.chat { display: flex; flex-direction: column; gap: 8px; padding: 12px; }
.chat h3 { margin: 0; font-size: 18px; font-weight: 600; color: #e0e0e0; }
.chat-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; height: 170px; overflow-y: auto; overflow-wrap: anywhere; }
.chat-log li { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: baseline; }
.chat-log .tag { font-size: 13px; padding: 0 6px; }
.chat-log time { color: var(--muted); font-size: 13px; }
.chat-log .empty { display: block; color: var(--muted); }
.chat-log li.invite { align-items: center; padding: 6px 8px; margin: 2px 0; background: rgba(255, 255, 85, .12); border: 2px solid var(--yellow); color: var(--yellow); }
.chat-log li.invite.mine { border-style: dashed; border-color: rgba(255, 255, 255, .3); background: rgba(255, 255, 255, .06); color: #e2e2e2; }
.chat-log li.invite .mc-btn { min-height: 34px; padding: 2px 14px; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { padding: 6px 8px; }

/* ---------- dialog + toasts */
.mc-dialog { border: 2px solid #000; padding: 22px; background: #c6c6c6; color: #3f3f3f; text-shadow: none; max-width: min(420px, calc(100vw - 32px)); box-shadow: inset 3px 3px 0 #fff, inset -3px -3px 0 #555; text-align: center; font: 19px/1.4 'Pixelify Sans', monospace; }
.mc-dialog::backdrop { background: rgba(0,0,0,.6); }
.mc-dialog h3 { margin: 0 0 8px; font-size: 24px; color: #3f3f3f; }
.mc-dialog p { margin: 0 0 16px; }
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; width: max-content; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: calc(100vw - 24px); }
.toast { background: #212121f2; border: 2px solid #000; box-shadow: inset 0 0 0 2px #555; padding: 10px 14px; color: var(--yellow); animation: slide .25s ease-out; }
@keyframes slide { from { transform: translateY(16px); opacity: 0; } }

@media (max-width: 760px) {
  body { font-size: 19px; }
  main { padding-top: 16px; }
  .screen.game { grid-template-columns: 1fr; gap: 10px; }
  .globe-wrap { max-height: 50vh; margin: 0 auto; }
  .panel { position: static; }
  .guesses { max-height: none; }
  .score b { font-size: 48px; }
  .corner { position: static; justify-content: center; text-align: center; }
  .screen.center { min-height: auto; }
  .player-btn { width: 130px; }
}

/* ---------- fonts
   Running and small text uses Nunito, a clean font that stays readable when small.
   Pixel fonts are kept for the Minecraft touches: Tiny5 for titles, big numbers and the countdown,
   Pixelify Sans for the stone buttons. */
body, .mc-dialog { font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif; font-weight: 600; }
body { font-size: 17px; line-height: 1.45; text-shadow: 0 1px 2px rgba(0, 0, 0, .55); }
b, .mc-title, .panel-head h2, h3 { font-weight: 800; }
.mc-title, .panel-head h2, .countdown, .score b, .player-btn, .mc-dialog h3, .quiz-score b, .quiz-big { font-family: Tiny5, 'Pixelify Sans', monospace; font-weight: 400; }
.mc-btn { font-family: 'Pixelify Sans', monospace; font-weight: 500; }
.splash { font-family: 'Pixelify Sans', monospace; }
/* Quiz answers are sentences, so they get the readable font even on stone buttons. */
.quiz-choices .mc-btn { font-family: 'Nunito', system-ui, sans-serif; font-weight: 700; font-size: 17px; text-shadow: 0 1px 2px rgba(0, 0, 0, .7); }
.quiz-q { font-weight: 700; }

/* Brighter greys so muted text stands out from the dark dirt background. */
:root { --muted: #c9c9c9; }
.hint, .breakdown, .closest, .opp, .guesses .km, .mc-sub, .tally { color: #e2e2e2; }

/* Nothing below 15px. */
.breakdown, .closest, .opp, .history .detail, .guesses .km, .hint, .corner, .check small, .quiz-meta, .quiz-score .to, .hard-badge { font-size: 16px; }
.tag, .vs, .history time, .globe-hint, .ac-list li small, .score small, .mc-btn small, .guesses .by,
.chat-log .tag, .chat-log time, .quiz-choices .who { font-size: 15px; }
.tag, .guesses .by { font-weight: 800; }