:root {
  /* Jeopardy palette */
  --bg: #00012a;             /* deep navy backdrop, just shy of black */
  --bg-2: #060CE9;           /* iconic Jeopardy blue (board cells, headers) */
  --bg-3: #04089c;           /* darker variant for disabled / used cells */
  --bg-card: #0a155d;        /* card surfaces */
  --gold: #F2C75C;           /* Jeopardy gold ($/amount text) */
  --gold-bright: #FFD876;
  --gold-dim: #8d6c2a;
  --text: #ffffff;
  --text-dim: #a7adcf;
  --accent: #060CE9;
  --danger: #e25862;
  --green: #4ec27a;
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  background: var(--gold);
  color: #1a1500;
  border: none;
  border-radius: 10px;
  padding: 0.85em 1.4em;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.05s, background 0.15s;
}

button:hover:not(:disabled) { background: #ffd55a; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { background: #444; color: #999; cursor: not-allowed; box-shadow: none; }

input[type="text"], input:not([type]) {
  font-family: inherit;
  font-size: 1.05rem;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 10px;
  padding: 0.75em 1em;
  width: 100%;
}

a { color: var(--accent); }
code { background: rgba(255,255,255,0.08); padding: 0 0.3em; border-radius: 3px; }
hr { border: none; border-top: 1px solid rgba(255,255,255,0.12); margin: 1.5em 0; }
h1, h2, h3 { margin-top: 0; font-weight: 700; }

/* ---------------- Player (phone) ---------------- */

body.page-join, body.page-play {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body.page-join main, body.page-play main {
  flex: 1;
  padding: 1.2em;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}

body.page-join h1 { font-size: 2rem; margin-bottom: 1.2em; color: var(--gold); }
body.page-join form { display: flex; flex-direction: column; gap: 1em; }
body.page-join label { display: flex; flex-direction: column; gap: 0.4em; color: var(--text-dim); font-size: 0.95em; }

.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85em 1.2em;
  background: var(--bg-card);
  border-bottom: 2px solid var(--bg-2);
}
.player-header .name { font-weight: 700; }
.player-header .score { color: var(--gold); font-weight: 700; font-size: 1.1rem; }

.phase { text-align: center; padding: 1em 0; }
.phase h2 { color: var(--gold); margin-bottom: 0.5em; }
.phase .muted { color: var(--text-dim); }

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75em;
  margin-top: 1.2em;
}
.choice-grid button {
  font-size: 1.05rem;
  padding: 1.4em 1em;
  text-align: left;
  white-space: normal;
  background: var(--bg-2);
  color: var(--text);
  border: 2px solid transparent;
  min-height: 110px;
}
.choice-grid button:hover:not(:disabled) { background: #1a30ff; }
.choice-grid button.selected { border-color: var(--gold); background: var(--gold); color: #1a1500; }
.choice-grid button.correct { border-color: var(--green); background: rgba(78,194,122,0.2); }
.choice-grid button.wrong { border-color: var(--danger); background: rgba(226,88,98,0.18); }
.choice-letter { font-weight: 700; opacity: 0.7; margin-right: 0.5em; }

.timer-bar {
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  margin: 0.6em 0;
  overflow: hidden;
}
.timer-bar > div {
  height: 100%;
  background: var(--gold);
  transition: width 0.2s linear;
}

/* Legacy 3-col per-category picker (no longer used in favor of phone-board grid). */
.picker-cells {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5em;
  margin-top: 1em;
}
.picker-cells button {
  padding: 0.9em 0.4em;
  font-size: 1rem;
}

/* Phone-side full board picker — mirrors controller board (cats × amounts) */
.phone-board {
  display: grid;
  gap: 4px;
  margin-top: 0.8em;
  width: 100%;
  min-width: 0;
}
.phone-board .pb-header,
.phone-board .pb-row {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.phone-board .pb-cell {
  background: var(--bg-2);
  color: var(--gold);
  font-weight: 800;
  font-size: 1.2rem;
  border: none;
  border-radius: 3px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  box-shadow: none;
  transition: transform 0.06s, background 0.12s;
}
.phone-board .pb-cell:hover:not(:disabled) { background: #1a30ff; }
.phone-board .pb-cell:active:not(:disabled) { transform: scale(0.95); }
.phone-board .pb-cell:disabled {
  background: var(--bg-3);
  color: transparent;
  cursor: not-allowed;
  opacity: 0.55;
}
.phone-board .pb-cat {
  background: var(--bg-2);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.45em 0.2em;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.05;
  aspect-ratio: 1 / 0.55;
  min-width: 0;
  overflow: hidden;
  word-break: break-word;
  hyphens: auto;
}

.pill {
  display: inline-block;
  padding: 0.25em 0.7em;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
  color: var(--text-dim);
  font-size: 0.85rem;
}
.pill.gold { background: var(--gold); color: #1a1500; font-weight: 700; }

/* ---------------- Controller (big screen) ---------------- */

body.page-controller {
  overflow: hidden;
}

#controller-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "header header"
    "stage  scoreboard";
  height: 100vh;
}

#controller-layout > header {
  grid-area: header;
  padding: 0.8em 1.5em;
  background: var(--bg-card);
  border-bottom: 2px solid var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#controller-layout > header h1 {
  margin: 0;
  font-size: 1.6rem;
  color: var(--gold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-shadow: 0 2px 0 rgba(0,0,0,0.4);
}
#controller-layout > header .join-info {
  display: flex;
  align-items: center;
  gap: 1em;
  color: var(--text-dim);
  font-size: 0.95rem;
}
#controller-layout > header .join-info .qr {
  width: 72px; height: 72px; background: #fff; padding: 4px; border-radius: 6px;
  display: block;
}

#stage {
  grid-area: stage;
  padding: 1.5em;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#scoreboard {
  grid-area: scoreboard;
  background: var(--bg-card);
  padding: 1em;
  overflow-y: auto;
  border-left: 2px solid var(--bg-2);
}
#scoreboard h2 { font-size: 1rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }
#scoreboard ol { list-style: none; padding: 0; margin: 0; }
#scoreboard li {
  display: flex;
  justify-content: space-between;
  padding: 0.4em 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
#scoreboard li .pos { color: var(--text-dim); width: 1.6em; }
#scoreboard li .name { flex: 1; }
#scoreboard li .pts { color: var(--gold); font-weight: 700; }
#scoreboard li.is-picker { background: rgba(245,197,66,0.12); }

.board {
  flex: 1;
  display: grid;
  gap: 6px;
  min-height: 0;
}
.board-header, .board-row {
  display: grid;
  gap: 6px;
}
.board-cell {
  background: var(--bg-2);
  border: 2px solid var(--bg);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  text-align: center;
  padding: 0.4em;
  min-height: 60px;
  text-shadow: 0 2px 0 rgba(0,0,0,0.4);
}
.board-cell.category {
  background: var(--bg-2);
  color: #fff;
  text-transform: uppercase;
  font-size: 1.1rem;
  letter-spacing: 0.05em;
}
.board-cell.amount {
  color: var(--gold);
  font-size: 2.4rem;
  cursor: default;
}
.board-cell.used {
  color: transparent;
  background: var(--bg-3);
  opacity: 0.4;
}
.board-cell.highlight { animation: pulse 0.6s ease infinite alternate; }

@keyframes pulse {
  from { box-shadow: 0 0 0 0 var(--gold); }
  to   { box-shadow: 0 0 0 6px rgba(245,197,66,0.25); }
}

.stage-intro, .stage-question, .stage-reveal, .stage-pick, .stage-end {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1em;
}
.stage-intro h2 { color: var(--gold); font-size: 2rem; margin: 0; }
.stage-intro .amount { font-size: 3rem; color: var(--gold); font-weight: 800; }

.stage-question .qtext {
  font-size: 1.8rem;
  font-weight: 600;
  max-width: 950px;
  line-height: 1.3;
}
.stage-question .qchoices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8em;
  width: 100%;
  max-width: 950px;
  margin-top: 1em;
}
.stage-question .qchoices .choice {
  background: var(--bg-card);
  padding: 1em;
  border-radius: 8px;
  font-size: 1.2rem;
  text-align: left;
  border: 2px solid var(--bg-2);
}
.stage-question .qchoices .choice.correct { background: rgba(78,194,122,0.25); border-color: var(--green); }
.stage-question .qchoices .choice.wrong-many { opacity: 0.4; }
.stage-question .submission-counter { font-size: 1.1rem; color: var(--text-dim); }
.stage-question .timer-num { font-size: 4rem; font-weight: 800; color: var(--gold); }

.stage-reveal h2 { color: var(--gold); }
.stage-reveal .counts { color: var(--text-dim); }

.stage-pick h2 { color: var(--gold); font-size: 2rem; }
.stage-pick .who { font-size: 1.4rem; }
.stage-pick .timer-num { font-size: 3rem; color: var(--gold); font-weight: 800; }

.stage-end .winner { font-size: 3.5rem; color: var(--gold); font-weight: 800; }
.stage-end .final-list { font-size: 1.2rem; max-width: 600px; width: 100%; }
.stage-end .final-list li { padding: 0.5em 0; border-bottom: 1px solid rgba(255,255,255,0.08); display: flex; justify-content: space-between; }

.host-controls {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  gap: 0.5em;
  align-items: center;
  opacity: 0.85;
}
.host-controls:hover { opacity: 1; }
.host-controls button {
  background: rgba(255,255,255,0.18);
  color: var(--text);
  padding: 0.5em 0.9em;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: none;
  border: 1px solid rgba(255,255,255,0.2);
}
.host-controls button:hover { background: rgba(255,255,255,0.3); }
#ws-status {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--green);
  margin-right: 0.3em;
  text-shadow: 0 0 4px currentColor;
}
#ws-status.disconnected { color: var(--danger); }
