:root {
  color-scheme: dark;
  --ink: #f6f6ff;
  --muted: #aeb5d7;
  --deep: #0b1029;
  --line: rgba(218, 224, 255, 0.14);
  --lime: #d7ff72;
  --peach: #ffd2a9;
  font-family: "Avenir Next", Avenir, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
html { background: var(--deep); }
body {
  overflow: hidden;
  overscroll-behavior: none;
  background: radial-gradient(circle at 50% 0%, #1c2350, #0b1029 70%);
  color: var(--ink);
}
button { font: inherit; }
button:focus-visible { outline: 3px solid var(--lime); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-shell {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  display: flex;
  justify-content: center;
}
.game-card {
  width: 100%;
  max-width: calc((100dvh - 76px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 2.05);
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.game-header {
  flex: 0 0 52px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px 6px;
}
h1 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(18px, 2.2vw, 24px);
  font-weight: 800;
  letter-spacing: -0.055em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
h1 > span:last-child { color: var(--lime); }
.brand-star {
  display: inline-grid;
  width: 30px;
  height: 30px;
  margin-right: 3px;
  place-items: center;
  border-radius: 9px;
  background: var(--lime);
  color: var(--deep);
  font-size: 19px;
  vertical-align: -2px;
}
.header-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 5px; }
.best-score {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 0 7px;
  color: var(--muted);
  font-size: 13px;
}
.best-score strong { color: var(--ink); font-size: 17px; line-height: 1; }
.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 11px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.05);
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.icon-button:hover { background: rgba(255,255,255,.12); }
.icon-button:disabled { opacity: .35; cursor: default; }
.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sound-off, .icon-button[aria-pressed="true"] .sound-on { display: none; }
.icon-button[aria-pressed="true"] .sound-off { display: block; }

.stage-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  container-type: size;
  border: 1px solid rgba(222, 225, 255, .24);
  border-radius: clamp(16px, 2.5vmin, 25px);
  background: #7477c4;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#gameCanvas { display: block; width: 100%; height: 100%; cursor: pointer; }
.score-pill {
  position: absolute;
  top: 14px;
  left: 50%;
  display: grid;
  min-width: 50px;
  height: 50px;
  padding: 0 12px;
  place-items: center;
  transform: translateX(-50%);
  border: 1px solid rgba(255,255,255,.26);
  border-radius: 16px;
  background: rgba(11,16,41,.52);
  color: white;
  font-size: 25px;
  line-height: 1;
  pointer-events: none;
}
.game-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(10,14,40,.14);
  text-align: center;
  transition: opacity 150ms ease, visibility 150ms ease;
}
.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.overlay-panel {
  width: min(100%, 340px);
  padding: clamp(16px, 3vmin, 28px);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 24px;
  background: rgba(14,19,47,.88);
  box-shadow: 0 16px 50px rgba(7,10,32,.3);
}
.overlay-kicker {
  margin: 0 0 9px;
  color: var(--lime);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .14em;
}
.game-overlay h2 {
  margin: 0 0 18px;
  font-size: clamp(25px, 5vmin, 38px);
  font-weight: 800;
  letter-spacing: -.06em;
  line-height: 1.05;
}
.game-overlay h2 em { color: var(--peach); font-style: normal; }
.primary-button {
  min-width: 164px;
  min-height: 48px;
  padding: 11px 22px;
  border: 0;
  border-radius: 14px;
  background: var(--lime);
  color: var(--deep);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.primary-button:hover { background: #e5ff9f; }
.primary-button:active { transform: translateY(2px); }
.overlay-hint { margin: 15px 0 0; color: #d1d5ea; font-size: 13px; line-height: 1.3; }
.hint-touch { display: none; }
.final-score {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 9px;
  margin: -7px 0 16px;
  color: var(--muted);
  font-size: 14px;
}
.final-score strong { color: var(--peach); font-size: 28px; line-height: 1; }

@media (pointer: coarse) {
  .hint-touch { display: inline; }
  .hint-pointer { display: none; }
}
@media (max-width: 380px) {
  .best-score { gap: 4px; padding: 0 3px; font-size: 12px; }
  .header-actions { gap: 3px; }
  .brand-star { width: 27px; height: 27px; font-size: 17px; }
}
@media (max-height: 480px) {
  .app-shell { padding: max(5px, env(safe-area-inset-top)) max(5px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(5px, env(safe-area-inset-left)); }
  .game-card { max-width: calc((100dvh - 58px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 2.05); }
  .game-header { flex-basis: 46px; padding-bottom: 3px; }
  .icon-button { width: 40px; height: 40px; padding: 9px; border-radius: 12px; }
  .brand-star { width: 27px; height: 27px; font-size: 17px; }
}
@container (max-height: 280px) {
  .overlay-panel { width: min(100%, 300px); padding: 12px 18px; border-radius: 18px; }
  .overlay-kicker { margin-bottom: 5px; font-size: 11px; }
  .game-overlay h2 { margin-bottom: 9px; font-size: 23px; }
  .primary-button { min-height: 40px; padding: 8px 18px; font-size: 14px; }
  .overlay-hint { margin-top: 7px; font-size: 12px; }
  .final-score { margin: -2px 0 9px; }
  .final-score strong { font-size: 22px; }
  .score-pill { top: 8px; min-width: 38px; height: 38px; font-size: 20px; border-radius: 12px; }
}
@container (max-height: 175px) {
  .overlay-kicker, .overlay-hint { display: none; }
  .overlay-panel { padding: 8px 14px; }
  .game-overlay h2 { margin-bottom: 6px; font-size: 19px; }
  .final-score { margin-bottom: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  .game-overlay { transition: none; }
}

