/* =========================================================
   TekaMET — Atmospheric Modern Game UI
   Weather & Meteorology aesthetic: Deep Sky, Aurora glow,
   Glassmorphism, tactile game boards, and sleek typography.
   Game logic classes & selectors strictly preserved.
   ========================================================= */

:root {
  --bg: #070b14;
  --bg-gradient: radial-gradient(120% 80% at 50% -20%, #121f3d 0%, #080d1a 60%, #05070f 100%);
  --bg-2: #0d1527;
  --panel: rgba(15, 23, 42, 0.72);
  --panel-hover: rgba(22, 34, 61, 0.82);
  --panel-2: rgba(26, 38, 69, 0.85);
  --panel-solid: #0f172a;
  --elevated: rgba(30, 41, 71, 0.9);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.18);
  --line-glow: rgba(56, 189, 248, 0.35);
  --text: #f8fafc;
  --muted: #94a3b8;
  --subtle: #64748b;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.14);
  --accent-glow: rgba(56, 189, 248, 0.28);
  --accent-2: #34d399;
  --accent-2-soft: rgba(52, 211, 153, 0.14);
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.3);
  --shadow: 0 12px 36px -4px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --shadow-glow: 0 16px 40px -8px rgba(56, 189, 248, 0.22);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Word search pastel-vibrant found colors */
  --found-1: #2dd4bf;
  --found-2: #60a5fa;
  --found-3: #a78bfa;
  --found-4: #f472b6;
  --found-5: #fbbf24;
  --found-6: #34d399;
  --found-7: #fb7185;
  --found-8: #38bdf8;
}

* {
  box-sizing: border-box;
}

/* Custom modern slim scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}

html, body {
  margin: 0;
  min-height: 100%;
  background-color: #060b14;
  color: var(--text);
  font-family: var(--font);
  font-feature-settings: "cv01", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background-color: #060b14;
  background-image: 
    linear-gradient(180deg, rgba(7, 14, 28, 0.38) 0%, rgba(9, 18, 36, 0.52) 45%, rgba(5, 9, 20, 0.85) 100%),
    url("img/bg-sky.png");
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  pointer-events: none;
  transform: translateZ(0);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#app {
  min-height: 100dvh;
  max-width: 1060px;
  margin: 0 auto;
  padding: 24px 20px 36px;
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  padding-bottom: max(36px, env(safe-area-inset-bottom));
  padding-top: max(24px, env(safe-area-inset-top));
  position: relative;
  z-index: 1;
}

body.dragging-ws {
  overflow: hidden;
  touch-action: none;
}
body.dragging-ws #app {
  touch-action: none;
}

.screen {
  display: none;
}
.screen.active {
  display: block;
  animation: fade .2s cubic-bezier(0.16, 1, 0.3, 1);
}
[hidden],
.screen[hidden] {
  display: none !important;
}
body.modal-open {
  overflow: hidden !important;
}

@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- HOME & AMBIENT SKY ---------- */
.bg-orbs {
  display: none !important;
}

.hero {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 12px 14px;
}

.logo {
  margin: 0;
  font-size: clamp(3rem, 10vw, 4.4rem);
  line-height: 1;
  letter-spacing: -0.05em;
  font-weight: 700;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
  width: 100%;
}
.logo-teka {
  color: #ffffff;
  font-weight: 700;
  letter-spacing: -0.04em;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.75), 0 4px 28px rgba(3, 7, 18, 0.9);
}
.logo-met {
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #7dd3fc 0%, #38bdf8 38%, #34d399 95%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 14px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 24px rgba(56, 189, 248, 0.45));
  position: relative;
}

.logo-rule {
  width: 64px;
  height: 3px;
  margin: 16px auto 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.95), rgba(52, 211, 153, 0.75), transparent);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.5);
}

.tagline {
  margin: 0 auto;
  max-width: 440px;
  color: #ffffff;
  font-size: 1.02rem;
  line-height: 1.6;
  font-weight: 600;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8), 0 1px 3px rgba(0, 0, 0, 0.95);
  letter-spacing: 0.01em;
}

/* ---------- STATS BAR ---------- */
.stats-bar {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px auto 18px;
  max-width: 540px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 10px 12px;
  text-align: center;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.stat:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.3);
  background: var(--panel-hover);
  box-shadow: 0 12px 28px -6px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.stat-val {
  display: block;
  font-size: 1.45rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #ffffff 40%, #94a3b8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat-label {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-top: 3px;
  display: block;
}

/* ---------- GAME CARDS ---------- */
.game-cards {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  max-width: 580px;
  margin: 0 auto;
}
.game-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease, background .2s ease;
  position: relative;
  overflow: hidden;
}
.game-card:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.35);
  background: var(--panel-hover);
  box-shadow: 0 16px 36px -8px rgba(0, 0, 0, 0.5), 0 0 24px -6px rgba(56, 189, 248, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

/* Card 1: Cari Perkataan */
.game-card[data-game="wordsearch"] .game-icon {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2) 0%, rgba(14, 165, 233, 0.08) 100%);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.28);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.18);
}
.game-card[data-game="wordsearch"] .progress-fill {
  background: linear-gradient(90deg, #38bdf8 0%, #0284c7 100%);
}

/* Card 2: Teka Silang Kata */
.game-card-cw {
  border-color: rgba(52, 211, 153, 0.16);
}
.game-card-cw:hover {
  border-color: rgba(52, 211, 153, 0.4);
  box-shadow: 0 16px 36px -8px rgba(0, 0, 0, 0.5), 0 0 24px -6px rgba(52, 211, 153, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.game-card-cw .game-icon {
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.2) 0%, rgba(16, 185, 129, 0.08) 100%);
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.28);
  box-shadow: 0 0 20px rgba(52, 211, 153, 0.18);
}
.game-card-cw .progress-fill {
  background: linear-gradient(90deg, #34d399 0%, #059669 100%);
}

/* Card 3: Bilik Live */
.game-card-live {
  border-color: rgba(245, 158, 11, 0.16);
}
.game-card-live:hover {
  border-color: rgba(245, 158, 11, 0.4);
  box-shadow: 0 16px 36px -8px rgba(0, 0, 0, 0.5), 0 0 24px -6px rgba(245, 158, 11, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.game-card-live .game-icon {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(217, 119, 6, 0.08) 100%);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.28);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.18);
}
.live-tag {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.22);
  padding: 3px 10px;
  border-radius: 999px;
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.game-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: transform .2s ease;
}
.game-card:hover .game-icon {
  transform: scale(1.05);
}
.game-icon svg {
  width: 28px;
  height: 28px;
}
.game-body h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #ffffff;
}
.game-body p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.progress-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--accent);
  transition: width .4s cubic-bezier(0.4, 0, 0.2, 1);
}
.prog-text {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}
.chev {
  color: var(--subtle);
  transition: transform .2s ease, color .2s ease;
  flex-shrink: 0;
}
.game-card:hover .chev,
.tahap-card:hover .chev {
  transform: translateX(4px);
  color: #ffffff;
}

.home-foot {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin-top: 26px;
  padding-top: 4px;
  text-align: center;
}
.linkish {
  color: #e2e8f0;
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding: 6px 8px;
  border-radius: 6px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
  transition: color .15s ease, background .15s ease;
}
.linkish:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}
.dot-sep {
  color: #94a3b8;
  margin: 0 2px;
  opacity: 0.8;
}

/* ---------- TOPBAR ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.topbar h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
}
.spacer {
  flex: 1;
}

.icon-btn,
.icon-btn.sm,
.sound-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0;
  flex-shrink: 0;
  transition: transform .14s ease, border-color .14s ease, background .14s ease, color .14s ease, box-shadow .14s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
}
.icon-btn:hover,
.icon-btn.sm:hover,
.sound-btn:hover {
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.icon-btn:active,
.icon-btn.sm:active,
.sound-btn:active {
  transform: translateY(1px);
}
.sound-btn .sound-icon,
.icon-btn.sm svg,
.icon-btn svg {
  width: 20px;
  height: 20px;
  display: block;
  pointer-events: none;
}
.sound-btn.is-muted,
.sound-btn[aria-pressed="true"],
.icon-btn.sm[aria-pressed="true"] {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.12);
}

/* ---------- LEVEL LIST & TAHAP ---------- */
.tahap-cards {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
  max-width: 580px;
  margin: 0 auto;
}
.tahap-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 20px;
  border-radius: var(--radius-lg);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.tahap-card:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.35);
  background: var(--panel-hover);
  box-shadow: 0 16px 36px -8px rgba(0, 0, 0, 0.5), 0 0 24px -6px rgba(56, 189, 248, 0.16);
}
.tahap-num {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  font-weight: 700;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.22) 0%, rgba(14, 165, 233, 0.08) 100%);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.28);
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.18);
}
.tahap-card.tahap-2 .tahap-num {
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.22) 0%, rgba(16, 185, 129, 0.08) 100%);
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.28);
  box-shadow: 0 0 18px rgba(52, 211, 153, 0.18);
}
.tahap-card.tahap-2:hover {
  border-color: rgba(52, 211, 153, 0.4);
  box-shadow: 0 16px 36px -8px rgba(0, 0, 0, 0.5), 0 0 24px -6px rgba(52, 211, 153, 0.18);
}
.tahap-body h2 {
  margin: 0 0 3px;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #ffffff;
}
.tahap-body p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  max-width: 680px;
  margin: 0 auto;
}
.level-card {
  position: relative;
  padding: 22px 20px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  text-align: left;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
  cursor: pointer;
}
.level-card:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.35);
  background: var(--panel-hover);
  box-shadow: 0 12px 30px -6px rgba(0, 0, 0, 0.45), 0 0 20px rgba(56, 189, 248, 0.14);
}
.level-card.done {
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.08);
}
.level-card.done:hover {
  border-color: rgba(52, 211, 153, 0.55);
  box-shadow: 0 12px 30px -6px rgba(0, 0, 0, 0.45), 0 0 20px rgba(52, 211, 153, 0.2);
}
.level-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.level-id {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.03em;
}
.level-card.diff-easy .level-id {
  color: #38bdf8;
}
.level-card.diff-hard .level-id {
  color: #fb7185;
}
.level-card.done .level-id {
  color: #34d399;
}
  margin-top: 8px;
}
.diff-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.diff-badge.diff-easy {
  color: #86efac;
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.28);
}
.diff-badge.diff-mid {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.3);
}
.diff-badge.diff-hard {
  color: #fda4af;
  background: rgba(244, 63, 94, 0.14);
  border-color: rgba(244, 63, 94, 0.3);
}
.level-card.diff-easy { border-color: rgba(34, 197, 94, 0.2); }
.level-card.diff-mid { border-color: rgba(245, 158, 11, 0.2); }
.level-card.diff-hard { border-color: rgba(244, 63, 94, 0.2); }
.level-sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}
.level-preview {
  margin-top: 6px;
  color: var(--subtle);
  font-size: 0.74rem;
  font-family: var(--mono);
  letter-spacing: 0.02em;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.level-check {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  color: #042016;
  display: none;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 800;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.45);
}
.level-card.done .level-check { display: grid; }

/* ---------- PLAY (WORD SEARCH) ---------- */
.play-top .play-title-wrap {
  flex: 1;
  min-width: 0;
}
.play-title-wrap h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
}
.play-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}
.play-meta .dot {
  opacity: 0.45;
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  gap: 20px;
  align-items: start;
}

/* Tactile crisp game board */
.grid-wrap {
  position: relative;
  width: 100%;
  max-width: min(100%, 680px);
  margin: 0 auto;
  user-select: none;
  touch-action: none;
  background: #f1f5f9;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: 0 20px 48px -8px rgba(0, 0, 0, 0.65), 0 0 32px rgba(56, 189, 248, 0.12), inset 0 2px 4px rgba(255, 255, 255, 0.8);
}

.letter-grid {
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  gap: 6px;
  position: relative;
  z-index: 1;
}

.cell {
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(0.82rem, 2.5vw, 1.12rem);
  letter-spacing: 0.02em;
  color: #0f172a;
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.06);
  transition: background .12s ease, color .12s ease, transform .12s ease, box-shadow .12s ease;
  will-change: background, transform;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.cell:hover {
  background: #f8fafc;
  border-color: rgba(56, 189, 248, 0.4);
}
.cell.selected {
  background: #bae6fd !important;
  color: #0369a1 !important;
  border-color: #38bdf8 !important;
  box-shadow: 0 0 0 2px #38bdf8, 0 4px 12px rgba(56, 189, 248, 0.35) !important;
  transform: scale(1.04);
  z-index: 2;
}
.cell.found {
  font-weight: 800;
  border-color: transparent;
  animation: foundPop .26s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
@keyframes foundPop {
  0% { transform: scale(0.92); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
.cell.hint {
  outline: 2px solid #e0a21a;
  outline-offset: -2px;
  animation: pulse 1s ease infinite;
  background: #fef3c7;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224, 162, 26, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(224, 162, 26, 0); }
}

.line-layer {
  position: absolute;
  inset: 16px;
  width: calc(100% - 32px);
  height: calc(100% - 32px);
  pointer-events: none;
  z-index: 2;
}

.word-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  position: sticky;
  top: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 0;
}
.word-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.word-panel h3 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7dd3fc;
}
.word-panel .panel-sub,
.panel-help {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}
.word-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
}
.word-list li {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-direction: row-reverse;
  gap: 10px;
  color: var(--text);
  transition: background .15s ease, border-color .15s ease, transform .15s ease, opacity .15s ease;
  cursor: pointer;
  min-height: 42px;
}
.word-list li > span:first-child {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.word-list li:hover {
  background: rgba(56, 189, 248, 0.09);
  border-color: rgba(56, 189, 248, 0.35);
  transform: translateX(-2px);
}
.word-list li:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.word-list li.found {
  text-decoration: none;
  opacity: 0.55;
  border-color: rgba(52, 211, 153, 0.3);
  background: rgba(52, 211, 153, 0.1);
  color: #6ee7b7;
}
.word-list li.found > span:first-child {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  text-decoration-color: rgba(110, 231, 183, 0.7);
}
.word-list li .mark {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}
.word-list li.found .mark {
  opacity: 1;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.22);
}

.encourage {
  min-height: 0;
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.22);
  color: #bae6fd;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.1);
}
.encourage:empty {
  display: none;
  margin: 0;
  padding: 0;
  border: 0;
}
.encourage.pop {
  animation: fade .22s ease;
}

.play-actions {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}
.play-actions .btn.ghost {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--line);
}
.play-actions .btn.ghost:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.07);
}

/* ---------- BUTTONS ---------- */
.btn {
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .14s ease, filter .14s ease, box-shadow .14s ease, background .14s ease;
  user-select: none;
  -webkit-user-select: none;
}
.btn.primary {
  background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 18px rgba(14, 165, 233, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.btn.primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(14, 165, 233, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn.primary:active {
  transform: translateY(1px);
  filter: brightness(0.95);
  box-shadow: 0 2px 10px rgba(14, 165, 233, 0.3);
}
.btn.ghost {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--text);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.btn.ghost:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
  transform: translateY(-1px);
}
.btn.ghost:active {
  transform: translateY(1px);
  background: rgba(255, 255, 255, 0.04);
}
.btn.full-width {
  width: 100%;
}
.btn-sm {
  padding: 0 14px;
  font-size: 0.84rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  min-height: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-weight: 500;
}
.btn-sm:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

/* ---------- MODALS ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(3, 7, 18, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 16px;
}
.modal[hidden] {
  display: none;
}
.modal-card {
  width: min(100%, 420px);
  background: linear-gradient(180deg, #152037 0%, #0d1527 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-xl);
  padding: 28px 24px 22px;
  text-align: center;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.7), 0 0 40px rgba(56, 189, 248, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  animation: popModal .26s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes popModal {
  from { opacity: 0; transform: scale(0.92) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.win-icon {
  margin-bottom: 12px;
}
.win-icon svg {
  filter: drop-shadow(0 0 18px rgba(52, 211, 153, 0.45));
}
.modal-card h2 {
  margin: 4px 0 8px;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #ffffff;
}
.modal-card p {
  margin: 0;
  color: var(--muted);
}
.modal-sub {
  color: var(--muted);
  margin: 0 0 16px;
  font-size: 0.92rem;
  line-height: 1.45;
}
.win-time {
  margin-top: 10px !important;
  font-size: 1rem;
}
.win-time strong {
  color: #ffffff;
  font-family: var(--mono);
}
.win-best {
  margin-top: 6px !important;
  color: var(--muted);
  font-size: 0.88rem;
}
.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}
.modal-actions.col-3 {
  grid-template-columns: 1fr 1fr 1fr;
}
.field {
  display: grid;
  gap: 7px;
  text-align: left;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
}
.field input,
.lb-filters select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.field input:focus,
.lb-filters select:focus {
  border-color: #38bdf8;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

/* Word Search Pastel Found Variants */
.found-c0 { background: #7dd3c0 !important; color: #06251d !important; }
.found-c1 { background: #8ec5f7 !important; color: #0a1f38 !important; }
.found-c2 { background: #c4b5fd !important; color: #2a1058 !important; }
.found-c3 { background: #f9a8d4 !important; color: #47071f !important; }
.found-c4 { background: #fcd34d !important; color: #3f1e05 !important; }
.found-c5 { background: #86efac !important; color: #042a14 !important; }
.found-c6 { background: #fda4af !important; color: #46041a !important; }
.found-c7 { background: #7dd3fc !important; color: #0a4668 !important; }

.word-list li .mark.found-c0 { background: #5cc4ad; }
.word-list li .mark.found-c1 { background: #6fb3f0; }
.word-list li .mark.found-c2 { background: #b3a2f5; }
.word-list li .mark.found-c3 { background: #f58fc6; }
.word-list li .mark.found-c4 { background: #fbbf24; }
.word-list li .mark.found-c5 { background: #6ee7a0; }
.word-list li .mark.found-c6 { background: #fb92a1; }
.word-list li .mark.found-c7 { background: #5ec8f7; }

/* ---------- CROSSWORD ---------- */
.cw-active-clue {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: center;
  padding: 14px 18px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid rgba(56, 189, 248, 0.25);
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.4), 0 0 16px rgba(56, 189, 248, 0.1);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.cw-clue-num {
  font-weight: 700;
  color: #38bdf8;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}
.cw-clue-dir {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: #bae6fd;
  background: rgba(56, 189, 248, 0.14);
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.25);
}
.cw-clue-text {
  flex: 1 1 100%;
  color: #ffffff;
  font-size: 1rem;
  line-height: 1.45;
  font-weight: 500;
}

.cw-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(250px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.cw-grid-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  container-type: inline-size;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.cw-grid {
  display: grid;
  gap: 3px;
  width: 100%;
  margin: 0 auto;
}

.cw-cell {
  position: relative;
  width: auto;
  aspect-ratio: 1;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  border-radius: 6px;
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(0.55rem, 9cqw, 1rem);
  user-select: none;
  overflow: visible;
}
@container (min-width: 0px) {
  .cw-cell {
    font-size: clamp(0.55rem, calc(100cqw / var(--cw-cols, 13) / 2.3), 1.1rem);
  }
}
.cw-cell.block {
  background: transparent;
  pointer-events: none;
}
.cw-cell.letter {
  background: #ffffff;
  color: #0f172a;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  transition: background .12s ease, transform .12s ease;
}
.cw-cell.letter:hover {
  background: #f1f5f9;
}
.cw-cell.selected {
  background: #fde047 !important;
  color: #713f12 !important;
  outline: 2px solid #eab308;
  outline-offset: -2px;
  box-shadow: 0 0 14px rgba(234, 179, 8, 0.5) !important;
  z-index: 3;
}
.cw-cell.in-word {
  background: #e0f2fe;
}
.cw-cell.correct {
  background: #86efac !important;
  color: #064e3b !important;
}
.cw-cell.wrong {
  background: #fecdd3 !important;
  color: #881337 !important;
}
.cw-cell.locked {
  background: #a7f3d0 !important;
  color: #064e3b !important;
  box-shadow: inset 0 0 0 2px rgba(5, 150, 105, 0.3);
  cursor: default;
}
.cw-cell.locked input {
  cursor: default;
  caret-color: transparent;
  pointer-events: none;
}
.cw-cell.locked::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #059669;
  opacity: 0.9;
  pointer-events: none;
  z-index: 4;
}
.cw-cell .cw-num {
  position: absolute;
  top: 1px;
  left: 3px;
  z-index: 5;
  min-width: 0.9em;
  padding: 0 1px;
  font-size: clamp(0.48rem, 1.4cqw, 0.74rem);
  font-weight: 700;
  color: #1e293b;
  font-family: var(--font);
  line-height: 1.1;
  pointer-events: none;
}
.cw-cell.has-num input {
  padding-top: 8px;
  line-height: 1;
}
.cw-cell input {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  text-align: center;
  font: inherit;
  font-size: max(16px, 1em);
  color: inherit;
  text-transform: uppercase;
  padding: 0;
  caret-color: #0284c7;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0;
}
.cw-len {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cw-active-clue .cw-len {
  margin-left: 0;
  color: #bae6fd;
  background: rgba(56, 189, 248, 0.15);
}
.cw-pattern {
  flex: 1 1 100%;
  margin-top: 2px;
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.18em;
  color: #38bdf8;
  font-size: 1.05rem;
}
.cw-cell.hinted input {
  color: #1d4ed8;
}

.cw-clues {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: grid;
  gap: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.cw-clue-col h3 {
  margin: 0 0 10px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #7dd3fc;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.cw-clue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}
.cw-clue-list li {
  margin: 0;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.88rem;
  line-height: 1.4;
  border: 1px solid transparent;
  color: var(--text);
  transition: background .12s ease, border-color .12s ease;
}
.cw-clue-list li:hover {
  background: rgba(255, 255, 255, 0.05);
}
.cw-clue-list li.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.35);
  color: #ffffff;
}
.cw-clue-list li.solved {
  opacity: 0.5;
  text-decoration: line-through;
}
.cw-clue-list .n {
  display: inline-block;
  min-width: 1.4em;
  font-weight: 700;
  color: #38bdf8;
  font-variant-numeric: tabular-nums;
}

/* ---------- PLAYER & CONTINUE CARDS ---------- */
.player-card {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  max-width: 540px;
  margin: 20px auto 14px;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.player-card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.player-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.16) 0%, rgba(99, 102, 241, 0.16) 100%);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.28);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.16);
}
.player-meta {
  min-width: 0;
}
.player-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-class {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
}

.continue-card {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  max-width: 540px;
  margin: 0 auto 16px;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.12) 0%, rgba(15, 23, 42, 0.8) 100%);
  border: 1px solid rgba(56, 189, 248, 0.3);
  box-shadow: 0 8px 30px -4px rgba(56, 189, 248, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  overflow: hidden;
}
.continue-card[hidden] {
  display: none !important;
}
.continue-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, #38bdf8, #34d399);
  border-radius: 4px 0 0 4px;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.6);
}
.continue-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #38bdf8;
  font-weight: 700;
}
.continue-title {
  font-weight: 600;
  margin-top: 3px;
  font-size: 1.05rem;
  color: #ffffff;
  letter-spacing: -0.01em;
}
.continue-sub {
  color: var(--muted);
  font-size: 0.84rem;
  margin-top: 2px;
}

/* ---------- TUTORIAL ---------- */
.tutorial-card {
  text-align: left;
}
.tut-step {
  display: none;
}
.tut-step.active {
  display: block;
  animation: fade .22s ease;
}
.tut-num {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(56, 189, 248, 0.16);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.28);
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 12px;
}
.tut-step h3 {
  margin: 0 0 8px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
}
.tut-step p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.92rem;
}
.tut-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 20px 0 6px;
}
.tut-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  transition: background .2s ease, transform .2s ease;
}
.tut-dots span.on {
  background: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
  transform: scale(1.15);
}

/* ---------- MEANING TOAST ---------- */
.meaning-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  z-index: 60;
  width: min(92vw, 420px);
  padding: 16px 20px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #17243c 0%, #0d1527 100%);
  border: 1px solid rgba(56, 189, 248, 0.3);
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.7), 0 0 30px rgba(56, 189, 248, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s cubic-bezier(0.16, 1, 0.3, 1), transform .22s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.meaning-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.meaning-word {
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  font-family: var(--mono);
  font-size: 0.95rem;
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
}
.meaning-text {
  color: #f1f5f9;
  font-size: 0.92rem;
  line-height: 1.45;
}
.meaning-example {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
  border-top: 1px solid var(--line);
  padding-top: 6px;
}

/* ---------- SHAKE & CONFETTI ---------- */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}
.shake {
  animation: shake .35s ease;
}

.confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}
#win-modal .modal-card {
  position: relative;
  z-index: 2;
}
#win-modal {
  position: fixed;
}

/* ---------- QUIZ ---------- */
.quiz-card {
  max-width: 620px;
  margin: 0 auto;
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.quiz-q {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0 0 18px;
  line-height: 1.5;
  letter-spacing: -0.02em;
  color: #ffffff;
}
.quiz-choices {
  display: grid;
  gap: 10px;
}
.quiz-choice {
  text-align: left;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  transition: background .12s ease, border-color .12s ease, transform .12s ease;
}
.quiz-choice:hover:not(:disabled) {
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(255, 255, 255, 0.07);
  transform: translateX(2px);
}
.quiz-choice.correct {
  background: rgba(52, 211, 153, 0.16) !important;
  border-color: rgba(52, 211, 153, 0.45) !important;
  color: #86efac;
}
.quiz-choice.wrong {
  background: rgba(248, 113, 113, 0.16) !important;
  border-color: rgba(248, 113, 113, 0.45) !important;
  color: #fda4af;
}
.quiz-feedback {
  margin: 14px 0 0;
  font-size: 0.92rem;
  line-height: 1.45;
  font-weight: 500;
}
.quiz-feedback.ok {
  color: #86efac;
}
.quiz-feedback.bad {
  color: #fda4af;
}
.quiz-score {
  font-size: 2.2rem;
  font-weight: 700;
  color: #ffffff;
  margin: 10px 0;
  letter-spacing: -0.03em;
  font-family: var(--mono);
}

/* ---------- LEADERBOARD ---------- */
.lb-wrap {
  max-width: 620px;
  margin: 0 auto;
}
.lb-filters {
  display: grid;
  gap: 14px;
  margin-bottom: 6px;
}
.lb-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 5px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}
.lb-tab {
  padding: 9px 8px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid transparent;
  transition: background .14s ease, color .14s ease;
}
.lb-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}
.lb-tab.active {
  color: #ffffff;
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.3);
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.15);
}
.lb-filters .field {
  margin-bottom: 0;
}
.lb-filters select {
  appearance: none;
  font-weight: 500;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 2px),
    calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  background-color: rgba(255, 255, 255, 0.04);
}
.lb-filters select option,
.lb-filters select optgroup {
  background: #0f172a;
  color: #f8fafc;
}
.lb-help {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
  margin: 14px 0;
}
.lb-status {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
  margin-bottom: 12px;
}
.lb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.lb-item {
  display: grid;
  grid-template-columns: 44px 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 13px 16px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform .14s ease, border-color .14s ease;
}
.lb-item:hover {
  transform: translateX(2px);
  border-color: var(--line-strong);
}
.lb-item.me {
  border-color: rgba(56, 189, 248, 0.45);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.14) 0%, rgba(15, 23, 42, 0.85) 100%);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.16);
}
.lb-rank {
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 0.95rem;
}
.lb-item:nth-child(1) .lb-rank {
  color: #f59e0b;
  text-shadow: 0 0 10px rgba(245, 158, 11, 0.45);
}
.lb-item:nth-child(2) .lb-rank {
  color: #cbd5e1;
}
.lb-item:nth-child(3) .lb-rank {
  color: #d97706;
}
.lb-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.01em;
  color: #ffffff;
}
.lb-set {
  color: var(--subtle);
  font-size: 0.8rem;
  font-family: var(--mono);
}
.lb-time {
  font-family: var(--mono);
  font-weight: 700;
  color: #34d399;
  min-width: 4.4em;
  text-align: right;
  font-size: 0.95rem;
}
.lb-submit-status {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
}

/* ---------- AUTH / PROFILE ---------- */
.auth-card {
  text-align: left;
}
.auth-card h2,
.auth-card .modal-sub {
  text-align: center;
}
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 5px;
  margin: 0 0 16px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}
.auth-tab {
  padding: 9px 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--muted);
  transition: background .12s ease, color .12s ease;
}
.auth-tab.active {
  color: #ffffff;
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.3);
}
.auth-hint {
  margin: 0 0 10px;
  color: var(--subtle);
  font-size: 0.8rem;
  line-height: 1.45;
}
.auth-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: #fca5a5;
  font-size: 0.86rem;
  font-weight: 500;
}
.auth-logout {
  display: block;
  width: 100%;
  margin-top: 14px;
  text-align: center;
  color: #fda4af !important;
}

/* ---------- LIVE MODE ---------- */
.live-join-card {
  max-width: 420px;
  margin: 28px auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: grid;
  gap: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.live-join-card input {
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  font-family: var(--mono);
}
.live-hint {
  color: var(--muted);
  font-size: 0.84rem;
  margin: 0;
  text-align: center;
}

.live-stage {
  max-width: 840px;
  margin: 0 auto;
  padding: 12px 0 32px;
}
.live-stage.player {
  max-width: 540px;
}
.live-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.live-panel[hidden] {
  display: none;
}

.live-code-wrap {
  text-align: center;
  margin-bottom: 18px;
}
.live-code-label {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
}
.live-code {
  font-family: var(--mono);
  font-size: clamp(2.4rem, 8.5vw, 3.4rem);
  font-weight: 700;
  letter-spacing: 0.22em;
  color: #38bdf8;
  text-shadow: 0 0 24px rgba(56, 189, 248, 0.45);
}
.live-code-sub {
  color: var(--subtle);
  font-size: 0.82rem;
}
.live-lobby-side {
  display: grid;
  gap: 14px;
}
.live-count {
  font-weight: 600;
  font-size: 1rem;
  color: #ffffff;
}
.live-player-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}
.live-player-list li {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  font-weight: 600;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.live-player-list .live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.6);
}
.live-empty {
  color: var(--muted);
  font-weight: 400;
}

.live-countdown {
  display: grid;
  place-items: center;
  min-height: 40vh;
  font-size: clamp(4.5rem, 18vw, 8.5rem);
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 40px rgba(56, 189, 248, 0.5);
  letter-spacing: -0.04em;
  animation: cdZoom 1s ease infinite;
}
.live-countdown[hidden] {
  display: none;
}
@keyframes cdZoom {
  0% { transform: scale(0.85); opacity: 0.5; }
  30% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.03); opacity: 0.9; }
}

.live-qhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
}
.live-timer {
  font-family: var(--mono);
  font-size: 1.2rem;
  color: var(--warn);
  font-weight: 700;
}
.live-qtext {
  font-size: clamp(1.15rem, 3.4vw, 1.6rem);
  line-height: 1.45;
  margin: 14px 0 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #ffffff;
}
.live-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.live-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.3;
  color: #ffffff;
  border: 2px solid transparent;
  text-align: left;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  transition: transform .14s ease, filter .14s ease;
}
.live-choice.c0 { background: linear-gradient(135deg, #d946ef 0%, #c026d3 100%); }
.live-choice.c1 { background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); }
.live-choice.c2 { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.live-choice.c3 { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.live-shape {
  font-size: 1.2rem;
  opacity: 0.95;
}
.live-choices.buttons .live-choice {
  cursor: pointer;
  border: 0;
}
.live-choices.buttons .live-choice:active {
  transform: scale(0.97);
}
.live-choices.buttons .live-choice.picked {
  outline: 3px solid #ffffff;
  outline-offset: -2px;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
}
.live-choices.buttons .live-choice[disabled] {
  opacity: 0.55;
}
.live-choices.buttons .live-choice.picked[disabled] {
  opacity: 1;
}
.live-answers {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.88rem;
}

.live-correct {
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 1.1rem;
  color: #ffffff;
  margin-bottom: 10px;
  font-weight: 700;
}
.live-correct.c0 { background: #c026d3; }
.live-correct.c1 { background: #2563eb; }
.live-correct.c2 { background: #d97706; }
.live-correct.c3 { background: #059669; }
.live-explain {
  color: var(--muted);
  margin: 6px 0 16px;
  line-height: 1.45;
}
.live-lb-title {
  margin: 8px 0 10px;
  font-size: 0.82rem;
  color: #7dd3fc;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.live-scores {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.live-scores li {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  font-weight: 600;
  border: 1px solid var(--line);
}
.live-scores li:first-child {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fef3c7;
}

.live-podium {
  max-width: 480px;
  margin: 0 auto;
}
.live-podium[hidden] {
  display: none;
}
.live-podium h2 {
  text-align: center;
  margin-bottom: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
}
.podium-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  margin-bottom: 8px;
  font-size: 1.1rem;
  font-weight: 600;
}
.podium-row.p0 {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.35);
  font-size: 1.25rem;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.18);
}
.podium-row .medal {
  font-size: 1.4rem;
}
.podium-row .name {
  flex: 1;
}

.player-bar {
  gap: 12px;
}
.player-id {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.live-chip {
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.85rem;
  color: #fde68a;
}
.live-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #ffffff;
}
.live-score {
  color: var(--muted);
  font-size: 0.88rem;
  white-space: nowrap;
}
.live-score strong {
  color: var(--warn);
  font-size: 1.15rem;
  font-family: var(--mono);
}

.live-spinner {
  width: 40px;
  height: 40px;
  margin: 20px auto 14px;
  border-radius: 50%;
  border: 3px solid rgba(56, 189, 248, 0.18);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
#player-wait {
  text-align: center;
}
.live-feedback {
  min-height: 1.4em;
  text-align: center;
  margin: 12px 0 0;
  font-weight: 600;
}
.live-result {
  font-size: 1.8rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 14px;
  letter-spacing: -0.02em;
}
.live-result.ok { color: var(--accent-2); }
.live-result.bad { color: var(--danger); }

/* ---------- RESPONSIVE BREAKPOINTS ---------- */
@media (max-width: 820px) {
  .play-layout,
  .cw-layout {
    grid-template-columns: 1fr;
  }
  .word-panel {
    position: static;
  }

  /* Word search mobile: dock layout */
  #screen-play.screen.active {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    overflow: hidden;
    min-height: 0;
    padding-bottom: 0;
  }
  #screen-play .play-top {
    flex-shrink: 0;
    margin-bottom: 8px;
    gap: 8px;
    padding: 0 4px;
  }
  #screen-play .play-title-wrap h2 {
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #screen-play .play-meta {
    font-size: 0.78rem;
    gap: 6px;
  }
  #screen-play .play-layout {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    min-height: 0;
    overflow: hidden;
  }

  #screen-play .grid-wrap {
    width: min(100%, 52dvh, 100%);
    max-width: 100%;
    max-height: min(52dvh, calc(100dvh - 270px));
    aspect-ratio: 1 / 1;
    flex: 0 0 auto;
    padding: 10px;
    border-radius: 16px;
    margin: 0 auto 10px;
    box-sizing: border-box;
    align-self: center;
  }
  #screen-play .letter-grid {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    max-height: 100%;
    gap: 4px;
  }
  #screen-play .cell {
    border-radius: 7px;
    font-size: clamp(0.7rem, 2.7vw, 0.95rem);
  }
  #screen-play .line-layer {
    inset: 10px;
    width: calc(100% - 20px);
    height: calc(100% - 20px);
  }

  #screen-play .word-panel {
    flex: 0 1 auto;
    width: min(100%, 52dvh, 100%);
    max-width: 100%;
    min-height: 0;
    max-height: min(42dvh, 320px);
    margin: 0 auto;
    padding: 12px 14px 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-self: center;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #141e33 0%, #0c1424 100%);
    overscroll-behavior: contain;
    box-shadow: 0 -10px 32px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
  }
  #screen-play .word-panel-head {
    flex-shrink: 0;
    margin-bottom: 8px;
    text-align: center;
    justify-content: center;
  }
  #screen-play .word-panel h3 {
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    margin: 0;
    color: #7dd3fc;
    width: 100%;
    text-align: center;
  }
  #screen-play .word-panel .panel-sub {
    display: none;
  }
  #screen-play .word-list {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    align-content: start;
    justify-items: stretch;
    padding-bottom: 2px;
    width: 100%;
  }
  #screen-play .word-list li {
    padding: 8px 10px;
    font-size: 0.7rem;
    letter-spacing: 0.03em;
    min-height: 36px;
    border-radius: 999px;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
  }
  #screen-play .word-list li:last-child:nth-child(odd) {
    grid-column: 1;
    max-width: none;
    justify-self: stretch;
  }
  #screen-play .word-list li .mark {
    width: 7px;
    height: 7px;
  }
  #screen-play .encourage {
    flex-shrink: 0;
    margin-top: 8px;
    padding: 7px 10px;
    font-size: 0.76rem;
    border-radius: 8px;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
  }
  #screen-play .play-actions {
    flex-shrink: 0;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    width: 100%;
  }
  #screen-play .play-actions .btn {
    min-height: 38px;
    padding: 7px 14px;
    font-size: 0.82rem;
    border-radius: 10px;
    width: 100%;
  }

  .cw-clue-list {
    max-height: 220px;
    overflow: auto;
  }
  .cw-clues {
    grid-template-columns: 1fr 1fr;
  }
  .cw-clues .play-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .live-choices { grid-template-columns: 1fr; }
  .live-qtext { font-size: 1.15rem; }

  #screen-play .grid-wrap {
    width: min(100%, 50dvh, 100%);
    max-height: min(50dvh, calc(100dvh - 250px));
    padding: 8px;
    border-radius: 14px;
    margin: 0 auto 8px;
  }
  #screen-play .line-layer {
    inset: 8px;
    width: calc(100% - 16px);
    height: calc(100% - 16px);
  }
  #screen-play .word-panel {
    width: min(100%, 50dvh, 100%);
    min-height: 0;
    max-height: min(40dvh, 300px);
    margin: 0 auto;
    padding: 11px 12px 8px;
  }
  #screen-play .word-list li {
    padding: 7px 10px;
    font-size: 0.68rem;
    min-height: 34px;
  }
}

@media (max-width: 520px) {
  .modal-actions.col-3,
  .modal-actions { grid-template-columns: 1fr; }
  .cw-clues { grid-template-columns: 1fr; }
  .lb-item { grid-template-columns: 36px 1fr auto; }
  .lb-set { display: none; }
  .lb-tab { font-size: 0.74rem; padding: 8px 4px; }
}

@media (max-width: 480px) {
  #app {
    padding: 14px 12px 20px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
  .hero { padding: 20px 4px 6px; }
  .game-card { padding: 15px; gap: 14px; }
  .game-icon { width: 46px; height: 46px; border-radius: 12px; }
  .stats-bar { gap: 8px; margin: 14px auto 14px; }
  .stat { padding: 12px 6px 10px; }
  .stat-val { font-size: 1.25rem; }
  .player-card { gap: 10px; padding: 12px 14px; }
  .player-avatar { width: 38px; height: 38px; border-radius: 10px; }
}

/* Very short phones */
@media (max-width: 820px) and (max-height: 740px) {
  #screen-play .grid-wrap {
    width: min(100%, 46dvh);
    max-height: min(46dvh, calc(100dvh - 230px));
  }
  #screen-play .word-panel {
    min-height: 120px;
    max-height: min(38dvh, 260px);
    padding: 10px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  }
  #screen-play .play-actions .btn {
    min-height: 34px;
    font-size: 0.78rem;
    padding: 5px 10px;
  }
}

@media (max-width: 820px) and (max-height: 640px) {
  #screen-play .grid-wrap {
    width: min(100%, 42dvh);
    max-height: min(42dvh, calc(100dvh - 200px));
  }
  #screen-play .word-list li {
    padding: 6px 8px;
    font-size: 0.64rem;
    min-height: 32px;
  }
  #screen-play .encourage {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- LOW SPEC / DEVICE LAMA / PERFORMANCE MODE ---------- */
/* Fallback solid backgrounds for browsers without backdrop-filter support */
@supports not ((-webkit-backdrop-filter: blur(10px)) or (backdrop-filter: blur(10px))) {
  .player-card,
  .stat,
  .game-card,
  .tahap-card,
  .level-card,
  .word-panel,
  .cw-active-clue,
  .cw-grid-wrap,
  .cw-clues,
  .modal-card,
  .meaning-toast,
  .live-panel,
  .live-join-card,
  .lb-item,
  .quiz-card {
    background: #0f172a !important;
  }
}

/* Mod Ringan (Low-Spec / High Performance Mode) */
html.low-spec {
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.3);
}

html.low-spec .bg-orbs {
  display: none !important;
}

html.low-spec *,
html.low-spec *::before,
html.low-spec *::after {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  filter: none !important;
  text-shadow: none !important;
}

html.low-spec .player-card,
html.low-spec .stat,
html.low-spec .game-card,
html.low-spec .tahap-card,
html.low-spec .level-card,
html.low-spec .word-panel,
html.low-spec .cw-active-clue,
html.low-spec .cw-grid-wrap,
html.low-spec .cw-clues,
html.low-spec .modal-card,
html.low-spec .meaning-toast,
html.low-spec .live-panel,
html.low-spec .live-join-card,
html.low-spec .lb-item,
html.low-spec .quiz-card {
  background: #0f172a !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

html.low-spec .grid-wrap {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

html.low-spec .game-card:hover,
html.low-spec .tahap-card:hover,
html.low-spec .stat:hover,
html.low-spec .level-card:hover,
html.low-spec .btn:hover,
html.low-spec .btn:active,
html.low-spec .icon-btn:hover {
  transform: none !important;
}

#btn-low-spec.active-mode {
  color: #38bdf8 !important;
  font-weight: 600;
  background: rgba(56, 189, 248, 0.12) !important;
}

/* Performance DOM containment for grids */
.letter-grid,
.cw-grid {
  contain: layout style;
}
.cell {
  contain: content;
}

/* =========================================================
   ADMIN PANEL & LIVE QUIZ IMAGES
   ========================================================= */
.admin-card {
  max-width: 680px;
  width: 95%;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Clips to rounded corners cleanly! Tiada scrollbar terkeluar bucu */
  padding: 0;
  text-align: left;
}
.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px 14px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(21, 32, 55, 0.98);
  flex-shrink: 0;
}
.admin-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.admin-title-wrap h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}
.admin-badge {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  font-weight: 800;
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.05em;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.35);
}
.btn-admin-mode {
  border-color: rgba(245, 158, 11, 0.45) !important;
  color: #fbbf24 !important;
}
.btn-admin-mode:hover {
  background: rgba(245, 158, 11, 0.12) !important;
  border-color: #f59e0b !important;
}
.admin-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 22px 10px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 21, 39, 0.5);
  flex-shrink: 0;
  overflow-x: auto;
}
.admin-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 22px 24px;
  scroll-behavior: smooth;
}
.admin-tab {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.admin-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}
.admin-tab.active {
  background: rgba(56, 189, 248, 0.14);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}
.admin-section-header h3 {
  margin: 0 0 4px 0;
  font-size: 1.05rem;
}
.admin-cloud-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.22);
  padding: 8px 12px;
  border-radius: 8px;
  margin-top: 10px;
  margin-bottom: 12px;
}
.admin-cloud-indicator {
  font-size: 0.76rem;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.16);
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.admin-cloud-indicator.syncing {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.16);
}
.admin-cloud-indicator.warn {
  color: #f87171;
  background: rgba(248, 113, 113, 0.16);
}
.admin-cloud-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}
.admin-q-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 14px;
  background: rgba(255, 255, 255, 0.02);
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.admin-q-form textarea {
  width: 100%;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  resize: vertical;
}
.admin-img-upload-box {
  background: rgba(0, 0, 0, 0.2);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
.field-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.field-label.full {
  grid-column: 1 / -1;
}
.admin-img-inputs {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.btn-file-label {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-file-label input[type="file"] {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.admin-img-inputs input[type="url"] {
  flex: 1;
  min-width: 200px;
  padding: 7px 10px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
}
.or-sep {
  font-size: 0.8rem;
  color: var(--subtle);
}
.admin-img-preview-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.admin-img-preview-wrap img {
  max-height: 80px;
  max-width: 140px;
  border-radius: 6px;
  object-fit: contain;
  background: #000;
  border: 1px solid var(--line);
}
.btn-xs {
  padding: 4px 8px;
  font-size: 0.76rem;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-xs.danger,
.btn.danger {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.35);
}
.btn-xs.danger:hover,
.btn.danger:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #fff;
}
.admin-choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 580px) {
  .admin-choices-grid {
    grid-template-columns: 1fr;
  }
}
.choice-field {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
}
.choice-field:focus-within {
  border-color: #38bdf8;
}
.choice-letter {
  font-weight: 700;
  color: #38bdf8;
  min-width: 14px;
}
.choice-field input[type="text"] {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  outline: none;
  font-size: 0.88rem;
}
.admin-sep {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 20px 0;
}
.admin-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.admin-list-header h3 {
  margin: 0;
  font-size: 1.05rem;
}
.admin-list-btns {
  display: flex;
  gap: 8px;
}
.admin-quiz-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}
.admin-quiz-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: left;
}
.admin-q-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.admin-q-num {
  font-weight: 800;
  color: #38bdf8;
  font-size: 0.85rem;
}
.admin-q-text {
  flex: 1;
  margin: 0;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.4;
}
.admin-q-thumb-wrap {
  margin: 8px 0;
}
.admin-q-thumb {
  max-height: 80px;
  max-width: 140px;
  border-radius: 6px;
  object-fit: contain;
  background: #000;
  border: 1px solid var(--line);
}
.admin-q-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.admin-choice-tag {
  font-size: 0.78rem;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}
.admin-choice-tag.correct {
  background: rgba(34, 197, 94, 0.18);
  color: #34d399;
  font-weight: 700;
  border: 1px solid rgba(34, 197, 94, 0.35);
}
.admin-q-explain {
  margin: 8px 0 0 0;
  font-size: 0.8rem;
  color: var(--subtle);
}
.admin-empty {
  text-align: center;
  padding: 30px;
  color: var(--muted);
  font-size: 0.9rem;
}
.admin-danger-box {
  display: flex;
  gap: 14px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  text-align: left;
}
.danger-icon {
  font-size: 1.8rem;
  line-height: 1;
}
.admin-danger-box h3 {
  margin: 0 0 4px 0;
  color: #f87171;
  font-size: 1rem;
}
.admin-danger-box p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
}
.admin-lb-action-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  text-align: left;
}
.admin-lb-action-card h4 {
  margin: 0 0 6px 0;
  font-size: 0.95rem;
}
.admin-lb-action-card p {
  margin: 0 0 14px 0;
  font-size: 0.84rem;
  color: var(--muted);
}
.admin-status-msg {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.88rem;
}
.admin-status-msg.loading {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
}
.admin-status-msg.success {
  background: rgba(34, 197, 94, 0.15);
  color: #34d399;
}
.admin-status-msg.error {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* Bilik Live & Quiz Images */
.live-qimg-wrap {
  margin: 10px auto 14px auto;
  text-align: center;
  max-width: 480px;
}
.live-qimg {
  max-width: 100%;
  max-height: 220px;
  border-radius: 10px;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  display: block;
  margin: 0 auto;
}
.btn-admin-header {
  border-color: rgba(245, 158, 11, 0.35) !important;
  color: #fbbf24 !important;
  background: rgba(245, 158, 11, 0.1) !important;
}
.btn-admin-header:hover {
  background: rgba(245, 158, 11, 0.2) !important;
  border-color: rgba(245, 158, 11, 0.6) !important;
}
.admin-link {
  color: #fbbf24 !important;
  font-weight: 600;
}

