:root {
  --bg: #07070c;
  --bg2: #12121a;
  --panel: #16161f;
  --ink: #f4efe6;
  --muted: #9a9488;
  --amber: #ffb020;
  --pink: #ff3d8a;
  --cyan: #2ee6d6;
  --lime: #c6ff3d;
  --danger: #ff4d4d;
  --wood: #6b3d1f;
  --safe: #1b3d2a;
  --shadow: rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Trebuchet MS", "Avenir Next Condensed", "Arial Narrow", "Segoe UI", sans-serif;
  min-height: 100%;
  overflow: hidden;
  touch-action: manipulation;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(ellipse at top, rgba(255, 61, 138, 0.16), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(46, 230, 214, 0.12), transparent 45%),
    linear-gradient(180deg, #0c0c14 0%, #07070c 100%);
}

body.hub { overflow: auto; }

a { color: var(--cyan); text-decoration: none; }
button, .btn {
  font-family: inherit;
  cursor: pointer;
  border: 0;
  color: inherit;
}

.wrap {
  width: min(980px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 60px;
}

.kicker {
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--amber);
  font-size: 0.72rem;
  margin: 0 0 8px;
}

h1, h2, h3 { margin: 0; letter-spacing: 0.04em; }
h1 {
  font-size: clamp(2.3rem, 8vw, 4.2rem);
  line-height: 0.9;
  text-transform: uppercase;
  text-shadow: 0 0 24px rgba(255, 176, 32, 0.45);
}

.lede {
  color: var(--muted);
  max-width: 38em;
  font-size: 1.05rem;
  line-height: 1.45;
  margin: 14px 0 28px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 800px) {
  .grid { grid-template-columns: 1fr; }
}

.card {
  display: block;
  background: linear-gradient(180deg, #1a1a26 0%, #12121a 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 18px 18px 20px;
  box-shadow: 0 10px 30px var(--shadow);
  transition: transform 0.16s ease, border-color 0.16s ease;
  color: inherit;
  min-height: 210px;
  position: relative;
  overflow: hidden;
}

.card:hover, .card:focus {
  transform: translateY(-3px);
  border-color: rgba(255, 176, 32, 0.55);
}

.card::after {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: var(--glow, rgba(255, 176, 32, 0.16));
  pointer-events: none;
}

.card h2 {
  font-size: 1.6rem;
  text-transform: uppercase;
  margin: 8px 0 8px;
}

.card p { margin: 0; color: var(--muted); line-height: 1.4; }
.tag {
  display: inline-block;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--glowink, var(--amber));
}

.foot {
  margin-top: 28px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Game shell */
.game-page { height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(7, 7, 12, 0.86);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 5;
}
.topbar a, .topbar .ghost {
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: transparent;
  padding: 8px 10px;
}
.topbar .title {
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.9rem;
  color: var(--amber);
}
.stage {
  flex: 1;
  position: relative;
  min-height: 0;
}
.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(7, 7, 12, 0.55);
  z-index: 4;
}
.overlay.hidden { display: none; }
.panel {
  width: min(460px, 100%);
  background: linear-gradient(180deg, #1c1c28, #12121a);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 22px 20px 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  max-height: calc(100dvh - 80px);
  overflow: auto;
}
.panel h1 { font-size: clamp(1.8rem, 7vw, 2.6rem); }
.panel p { color: var(--muted); line-height: 1.45; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.btn, button.btn {
  background: var(--amber);
  color: #1a1204;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.95rem;
  box-shadow: 0 0 18px rgba(255, 176, 32, 0.28);
}
.btn.pink { background: var(--pink); color: #fff; box-shadow: 0 0 18px rgba(255, 61, 138, 0.28); }
.btn.cyan { background: var(--cyan); color: #06211f; box-shadow: 0 0 18px rgba(46, 230, 214, 0.28); }
.btn.lime { background: var(--lime); color: #1a2406; }
.btn.ghost {
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.wide { width: 100%; }
.chip {
  background: #232330;
  border-radius: 999px;
  padding: 8px 12px;
  border: 1px solid transparent;
  color: var(--ink);
  font-weight: 700;
}
.chip.on { border-color: var(--amber); color: var(--amber); }
.stats { font-size: 0.88rem; color: var(--muted); line-height: 1.5; }
.hud-html {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  z-index: 3;
  pointer-events: none;
}
.hud-html .btn, .hud-html button {
  pointer-events: auto;
  min-width: 56px;
  min-height: 48px;
}
input[type="text"] {
  background: #0d0d14;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  width: 100%;
}
