/* ── Design tokens (Pixel Art / arcade neon) ── */
:root {
  --bg: #0f172a;
  --bg-deep: #080d18;
  --bg-card: rgba(255, 255, 255, .05);
  --bg-hover: rgba(255, 255, 255, .08);
  --bg-muted: #1f1829;
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .18);
  --text: #ffffff;
  --text-muted: #9aa5bd;
  --primary: #dc2626;
  --secondary: #2563eb;
  --accent: #22c55e;
  --gold: #fbbf24;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 4px 24px rgba(0, 0, 0, .45);
  --shadow-lg: 0 18px 60px rgba(0, 0, 0, .6);
  --font-head: 'Press Start 2P', ui-monospace, monospace;
  --font-body: 'VT323', ui-monospace, monospace;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.22rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, .028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .028) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 10%, transparent 78%);
}
.glow {
  position: fixed;
  inset: -35% -20% auto -20%;
  height: 72vh;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(ellipse at 22% 0%, rgba(220, 38, 38, .3), transparent 58%),
    radial-gradient(ellipse at 78% 0%, rgba(37, 99, 235, .32), transparent 58%);
}
img, canvas { display: block; max-width: 100%; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ── Typography helpers ── */
h1, h2, h3, .nav-logo, .stat-value, .badge, kbd, .btn { font-family: var(--font-head); }
.ico { width: 20px; height: 20px; stroke-width: 2; flex: none; }
.ico.sm { width: 15px; height: 15px; }
.shell { max-width: 1180px; margin: 0 auto; padding: 0 1.25rem 2rem; }
.section { padding: 3.25rem 0 .5rem; }
.section-title { font-size: clamp(.95rem, 2.2vw, 1.35rem); margin-bottom: .7rem; }
.section-sub { color: var(--text-muted); max-width: 620px; margin-bottom: 1.75rem; }
.hint { color: var(--text-muted); font-size: 1rem; display: flex; gap: .5rem; align-items: flex-start; margin-top: 1rem; }

/* ── Navbar ── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 1.25rem;
  background: rgba(15, 23, 42, .82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav-logo { display: flex; align-items: center; gap: .6rem; font-size: .82rem; color: var(--accent); }
.nav-links { display: flex; gap: 1.4rem; }
.nav-link { color: var(--text-muted); text-decoration: none; font-size: 1.05rem; transition: color .2s ease, transform .2s ease; }
.nav-link:hover { color: var(--text); transform: translateY(-2px); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .7rem 1.25rem;
  border-radius: 999px;
  font-size: .68rem;
  letter-spacing: .02em;
  cursor: pointer;
  border: none;
  color: var(--text);
  background: var(--bg-hover);
  transition: transform .15s ease, box-shadow .15s ease, background .2s ease, opacity .2s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #16a34a); color: #06140c; box-shadow: 0 8px 30px rgba(34, 197, 94, .32); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 14px 40px rgba(34, 197, 94, .45); }
.btn-ghost { background: transparent; border: 1.5px solid var(--border-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); }
.btn-icon { padding: .6rem; border-radius: 50%; }
.btn-sm { padding: .5rem .9rem; font-size: .6rem; }

/* ── Hero ── */
.hero { text-align: center; padding: 3.5rem 0 .5rem; }
.hero h1 { font-size: clamp(1.25rem, 4.6vw, 2.5rem); line-height: 1.5; margin-bottom: 1.2rem; }
.hero p { color: var(--text-muted); font-size: 1.25rem; max-width: 640px; margin: 0 auto; }
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .6rem;
  color: var(--primary);
  border: 1px solid rgba(220, 38, 38, .35);
  background: rgba(220, 38, 38, .1);
  padding: .4rem .8rem;
  border-radius: 999px;
  margin-bottom: 1.4rem;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .58rem;
  padding: .38rem .75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  color: var(--text-muted);
  transition: background .25s ease, color .25s ease;
}
.badge.live { background: rgba(34, 197, 94, .16); color: var(--accent); }
.badge.paused { background: rgba(251, 191, 36, .16); color: var(--gold); }
.badge.dead { background: rgba(220, 38, 38, .18); color: #f87171; }

/* ── Game layout ── */
.game-wrap {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) 300px;
  gap: 1.25rem;
  align-items: start;
  margin-top: 2.5rem;
}
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  padding: 1.1rem;
}
.stats { display: grid; gap: .85rem; }
.stat { display: flex; flex-direction: column; gap: .35rem; }
.stat-label { font-family: var(--font-head); font-size: .5rem; color: var(--text-muted); display: flex; align-items: center; gap: .4rem; letter-spacing: .04em; }
.stat-value { font-size: 1.5rem; letter-spacing: .04em; transition: color .25s ease, transform .25s ease; }
.stat-value.accent { color: var(--gold); }
.stat-value.bump { transform: scale(1.18); color: var(--accent); }

/* ── Board ── */
.board-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  padding: 1rem;
  display: grid;
  gap: .85rem;
}
.board-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.board-actions { display: flex; gap: .5rem; }
.board-hold {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: radial-gradient(circle at 50% 0%, #16203a, var(--bg-deep) 70%);
  border: 1px solid var(--border-strong);
  box-shadow: inset 0 0 60px rgba(37, 99, 235, .18);
  aspect-ratio: 1 / 1;
}
#board { width: 100%; height: 100%; touch-action: none; }

/* ── Overlay + modal ── */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(8, 13, 24, .78);
  backdrop-filter: blur(5px);
  animation: fadeUp .22s ease;
}
.overlay[hidden] { display: none; }
.modal {
  width: 100%;
  max-width: 400px;
  text-align: center;
  background: linear-gradient(180deg, #131d33, #0c1322);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.4rem;
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: .9rem;
  justify-items: center;
}
.modal h2 { font-size: clamp(.8rem, 2.4vw, 1.1rem); line-height: 1.7; }
.modal p { color: var(--text-muted); font-size: 1.1rem; }
.modal .modal-score { font-family: var(--font-head); font-size: .72rem; color: var(--accent); }
.modal .row { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; }
.modal-icon { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 50%; background: rgba(34, 197, 94, .14); color: var(--accent); }
.modal-icon.dead { background: rgba(220, 38, 38, .16); color: #f87171; }

/* ── Touch D-pad ── */
.dpad { direction: ltr; display: grid; grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(3, 58px); gap: .5rem; justify-content: center; }
.dbtn {
  border: 1.5px solid var(--border-strong);
  background: var(--bg-hover);
  color: var(--text);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .12s ease, background .2s ease, box-shadow .2s ease;
}
.dbtn:hover { background: rgba(34, 197, 94, .18); box-shadow: 0 0 18px rgba(34, 197, 94, .25); }
.dbtn:active { transform: scale(.94); }
.dbtn.up { grid-area: 1 / 2; }
.dbtn.left { grid-area: 2 / 1; }
.dbtn.right { grid-area: 2 / 3; }
.dbtn.down { grid-area: 3 / 2; }

/* ── Settings ── */
.panel-title { font-size: .65rem; margin-bottom: 1rem; color: var(--accent); }
.panel-label { font-family: var(--font-head); font-size: .5rem; color: var(--text-muted); display: block; margin-bottom: .55rem; letter-spacing: .04em; }
.field { margin-bottom: 1.15rem; }
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .35rem;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .35rem;
}
.tab {
  font-family: var(--font-head);
  font-size: .52rem;
  padding: .55rem .3rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .2s ease, color .2s ease, transform .15s ease;
}
.tab:hover { color: var(--text); transform: translateY(-1px); }
.tab.active { background: linear-gradient(135deg, var(--primary), #b91c1c); color: #fff; box-shadow: 0 6px 20px rgba(220, 38, 38, .3); }
.switch { display: flex; align-items: flex-start; gap: .7rem; cursor: pointer; padding: .5rem 0; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.track { flex: none; width: 44px; height: 24px; border-radius: 999px; background: rgba(255, 255, 255, .12); border: 1px solid var(--border); position: relative; transition: background .22s ease; margin-top: .15rem; }
.knob { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .22s cubic-bezier(.4, 0, .2, 1); }
.switch input:checked + .track { background: rgba(34, 197, 94, .55); }
.switch input:checked + .track .knob { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 3px; }
.switch-text { font-size: 1.08rem; }
.switch-text small { display: block; color: var(--text-muted); font-size: .95rem; }

/* ── Cards / sections ── */
.grid { display: grid; gap: 1.1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  padding: 1.4rem;
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.card h3 { font-size: .68rem; margin-bottom: .7rem; }
.card p { color: var(--text-muted); font-size: 1.12rem; }
.item-card { position: relative; padding-top: 1.7rem; }
.item-card .dot { position: absolute; top: 1.4rem; left: 1.4rem; width: 16px; height: 16px; border-radius: 4px; }
.dot.eat { background: var(--primary); box-shadow: 0 0 14px var(--primary); }
.dot.gold { background: var(--gold); box-shadow: 0 0 14px var(--gold); border-radius: 50%; }
.dot.block { background: var(--secondary); box-shadow: 0 0 14px var(--secondary); }
.key-list { display: grid; gap: .85rem; }
.key-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: 1.08rem; color: var(--text-muted); }
kbd {
  font-family: var(--font-head);
  font-size: .52rem;
  padding: .4rem .5rem;
  border-radius: 6px;
  background: var(--bg-muted);
  border: 1px solid var(--border-strong);
  border-bottom-width: 3px;
  color: var(--text);
}

/* ── Footer ── */
.footer {
  max-width: 1180px;
  margin: 2.5rem auto 0;
  padding: 1.5rem 1.25rem 2.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 1.05rem;
}
.footer-dim { color: rgba(154, 165, 189, .6); }

/* ── Toast ── */
.toast-wrap { position: fixed; bottom: 1.25rem; inset-inline-start: 1.25rem; z-index: 60; display: grid; gap: .5rem; max-width: 320px; }
.toast {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  background: rgba(34, 197, 94, .16);
  border: 1px solid rgba(34, 197, 94, .35);
  color: #86efac;
  box-shadow: var(--shadow-lg);
  animation: fadeUp .25s ease;
}
.toast.warn { background: rgba(251, 191, 36, .14); border-color: rgba(251, 191, 36, .35); color: #fcd34d; }
.toast.info { background: rgba(37, 99, 235, .16); border-color: rgba(37, 99, 235, .4); color: #93c5fd; }

/* ── Animations ── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.fade-up { animation: fadeUp .5s ease both; }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .game-wrap { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .settings { order: 3; }
}
@media (max-width: 640px) {
  body { font-size: 1.12rem; }
  .nav-links { display: none; }
  .hero { padding-top: 2.25rem; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .board-card { padding: .75rem; }
  .dpad { grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(3, 52px); }
  .footer { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto; }
}

/* Hide icon placeholders if the icon CDN is unavailable (graceful degradation) */
i[data-lucide]:empty { display: none; }
