/* ============================================================
   Wheel of Fortune — Styles
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0a0a1a;
  --bg-card:     #12122a;
  --bg-tile:     #1e1e3f;
  --accent:      #FFD700;
  --accent2:     #E31837;
  --green:       #27ae60;
  --blue:        #2980b9;
  --text:        #f0f0f0;
  --text-muted:  #888;
  --radius:      8px;
  --tile-size:   58px;
  --tile-gap:    4px;
}

html, body { height: 100%; background: linear-gradient(rgba(0,0,0,0.65), rgba(0,0,0,0.65)), url('background.png') center center / cover fixed no-repeat; color: var(--text); font-family: 'Segoe UI', Arial, sans-serif; }
#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ── Shared Utilities ─────────────────────────────────────── */
.screen { display: flex; flex-direction: column; }
.muted  { color: var(--text-muted); font-size: 0.9rem; }

.btn {
  padding: 0.5rem 1.2rem; border: none; border-radius: var(--radius);
  cursor: pointer; font-size: 1rem; font-weight: 600; transition: filter 0.15s, transform 0.1s;
}
.btn:hover:not(:disabled) { filter: brightness(1.15); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary   { background: var(--accent); color: #000; }
.btn-secondary { background: #333; color: var(--text); }
#btn-buy-vowel { background: #d96b00; color: #fff; }
#btn-buy-vowel:hover:not(:disabled) { background: #f07a00; }
.btn-solve     { background: var(--green); color: #fff; }
.btn-skip      { background: #1a5fa8; color: #fff; }
.btn-skip:hover { background: #2272c3; }
.btn-large     { padding: 0.75rem 2rem; font-size: 1.15rem; }
.btn-small     { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

.inline-form { display: flex; gap: 0.5rem; margin-top: 1rem; }
.inline-form input {
  flex: 1; padding: 0.6rem 0.9rem; border-radius: var(--radius);
  border: 2px solid #333; background: #1a1a30; color: var(--text); font-size: 1rem;
}
.inline-form input:focus { outline: none; border-color: var(--accent); }

/* ── WOF Logo ─────────────────────────────────────────────── */
.wof-logo-small, .wof-logo-header {
  font-family: 'Impact', 'Arial Black', sans-serif;
  letter-spacing: 0.15em; color: var(--accent);
  text-shadow: 0 0 20px rgba(255,215,0,0.5);
}
.wof-logo-small  { font-size: 2rem; text-align: center; margin-bottom: 1.2rem; }
.wof-logo-small.wof-logo-lobby { font-size: 4.5rem; margin-bottom: 1rem; }
.wof-logo-header { font-size: 1.9rem; }
.wof-logo-img {
  display: block;
  margin: 0 auto 1.2rem;
  max-width: 100%;
}
.wof-logo-img.wof-logo-img-lobby {
  margin-bottom: 1rem;
}
.wof-logo-img-hero {
  width: 500px;
  max-width: 90vw;
  margin-bottom: 0;
}
.wof-logo-above-card {
  text-align: center;
  margin-bottom: 0.4rem;
  background: var(--bg-card);
  border-radius: 12px;
  padding: 0.75rem 1.5rem;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  width: 100%;
  max-width: 560px;
}
/* ── No-Game / Join Screen ────────────────────────────────── */
#screen-join,
#screen-lobby {
  align-items: center;
  justify-content: flex-start;
  padding-top: 3rem;
  padding-left: 1rem;
  padding-right: 1rem;
  padding-bottom: 2rem;
}
.center-card {
  width: 100%; max-width: 560px; margin: auto; background: var(--bg-card);
  border-radius: 12px; padding: 1.5rem 2rem 2rem; box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  overflow: hidden;
}
.center-card-logo {
  text-align: center;
  margin: -1.5rem -2rem 1.25rem;
  padding: 1rem 1.5rem 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.center-card p { margin-bottom: 0.8rem; line-height: 1.5; color: var(--text-muted); }
.game-name-row  { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 1rem; }
.game-name-row p { margin: 0; color: var(--text); }
.game-name-row strong { color: var(--accent); }

/* "How to Play" row placed above the large logo on join/lobby screens */
.htp-above-logo-row {
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 560px;
  padding-bottom: 0.4rem;
}
.htp-above-logo-row--lobby {
  max-width: 560px;
  padding-right: 0;
}

/* For the join screen, the button sits inside the card above center-card-logo */
.htp-above-logo-row:not(.htp-above-logo-row--lobby) {
  margin-bottom: 0.5rem;
}

/* ── Lobby Screen ─────────────────────────────────────────── */
.lobby-container { width: 100%; max-width: 560px; margin: auto; padding: 0.75rem 2rem 2rem; text-align: center; }
.lobby-container h2 { color: var(--accent); margin-bottom: 1.5rem; }
.player-list-container { background: var(--bg-card); border-radius: var(--radius); padding: 1rem 1.5rem; margin-bottom: 1.5rem; }
.player-list-container h3 { color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.8rem; }
#lobby-player-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
#lobby-player-list li {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-tile); border-radius: 6px; padding: 0.55rem 0.9rem;
}
.player-name { font-weight: 600; }
.player-host-badge {
  display: inline-block; font-size: 0.65rem; background: var(--accent); color: #000;
  border-radius: 4px; padding: 1px 5px; margin-left: 0.5rem; font-weight: 700; text-transform: uppercase;
}
.player-disconnected { opacity: 0.45; text-decoration: line-through; }
.btn-remove {
  padding: 0.2rem 0.6rem; background: var(--accent2); color: #fff;
  border: none; border-radius: 4px; font-size: 0.75rem; cursor: pointer;
}
.lobby-instructions { font-size: 0.85rem; color: #fff; margin-bottom: 1.5rem; }
#lobby-waiting { color: #fff; }

/* ── Game Header ──────────────────────────────────────────── */
.game-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 1.2rem; background: #0d0d22; border-bottom: 2px solid var(--accent);
}
.game-header-left { display: flex; align-items: center; gap: 0.75rem; }
.round-indicator { font-weight: 700; color: var(--accent); font-size: 1rem; }
.room-name-display { color: var(--text-muted); font-size: 1.05rem; font-weight: 800; }
.game-header-right { display: flex; align-items: center; gap: 0.4rem; }
.btn-new-game { background: transparent; border: 1px solid #ff6b6b; color: #ff6b6b; font-size: 0.92rem; padding: 0.25rem 0.65rem; border-radius: 4px; cursor: pointer; font-weight: 600; letter-spacing: 0.02em; transition: background 0.15s, color 0.15s; }
.btn-new-game:hover { background: #ff6b6b; color: #fff; }

/* ── Player Bar ───────────────────────────────────────────── */
.player-bar {
  display: flex; gap: 0.5rem; padding: 0.5rem 1rem; background: #0d0d22;
  border-bottom: 1px solid #222; overflow-x: auto; flex-wrap: nowrap;
}
.player-card {
  position: relative;
  min-width: 120px; background: var(--bg-card); border-radius: var(--radius);
  padding: 0.5rem 0.75rem; border: 2px solid transparent; transition: border-color 0.2s;
  flex-shrink: 0;
}
.player-card:has(.player-card-host-badge) {
  padding-left: 1.25rem;
}
.player-card.active-turn { border-color: var(--accent); box-shadow: 0 0 10px rgba(255,215,0,0.4); animation: pulse-glow 1.5s ease-in-out infinite; }
.player-card.disconnected { opacity: 0.4; }
.player-card-name { font-weight: 700; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.player-card-total { color: #fff; font-size: 1.1rem; font-weight: 800; }
.player-card-round { color: var(--accent); font-size: 1rem; font-weight: 700; }
.player-card-host-badge {
  position: absolute;
  left: 0; top: 50%; transform: translateY(-50%) rotate(180deg);
  writing-mode: vertical-rl; text-orientation: mixed;
  font-size: 0.75rem; color: #e06800; text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 900;
  padding: 4px 2px 4px 1px;
  background: rgba(224,104,0,0.1);
  border-radius: 3px 0 0 3px;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(255,215,0,0.3); }
  50% { box-shadow: 0 0 18px rgba(255,215,0,0.8); }
}
@keyframes spin-btn-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); box-shadow: 0 0 20px rgba(255,215,0,0.85), 0 3px 10px rgba(0,0,0,0.65); }
  50% { transform: translate(-50%, -50%) scale(1.1); box-shadow: 0 0 32px rgba(255,215,0,1), 0 4px 14px rgba(0,0,0,0.75); }
}

/* ── Puzzle Board ─────────────────────────────────────────── */
.puzzle-board {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start;
  gap: calc(var(--tile-gap) * 4); padding: 1rem; max-width: 980px; margin: 0 auto;
}

/* A "word" is a flex row of tiles with a gap between words */
.puzzle-word { display: flex; gap: var(--tile-gap); flex-wrap: nowrap; }

.puzzle-tile {
  width: var(--tile-size); height: var(--tile-size);
  background: #222244; border: 2px solid #3a3a6a; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 700; color: transparent;
  transform-style: preserve-3d; perspective: 600px;
  transition: transform 0.45s ease, color 0.1s 0.3s;
  user-select: none;
}
.puzzle-tile.revealed {
  background: #1a4a8a; border-color: #3088dd; color: var(--text);
  transform: rotateY(180deg);
}
.puzzle-tile.revealed-instant { background: #1a4a8a; border-color: #3088dd; color: var(--text); }

/* Space tiles (gaps between words) */
.puzzle-space { width: var(--tile-gap); height: var(--tile-size); background: transparent; }

/* Auto-shown chars (punctuation) */
.puzzle-tile.auto-shown { background: transparent; border-color: transparent; color: #aaa; font-size: 1.8rem; }

/* Tile entrance animation — staggered left-to-right, top-to-bottom on new puzzle */
@keyframes tile-enter {
  0%   { opacity: 0; transform: scale(0.25); }
  60%  { opacity: 1; transform: scale(1.12); }
  100% { opacity: 1; transform: scale(1); }
}
.puzzle-tile.tile-entering {
  animation: tile-enter 0.38s ease-out backwards;
}

.puzzle-category {
  text-align: center; color: #fff; font-size: 1.1rem;
  text-transform: uppercase; letter-spacing: 0.1em; margin-top: 0.75rem; margin-bottom: 0.2rem;
}

/* ── Toss-Up Phase ────────────────────────────────────────── */
.tossup-header { text-align: center; padding: 1rem 0 0.5rem; }
.tossup-header h2 { color: var(--accent); font-size: 1.5rem; }
.tossup-subtitle { color: #fff; font-size: 0.9rem; margin-top: 0.3rem; }
.tossup-action { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 1rem; }
.buzz-btn { font-size: 1.4rem; padding: 1rem 3rem; animation: buzz-pulse 1s ease-in-out infinite; }
.buzz-btn.buzz-clicked {
  animation: buzz-shake 0.45s ease-in-out forwards;
}
@keyframes buzz-shake {
  0%   { transform: translateX(0)   scale(1); }
  15%  { transform: translateX(-8px) scale(1.06); }
  30%  { transform: translateX(8px)  scale(1.06); }
  45%  { transform: translateX(-6px) scale(1.03); }
  60%  { transform: translateX(6px)  scale(1.03); }
  75%  { transform: translateX(-3px) scale(1.01); }
  90%  { transform: translateX(3px)  scale(1.01); }
  100% { transform: translateX(0)   scale(1); }
}
.tossup-status { color: var(--text-muted); text-align: center; font-size: 0.95rem; }
.solve-prompt { color: var(--accent); font-weight: 700; }
.solve-input-row { display: flex; gap: 0.5rem; }
.solve-input-row input {
  padding: 0.6rem 0.9rem; border-radius: var(--radius); border: 2px solid #333;
  background: #1a1a30; color: var(--text); font-size: 1rem; min-width: 280px;
}
.solve-input-row input:focus { outline: none; border-color: var(--accent); }
.solve-timer {
  font-size: 2.5rem; font-weight: 700; color: var(--accent); text-align: center;
  min-width: 60px;
}
.solve-timer.urgent { color: var(--accent2); animation: timer-blink 0.5s ease-in-out infinite; }

@keyframes buzz-pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(255,215,0,0.4); }
  50% { box-shadow: 0 0 25px rgba(255,215,0,0.9); }
}
@keyframes timer-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Main Round ───────────────────────────────────────────── */
.round-main-area {
  display: flex; gap: 1.5rem; padding: 0 1rem 1rem;
  justify-content: center; flex-wrap: wrap;
}
.wheel-column { display: flex; flex-direction: column; align-items: center; gap: 0.8rem; }
.wheel-wrapper {
  position: relative;
  display: inline-block;
  filter: drop-shadow(0 0 28px rgba(255, 215, 0, 0.55)) drop-shadow(0 6px 24px rgba(0, 0, 0, 0.75));
  transition: opacity 0.4s ease;
}
.wheel-wrapper.wheel-inactive {
  opacity: 0.70;
  filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.15)) drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5)) grayscale(0.4);
}

/* Wheel entrance bounce — fires when a new round question appears */
@keyframes wheel-enter {
  0%   { opacity: 0; transform: scale(0.65); }
  55%  { opacity: 1; transform: scale(1.1); }
  75%  { transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1); }
}
.wheel-wrapper.wheel-entering {
  animation: wheel-enter 0.65s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.spin-btn-overlay {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-weight: 800;
  padding: 0;
  border-radius: 50%;
  width: 108px; height: 108px;
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
  background: radial-gradient(circle, #ffe066 0%, #e6b800 60%, #b38600 100%);
  color: #1a0a00;
  border: 4px solid #fff;
  box-shadow: 0 0 20px rgba(255,215,0,0.85), 0 3px 10px rgba(0,0,0,0.65);
  font-size: 1.6rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.spin-btn-overlay:not(:disabled) {
  animation: spin-btn-pulse 2.2s ease-in-out infinite;
}
.spin-btn-overlay:hover:not(:disabled) {
  animation: none;
  transform: translate(-50%, -50%) scale(1.1);
  box-shadow: 0 0 24px rgba(255,215,0,1), 0 2px 12px rgba(0,0,0,0.8);
}
.spin-btn-overlay:disabled { opacity: 0.5; cursor: default; }

/* ── Action Panel ─────────────────────────────────────────── */
.action-panel { width: 480px; display: flex; flex-direction: column; gap: 0.8rem; }
.turn-status {
  text-align: center; font-size: 1rem; font-weight: 600;
  padding: 0.5rem; background: var(--bg-card); border-radius: var(--radius);
  min-height: 38px;
}

/* ── Keyboard ─────────────────────────────────────────────── */
.keyboard { display: flex; flex-direction: column; gap: 0.4rem; }
.keyboard-row { display: flex; gap: 0.35rem; flex-wrap: wrap; justify-content: center; }

.key-btn {
  width: 38px; height: 38px; border: 1px solid #fff; border-radius: 5px;
  font-size: 0.95rem; font-weight: 700; cursor: pointer;
  background: #2a2a50; color: var(--text); transition: background 0.15s, opacity 0.15s;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 18px rgba(255,255,255,0.65);
}
.key-btn:hover:not(:disabled) { background: #4a4a80; }
.key-btn.used-correct  { background: #1a4a8a; color: #7cc; opacity: 0.45; border: 1px solid transparent; box-shadow: 0 0 8px rgba(255,255,255,0.55); }
.key-btn.used-wrong    { background: #3a1a1a; color: #a44; opacity: 0.45; border: 1px solid transparent; box-shadow: none; }
.key-btn.consonant     { background: #2a2a50; }
.key-btn.vowel         { background: #1a2a1a; }
.key-btn:disabled      { opacity: 0.3; cursor: not-allowed; }

.action-buttons { display: flex; gap: 0.7rem; flex-wrap: wrap; }
#speed-solve-btn-row { justify-content: center; }
.solve-form { display: flex; flex-direction: column; gap: 0.5rem; }
.solve-form input {
  padding: 0.6rem 0.9rem; border-radius: var(--radius); border: 2px solid #333;
  background: #1a1a30; color: var(--text); font-size: 1rem;
}
.solve-form input:focus { outline: none; border-color: var(--accent); }

.spin-result-banner {
  text-align: center; font-size: 1.3rem; font-weight: 700;
  padding: 0.75rem; border-radius: var(--radius);
  background: var(--bg-card);
}
.spin-result-banner.bankrupt { background: #1a0000; color: var(--accent2); }
.spin-result-banner.lose-turn { background: #1a1a1a; color: #aaa; }
.spin-result-banner.free-play { background: #0a1a0a; color: #6f6; }
.spin-result-banner.value { background: #0a1a0a; color: var(--accent); }

/* ── Speed Round ──────────────────────────────────────────── */
.speed-round-header { text-align: center; padding: 0.8rem 0 0.3rem; }
.speed-round-header h2 { color: var(--accent); font-size: 1.4rem; }
.speed-value-display { font-size: 1.1rem; color: #7df; font-weight: 600; }
.speed-spin-area { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; padding: 1rem; }
.speed-spin-status { color: #ccc; font-size: 1rem; text-align: center; transition: color 0.3s, font-size 0.3s; }
.speed-action { max-width: 600px; margin: 0 auto; padding: 0 1rem; display: flex; flex-direction: column; gap: 1rem; }

/* ── Bonus Round ──────────────────────────────────────────── */
.bonus-header { text-align: center; padding: 0.8rem 0 0.3rem; }
.bonus-header h2 { color: var(--accent); font-size: 1.5rem; }
.bonus-player-name { font-size: 1.1rem; color: #7df; font-weight: 600; }
.bonus-free-letters { text-align: center; padding: 0.5rem; color: var(--text-muted); font-size: 0.9rem; }
.free-letters-label { margin-right: 0.5rem; }
.free-letters-value { color: var(--accent); font-weight: 700; font-size: 1.1rem; }
.bonus-keyboard { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; margin: 0.8rem 0; }
.bonus-keyboard-row { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: center; }
.bonus-picker-instructions { text-align: center; color: var(--text-muted); margin-bottom: 0.5rem; }
.bonus-selection-display { text-align: center; font-size: 1rem; margin: 0.5rem 0; }
#bonus-selected-consonants, #bonus-selected-vowel { color: var(--accent); font-weight: 700; font-size: 1.2rem; }
.bonus-timer { font-size: 3rem; text-align: center; margin: 0.5rem 0; }
.bonus-spectator-status { text-align: center; color: var(--text-muted); padding: 1rem; font-size: 1rem; }
.bonus-result { text-align: center; padding: 1.5rem; }
.bonus-envelope-reveal {
  font-size: 2rem; font-weight: 700; color: var(--accent);
  animation: score-pop 0.5s ease-out;
}
#bonus-picker, #bonus-solve-area { max-width: 560px; margin: 0 auto; padding: 0 1rem; }

/* ── Transition / Interstitial ────────────────────────────── */
#phase-transition { display: flex; align-items: center; justify-content: center; flex: 1; }
.transition-card { text-align: center; padding: 2rem; }
.transition-message { font-size: 1.8rem; font-weight: 700; color: var(--accent); margin-bottom: 0.8rem; }
.transition-sub      { font-size: 1.1rem; color: var(--text-muted); margin-bottom: 1rem; }
.transition-countdown { font-size: 1.5rem; color: var(--text-muted); }

/* ── Game Over ────────────────────────────────────────────── */
#phase-gameover { display: flex; flex-direction: column; align-items: center; padding: 2rem; gap: 1.5rem; }
.gameover-title { color: var(--accent); font-size: 2rem; }
.final-scores { display: flex; flex-direction: column; gap: 0.6rem; min-width: 320px; max-width: 500px; width: 100%; }
.final-score-item {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-card); border-radius: var(--radius); padding: 0.75rem 1rem;
}
.final-score-item:first-child { border: 2px solid var(--accent); }
.rank { font-size: 1.4rem; margin-right: 0.5rem; }
.gameover-actions { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
@keyframes score-item-enter {
  0%   { opacity: 0; transform: translateY(28px) scale(0.95); }
  60%  { opacity: 1; transform: translateY(-4px) scale(1.02); }
  100% { opacity: 1; transform: translateY(0)   scale(1); }
}
.final-score-item {
  animation: score-item-enter 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
/* ── Bankrupt Animation ───────────────────────────────────── */
.bankrupt-shake { animation: bankrupt-shake 0.5s ease-in-out; }
@keyframes bankrupt-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-10px); }
  30% { transform: translateX(10px); }
  45% { transform: translateX(-8px); }
  60% { transform: translateX(8px); }
  75% { transform: translateX(-4px); }
  90% { transform: translateX(4px); }
}
.bankrupt-overlay {
  position: fixed; inset: 0; background: rgba(180,0,0,0.25);
  pointer-events: none; animation: bankrupt-flash 0.6s ease-out forwards;
  z-index: 100;
}
@keyframes bankrupt-flash {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Score Counter Animation ──────────────────────────────── */
@keyframes score-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.3); color: #fff; }
  100% { transform: scale(1); }
}
.score-pop { animation: score-pop 0.4s ease-out; }

/* ── Confetti ─────────────────────────────────────────────── */
.confetti-piece {
  position: fixed; top: -20px; width: 10px; height: 16px;
  border-radius: 2px; opacity: 0;
  animation: confetti-fall linear forwards;
  z-index: 200;
}
@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 800px) {
  :root { --tile-size: 38px; }
  .round-main-area { flex-direction: column; align-items: center; }
  #wheel-canvas { width: 340px !important; height: 340px !important; }
  .action-panel { width: 100%; max-width: 420px; }
}
@media (max-width: 480px) {
  :root { --tile-size: 30px; }
  .key-btn { width: 30px; height: 30px; font-size: 0.8rem; }
  .game-header { flex-direction: column; gap: 0.3rem; text-align: center; }
  .game-header-left, .game-header-right { justify-content: center; }
}

/* ── Earnings Notifications ─────────────────────────────────── */
#earnings-notifications {
  position: fixed; top: 4rem; right: 1rem; z-index: 9999;
  display: flex; flex-direction: column; gap: 0.5rem;
  pointer-events: none; align-items: flex-end;
}
.earnings-toast {
  background: #1a7a1a;
  border: 1px solid #2ecc2e;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  box-shadow: 0 4px 18px rgba(0,0,0,0.6), 0 0 8px rgba(46,204,46,0.4);
  animation: toast-in 0.3s ease forwards;
  white-space: nowrap;
}
.earnings-toast.toast-loss {
  background: #a01010;
  border-color: #e05050;
  box-shadow: 0 4px 18px rgba(0,0,0,0.6), 0 0 8px rgba(204,50,50,0.45);
}
.earnings-toast.bankrupt-toast {
  background: #cc0000;
  border-color: #ff4444;
  box-shadow: 0 4px 18px rgba(0,0,0,0.6), 0 0 8px rgba(204,0,0,0.5);
}
.earnings-toast.fade-out {
  animation: toast-out 0.6s ease forwards;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(50px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(50px); }
}
.player-card.score-flash-positive {
  animation: card-score-flash-positive 1s ease forwards;
}
@keyframes card-score-flash-positive {
  0%   { background: var(--bg-card); }
  25%  { background: rgba(30, 180, 80, 0.6); }
  100% { background: var(--bg-card); }
}
.player-card.score-flash-negative {
  animation: card-score-flash-negative 1s ease forwards;
}
@keyframes card-score-flash-negative {
  0%   { background: var(--bg-card); }
  25%  { background: rgba(210, 40, 40, 0.6); }
  100% { background: var(--bg-card); }
}

/* ── How to Play Button ───────────────────────────────── */
.btn-how-to-play {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-how-to-play:hover { background: var(--accent); color: #000; }

/* ── Settings Button ──────────────────────────────────── */
@keyframes gear-spin-cw  { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes gear-spin-ccw { from { transform: rotate(360deg); } to { transform: rotate(0deg); } }
.btn-settings {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.22rem 0.4rem;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-settings .gear-icon {
  display: inline-block;
  animation: gear-spin-ccw 0.45s ease-out forwards;
}
.btn-settings:hover .gear-icon {
  animation: gear-spin-cw 0.45s ease-in-out forwards;
}

/* ── QR Invite Button ─────────────────────────────────── */
.btn-qr-invite {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.22rem 0.3rem;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}
.btn-qr-invite:hover { color: #fff; }

/* ── QR Code Modal ────────────────────────────────────── */
.qr-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qr-modal {
  position: relative;
  background: #1a1a35;
  border: 2px solid var(--accent);
  border-radius: 12px;
  padding: 2rem 2.5rem;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
  max-width: 320px;
  width: 90%;
}
.qr-close-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
}
.qr-close-btn:hover { color: var(--text); }
.qr-modal-title {
  color: var(--accent);
  font-size: 1.2rem;
  margin-bottom: 0.4rem;
}
.qr-modal-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.qr-code-img {
  width: 200px;
  height: 200px;
  display: block;
  margin: 0 auto 1rem;
  border-radius: 8px;
  background: #fff;
}
.qr-url-text {
  font-size: 0.72rem;
  color: var(--text-muted);
  word-break: break-all;
  margin-top: 0;
}

/* ── Settings Modal ───────────────────────────────────── */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.settings-modal {
  position: relative;
  width: 90%;
  max-width: 420px;
  background: #1a1a35;
  border: 2px solid var(--accent);
  border-radius: 12px;
  padding: 2rem 2.5rem;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
}
.settings-close-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: rgba(255,255,255,0.06);
  border: none;
  color: #aaa;
  font-size: 1.2rem;
  width: 2rem;
  height: 2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
}
.settings-close-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.settings-title {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--accent);
  text-align: center;
  margin: 0 0 1.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.settings-body { display: flex; flex-direction: column; }
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.settings-row:last-child { border-bottom: none; }
.settings-row label {
  color: #ddd;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.settings-row input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--accent);
  cursor: pointer;
}
.settings-row select {
  font-size: 0.95rem;
  padding: 4px 8px;
  border-radius: 6px;
  background: #0d0d22;
  color: var(--text);
  border: 1px solid #444;
  cursor: pointer;
}

/* ── How to Play Modal ────────────────────────────────── */
#debug-log-overlay .htp-modal { width: min(1140px, 100%); }
.htp-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.htp-modal {
  position: relative;
  background: #13132b;
  border: 2px solid var(--accent);
  border-radius: 10px;
  width: min(680px, 100%);
  max-height: 95vh;
  overflow-y: auto;
  padding: 2rem 2rem 1.5rem;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
}
.htp-close-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: transparent;
  border: none;
  color: #ccc;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  width: 2.2rem;
  height: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
}
.htp-close-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.htp-title {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--accent);
  text-align: center;
  margin: 0 0 1.2rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.htp-body h3 {
  font-size: 1rem;
  font-weight: 800;
  color: #FFD700;
  margin: 1.1rem 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.htp-body p, .htp-body li {
  color: #ddd;
  font-size: 0.92rem;
  line-height: 1.55;
  margin: 0 0 0.3rem;
}
.htp-body ul {
  padding-left: 1.3rem;
  margin: 0 0 0.4rem;
}
.htp-body li { list-style: disc; }

/* ── Idle Pause Overlay ────────────────────────────────── */
#idle-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 11000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.idle-modal {
  text-align: center;
  color: #fff;
  padding: 2.5rem 3rem;
  background: rgba(10, 10, 26, 0.92);
  border: 2px solid rgba(255, 215, 0, 0.35);
  border-radius: 16px;
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.8);
  max-width: 420px;
  width: 90%;
  pointer-events: none;
}
.idle-pause-icon {
  font-size: 5rem;
  line-height: 1;
  margin-bottom: 1rem;
  display: block;
}
.idle-title {
  font-family: 'Impact', 'Arial Black', sans-serif;
  font-size: 2rem;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
  margin-bottom: 0.6rem;
}
.idle-subtitle {
  font-size: 1rem;
  color: #ccc;
  line-height: 1.5;
  margin-bottom: 1.75rem;
}
.idle-continue-btn {
  display: inline-block;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem 2rem;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  pointer-events: all;
  transition: filter 0.15s, transform 0.1s;
}
.idle-continue-btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.idle-continue-btn:active { transform: translateY(0); }
