/* ================================================================
   CLASSROOM GAMES — Unified Design System  v3
   Deep teal-navy · glass-card UI · clean spacing
   ================================================================ */

:root {
  --bg-a:         #0f2027;
  --bg-b:         #203a43;
  --bg-c:         #2c5364;
  --accent:       #00c9a7;
  --accent2:      #f7b731;
  --danger:       #ef4444;
  --safe:         #22c55e;
  --text:         #ffffff;
  --text-dim:     rgba(255,255,255,0.65);
  --glass:        rgba(255,255,255,0.09);
  --glass-hi:     rgba(255,255,255,0.16);
  --glass-border: rgba(255,255,255,0.18);
  --shadow:       0 8px 32px rgba(0,0,0,0.45);
  --card-size:    76px;
  --gap:          6px;
}

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

body {
  background: linear-gradient(135deg, var(--bg-a) 0%, var(--bg-b) 50%, var(--bg-c) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Segoe UI', system-ui, Arial, sans-serif;
  min-height: 100vh;
  padding: 10px 10px 60px;
  overflow-x: hidden;
}

h1 {
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 900;
  text-align: center;
  margin: 4px 0 8px;
  text-shadow: 0 2px 12px rgba(0,0,0,0.6);
  background: linear-gradient(90deg, #fff 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Controls bar ──────────────────────────────── */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 0 auto 10px;
  max-width: 95vw;
  background: var(--glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}

button {
  padding: 9px 18px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  font-weight: 700;
  font-size: clamp(0.85rem, 2vw, 1rem);
  cursor: pointer;
  min-width: 110px;
  transition: filter 0.15s, transform 0.1s;
  background: var(--glass-hi);
  color: var(--text);
}
button:hover  { filter: brightness(1.18); transform: translateY(-1px); }
button:active { transform: translateY(0); filter: brightness(0.95); }

#fullscreen { background: #1d4ed8; border-color: #3b82f6; }
#home       { background: #7c3aed; border-color: #a78bfa; }
#newGame    { background: #0f766e; border-color: var(--accent); }
#rollAll    { background: var(--safe); border-color: #4ade80; color: #000; }

/* ── Global select/option dark fix ───────────────────────── */
select        { background: #1a2a38; color: white; }
select option { background: #1a2a38; color: white; }

.controls input,
.controls select {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.10);
  color: white;
  font-size: clamp(0.85rem, 2vw, 1rem);
  font-weight: 600;
}
.controls label {
  font-size: clamp(0.85rem, 2vw, 1rem);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
}

/* ── Turn indicator ────────────────────────────── */
#currentTurn {
  font-size: clamp(1.2rem, 3.5vw, 1.8rem);
  font-weight: 800;
  text-align: center;
  margin: 10px 0;
  padding: 10px 20px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  width: 100%;
  max-width: 820px;
}

/* ── Game wrapper ──────────────────────────────── */
.game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* ── Scoreboard ────────────────────────────────── */
.scoreboard {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  width: 100%;
}

.team-score {
  background: var(--glass);
  border: 2px solid var(--glass-border);
  border-radius: 14px;
  color: var(--text);
  font-size: clamp(1.1rem, 2.5vw, 1.6rem);
  font-weight: 800;
  text-align: center;
  min-width: 120px;
  padding: 10px 16px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.team-score small { font-size: 0.55em; display: block; opacity: 0.7; font-weight: 500; }
.team-score.active {
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(0,201,167,0.5);
  transform: scale(1.07);
}

/* ── Modal ─────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.25);
  align-items: flex-start; justify-content: center;
  z-index: 2000;
  padding-top: 80px;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: rgba(15, 32, 45, 0.97);
  border: 2px solid var(--accent);
  color: white;
  padding: 24px 32px;
  border-radius: 20px;
  text-align: center;
  max-width: 92%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.modal-buttons { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-bottom: 18px; }
.modal-cancel {
  padding: 10px 28px;
  background: var(--danger);
  color: white; border: none;
  border-radius: 10px; font-size: 1rem; cursor: pointer; font-weight: 700;
}

/* ── Shared setup screens ──────────────────────── */
.setup-screen, .hm-setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 30px 20px;
  text-align: center;
  width: 100%;
  max-width: 560px;
}
.setup-screen h2, .hm-setup h2 {
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 900;
  background: linear-gradient(90deg, #fff, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.setup-section, .hm-setup-section { width: 100%; }
.setup-section label, .hm-setup-section label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}
.team-picker, .mode-picker, .wordlist-picker, .hm-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.team-picker button, .mode-picker button,
.wordlist-picker button, .hm-picker button {
  min-width: 56px;
  padding: 10px 16px;
  background: var(--glass-hi);
  border: 2px solid var(--glass-border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
}
.team-picker button.selected, .mode-picker button.selected,
.wordlist-picker button.selected, .hm-picker button.hm-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  transform: scale(1.08);
}
.start-btn, .hm-start-btn {
  padding: 14px 44px;
  font-size: 1.15rem;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 40px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(0,201,167,0.4);
  min-width: unset;
  letter-spacing: 0.04em;
  transition: filter 0.2s, transform 0.1s;
}
.start-btn:hover, .hm-start-btn:hover { filter: brightness(1.1); transform: scale(1.03); }

/* ── Team container (Battle Teams) ────────────── */
.team-container {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 800;
  text-align: center;
  min-width: 120px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, border-color 0.2s;
}
.team-container.active-team { border-color: var(--accent); transform: scale(1.06); }
.team-name { font-size: 0.9rem; font-weight: 700; margin-bottom: 4px; opacity: 0.8; }
.team-container input {
  width: 70px; font-size: 1.4rem; font-weight: 900;
  text-align: center; border: 2px solid var(--glass-border);
  border-radius: 8px; padding: 2px 4px;
  background: rgba(255,255,255,0.12); color: white;
}
.safe-indicator { font-size: 1.1em; margin-left: 4px; }

/* ================================================================
   BATTLE TEAMS
   ================================================================ */
.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols,6), var(--card-size));
  gap: var(--gap);
  justify-content: center;
  margin: 14px auto;
}
.tile {
  width: var(--card-size); height: var(--card-size);
  background: #1e293b;
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  position: relative; overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  cursor: pointer;
}
.cover {
  position: absolute; inset: 0;
  background: linear-gradient(45deg, #f97316, #fbbf24);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 2em; font-weight: bold;
  text-shadow: 2px 2px 5px #000;
  border-radius: 8px; transition: opacity 0.5s;
}
.cover.hidden { opacity: 0; pointer-events: none; }
.symbol {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,0.35);
  font-size: 1.55em;
  padding: 3px;
  gap: 2px;
}
.symbol-text {
  font-size: 0.33em;
  font-weight: 800;
  text-align: center;
  line-height: 1.15;
  white-space: nowrap;
  overflow: visible;
  letter-spacing: -0.02em;
}

/* ================================================================
   CONNECT 4
   ================================================================ */
.col-selector {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  width: 90vmin;
  max-width: 650px;
  padding: 0 18px;
  margin-bottom: 4px;
}
.col-btn {
  background: var(--glass-hi);
  color: white;
  border: 1px solid var(--glass-border);
  font-size: 1.2rem; font-weight: 900;
  border-radius: 10px; padding: 8px 0;
  cursor: pointer; min-width: unset;
  transition: background 0.14s, transform 0.12s;
}
.col-btn:hover     { background: var(--accent); color: #000; transform: scale(1.08); }
.col-btn.col-active { background: var(--accent2); color: #000; transform: scale(1.14); }

.connect4-board {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  width: 90vmin; max-width: 650px;
  aspect-ratio: 7/6;
  background: #1e3a8a;
  padding: 18px; border-radius: 20px;
  box-shadow: var(--shadow), 0 0 0 3px rgba(30,58,138,0.5);
}
.connect4-cell {
  background: #0f172a;
  border-radius: 50%;
  position: relative; overflow: hidden;
  cursor: pointer;
  box-shadow: inset 0 6px 16px rgba(0,0,0,0.7);
  transition: background 0.2s;
}
.connect4-cell:hover { background: #1e3a8a; }
.connect4-token {
  position: absolute;
  width: 90%; height: 90%; left: 5%; top: 5%;
  border-radius: 50%;
  transform: translateY(-150%);
  transition: transform 0.7s cubic-bezier(0.2,0.8,0.4,1);
}
.connect4-token.red    { background: radial-gradient(circle at 30% 30%, #fb923c, #dc2626); box-shadow: 0 6px 20px rgba(220,38,38,0.7); }
.connect4-token.yellow { background: radial-gradient(circle at 30% 30%, #fde68a, #f59e0b); box-shadow: 0 6px 20px rgba(245,158,11,0.7); }
body.connect4-page #team1 { border-color: #dc2626; }
body.connect4-page #team2 { border-color: #f59e0b; }

/* ================================================================
   BLOCKBUSTERS
   ================================================================ */
.blockbusters-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  max-width: 640px;
  margin: 14px auto;
}
.blockbusters-hex {
  width: 95px; height: 109px;
  background: var(--glass-hi);
  clip-path: polygon(30% 0%,70% 0%,100% 50%,70% 100%,30% 100%,0% 50%);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem; font-weight: 900;
  cursor: pointer; color: white;
  transition: background 0.25s, transform 0.18s;
}
.blockbusters-hex:hover   { transform: scale(1.06); }
.blockbusters-hex.gold    { background: var(--accent2); color: #000; }
.blockbusters-hex.blue    { background: #2563eb; color: white; }
.blockbusters-hex.winning-path {
  animation: hexPulse 1.4s ease-in-out infinite;
  box-shadow: 0 0 28px var(--accent2);
}
@keyframes hexPulse {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.14); }
}
body.blockbusters-page #goldTeam { border-color: var(--accent2); }
body.blockbusters-page #blueTeam { border-color: #3b82f6; }

/* ================================================================
   HANGMAN
   ================================================================ */

/* Game area — flex column, hidden until JS shows it */
.hm-game {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 900px;
}

/* Top row: canvas + right column side by side */
.hm-top {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
}

#hangmanCanvas {
  background: rgba(255,255,255,0.95);
  border-radius: 14px;
  box-shadow: var(--shadow);
  width: 220px;
  height: 260px;
  flex-shrink: 0;
}

/* Right column: word + optional diceman stacked */
.hm-word-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
  flex: 1;
  min-width: 240px;
  max-width: 420px;
}

.hm-word-board {
  font-weight: 900;
  padding: 14px 20px;
  background: rgba(255,255,255,0.95);
  color: #0f172a;
  border-radius: 14px;
  text-align: center;
  box-shadow: var(--shadow);
  min-height: 76px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0;
  line-height: 1.6;
}

/* Diceman panel */
.hm-diceman {
  background: rgba(0,0,0,0.45);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.hm-dice-face {
  font-size: 3.8rem;
  text-align: center;
  line-height: 1.1;
  margin-bottom: 10px;
}
.hm-dice-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.hm-dice-table td {
  padding: 4px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  color: var(--text-dim);
}
.hm-dice-table td:first-child { font-size: 1.05rem; width: 55px; }
.hm-bankrupt { color: var(--danger) !important; font-weight: 700; }

/* Letter grid */
.hm-letters {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 620px;
}
.hm-letters button {
  all: unset;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-hi);
  border: 1px solid var(--glass-border);
  color: white;
  border-radius: 8px;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  aspect-ratio: 1;
  min-width: 0;
  transition: background 0.12s, transform 0.1s;
}
.hm-letters button:hover    { background: var(--accent); color: #000; transform: scale(1.1); }
.hm-letters button:disabled { background: rgba(255,255,255,0.04); color: rgba(255,255,255,0.18); cursor: not-allowed; }
.hm-letters button.hm-vowel-locked { background: rgba(255,255,255,0.03); color: rgba(255,255,255,0.14); cursor: not-allowed; }

body.hangman-page .team-score.active {
  border-color: var(--accent2);
  box-shadow: 0 0 18px rgba(247,183,49,0.5);
}

/* ================================================================
   GRAMMAR CARDS
   ================================================================ */
.row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}
.card {
  width: 80px; height: 116px;
  background: white;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  position: relative;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Segoe UI', Arial, sans-serif;
  color: #111;
}
.card.face-down { background: #1e3a8a; color: white; font-size: 2.2rem; font-weight: bold; }
.corner { position: absolute; font-size: 0.85rem; font-weight: bold; text-align: center; line-height: 1.1; }
.corner.top    { top: 4px; left: 5px; }
.corner.bottom { bottom: 4px; right: 5px; transform: rotate(180deg); }
.big-rank { font-size: 2.2rem; font-weight: bold; position: absolute; top: 32%; transform: translateY(-50%); }
.suit-big { font-size: 1.8rem; position: absolute; bottom: 16%; }
.good { background: var(--safe)   !important; color: white !important; }
.bad  { background: var(--danger) !important; color: white !important; }

/* ================================================================
   PASSIVE DICE
   ================================================================ */
.reveal-box {
  max-width: 860px;
  width: 100%;
  margin: 10px auto 0;
  padding: 16px 20px;
  border-radius: 14px;
  background: var(--glass);
  border: 2px dashed var(--glass-border);
  cursor: pointer;
  user-select: none;
  text-align: center;
  transition: background 0.2s;
}
.reveal-box:hover { background: var(--glass-hi); }
.reveal-label {
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.reveal-content      { display: none; }
.reveal-content.show { display: flex; }

/* ================================================================
   MAIN MENU
   ================================================================ */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px;
}
.game-card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.25s, box-shadow 0.25s;
  text-align: center;
  backdrop-filter: blur(8px);
}
.game-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 48px rgba(0,0,0,0.6);
}
.game-thumb {
  height: 140px;
  background: #1e293b;
  background-size: cover;
  background-position: center;
}
.game-info { padding: 14px 16px 18px; }
.game-info h2 { font-size: clamp(1.1rem, 3vw, 1.5rem); font-weight: 800; margin-bottom: 5px; }
.game-info p  { font-size: clamp(0.8rem, 2vw, 0.92rem); margin-bottom: 14px; color: var(--text-dim); }
.play-btn {
  display: inline-block;
  padding: 9px 28px;
  background: var(--accent);
  color: #000;
  text-decoration: none;
  border-radius: 40px;
  font-weight: 800;
  font-size: clamp(0.88rem, 2vw, 1rem);
  transition: filter 0.2s, transform 0.15s;
  letter-spacing: 0.04em;
}
.play-btn:hover { filter: brightness(1.1); transform: scale(1.05); }
