/* LangWhich?. House chrome from joeycloud; the game surface is its own thing. */

/* The `hidden` attribute must always win. A bare `[hidden] { display: none }`
   in the UA sheet loses to ANY author rule that sets `display` — so `.options`
   (display: grid) kept the vocabulary choices on screen underneath a
   sentence-building question. !important here makes the attribute mean what it
   says for every element, in this app and in anything styled like it. */
[hidden] { display: none !important; }

:root {
  --bg: #0b0e13;
  --panel: #131922;
  --panel-2: #0f141b;
  --line: #232c39;
  --ink: #e6edf3;
  --muted: #8b98a5;
  --accent: #63d2a4;
  --accent-2: #4da3ff;
  --good: #46d39a;
  --bad: #ff8a8a;
  --warn: #ffcf7a;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent-2); }

/* ------------------------------------------------------------- top bar --- */
.topbar {
  display: flex; align-items: center; gap: .9rem;
  padding: .6rem 1rem;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.home-btn {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .32rem .62rem; border: 1px solid var(--line); border-radius: 7px;
  background: #161d27; color: var(--ink);
  font-size: .84rem; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.home-btn:hover { border-color: #39415a; text-decoration: none; }
.brand { display: flex; align-items: center; gap: .55rem; }
.brand-mark {
  display: grid; place-items: center; width: 28px; height: 28px;
  border-radius: 8px; background: linear-gradient(160deg, #2f6f57, #1b3d31);
  font-size: 1rem;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; font-weight: 650; }
.brand-text small { color: var(--muted); font-weight: 400; font-size: .72rem; }
.who { margin-left: auto; font-size: .82rem; color: var(--muted); }
.who strong { color: var(--ink); }
.who.muted { font-style: italic; }

/* --------------------------------------------------------------- layout --- */
main { max-width: 860px; margin: 0 auto; padding: 1.2rem 1rem 3rem; }
h2 { font-size: 1rem; margin: 1.4rem 0 .4rem; }
h2:first-child { margin-top: 0; }
.hint { color: var(--muted); font-size: .8rem; margin: .3rem 0 .6rem; }

.tabs { display: flex; gap: .3rem; margin-bottom: .9rem; flex-wrap: wrap; }
.tab {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 9px; padding: .4rem .8rem; font: inherit; font-size: .85rem;
  font-weight: 600; cursor: pointer;
}
.tab:hover { border-color: #39415a; color: var(--ink); }
.tab.is-active { background: #16302a; border-color: #2b5b4c; color: var(--ink); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; }
.panel[hidden] { display: none; }

/* ------------------------------------------------------------ pickers --- */
.lang-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: .5rem; }
.lang-grid.compact { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.lang-card {
  text-align: left; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: .55rem .7rem; cursor: pointer; font: inherit; color: var(--ink);
}
.lang-card:hover { border-color: #39415a; }
.lang-card.is-picked { border-color: var(--accent); background: #16302a; }
.lang-card .lc-native { display: block; font-size: 1.02rem; font-weight: 600; }
.lang-card .lc-name { display: block; font-size: .74rem; color: var(--muted); }

.chip-row { display: flex; gap: .45rem; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: .4rem;
  border: 1px solid var(--line); border-radius: 999px;
  padding: .32rem .75rem; font-size: .84rem; cursor: pointer; background: var(--panel-2);
}
.chip:has(input:checked) { border-color: var(--accent); background: #16302a; }
.chip input { margin: 0; }

.btn {
  background: #161d27; border: 1px solid var(--line); border-radius: 9px;
  color: var(--ink); padding: .5rem .9rem; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: #39415a; }
.btn.primary { background: #1f5b46; border-color: #2f7d61; color: #eafff6; }
.btn.primary:hover { border-color: var(--accent); }
.btn.wide { width: 100%; margin-top: .9rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .9rem; }

/* ---------------------------------------------------------------- game --- */
.hud { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .5rem; }
.hud-lang { font-weight: 650; }
.hud-mode { color: var(--muted); font-size: .78rem; margin-left: .5rem; }
.score { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); }
.hud-count { color: var(--muted); font-size: .8rem; margin-left: .5rem; }

.clock-track { height: 5px; background: #0d1219; border-radius: 999px; overflow: hidden; margin-bottom: 1rem; }
.clock-fill { height: 100%; width: 100%; background: var(--accent); transition: width .2s linear, background .4s; }
.clock-fill.low { background: var(--bad); }

.question-card {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 1.2rem 1rem; text-align: center; margin-bottom: 1rem;
}
.q-kicker { margin: 0 0 .4rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.q-prompt { margin: 0; font-size: 1.7rem; font-weight: 650; line-height: 1.3; }
.q-roman { margin: .35rem 0 0; color: var(--muted); font-size: .9rem; min-height: 1.2rem; }

.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .5rem; }
.option {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: .8rem .9rem; font: inherit; color: var(--ink); cursor: pointer; text-align: left;
}
.option:hover { border-color: var(--accent-2); }
.option .opt-text { display: block; font-size: 1.05rem; font-weight: 600; }
.option .opt-roman { display: block; font-size: .76rem; color: var(--muted); }
.option.right { border-color: var(--good); background: #14301f; }
.option.wrong { border-color: var(--bad); background: #341a1a; }
.option:disabled { cursor: default; }

.bank-built {
  min-height: 3.2rem; border-bottom: 2px solid var(--line); margin-bottom: .8rem;
  display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; padding-bottom: .4rem;
}
.bank { display: flex; flex-wrap: wrap; gap: .35rem; }
.tile {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
  padding: .45rem .7rem; font: inherit; font-size: 1rem; color: var(--ink); cursor: pointer;
}
.tile:hover { border-color: var(--accent-2); }
.tile.used { opacity: .25; cursor: default; }
.tile.placed { background: #1d2735; }

.feedback { min-height: 1.6rem; margin-top: .8rem; font-size: .88rem; font-weight: 600; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }

/* ------------------------------------------------------------- results --- */
.result h2 { font-size: 1.5rem; margin-top: 0; }
.result-sub { color: var(--muted); margin: 0 0 1rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1.2rem; font-size: .9rem; margin: 0 0 .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.bar { height: 8px; background: #0d1219; border-radius: 999px; overflow: hidden; margin: .3rem 0; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.missed { margin-top: 1.2rem; }
.missed-row { display: flex; justify-content: space-between; gap: 1rem; font-size: .85rem; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.missed-row .mr-right { color: var(--good); font-weight: 600; }

/* -------------------------------------------------------------- boards --- */
.boards { display: flex; flex-direction: column; gap: 1rem; }
.board { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.board-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: .6rem;
  background: var(--panel-2); padding: .5rem .75rem; font-weight: 600;
}
.board-head .bh-sub { color: var(--muted); font-weight: 400; font-size: .76rem; }
table.lb { border-collapse: collapse; width: 100%; font-size: .85rem; }
table.lb th, table.lb td { padding: .4rem .75rem; text-align: left; border-top: 1px solid var(--line); }
table.lb th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
table.lb td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.lb tr.is-me { background: #16302a; }
.lvl { display: inline-block; min-width: 2.6rem; text-align: center; border-radius: 999px;
       padding: 0 .5rem; font-weight: 700; font-size: .8rem; background: #1d2735; }
.lvl.high { background: #2f5b8a; }
.lvl.max { background: #6b4a12; }
.empty-note { color: var(--muted); font-size: .85rem; padding: .6rem .75rem; }
.notfound { max-width: 520px; margin: 4rem auto; padding: 0 1rem; }

/* ------------------------------------------------------------- new round ---
   The setup is a dialog that fills in one step at a time, so the later choices
   are not on screen before the earlier ones have an answer. */
.idle { padding: .5rem 0 1rem; }
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  padding: 1rem;
}
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(6, 9, 14, .72); backdrop-filter: blur(2px); }
.modal-card {
  position: relative;
  width: min(32rem, 100%);
  max-height: min(88vh, 46rem);
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
}
.modal-head {
  flex: none; display: flex; align-items: center; gap: .6rem;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 1.02rem; }
.modal-x {
  margin-left: auto; flex: none;
  width: 28px; height: 28px;
  background: #131a24; color: var(--muted);
  border: 1px solid var(--line); border-radius: 7px;
  font-size: .85rem; line-height: 1; cursor: pointer;
}
.modal-x:hover { color: var(--ink); border-color: var(--accent); }
.modal-body { padding: 1rem; overflow: auto; }
.modal-body h2 { margin: 0 0 .5rem; font-size: .95rem; }
/* Each revealed step gets a quiet rule above it, so the dialog reads as a
   sequence rather than a jumble. */
.step { padding-top: .9rem; border-top: 1px solid var(--line); margin-top: .9rem; }
.step[data-step="target"] { padding-top: 0; border-top: 0; margin-top: 0; }
