/* style.css — Chicken Lane.
 *
 * THE WORLD: the house instrument panel, driven at night. A dark console rail on
 * the left counts points and odds in mono; the playfield on the right is the
 * exhibit, and it is the one thing allowed a palette of its own, because a white
 * bird on a dirt track has to read as a bird at forty pixels.
 *
 * So: chrome = the shared tokens, exactly one accent, hairlines, no shadows.
 * Playfield and mascot = their own small palette (packed earth, grass, sodium
 * amber, a red comb). `--hazard` is a signal, not a second accent: it appears
 * only where the game is telling you something is dangerous or lost, never as
 * decoration.
 */

:root {
  --bg: #0e0f13;
  --panel: #15171d;
  --panel-2: #1b1e26;
  --line: #262a34;
  --text: #e8eaf0;
  --muted: #8b91a3;
  --accent: #7aa2ff;
  --radius: 8px;
  --font: "SF Mono", "Cascadia Code", Consolas, "JetBrains Mono", Menlo, monospace;

  /* signals, not accents */
  --hazard: #e0574d;

  /* playfield only: a dirt track between two grass verges */
  --well: #0b0c10;
  --track: #6b4f34;
  --verge: #20351a;
  --track-line: rgba(250, 246, 232, 0.34);
  --lamp: #ffe9b8;
  --bird: #f2f4f9;
  --bird-shade: #d5dae6;
  --comb: #e0574d;
  --beak: #e8a24a;
}

* { box-sizing: border-box; }

/* Author `display` rules beat the UA stylesheet's `[hidden]`, so this guard is
   the only thing that makes `element.hidden = true` actually hide the result
   card. Never assert on `.hidden` in a check; assert on computed display. */
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }

body {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 var(--font);
  overflow: hidden;
}

button, input { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- panel */

.panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px 16px 22px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.brand {
  margin: 0 0 8px;
  font-size: 22px;
  letter-spacing: 0.09em;
  font-weight: 700;
  color: var(--text);
}

.brand span { color: var(--accent); }

.intro { margin: 0 0 14px; font-size: 12px; }

.muted { color: var(--muted); }
.tiny { font-size: 11px; line-height: 1.7; }
.hint { margin: 6px 0 0; font-size: 11px; line-height: 1.6; }

.small {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.asidelabel {
  font-style: normal;
  text-transform: none;
  letter-spacing: 0;
  font-size: 10px;
  color: var(--hazard);
}

.group { margin-bottom: 12px; }

/* ------------------------------------------------------------- readouts */

.readout {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 8px;
}

.box {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 10px;
  min-width: 0;
}

.box span {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.box b {
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* ---------------------------------------------------------------- bets */

.bet-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px;
  align-items: stretch;
}

#bet {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 0;
  appearance: textfield;
  -moz-appearance: textfield;
}

#bet::-webkit-outer-spin-button,
#bet::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

#bet:hover { border-color: #333949; }

.chips {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 6px;
}

.chip {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 4px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.chip:hover { color: var(--text); border-color: #3a4152; }
.chip:active { background: #202430; }

.chip-wide {
  width: 100%;
  margin-bottom: 14px;
  padding: 6px;
  font-size: 11px;
}

.chip-wide:hover { color: var(--accent); border-color: #35405a; }

/* --------------------------------------------------------------- roads */

.roads {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.road {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 8px;
  cursor: pointer;
  text-align: left;
  transition: border-color 140ms ease, background 140ms ease;
}

.road:hover { border-color: #3a4152; }

.road[aria-checked="true"] {
  border-color: var(--accent);
  background: #1c2333;
}

.road-name { font-size: 12px; font-weight: 600; }
.road-sub { font-size: 10px; color: var(--muted); }
.road-max {
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.road[aria-checked="true"] .road-max { color: var(--accent); }

/* ------------------------------------------------------------- actions */

.actions .btn { width: 100%; }

.btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.btn:hover { background: #202430; border-color: #3a4152; }
.btn:active { background: #191d26; }

.btn:disabled {
  cursor: not-allowed;
  color: #5a6072;
  border-color: var(--line);
  background: transparent;
}

.btn-step { padding: 8px 10px; font-size: 12px; color: var(--muted); }
.btn-step:hover { color: var(--text); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #10131a;
  margin-bottom: 6px;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.1em;
}

.btn-primary:hover { background: #8db0ff; border-color: #8db0ff; }
.btn-primary:active { background: #6b93f2; border-color: #6b93f2; }
.btn-primary:disabled {
  background: transparent;
  border-color: var(--line);
  color: #5a6072;
}

.btn-cash {
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.btn-cash[data-live="1"] {
  color: var(--accent);
  border-color: #3c4a68;
  background: #1d2331;
  font-weight: 700;
}

.btn-cash[data-live="1"]:hover { border-color: var(--accent); background: #212a3b; }

.keys { margin: 8px 0 0; font-size: 10px; text-align: center; }

kbd {
  font: inherit;
  font-size: 10px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 4px;
  color: var(--text);
}

/* -------------------------------------------------------------- details */

.fold {
  border-top: 1px solid var(--line);
  padding: 10px 0 2px;
}

.fold summary {
  cursor: pointer;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.fold summary::-webkit-details-marker { display: none; }
.fold summary:hover { color: var(--text); }
.fold[open] summary { color: var(--text); }
.fold[open] summary::after { content: "–"; color: var(--muted); }
.fold:not([open]) summary::after { content: "+"; color: var(--muted); }

.tablewrap {
  max-height: 232px;
  overflow-y: auto;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.odds {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.odds th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  text-align: right;
  font-weight: 400;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 5px 7px;
  border-bottom: 1px solid var(--line);
}

.odds th:first-child, .odds td:first-child { text-align: left; }

.odds td {
  text-align: right;
  padding: 4px 7px;
  color: var(--text);
  border-bottom: 1px solid #1d212a;
}

.odds tr:last-child td { border-bottom: 0; }
.odds tr.now td { background: #1c2333; color: var(--accent); }
.odds td.dim { color: var(--muted); }

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  margin: 10px 0 4px;
  font-size: 11px;
}

.facts dt { color: var(--muted); }
.facts dd {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

#client-seed {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  min-width: 0;
}

.legal {
  margin: 18px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  line-height: 1.7;
}

.legal b { color: var(--text); font-weight: 600; }

/* ---------------------------------------------------------------- birds */

.birds {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 10px 0 2px;
}

.bird {
  display: grid;
  place-items: center;
  padding: 5px 2px 3px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}

.bird canvas { image-rendering: pixelated; display: block; }
.bird:hover { border-color: #3a4152; }

.bird[aria-checked="true"] {
  border-color: var(--accent);
  background: #1c2333;
}

/* ---------------------------------------------------------------- stage */

.stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.statusbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  font-size: 11px;
  color: var(--muted);
}

.statusbar b {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-left: 3px;
}

.canvas-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: var(--well);
  border-top: 1px solid #191c23;
}

#road {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.canvas-hint {
  position: absolute;
  left: 14px;
  top: 10px;
  margin: 0;
  /* A pill, because the hint sits over the track and the herds wander under it. */
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(9, 10, 14, 0.72);
  font-size: 11px;
  color: #9aa2b8;
  pointer-events: none;
  transition: opacity 240ms ease;
}

.canvas-hint.gone { opacity: 0; }

/* --------------------------------------------------------------- result */

.result {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(9, 10, 14, 0.72);
  animation: rise 180ms ease-out;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  min-width: 232px;
  max-width: 320px;
  text-align: center;
}

.card .kicker {
  margin: 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.card.lost .kicker { color: var(--hazard); }
.card.won .kicker { color: var(--accent); }

.card .big {
  margin: 6px 0 2px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.card .line {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.card .next {
  margin: 6px 0 2px;
  font-size: 11px;
  color: var(--accent);
  min-height: 1px;
}

.card .next:empty { display: none; }

.card .buttons {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  margin-top: 16px;
}

.card .buttons .btn { margin-bottom: 0; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------------- sound */

.mute {
  position: fixed;
  right: 12px;
  bottom: 12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  line-height: 1;
}

.mute:hover { color: var(--text); border-color: #3a4152; }
.mute[aria-pressed="true"] { color: #5a6072; }

/* ---------------------------------------------------------- contraction */

@media (max-width: 720px) {
  body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }

  .panel {
    max-height: 45vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px 14px 0;
  }

  .brand { font-size: 20px; margin-bottom: 6px; }
  /* The rail is a scrolling top bar on a phone, so the two things the player
     actually presses ride along at the bottom of it instead of sinking below
     two screens of settings. Contraction, not a second layout. */
  .actions {
    position: sticky;
    bottom: 0;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    align-items: stretch;
    background: var(--panel);
    margin-bottom: 0;
    padding: 8px 0 10px;
    border-top: 1px solid var(--line);
  }

  .actions .btn { margin-bottom: 0; }

  .intro { display: none; }
  .keys { display: none; }
  .canvas-hint { display: none; }
  .statusbar { padding: 8px 12px; gap: 2px 14px; }
  .mute { right: 8px; bottom: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
