:root {
  color-scheme: dark;
  --ink: #f5f3ea;
  --muted: #9ba3b7;
  --cyan: #66f2ff;
  --violet: #9a7cff;
  --coral: #ff6b7a;
  --panel: rgba(13, 18, 42, .82);
}

* { box-sizing: border-box; }

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

button { -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  overflow-x: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 18%, rgba(74, 55, 145, .28), transparent 34rem),
    linear-gradient(145deg, #050711 0%, #090d20 52%, #070917 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .2;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.16'/%3E%3C/svg%3E");
}

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 28px;
}

.brandbar, .footer-note {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.brandbar { margin-bottom: 14px; }

.eyebrow, .kicker, .micro, .footer-note, .icon-button {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .18em;
}

.eyebrow { margin: 0 0 3px; color: var(--cyan); }

h1 {
  margin: 0;
  font-size: clamp(32px, 6vw, 70px);
  line-height: .86;
  letter-spacing: -.06em;
}

.icon-button {
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--ink);
  background: rgba(255,255,255,.04);
  cursor: pointer;
}

.game-frame {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 24px;
  background: #050817;
  box-shadow: 0 28px 90px rgba(0,0,0,.46), inset 0 0 80px rgba(67, 46, 159, .12);
}

.game-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.035);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  opacity: 0;
  visibility: hidden;
  background: radial-gradient(circle, rgba(8, 12, 31, .68), rgba(4, 6, 16, .91));
  backdrop-filter: blur(8px);
  transition: opacity .25s ease, visibility .25s ease;
}

.overlay.visible { opacity: 1; visibility: visible; }

.card {
  width: min(590px, 100%);
  padding: clamp(24px, 5vw, 46px);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 22px;
  text-align: center;
  background: linear-gradient(155deg, rgba(20, 27, 60, .96), rgba(10, 14, 34, .96));
  box-shadow: 0 24px 80px rgba(0,0,0,.44);
}

.kicker { margin: 0 0 13px; color: var(--cyan); }

.card h2 {
  margin: 0;
  font-size: clamp(34px, 6vw, 64px);
  line-height: .93;
  letter-spacing: -.055em;
}

.lead {
  width: min(460px, 100%);
  margin: 20px auto 22px;
  color: #c2c7d5;
  line-height: 1.55;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0 0 22px;
}

.controls-grid div {
  display: flex;
  min-height: 64px;
  flex-direction: column;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
  background: rgba(255,255,255,.035);
}

.controls-grid span { font-size: 13px; font-weight: 900; color: #fff; }
.controls-grid small { margin-top: 5px; color: var(--muted); font-size: 10px; letter-spacing: .08em; }

.primary {
  min-width: 230px;
  border: 0;
  border-radius: 999px;
  padding: 15px 25px;
  color: #07121b;
  background: linear-gradient(90deg, var(--cyan), #a3ffdf);
  box-shadow: 0 10px 34px rgba(102, 242, 255, .2);
  font: inherit;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .14em;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}

.primary:hover { transform: translateY(-2px); box-shadow: 0 14px 42px rgba(102, 242, 255, .3); }
.primary:active { transform: translateY(1px); }
.micro { margin: 14px 0 0; color: #747d96; letter-spacing: .05em; }
.touch-label, .touch-controls { display: none; }

.results {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 25px 0 18px;
}

.results div { padding: 15px 8px; border-top: 1px solid rgba(255,255,255,.12); }
.results strong { display: block; font-size: 28px; }
.results span { color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .14em; }
.insight { min-height: 48px; color: #c8cedd; line-height: 1.5; }

.pause-badge {
  position: absolute;
  inset: 50% auto auto 50%;
  padding: 11px 16px;
  opacity: 0;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 999px;
  background: rgba(5, 8, 23, .85);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .2em;
  pointer-events: none;
}

.pause-badge.visible { opacity: 1; }

.footer-note {
  align-items: center;
  padding: 12px 6px 0;
  color: #707990;
  letter-spacing: .1em;
}

@media (max-width: 680px) {
  html, body { min-height: 100%; overscroll-behavior: none; }
  body { overflow: hidden; }
  .shell { width: 100%; height: 100dvh; padding: 0; display: flex; flex-direction: column; }
  .brandbar { min-height: 58px; margin: 0; padding: max(8px, env(safe-area-inset-top)) 12px 8px; align-items: center; }
  .eyebrow { font-size: 8px; letter-spacing: .11em; }
  h1 { font-size: 31px; }
  .icon-button { padding: 8px 10px; font-size: 9px; }
  .game-frame { flex: 1; min-height: 0; border: 0; border-radius: 0; }
  canvas { width: 100%; height: auto; aspect-ratio: 2 / 3; }
  .overlay { padding: 12px 14px calc(78px + env(safe-area-inset-bottom)); overflow-y: auto; align-items: center; }
  .card { width: min(100%, 430px); padding: 20px 16px; border-radius: 18px; }
  .card h2 { font-size: clamp(30px, 10vw, 44px); }
  .lead { margin: 12px auto 14px; font-size: 14px; line-height: 1.35; }
  .controls-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 14px; }
  .controls-grid div { min-height: 52px; }
  .desktop-control, .desktop-label { display: none !important; }
  .touch-label { display: inline; }
  .micro.touch-label { display: block; }
  .primary { min-width: min(230px, 100%); padding: 14px 20px; }
  .micro { margin-top: 10px; font-size: 9px; line-height: 1.35; }
  .results { margin: 16px 0 10px; }
  .results strong { font-size: 22px; }
  .insight { min-height: 0; font-size: 13px; }
  .touch-controls {
    position: absolute;
    z-index: 4;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 12px;
    display: flex;
    justify-content: space-between;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .18s ease;
  }
  .touch-controls.visible { opacity: 1; visibility: visible; }
  .touch-controls button {
    min-width: 96px;
    min-height: 48px;
    border: 1px solid rgba(255,255,255,.23);
    border-radius: 999px;
    color: #f5f3ea;
    background: rgba(7, 12, 31, .82);
    backdrop-filter: blur(8px);
    font: 900 10px/1 system-ui;
    letter-spacing: .13em;
    pointer-events: auto;
    touch-action: none;
  }
  .touch-controls button.active { color: #07121b; background: #66f2ff; }
  .footer-note { display: none; }
}

@media (max-width: 680px) and (max-height: 640px) {
  .brandbar { display: none; }
  .overlay { padding-top: 8px; }
  .card { padding-top: 14px; padding-bottom: 14px; }
  .lead { margin: 8px auto 10px; }
}
