:root {
  --ink: #02060a;
  --panel: rgba(4, 14, 22, 0.82);
  --panel-lit: rgba(10, 30, 44, 0.9);
  --text: #e2f8ff;
  --text-dim: #7ab4cc;
  --accent: #5fd3ff;
  --accent-lit: #c8f1ff;
  --accent-rgb: 95, 211, 255;
  --enemy: #ff9a52;
  --danger: #ff4b3e;
  --font-display: "Share Tech Mono", "Consolas", monospace;
  --font-ui: "Rajdhani", "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  /* Board spans the full short edge (phones), otherwise as tall as the
     viewport allows under the HUD, capped so it doesn't get absurd on 4K. */
  --board-max: min(100vw, calc(100dvh - 92px), 1100px);
}
html[data-theme="amber"] {
  --text: #fff1d6;
  --text-dim: #b39a6e;
  --accent: #ffb03a;
  --accent-lit: #ffe3a6;
  --accent-rgb: 255, 176, 58;
  --enemy: #6fd4ff;
  --panel: rgba(22, 12, 4, 0.82);
  --panel-lit: rgba(44, 26, 8, 0.9);
}
html[data-theme="white"] {
  --text: #f2f6fa;
  --text-dim: #9aa8b6;
  --accent: #dfe8f2;
  --accent-lit: #ffffff;
  --accent-rgb: 223, 232, 242;
  --enemy: #ff8a7a;
  --panel: rgba(14, 16, 20, 0.82);
  --panel-lit: rgba(30, 34, 40, 0.9);
}
html[data-theme="pink"] {
  --text: #ffe6f0;
  --text-dim: #b8768f;
  --accent: #ff2d8a;
  --accent-lit: #ffc8de;
  --accent-rgb: 255, 45, 138;
  --enemy: #ffb15a;
  --panel: rgba(24, 3, 12, 0.82);
  --panel-lit: rgba(46, 6, 24, 0.9);
}

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

html,
body {
  min-height: 100%;
  height: 100%;
}

body {
  font-family: var(--font-ui);
  font-size: 16px;
  color: var(--text);
  background: var(--ink);
  overflow-x: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* —— Hologram canvas (fullscreen, behind the UI) —— */
.holo {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  pointer-events: none;
}
.crt-glass {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(255, 255, 255, 0.05), transparent 60%),
    radial-gradient(ellipse 100% 100% at 50% 50%, transparent 60%, rgba(0, 0, 0, 0.45) 100%);
}

.splash,
.game-app,
.overlay {
  position: relative;
  z-index: 2;
}

button,
select,
a.btn {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
  text-decoration: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35em;
  min-height: 46px;
  padding: 0.55em 1.25em;
  border-radius: 2px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 1rem;
  transition: transform 0.12s var(--ease), background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.btn:active {
  transform: scale(0.98);
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: rgba(var(--accent-rgb), 0.16);
  color: var(--accent-lit);
  border: 1px solid rgba(var(--accent-rgb), 0.75);
  box-shadow:
    0 0 14px rgba(var(--accent-rgb), 0.25),
    inset 0 0 18px rgba(var(--accent-rgb), 0.12);
  text-shadow: 0 0 8px rgba(var(--accent-rgb), 0.8);
}
.btn-primary:hover {
  background: rgba(var(--accent-rgb), 0.28);
  box-shadow:
    0 0 22px rgba(var(--accent-rgb), 0.4),
    inset 0 0 22px rgba(var(--accent-rgb), 0.18);
}

.btn-secondary {
  background: var(--panel);
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  color: var(--text);
}
.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent-lit);
}

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(var(--accent-rgb), 0.2);
  color: var(--text-dim);
}
.btn-ghost:hover {
  border-color: rgba(var(--accent-rgb), 0.5);
  color: var(--text);
}

.btn-icon {
  width: 42px;
  min-height: 42px;
  padding: 0;
  font-size: 1.25rem;
  background: var(--panel);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  border-radius: 2px;
}

.back-btn {
  background: var(--panel);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  padding-inline: 0.85em;
  font-size: 0.95rem;
}

/* —— Splash —— */
html.is-splash .game-app {
  display: none !important;
}
html.is-playing .splash {
  display: none !important;
}

.splash {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
}

.splash-stage {
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.splash-eyebrow {
  font-family: var(--font-display);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--accent);
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.8);
  animation: rise 0.6s var(--ease) both;
}

.splash-brand {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.2rem, 9vw, 3.4rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 0.95;
  color: var(--accent-lit);
  text-shadow:
    0 0 6px rgba(var(--accent-rgb), 0.9),
    0 0 28px rgba(var(--accent-rgb), 0.55),
    2px 0 0 rgba(255, 60, 60, 0.35),
    -2px 0 0 rgba(60, 120, 255, 0.35);
  animation: rise 0.7s var(--ease) 0.05s both;
}

.splash-tag {
  max-width: 34ch;
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text-dim);
  animation: rise 0.7s var(--ease) 0.1s both;
}

/* Empty square placeholder — the hologram frames the board into it. */
.splash-hero {
  width: min(78%, 300px);
  aspect-ratio: 1;
  margin: 8px 0 4px;
  animation: rise 0.8s var(--ease) 0.12s both;
}

.splash-cta {
  width: 100%;
  display: grid;
  gap: 10px;
  animation: rise 0.75s var(--ease) 0.18s both;
}
.splash-cta .btn {
  width: 100%;
}

.board-picker {
  width: 100%;
  display: grid;
  gap: 6px;
  text-align: left;
  animation: rise 0.75s var(--ease) 0.22s both;
}
.board-picker-label {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.board-picker select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  background: var(--panel);
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  border-radius: 2px;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* —— Overlays —— */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 4, 8, 0.66);
  backdrop-filter: blur(4px);
}
.overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(420px, 100%);
  padding: 22px 20px;
  background: var(--panel-lit);
  border: 1px solid rgba(var(--accent-rgb), 0.45);
  border-radius: 2px;
  box-shadow:
    0 0 30px rgba(var(--accent-rgb), 0.18),
    0 20px 50px rgba(0, 0, 0, 0.6),
    inset 0 0 40px rgba(var(--accent-rgb), 0.06);
  text-align: center;
}
.overlay-card h2 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 1.45rem;
  color: var(--accent-lit);
  text-shadow: 0 0 12px rgba(var(--accent-rgb), 0.7);
  margin-bottom: 8px;
}
.overlay-sub {
  color: var(--text-dim);
  margin-bottom: 18px;
  line-height: 1.4;
}

.diff-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.tutorial-card {
  text-align: left;
  max-height: min(84dvh, 640px);
  display: flex;
  flex-direction: column;
}
.tut-body {
  flex: 1;
  overflow: auto;
  padding: 4px 2px 12px;
  color: var(--text);
  line-height: 1.45;
}
.tut-body h3 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 1.05rem;
  color: var(--accent);
  margin: 0 0 8px;
}
.tut-body p + p,
.tut-body ul {
  margin-top: 10px;
}
.tut-body ul {
  padding-left: 1.2em;
}
.tut-body li {
  margin: 0.35em 0;
}
.tut-body .piece-name {
  color: var(--accent-lit);
  font-weight: 700;
}
.tut-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid rgba(var(--accent-rgb), 0.2);
  padding-top: 12px;
}
.tut-page {
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  color: var(--text-dim);
}

.promo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.promo-choice {
  display: grid;
  gap: 6px;
  padding: 10px 6px;
  background: #000;
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  border-radius: 2px;
}
.promo-choice:hover {
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.35);
}
.promo-choice img {
  width: 100%;
  max-width: 64px;
  margin: 0 auto;
  display: block;
  mix-blend-mode: screen;
  filter: drop-shadow(0 0 6px rgba(var(--accent-rgb), 0.7));
}
.promo-choice span {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* —— Game —— */
.game-app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  /* no side padding: the board runs edge to edge on narrow screens */
  padding:
    max(8px, env(safe-area-inset-top))
    0
    max(10px, env(safe-area-inset-bottom));
}

.hud {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding: 0 max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
}
.hud-center {
  text-align: center;
  min-width: 0;
}
.turn-label {
  font-family: var(--font-display);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 1rem;
  color: var(--accent-lit);
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.7);
}
.status-label {
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--danger);
  text-shadow: 0 0 10px rgba(255, 75, 62, 0.7);
  min-height: 1.2em;
}
.hud-actions {
  display: flex;
  gap: 6px;
}

.stage {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: visible;
  touch-action: none;
}

/* Square placeholder; the renderer frames the board into it. */
.board-stage {
  position: relative;
  width: var(--board-max);
  aspect-ratio: 1;
  touch-action: none;
}

.board-hit {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

@media (min-width: 720px) {
  .splash-stage {
    width: min(480px, 100%);
  }
  .splash-hero {
    width: min(70%, 320px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .splash-eyebrow,
  .splash-brand,
  .splash-tag,
  .splash-hero,
  .splash-cta,
  .board-picker {
    animation: none !important;
    transition: none !important;
  }
}
