/* Corporate Buzzword Bingo — navy & blue, per the mockup */

:root {
  --navy: #101c3a;
  --navy-deep: #0b142b;
  --blue: #4a7fe8;
  --blue-bright: #6ba0ff;
  --blue-pale: #cddcf7;
  --paper: #f5f4ef;
  --paper-dim: #e8e6de;
  --ink: #1a2647;
  --gold: #f4c542;
  /* Derived translucents — themes must override these too */
  --line: rgba(107, 160, 255, 0.35);        /* hairline borders */
  --tint: rgba(74, 127, 232, 0.14);         /* soft fills / hovers */
  --tint-strong: rgba(74, 127, 232, 0.28);  /* marked-square glow */
  --backdrop: rgba(11, 20, 43, 0.88);       /* overlay dim layer */
  --radius: 10px;
}

/* ---------- Pack themes (ENGINEERING.md §24) ----------
 * Theme + word list travel together: app.js sets body[data-pack] from
 * the selected deck, and the theme rides the share URL's &pack= param,
 * so every joiner gets the same skin. Everything below re-points the
 * palette; layout never changes. */

body[data-pack="fire"] {
  --navy: #2b0d0a;
  --navy-deep: #1b0605;
  --blue: #e0452f;
  --blue-bright: #ff7a5c;
  --blue-pale: #f6cfc2;
  --paper: #fdf3e7;
  --paper-dim: #f3e2cd;
  --ink: #3a1410;
  --gold: #ffb238;
  --line: rgba(255, 122, 92, 0.35);
  --tint: rgba(224, 69, 47, 0.14);
  --tint-strong: rgba(224, 69, 47, 0.28);
  --backdrop: rgba(24, 6, 4, 0.9);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
}

body {
  background: var(--navy);
  color: var(--paper);
  font-family: "Avenir Next", "Segoe UI", Futura, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 860px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.view { display: flex; flex-direction: column; flex: 1; }
[hidden] { display: none !important; }

/* ---------- Masthead ---------- */

.masthead { text-align: center; padding: 28px 0 8px; }
.megaphone { font-size: 44px; transform: rotate(-12deg); display: inline-block; }

.masthead-kicker {
  font-size: clamp(26px, 6vw, 44px);
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--paper);
}

.masthead-title {
  font-size: clamp(56px, 14vw, 110px);
  font-weight: 900;
  letter-spacing: 18px;
  margin-left: 18px; /* offset trailing letter-spacing */
  color: var(--blue);
  line-height: 1;
}

.masthead-tag {
  color: var(--blue-bright);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: clamp(11px, 2.6vw, 15px);
  margin-top: 10px;
}

/* ---------- Lobby ---------- */

.lobby {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 36px 0;
}

.btn {
  font: inherit;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--blue);
  color: white;
  padding: 14px 28px;
  font-size: 16px;
}
.btn-primary:hover { filter: brightness(1.1); }

.btn-big { font-size: 20px; padding: 18px 40px; }

.btn-secondary {
  background: transparent;
  color: var(--blue-bright);
  border: 2px solid var(--blue);
  padding: 10px 18px;
  font-size: 14px;
}
.btn-secondary:hover { background: var(--tint); }

.btn-small { padding: 7px 14px; font-size: 12px; }

.pack-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--blue-pale);
  font-size: 14px;
  font-weight: 700;
}
#select-pack {
  font: inherit;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 2px solid var(--blue);
  background: var(--navy-deep);
  color: var(--paper);
  outline: none;
}
#select-pack:focus { border-color: var(--blue-bright); }

.lobby-divider {
  color: var(--blue-pale);
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.lobby-divider::before,
.lobby-divider::after {
  content: "";
  display: block;
  width: 60px;
  height: 1px;
  background: currentColor;
}

.join-form { display: flex; gap: 10px; }

#input-code {
  font: inherit;
  font-weight: 800;
  letter-spacing: 6px;
  text-transform: uppercase;
  text-align: center;
  width: 190px;
  padding: 10px 6px;
  border-radius: var(--radius);
  border: 2px solid var(--blue);
  background: var(--navy-deep);
  color: var(--paper);
  outline: none;
}
#input-code:focus { border-color: var(--blue-bright); }
#input-code::placeholder { color: var(--blue-pale); opacity: 0.4; letter-spacing: 3px; }

.join-error { color: #ff9a9a; font-size: 14px; }

/* ---------- Rules strip ---------- */

.rules-strip {
  margin-top: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  border-top: 2px solid var(--line);
  padding: 20px 4px 10px;
}

.rules-col h3 {
  color: var(--blue-bright);
  text-transform: uppercase;
  font-size: 13px;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.rules-col ul { list-style: none; }
.rules-col li {
  font-size: 12.5px;
  color: var(--blue-pale);
  padding-left: 14px;
  position: relative;
  margin-bottom: 5px;
  line-height: 1.35;
}
.rules-col li::before { content: "•"; position: absolute; left: 0; color: var(--blue); }

@media (max-width: 620px) {
  .rules-strip { grid-template-columns: 1fr; }
}

/* ---------- Game header ---------- */

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 0 14px;
}

.home-link {
  color: var(--paper);
  font-weight: 900;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 15px;
}
.home-link:hover { color: var(--blue-bright); }

.game-header-right { display: flex; align-items: center; gap: 10px; }

.code-chip {
  background: var(--navy-deep);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--blue-pale);
}
.code-chip strong { color: white; letter-spacing: 2px; }

.pack-chip {
  background: var(--navy-deep);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
}

/* ---------- Status banner ---------- */

.status-banner {
  text-align: center;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-size: clamp(11px, 2.6vw, 14px);
  color: var(--blue-bright);
  padding: 6px 0 14px;
}

.rule-note {
  text-align: center;
  font-size: clamp(11px, 2.4vw, 13px);
  font-style: italic;
  color: var(--blue-pale);
  padding: 8px 0 2px;
}

.scorebar {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: clamp(11px, 2.6vw, 14px);
  font-weight: 700;
  color: var(--paper);
  padding: 0 0 10px;
}
.scorebar #score-now { color: var(--gold); }
.scorebar-sep { opacity: 0.5; }

/* ---------- Career ladder module (ENGINEERING.md §13) ---------- */

.career-module {
  display: block;
  width: min(100%, 420px);
  margin: 0 auto 12px;
  background: var(--navy-deep);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  cursor: pointer;
  font: inherit;
  color: var(--paper);
  text-align: left;
  transition: border-color 0.15s ease;
}
.career-module:hover { border-color: var(--blue-bright); }

.career-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.career-rank {
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: clamp(15px, 3.6vw, 19px);
  color: var(--gold);
}
.career-points {
  font-size: 12px;
  font-weight: 700;
  color: var(--blue-pale);
  white-space: nowrap;
}

.career-bar {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: var(--tint);
  margin: 8px 0 6px;
  overflow: hidden;
}
.career-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--blue-bright));
  transition: width 0.4s ease;
}
.career-next { font-size: 11px; color: var(--blue-pale); opacity: 0.85; }

/* ---------- Game layout (board + roster) ---------- */

.game-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-start;
  justify-content: center;
}

/* The board column scales with the window: never wider than the layout,
 * never taller than what's left of the viewport after the app chrome,
 * capped so it doesn't grow huge on big monitors. */
.board-col {
  flex: 1 1 300px;
  width: 100%;
  max-width: clamp(260px, calc(100dvh - 250px), 560px);
  margin: 0 auto;
  container-type: inline-size;
}

.roster { flex: 1 1 200px; max-width: 280px; min-width: 200px; }

@media (max-width: 640px) {
  .board-col { max-width: min(100%, clamp(260px, calc(100dvh - 250px), 560px)); }
  .roster { max-width: none; }
}

/* ---------- Board ---------- */

.board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  background: var(--navy-deep);
  border: 3px solid var(--paper);
  border-radius: 6px;
  padding: 6px;
}

.board-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(14px, 4.5cqw, 34px);
  font-weight: 900;
  color: var(--blue);
  background: var(--paper);
  border-radius: 3px;
  padding: 4px 0;
}

.cell {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px;
  background: var(--paper);
  color: var(--ink);
  border: none;
  border-radius: 3px;
  font: inherit;
  font-weight: 700;
  text-transform: uppercase;
  font-size: clamp(7px, 1.9cqw, 13px);
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.12s ease;
  overflow: hidden;
  word-break: break-word;
  hyphens: auto;
}
.cell:hover { background: var(--paper-dim); }

.cell.marked {
  background: var(--blue-pale);
  color: var(--navy);
}
.cell.marked::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at center, var(--tint-strong) 0 58%, transparent 60%);
  pointer-events: none;
}

.cell.free {
  background: var(--blue-pale);
  color: var(--navy);
  font-weight: 900;
  cursor: default;
}

.cell.in-line {
  outline: 3px solid var(--gold);
  outline-offset: -3px;
}

.cell.freq-rare::before {
  content: "★";
  position: absolute;
  top: 1px;
  right: 3px;
  font-size: 10px;
  line-height: 1;
  color: var(--gold);
}

.cell.pop { animation: pop 0.18s ease; }
@keyframes pop {
  50% { transform: scale(1.07); }
}

/* ---------- Roster ---------- */

.roster {
  background: var(--navy-deep);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.roster-title {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--blue-bright);
  margin-bottom: 10px;
}

.name-form { display: flex; flex-wrap: wrap; gap: 8px; }

#input-name {
  font: inherit;
  font-weight: 700;
  flex: 1 1 120px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 2px solid var(--blue);
  background: var(--navy);
  color: var(--paper);
  outline: none;
}
#input-name:focus { border-color: var(--blue-bright); }
#input-name::placeholder { color: var(--blue-pale); opacity: 0.5; }

.name-note {
  flex-basis: 100%;
  font-size: 11px;
  font-style: italic;
  color: var(--blue-pale);
  opacity: 0.8;
}

.roster-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }

.roster-player {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--tint);
  font-size: 14px;
}
.roster-player.me { outline: 2px solid var(--blue); }
.roster-player .p-name {
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}
.roster-player .p-score { font-weight: 800; color: var(--gold); white-space: nowrap; }
.roster-player .p-marks { font-size: 11px; color: var(--blue-pale); white-space: nowrap; }
.roster-player.leader .p-name::after { content: " 👑"; }

.roster-status {
  margin-top: 8px;
  font-size: 11px;
  font-style: italic;
  color: var(--blue-pale);
  opacity: 0.8;
}

/* ---------- Bonus bar ---------- */

.bonus-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 0 4px;
}

.bonus-buttons { display: contents; }

.bonus-label {
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 11px;
  color: var(--blue-pale);
  opacity: 0.7;
}

.btn-bonus {
  background: transparent;
  border: 1.5px dashed var(--blue);
  color: var(--blue-pale);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
}
.btn-bonus:hover { background: var(--tint); }
.bonus-reward { color: var(--gold); font-weight: 800; margin-left: 4px; }

.wild-count {
  background: var(--gold);
  color: var(--navy);
  font-weight: 900;
  font-size: 12px;
  border-radius: 999px;
  padding: 6px 12px;
  animation: pop 0.18s ease;
}

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

.game-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 10px 0;
}

/* ---------- Scoring strip ---------- */

.scoring-strip {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
  border-top: 2px solid var(--line);
  padding: 14px 0 6px;
}

.tier {
  font-size: 12px;
  color: var(--blue-pale);
  opacity: 0.55;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tier.achieved { opacity: 1; color: var(--gold); font-weight: 800; }
.tier.current { opacity: 0.9; color: var(--blue-bright); font-weight: 700; }

/* ---------- Win overlay ---------- */

.win-overlay {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.win-box {
  background: var(--paper);
  color: var(--ink);
  border-radius: 16px;
  text-align: center;
  padding: 36px 32px 26px;
  max-width: 420px;
  width: 100%;
  animation: winpop 0.25s ease;
}
@keyframes winpop {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.win-emoji { font-size: 56px; }
.win-box h2 {
  font-size: 44px;
  font-weight: 900;
  letter-spacing: 6px;
  color: var(--blue);
  margin: 8px 0 4px;
}
.win-box p { font-weight: 700; margin-bottom: 20px; }
.win-points {
  color: var(--blue);
  font-size: 15px;
  margin-bottom: 12px !important;
}
.win-flex {
  margin-top: 18px;
  font-size: 12px !important;
  font-weight: 500 !important;
  color: #6a7290;
  line-height: 1.5;
}

/* ---------- Ladder overlay ---------- */

.ladder-box { max-width: 460px; text-align: left; padding: 26px 26px 22px; }
.ladder-box h2 {
  font-size: 24px;
  letter-spacing: 2px;
  text-align: center;
  margin: 0 0 14px;
}
.ladder-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 18px;
  max-height: 55vh;
  overflow-y: auto;
}
.ladder-rung {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
  color: #6a7290;
}
.ladder-rung .rung-pts { font-size: 12px; white-space: nowrap; }
.ladder-rung.cleared { color: var(--ink); }
.ladder-rung.cleared .rung-pts { color: #3a9d5c; }
.ladder-rung.current { background: var(--blue); color: white; }

/* ---------- Promotion overlay ---------- */

.promo-sub {
  font-size: 13px !important;
  font-weight: 500 !important;
  color: #6a7290;
  margin-bottom: 10px !important;
}
.promo-rank {
  display: inline-block;
  background: var(--gold);
  color: var(--navy);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 20px;
  padding: 8px 20px;
  border-radius: 999px;
  margin-bottom: 22px !important;
}

/* ---------- Overlay action rows + rank sharing (ENGINEERING.md §23) ---------- */

.overlay-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
/* btn-secondary is styled for the navy page; on paper overlays the
 * outline needs the solid brand color to stay readable. */
.btn-share-rank {
  color: var(--blue);
  border-color: var(--blue);
}
.ladder-box .overlay-actions { justify-content: center; }

/* ---------- Host control ---------- */

.btn-host { border-color: var(--gold); color: var(--gold); }
.btn-host:hover { background: rgba(244, 197, 66, 0.15); }

/* ---------- Confetti ---------- */

.confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 70; /* above overlays and toast — it's the celebration layer */
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--blue);
  color: white;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 22px;
  border-radius: 999px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  z-index: 60;
  animation: toast-in 0.2s ease;
}
@keyframes toast-in {
  from { transform: translate(-50%, 12px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
