/* =====================================================================
   Departures: a split-flap board in a night terminal.
   Charcoal hall, amber flap cells, region counters like gate signs, and
   every named country clattering onto the list.
   ===================================================================== */

:root {
  --hall: #14171c;
  --board: #0b0d10;
  --cell: #1d2126;
  --cell-edge: #33383f;
  --amber: #ffc94d;
  --amber-dim: #b98f34;
  --white: #e8ecf0;
  --muted: #798088;
  --green: #58d68d;
  --red: #ef6a5a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  color: var(--white);
  background:
    radial-gradient(ellipse at 50% -10%, rgba(255, 201, 77, 0.07), transparent 55%),
    linear-gradient(180deg, #181c22, var(--hall) 40%, #0e1013);
  overflow: hidden;
}

.nav-back-games {
  position: fixed; top: 14px; left: 16px; z-index: 50;
  font: 700 14px/1 "Barlow Condensed", sans-serif; letter-spacing: 1px;
  color: var(--amber); text-decoration: none;
  background: rgba(11, 13, 16, 0.85);
  border: 1px solid var(--cell-edge); border-radius: 6px;
  padding: 7px 12px;
}
.nav-back-games:hover { border-color: var(--amber-dim); color: #fff; }

/* ---- the board -------------------------------------------------------- */
#hall {
  height: 100%;
  max-width: 860px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding: 14px 14px 16px;
}

#board-top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 34px;
}
.sign {
  font-size: clamp(18px, 3.4vw, 30px); font-weight: 700; letter-spacing: 6px;
  color: var(--amber);
  text-shadow: 0 0 18px rgba(255, 201, 77, 0.35);
}
/* (a small phone: the sign's wide lettering closes up to stay on the screen) */
@media (max-width: 380px) { .sign { font-size: 17px; letter-spacing: 3.5px; } }
.clockwrap { display: flex; gap: 10px; }
.flap-cells {
  font-family: "B612 Mono", "Courier New", monospace;
  font-size: clamp(15px, 2.6vw, 22px); font-weight: 700;
  letter-spacing: 3px;
  color: var(--amber);
  background: var(--cell);
  border: 1px solid var(--cell-edge); border-radius: 5px;
  padding: 5px 10px;
  box-shadow: inset 0 -10px 12px -10px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  position: relative;
}
.flap-cells::after {   /* the split line */
  content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px;
  background: rgba(0, 0, 0, 0.55);
}
.flap-cells.warn { color: var(--red); }

/* ---- region gate signs -------------------------------------------------- */
#regions {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
  margin-top: 12px;
}
.gate {
  background: var(--board);
  border: 1px solid var(--cell-edge); border-radius: 7px;
  padding: 6px 8px 7px; text-align: center;
}
.gate .rname { font-size: 13px; font-weight: 700; letter-spacing: 2.5px; color: var(--muted); }
.gate .rcount {
  font-family: "B612 Mono", monospace; font-size: 17px; font-weight: 700;
  color: var(--white); margin-top: 1px;
}
.fxon .gate.pulse { animation: gatepulse 0.4s ease; }
@keyframes gatepulse { 0% { background: #2a2416; } 100% { background: var(--board); } }
/* Visual FX off: the gate holds the pulse's warm tint, still, until game.js
   clears .pulse (450ms) */
body:not(.fxon) .gate.pulse { background: #2a2416; }
.gate.done { border-color: var(--green); }
.gate.done .rname { color: var(--green); }
.gate.done .rcount { color: var(--green); }
.gate.done .rcount::after { content: " ✓"; }

/* ---- the departures list ------------------------------------------------ */
#log {
  flex: 1; min-height: 0;
  margin-top: 12px;
  background: var(--board);
  border: 1px solid var(--cell-edge); border-radius: 10px;
  padding: 10px 12px;
  overflow-y: auto;
  list-style: none;
}
#log li {
  display: flex; align-items: baseline; gap: 10px;
  font-family: "B612 Mono", monospace;
  font-size: clamp(13px, 2vw, 17px); font-weight: 700; letter-spacing: 1px;
  padding: 4px 2px;
  border-bottom: 1px solid rgba(51, 56, 63, 0.5);
  color: var(--white);
}
#log li .dest { flex: 1; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#log li .via { color: var(--muted); font-size: 0.8em; }
/* naming capitals: the country a city departs, beside it */
#log li .cty { color: var(--muted); font-size: 0.75em; white-space: nowrap; }
#log li.missed .cty { color: var(--red); opacity: 0.7; }
#log li .status { color: var(--green); font-size: 0.8em; letter-spacing: 2px; }
#log li.missed .dest, #log li.missed .via { color: var(--red); opacity: 0.85; }
#log li.missed .status { color: var(--red); }
#log li .dest span { display: inline-block; }
.fxon #log li.new .dest span { animation: flapin 0.22s steps(3) backwards; }
@keyframes flapin {
  from { transform: scaleY(0.1); filter: brightness(2); }
  to { transform: scaleY(1); }
}
/* Visual FX off: no flap, so a country just named holds amber on a lit row
   until game.js clears .fresh (800ms) */
body:not(.fxon) #log li.fresh { background: rgba(255, 201, 77, 0.08); }
body:not(.fxon) #log li.fresh .dest { color: var(--amber); }
/* the idle board hint */
#log .idle {
  border: 0; color: var(--muted); font-weight: 400; letter-spacing: 2px;
  justify-content: center; padding-top: 16px;
}

/* ---- the desk ------------------------------------------------------------ */
#desk {
  display: flex; align-items: center; gap: 10px;
  margin-top: 12px;
  background: var(--board);
  border: 1px solid var(--cell-edge); border-radius: 10px;
  padding: 10px 12px;
}
#desk label { font-size: 13px; font-weight: 700; letter-spacing: 3px; color: var(--muted); }
#answer {
  flex: 1; min-width: 0;
  font-family: "B612 Mono", monospace; font-size: 18px; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--amber); background: var(--cell);
  border: 1px solid var(--cell-edge); border-radius: 6px;
  padding: 8px 12px;
}
#answer:focus { outline: none; border-color: var(--amber-dim); }
/* (the hint in the empty box shrinks with the screen, so a small phone's
   box still shows all of it) */
#answer::placeholder { color: #5a5f66; text-transform: none; letter-spacing: 0; font-size: min(1em, 4.2vw); }
#answer.shake { animation: shake 0.3s ease; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(4px); } }
/* Visual FX off: no shake, so a name the board doesn't know turns the box red
   until game.js clears .shake (500ms) */
body:not(.fxon) #answer.shake { animation: none; color: var(--red); border-color: var(--red); }
#hint { font-size: 13px; color: var(--amber); white-space: nowrap; }
#hint kbd { font-family: inherit; border: 1px solid var(--amber-dim); border-radius: 4px; padding: 0 5px; }
#giveup {
  font: 700 14px/1 "Barlow Condensed", sans-serif; letter-spacing: 2px; cursor: pointer;
  color: var(--red); background: none;
  border: 1px solid #5a3531; border-radius: 6px; padding: 9px 12px;
  white-space: nowrap;
}
#giveup:hover { border-color: var(--red); }

#toast {
  position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%); z-index: 40;
  font: 700 14px/1 "B612 Mono", monospace; letter-spacing: 2px;
  color: var(--hall); background: var(--amber);
  border-radius: 6px; padding: 8px 14px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}

/* ---- panels ---------------------------------------------------------------- */
.panel {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  padding: 26px 16px; overflow-y: auto;
  background: rgba(5, 6, 8, 0.7);
}
.panel[hidden] { display: none; }
/* centred while it fits; a card taller than the screen starts at the top and
   the panel scrolls (centring alone would put its heading out of reach) */
.panel > .card { margin: auto; }
.card {
  width: min(440px, 100%);
  background: linear-gradient(180deg, #1b2026, #12151a);
  border: 1px solid var(--cell-edge); border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.7);
  padding: 24px 24px 20px;
}
.card.wide { width: min(560px, 100%); }
.card h1, .card h2 {
  font-weight: 700; letter-spacing: 6px; color: var(--amber);
  text-shadow: 0 0 16px rgba(255, 201, 77, 0.3);
}
.card h1 { font-size: 30px; }
.card h2 { font-size: 22px; letter-spacing: 4px; }
.card .tag { color: var(--muted); margin: 3px 0 12px; font-size: 15px; }
.card .how { font-size: 15px; line-height: 1.55; margin-bottom: 14px; color: var(--white); }
.card .how b { color: var(--amber); }

kbd {
  font-family: "B612 Mono", monospace; font-size: 11px;
  background: var(--cell); color: var(--amber);
  border: 1px solid var(--cell-edge); border-radius: 4px; padding: 1px 6px;
}

.pick .seg { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.pick .seg.regions { flex-direction: row; flex-wrap: wrap; }
.pick .seg[hidden] { display: none; }   /* the continents, only for One Continent */
.seg button {
  font-family: inherit; font-size: 16px; font-weight: 500; text-align: left; cursor: pointer;
  color: var(--white); background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--cell-edge); border-radius: 8px; padding: 9px 13px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
}
.seg.regions button { flex: 1; justify-content: center; padding: 7px 6px; font-size: 14px; letter-spacing: 1px; }
.seg button small { font-size: 12.5px; color: var(--muted); }
.seg button.on { border-color: var(--amber); background: rgba(255, 201, 77, 0.07); }
.seg button.on b { color: var(--amber); }
.seg.regions button.on { color: var(--amber); }

.playbtn {
  font-family: inherit; font-size: 19px; font-weight: 700; letter-spacing: 3px;
  width: 100%; cursor: pointer;
  color: #14171c; background: linear-gradient(170deg, #ffe09a, var(--amber) 60%, #d9a52e);
  border: 0; border-radius: 9px; padding: 12px;
  box-shadow: 0 0 22px rgba(255, 201, 77, 0.25);
}
.playbtn:hover { filter: brightness(1.06); }
.playbtn:active { transform: translateY(2px); }
.playbtn kbd { background: rgba(20, 23, 28, 0.25); color: #14171c; border-color: transparent; }
.bests { margin-top: 12px; font-size: 13px; color: var(--muted); min-height: 17px; text-align: center; font-family: "B612 Mono", monospace; }

.card .big {
  font-family: "B612 Mono", monospace; font-size: 36px; font-weight: 700;
  color: var(--amber); margin: 8px 0 2px;
}
.card .stats { font-size: 14.5px; color: var(--muted); margin: 4px 0 12px; white-space: pre-line; line-height: 1.6; }
.missed {
  max-height: 38vh; overflow-y: auto;
  border: 1px solid var(--cell-edge); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 14px;
  font-family: "B612 Mono", monospace; font-size: 12.5px; line-height: 1.7;
}
.missed h3 { font: 700 13px/2 "Barlow Condensed", sans-serif; letter-spacing: 3px; color: var(--muted); }
.missed b { color: var(--red); font-weight: 700; }
.missed span { color: #9aa4ad; }
.missed i { font-style: normal; font-size: 0.85em; opacity: 0.75; }
.card .row { display: flex; gap: 10px; flex-wrap: wrap; }
.card .row button {
  font-family: inherit; font-size: 16px; font-weight: 700; letter-spacing: 1px; cursor: pointer;
  color: var(--white); background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--cell-edge); border-radius: 8px; padding: 9px 18px;
}
.card .row button:first-child { color: #14171c; background: linear-gradient(170deg, #ffe09a, var(--amber)); border-color: transparent; }
.card .row button:active { transform: translateY(1px); }

@media (max-width: 640px) {
  .panel { padding-top: 62px; }      /* (a card starts below the corner buttons) */
  #board-top { flex-direction: column; align-items: stretch; gap: 6px; margin-top: 40px; }
  .clockwrap { justify-content: space-between; }
  #regions { grid-template-columns: repeat(5, 1fr); gap: 5px; }
  .gate .rname { font-size: 10px; letter-spacing: 1px; }
  .gate .rcount { font-size: 13px; }
  #desk { flex-wrap: wrap; }
  #desk label { display: none; }
  #hint { display: none; }
}
