:root {
  --bg: #0b1020;
  --panel: #111933;
  --accent: #5ef1a1;
  --accent-2: #7cc6ff;
  --text: #eef2ff;
  --muted: #9aa4bf;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: radial-gradient(1200px 800px at 20% -10%, #1b2a57 0%, var(--bg) 45%, #05070f 100%);
  color: var(--text);
}

a { color: inherit; text-decoration: none; }

.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 32px;
  align-items: center;
  padding: 64px 8vw 24px;
}

.card {
  background: linear-gradient(160deg, #141b39, #0e142b);
  border: 1px solid #24315c;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.brand {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: 0.8px;
  margin: 0 0 12px;
}

.subtitle {
  color: var(--muted);
  font-size: 18px;
  margin: 0 0 24px;
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--accent), #3bd2ff);
  color: #04131a;
  border: none;
  padding: 12px 20px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(59, 210, 255, 0.25);
}

.cta.secondary {
  background: transparent;
  border: 1px solid #2b3b6b;
  color: var(--text);
  box-shadow: none;
}

.game-shell {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  padding: 24px 8vw 64px;
}

.panel-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.badge {
  background: #1e2a52;
  color: var(--accent-2);
  padding: 6px 12px;
  border-radius: 999px;
  display: inline-block;
  font-size: 13px;
  margin-right: 8px;
}

.canvas-wrap {
  background: #050b1c;
  border: 1px solid #1f2c58;
  border-radius: 18px;
  padding: 16px;
}

#gameCanvas {
  width: 100%;
  max-width: 760px;
  background: #0b1328;
  border-radius: 12px;
  border: 1px solid #1d2b57;
  touch-action: none; /* prevent page scroll while swiping on canvas */
}

.word-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  background: #1a254c;
  border-radius: 10px;
  margin: 4px 6px 0 0;
  font-size: 14px;
}

.hud {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.stat {
  background: #101b3b;
  border: 1px solid #24315c;
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 130px;
}

.stat h4 {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
}

.stat p {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.footer {
  padding: 12px 8vw 40px;
  color: var(--muted);
  font-size: 13px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 24px 8vw 64px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  border-bottom: 1px solid #20305d;
  padding: 8px 6px;
  text-align: left;
}

@media (max-width: 980px) {
  .hero {
    grid-template-columns: 1fr;
  }
  .game-shell {
    grid-template-columns: 1fr;
  }
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

/* ────────────────────────────────────────────────────────
   LANDING SCREEN
──────────────────────────────────────────────────────── */
#landingScreen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse 1200px 700px at 50% 0%, #1b2a57 0%, #0b1020 55%, #04070f 100%);
}

.landing-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 20px;
  max-width: 540px;
  width: 100%;
}

.landing-snake-emoji {
  font-size: 72px;
  line-height: 1;
  margin-bottom: 12px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-12px); }
}

.glow {
  text-shadow: 0 0 30px rgba(94, 241, 161, 0.55), 0 0 60px rgba(94, 241, 161, 0.25);
}

.name-card {
  width: 100%;
  padding: 28px 24px;
  margin: 20px 0;
  border: 1px solid #2a3a6a;
}

.name-label {
  font-size: 15px;
  color: var(--muted);
  margin: 0 0 14px;
}

.name-input-row {
  display: flex;
  gap: 10px;
}

.name-input {
  flex: 1;
  background: #0d1732;
  border: 1.5px solid #2b3b6b;
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  padding: 11px 16px;
  outline: none;
  transition: border-color 0.2s;
}

.name-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(94, 241, 161, 0.12);
}

.name-input.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-7px); }
  40%       { transform: translateX(7px); }
  60%       { transform: translateX(-5px); }
  80%       { transform: translateX(5px); }
}

.features-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}

.feat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: #111933;
  border: 1px solid #1f2e58;
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 13px;
  color: var(--muted);
}

.feat-num {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

/* ────────────────────────────────────────────────────────
   SITE HEADER
──────────────────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 8vw;
  background: rgba(11, 16, 32, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #1a2650;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-sm {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.5px;
  text-decoration: none;
}

.no-underline {
  text-decoration: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-badge {
  background: #131e44;
  border: 1px solid #24315c;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
}

.cta.sm {
  padding: 7px 14px;
  font-size: 13px;
}

/* ────────────────────────────────────────────────────────
   GAME SELECTION
──────────────────────────────────────────────────────── */
#gameSelectScreen {
  min-height: 100vh;
}

.select-hero {
  text-align: center;
  padding: 48px 8vw 20px;
}

.select-hero h2 {
  font-size: 34px;
  font-weight: 800;
  margin: 0 0 8px;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 22px;
  padding: 16px 8vw 60px;
}

.game-card {
  background: linear-gradient(155deg, #141b3a, #0d1328);
  border: 1px solid #243163;
  border-radius: 20px;
  padding: 28px 24px;
  cursor: pointer;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.game-card:hover:not(.coming-soon) {
  transform: translateY(-5px);
  border-color: var(--accent);
  box-shadow: 0 18px 48px rgba(94, 241, 161, 0.12);
}

.game-card.coming-soon {
  opacity: 0.45;
  cursor: default;
}

.game-card-icon {
  font-size: 44px;
  line-height: 1;
}

.game-card h3 {
  margin: 0;
  font-size: 20px;
}

.game-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  flex: 1;
}

.game-card-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.muted-badge {
  background: #1e2a52;
  color: var(--muted);
}

.play-btn {
  display: inline-block;
  margin-top: 6px;
  background: linear-gradient(135deg, var(--accent), #3bd2ff);
  color: #04131a;
  font-weight: 700;
  font-size: 14px;
  padding: 9px 18px;
  border-radius: 10px;
  width: fit-content;
}

/* ────────────────────────────────────────────────────────
   GAME PAGE TWEAKS
──────────────────────────────────────────────────────── */
.next-word-chip {
  background: linear-gradient(135deg, #1e3a52, #1a2f48);
  border: 1.5px solid var(--accent);
  color: var(--accent);
  font-size: 20px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 12px;
  display: inline-block;
  letter-spacing: 0.5px;
  min-width: 80px;
  text-align: center;
  box-shadow: 0 0 14px rgba(94, 241, 161, 0.2);
}

.chip-correct {
  border: 1.5px solid #f7d774;
  color: #f7d774;
}

.chip-wrong {
  border: 1.5px solid #f08cc4;
  color: #f08cc4;
}

.how-to-card {
  background: #0d1732;
  border: 1px solid #1f2e58;
  border-radius: 12px;
  padding: 14px 16px;
}

@media (max-width: 620px) {
  .name-input-row { flex-direction: column; }
  .landing-snake-emoji { font-size: 54px; }
  .brand { font-size: 30px; }
  .game-grid { grid-template-columns: 1fr; }
  .site-header { padding: 12px 4vw; }
  .game-shell { padding: 16px 3vw 40px; }
}

/* ────────────────────────────────────────────────────────
   D-PAD (on-screen touch controls)
──────────────────────────────────────────────────────── */
.dpad {
  display: none; /* shown via JS when pointer:coarse */
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 16px auto 4px;
  user-select: none;
  -webkit-user-select: none;
}

.dpad-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dpad-center {
  width: 52px;
  height: 52px;
}

.dpad-btn {
  width: 60px;
  height: 60px;
  font-size: 22px;
  background: #1a274e;
  border: 1.5px solid #2e4080;
  border-radius: 14px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  transition: background 0.1s, transform 0.08s;
  -webkit-tap-highlight-color: transparent;
}

.dpad-btn:active {
  background: #2a3f7a;
  transform: scale(0.92);
}

/* ────────────────────────────────────────────────────────
   MOBILE GAME PAGE TWEAKS
──────────────────────────────────────────────────────── */
@media (max-width: 780px) {
  /* Stack canvas full-width first, then info panel below */
  .game-shell {
    grid-template-columns: 1fr;
    padding: 10px 3vw 80px;
  }

  /* Make HUD stats narrower on small screens */
  .stat {
    min-width: 70px;
    padding: 8px 10px;
  }
  .stat p { font-size: 16px; }

  /* Canvas fills full width */
  #gameCanvas {
    width: 100%;
    height: auto;
    max-width: 100%;
  }

  /* Larger touch targets for start button */
  #startBtn {
    padding: 14px;
    font-size: 17px;
  }

  /* Compact side panel on mobile */
  .canvas-wrap.card, .card {
    padding: 14px 12px;
  }

  #englishSentence {
    font-size: 15px !important;
  }

  .next-word-chip {
    font-size: 17px;
  }

  /* Hide the how-to on very small screens to save space */
  .how-to-card { display: none; }

  /* D-pad always visible on mobile */
  .dpad { margin-top: 12px; }
}

@media (max-width: 420px) {
  .dpad-btn { width: 52px; height: 52px; font-size: 18px; }
  .dpad-center { width: 44px; height: 44px; }
  .hud { gap: 8px; }
  .stat { min-width: 60px; padding: 6px 8px; }
}
