:root {
  color-scheme: dark;
  --omt-bg: #050816;
  --omt-panel: rgba(5, 10, 28, .94);
  --omt-accent: #67e8f9;
  --omt-accent-2: #a78bfa;
  --omt-text: #f8fafc;
  --omt-muted: #a9b7d0;
  --omt-border: rgba(255,255,255,.16);
  font-family: Inter, ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  min-height: 320px;
  margin: 0;
  overflow: hidden;
  background: var(--omt-bg);
}
body { color: var(--omt-text); }
button, select { color: inherit; font: inherit; }
button { min-height: 44px; cursor: pointer; touch-action: manipulation; }
button:focus-visible, select:focus-visible, canvas:focus-visible {
  outline: 3px solid var(--omt-accent);
  outline-offset: 2px;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 320px;
  overflow: hidden;
  isolation: isolate;
  background: var(--omt-bg);
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.game-hud {
  position: absolute;
  z-index: 20;
  inset: max(.45rem, env(safe-area-inset-top)) .45rem auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .35rem;
  pointer-events: none;
}
.scores, .controls { display: flex; gap: .3rem; }
.controls { pointer-events: auto; }
.hud-box, .icon-button {
  border: 1px solid var(--omt-border);
  border-radius: .72rem;
  background: rgba(3, 7, 20, .87);
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
  backdrop-filter: blur(8px);
}
.hud-box {
  min-width: 4.1rem;
  margin: 0;
  padding: .42rem .58rem;
}
.hud-box span, .hud-box strong { display: block; }
.hud-box span {
  color: var(--omt-muted);
  font-size: .54rem;
  font-weight: 900;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.hud-box strong {
  margin-top: .05rem;
  font-size: .88rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.icon-button {
  min-width: 42px;
  min-height: 42px;
  padding: .35rem;
  font-weight: 900;
}
.icon-button:hover { border-color: var(--omt-accent); }

.combo {
  position: absolute;
  z-index: 15;
  top: 4.1rem;
  left: 50%;
  margin: 0;
  padding: .35rem .75rem;
  border: 1px solid color-mix(in srgb, var(--omt-accent) 50%, transparent);
  border-radius: 999px;
  background: rgba(3,7,20,.78);
  color: var(--omt-accent);
  font-size: .72rem;
  font-weight: 950;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -.4rem);
  transition: opacity 140ms ease, transform 140ms ease;
}
.combo.visible { opacity: 1; transform: translate(-50%, 0); }

.overlay {
  position: absolute;
  z-index: 30;
  inset: 0;
  display: grid;
  overflow-y: auto;
  place-items: center;
  padding: 4.5rem .75rem max(1rem, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 50% 22%, color-mix(in srgb, var(--omt-accent) 17%, transparent), transparent 22rem),
    rgba(2, 5, 17, .84);
  backdrop-filter: blur(8px);
}
.overlay.hidden { display: none; }
.panel {
  width: min(100%, 31rem);
  padding: clamp(1rem, 4vw, 1.55rem);
  border: 1px solid var(--omt-border);
  border-radius: 1.25rem;
  background: var(--omt-panel);
  box-shadow: 0 28px 70px rgba(0,0,0,.48);
  text-align: center;
}
.game-icon {
  display: grid;
  width: 4rem;
  height: 4rem;
  margin: 0 auto .55rem;
  place-items: center;
  border-radius: 1rem;
  color: #07101e;
  background: linear-gradient(135deg, var(--omt-accent), var(--omt-accent-2));
  font-size: 2rem;
  font-weight: 950;
}
.eyebrow {
  margin: 0;
  color: var(--omt-accent);
  font-size: .62rem;
  font-weight: 950;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.panel h1 { margin: .35rem 0 0; font-size: clamp(1.75rem, 8vw, 2.75rem); line-height: 1; }
.screen-copy {
  max-width: 29rem;
  margin: .65rem auto;
  color: var(--omt-muted);
  font-size: .82rem;
  line-height: 1.5;
}
.instruction {
  margin: .75rem 0;
  padding: .72rem;
  border: 1px solid var(--omt-border);
  border-radius: .8rem;
  background: rgba(255,255,255,.04);
  color: var(--omt-muted);
  font-size: .74rem;
  line-height: 1.45;
}
.mode-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  margin: .7rem 0;
  color: var(--omt-muted);
  font-size: .72rem;
  font-weight: 800;
}
.mode-row select {
  min-height: 40px;
  max-width: 12rem;
  border: 1px solid var(--omt-border);
  border-radius: .65rem;
  padding: .35rem .7rem;
  background: #0c1530;
}
.panel-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .45rem; }
.primary, .secondary {
  padding: .65rem .95rem;
  border-radius: .75rem;
  font-size: .78rem;
  font-weight: 950;
}
.primary {
  border: 0;
  color: #06101c;
  background: linear-gradient(135deg, var(--omt-accent), var(--omt-accent-2));
}
.secondary { border: 1px solid var(--omt-border); background: rgba(255,255,255,.055); }

.toast {
  position: absolute;
  z-index: 45;
  bottom: max(1rem, env(safe-area-inset-bottom));
  left: 50%;
  max-width: min(88%, 27rem);
  margin: 0;
  padding: .62rem .85rem;
  border: 1px solid color-mix(in srgb, var(--omt-accent) 50%, transparent);
  border-radius: 999px;
  background: rgba(3,7,20,.92);
  font-size: .7rem;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, .7rem);
  transition: opacity 150ms ease, transform 150ms ease;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.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;
}

@media (max-width: 520px) {
  .game-hud { gap: .2rem; }
  .scores {
    display: grid;
    flex: 1 1 auto;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    min-width: 0;
    gap: .18rem;
  }
  .hud-box {
    min-width: 0;
    padding: .3rem .38rem;
    border-radius: .55rem;
    box-shadow: none;
  }
  .hud-box span { font-size: .47rem; }
  .hud-box strong { font-size: .76rem; }
  .icon-button { min-width: 40px; min-height: 40px; }
  .game-shell:has(.overlay.hidden) .controls > :not(#pause-button) { display: none; }
  .combo { top: 3.25rem; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .overlay { align-items: start; padding-top: 3.5rem; }
  .panel { padding: .75rem 1rem; }
  .game-icon { width: 2.8rem; height: 2.8rem; margin-bottom: .2rem; font-size: 1.35rem; }
  .panel h1 { font-size: 1.55rem; }
  .screen-copy, .instruction { margin: .35rem auto; }
  .mode-row { margin: .35rem 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
