:root {
  color-scheme: dark;
  --bg: #041027;
  --panel: rgba(7, 18, 44, .94);
  --line: rgba(255,255,255,.16);
  --text: #f7f2df;
  --muted: #afbdd8;
  --yellow: #ffd21f;
  --cyan: #3fd9ef;
  --green: #a9ff51;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: radial-gradient(circle at 50% 0, #133365, var(--bg) 55%); color: var(--text); font-family: system-ui, -apple-system, Segoe UI, sans-serif; }
body { min-height: 100vh; }
button { font: inherit; }
.app-shell { width: min(1100px, 100%); margin: 0 auto; padding: 10px clamp(8px,2vw,18px) 18px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand strong { color: var(--yellow); font-size: clamp(1.25rem, 4vw, 2rem); letter-spacing: .06em; text-shadow: 2px 2px 0 #000; }
.brand span { color: var(--muted); font-weight: 700; font-size: clamp(.72rem, 2vw, .95rem); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.module-version { border: 1px solid var(--line); border-radius: 999px; padding: 4px 9px; color: var(--muted); font-size: .72rem; }
.game-frame { position: relative; border: 2px solid rgba(255,255,255,.14); border-radius: 18px; overflow: hidden; background: #07142e; box-shadow: 0 18px 60px rgba(0,0,0,.35); }
canvas { display: block; width: 100%; aspect-ratio: 16 / 10; background: #081a39; cursor: crosshair; outline: none; touch-action: none; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(2, 8, 22, .66); backdrop-filter: blur(4px); z-index: 5; touch-action: pan-y; }
.hidden { display: none !important; }
.intro-overlay { padding: 0; overflow: hidden; }
.intro-overlay > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: saturate(1.05) brightness(.64); }
.intro-card, .panel { position: relative; z-index: 1; width: min(720px, 94%); padding: clamp(18px, 4vw, 32px); border: 1px solid rgba(255,255,255,.18); border-radius: 18px; background: var(--panel); box-shadow: 0 20px 70px rgba(0,0,0,.45); text-align: center; }
.intro-card { width: min(520px, 92%); }
.intro-card h1, .panel h2 { margin: 0 0 8px; color: var(--yellow); text-transform: uppercase; letter-spacing: .03em; text-shadow: 2px 2px 0 #000; }
.intro-card p, .panel p { color: var(--muted); line-height: 1.45; }
.panel.compact { width: min(590px, 94%); }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; color: var(--cyan); font-size: .75rem; font-weight: 900; margin-bottom: 6px; }
.primary, .weapon, .souffle, .upgrade-card { border: 0; border-radius: 12px; color: #081128; font-weight: 900; cursor: pointer; min-height: 44px; }
.primary { background: linear-gradient(#ffe15b, #ffc400); padding: 11px 20px; box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); }
.primary:active, .weapon:active, .souffle:active, .upgrade-card:active { transform: translateY(1px); }
.controls { display: flex; gap: 10px; align-items: stretch; justify-content: space-between; margin-top: 9px; }
.weapon-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; flex: 1; }
.weapon { background: #d8e0ef; padding: 8px 10px; }
.weapon span { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 4px; border-radius: 50%; background: rgba(0,0,0,.12); }
.weapon.active { background: var(--yellow); box-shadow: 0 0 0 2px #fff7 inset; }
.souffle { min-width: 145px; background: linear-gradient(#9cff80, #44d778); padding: 8px 14px; }
.souffle:disabled { filter: grayscale(1); opacity: .5; cursor: default; }
.help { color: var(--muted); font-size: .76rem; text-align: center; margin: 8px 0 0; }
.tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 12px 0 18px; }
.tag { border: 1px solid var(--line); border-radius: 999px; padding: 5px 9px; font-size: .75rem; color: #dce7ff; background: rgba(255,255,255,.05); }
.upgrade-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.upgrade-card { background: #eef4ff; padding: 14px; text-align: left; }
.upgrade-card strong { display: block; font-size: 1rem; margin-bottom: 5px; }
.upgrade-card small { display: block; color: #31405f; font-weight: 700; line-height: 1.35; }
@media (max-width: 660px) {
  .app-shell { padding-left: 4px; padding-right: 4px; }
  .brand span { display: none; }
  .game-frame { border-radius: 12px; }
  .controls { gap: 5px; }
  .weapon-group { gap: 4px; }
  .weapon { padding: 7px 5px; font-size: .75rem; }
  .weapon span { display: none; }
  .souffle { min-width: 112px; padding: 7px; font-size: .76rem; }
  .help { padding: 0 8px; }
  .upgrade-grid { grid-template-columns: 1fr; }
}
@media (max-width: 660px), (max-height: 520px) {
  .overlay {
    position: fixed;
    min-height: 100vh;
    min-height: 100dvh;
    padding:
      max(12px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 50;
  }
  .intro-overlay { overflow-y: auto; }
  .intro-card, .panel, .panel.compact {
    width: min(100%, 590px);
    max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    padding: clamp(14px, 4vw, 22px);
    border-radius: 14px;
    overflow-y: auto;
  }
  .intro-card h1, .panel h2 { font-size: clamp(1.25rem, 7vw, 2rem); }
  .intro-card p, .panel p { margin: 6px 0 10px; line-height: 1.35; }
  .tags { margin: 8px 0 12px; }
  .primary { width: 100%; min-height: 48px; }
}
