/* Swing Shift — UI in the approved palette: deep teal, brass, cream; vermilion only
   for hazards and pickups. Layout: portrait = world on top, control deck below;
   landscape = controls at the sides. Touch decks appear only on touch devices. */

:root {
  color-scheme: dark;
  --bg: #0a1418;
  --panel: rgba(15, 42, 51, 0.94);
  --panel-solid: #0f2a33;
  --ink: #151b1e;
  --cream: #efe2c4;
  --dim: #a9b8b4;
  --brass: #c9a14a;
  --brass-dark: #8a6a2c;
  --signal: #ff4d2e;
  --focus: #ffd27a;
  --text-scale: 1;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-size: calc(16px * var(--text-scale));
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--cream);
  font: 1rem/1.4 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ── layout ─────────────────────────────────────────────────────────────────── */

.app {
  height: 100dvh;
  display: grid;
  grid-template-areas: "stage" ;
  grid-template-rows: 1fr;
}
.stage { grid-area: stage; position: relative; min-height: 0; min-width: 0; overflow: hidden; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.deck { display: none; }

.touch .app {
  grid-template-areas: "stage stage" "move grip";
  grid-template-rows: auto 1fr;
  grid-template-columns: 1fr 1fr;
}
.touch .stage { aspect-ratio: 4 / 3; width: 100%; max-height: 62dvh; justify-self: center; }
.touch .deck {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 12px 16px calc(12px + var(--safe-b));
}
.touch .deck-move { grid-area: move; }
.touch .deck-grip { grid-area: grip; }
.touch.left-handed .app { grid-template-areas: "stage stage" "grip move"; }

@media (orientation: landscape) {
  .touch .app {
    grid-template-areas: "move stage grip";
    grid-template-rows: 1fr;
    grid-template-columns: minmax(150px, 1fr) auto minmax(150px, 1fr);
  }
  .touch .stage { height: 100dvh; width: auto; max-height: none; aspect-ratio: 4 / 3; max-width: calc(100vw - 300px); }
  .touch .deck-move { flex-direction: row; }
  .touch.left-handed .app { grid-template-areas: "grip stage move"; }
}

.pad, .grip {
  border: 3px solid var(--ink);
  background: linear-gradient(#d8b25c, var(--brass-dark));
  color: var(--ink);
  font-weight: 800;
  box-shadow: 0 4px 0 #3c2d12, inset 0 2px 0 rgba(255,255,255,.35);
  touch-action: none;
}
.pad { width: 76px; height: 76px; border-radius: 18px; font-size: 1.6rem; }
.grip { width: 120px; height: 120px; border-radius: 50%; font-size: 1.15rem; text-transform: uppercase; letter-spacing: .06em; }
.pad.is-held, .grip.is-held { transform: translateY(3px); box-shadow: 0 1px 0 #3c2d12; filter: brightness(1.12); }

/* ── HUD ────────────────────────────────────────────────────────────────────── */

.hud {
  position: absolute; left: 0; right: 0; top: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px;
  pointer-events: none;
  text-shadow: 0 2px 0 var(--ink);
}
.hud b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.hud-score { display: flex; align-items: baseline; gap: 6px; }
.mult { color: var(--focus); font-weight: 700; }
.hud-rings { display: flex; gap: 3px; }
.hud-rings i { width: 13px; height: 13px; border-radius: 50%; border: 3px solid var(--signal); box-shadow: 0 0 0 1px var(--ink); }
.hud-rings i.lost { border-color: #44504f; }
.hud-time { margin-left: auto; }
.hud-time.urgent b { color: var(--signal); }
.icon-btn {
  pointer-events: auto;
  width: 44px; height: 44px; border-radius: 12px;
  border: 2px solid var(--ink); background: rgba(15,42,51,.8); font-weight: 800;
}

.banner {
  position: absolute; left: 50%; top: 22%; transform: translateX(-50%);
  padding: 6px 14px; border-radius: 999px;
  background: rgba(21,27,30,.82); border: 2px solid var(--brass);
  font-weight: 700; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .25s ease;
}
.banner.show { opacity: 1; }
.banner.warn { border-color: var(--signal); }

.ready {
  position: absolute; inset: auto 0 12% 0; text-align: center; pointer-events: none;
  text-shadow: 0 2px 0 var(--ink);
}
.ready-controls { font-weight: 700; font-size: 1.05rem; margin: 0 0 4px; }
.ready-go { margin: 0; color: var(--focus); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* ── screens and dialogs ────────────────────────────────────────────────────── */

.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 16px; text-align: center;
  background: radial-gradient(ellipse at center, rgba(15,42,51,.72), rgba(10,20,24,.94));
  overflow-y: auto;
}
.brand-mark { display: flex; align-items: center; gap: 6px; font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.title { margin: 0; font-size: clamp(1.8rem, 6vw, 2.8rem); line-height: 1.05; color: var(--brass); text-shadow: 0 3px 0 var(--ink); letter-spacing: .02em; }
.tagline { margin: 0 0 6px; max-width: 34ch; color: var(--dim); }
.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.meta { margin: 0; color: var(--dim); font-size: .9rem; }
.conn { color: var(--signal); }
.more { color: var(--focus); }

.btn {
  min-height: 48px; padding: 10px 18px; border-radius: var(--radius);
  border: 2px solid var(--ink); background: #1d4651; cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.btn-primary { background: linear-gradient(#d8b25c, var(--brass-dark)); color: var(--ink); font-weight: 800; }
.btn-primary small { display: block; font-weight: 600; opacity: .85; }
.btn-ghost { background: transparent; border-color: #3b5960; box-shadow: none; }
#btn-daily { min-width: min(320px, 90%); font-size: 1.15rem; }

.big-score { margin: 0; font-size: 3rem; color: var(--brass); text-shadow: 0 3px 0 var(--ink); font-variant-numeric: tabular-nums; }
.stats { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, auto); gap: 2px 18px; color: var(--dim); }
.rank { min-height: 1.4em; margin: 2px 0; font-weight: 700; color: var(--focus); }

.dlg {
  width: min(92vw, 380px); max-height: 88dvh; overflow: auto;
  border: 3px solid var(--ink); border-radius: 18px; padding: 18px;
  background: var(--panel-solid); color: var(--cream);
  display: none; flex-direction: column; gap: 10px;
}
.dlg[open] { display: flex; }
.dlg-wide { width: min(94vw, 520px); }
.dlg::backdrop { background: rgba(5,10,12,.7); }
.dlg h2 { margin: 0 0 4px; color: var(--brass); }
.howto { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; text-align: left; }
.board { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.board li { display: grid; grid-template-columns: 2.4em 1fr auto; gap: 8px; padding: 4px 8px; border-radius: 8px; background: rgba(255,255,255,.04); }
.board li.you { background: rgba(201,161,74,.25); font-weight: 700; }
.board .score { font-variant-numeric: tabular-nums; }
.settings { display: grid; gap: 10px; }
.settings label { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; }
.settings label.check { justify-content: flex-start; }
.settings input[type=checkbox] { width: 22px; height: 22px; }
#form-nick { display: grid; gap: 10px; }
#form-nick label { display: grid; gap: 4px; text-align: left; }
input, select { font: inherit; padding: 8px 10px; border-radius: 10px; border: 2px solid var(--ink); background: #0b1f26; color: var(--cream); }

/* ── accessibility modes ────────────────────────────────────────────────────── */

.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after {
  animation: none !important; transition: none !important;
}
.high-contrast { --dim: #e6efe9; --panel-solid: #04161b; }
.high-contrast .btn, .high-contrast .pad, .high-contrast .grip { border-color: #fff; }
.high-contrast .banner { background: #000; }
