:root {
  color-scheme: dark;
  --bg: #03040c;
  --panel-border: rgba(99, 125, 255, 0.32);
  --text: #edf4ff;
  --muted: #9da9ca;
  --blue: #23dcff;
  --blue-deep: #1177ff;
  --yellow: #ffe46b;
  --orange: #ff9f43;
  --red: #ff315f;
  --green: #44ffc8;
  --purple: #b967ff;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 12%, rgba(35, 220, 255, 0.18), transparent 26rem),
    radial-gradient(circle at 86% 84%, rgba(255, 49, 95, 0.16), transparent 25rem),
    linear-gradient(135deg, #02030a 0%, var(--bg) 52%, #0a0415 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: -20%;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 0 48%, rgba(35, 220, 255, 0.09) 49%, transparent 50% 100%),
    linear-gradient(65deg, transparent 0 44%, rgba(255, 228, 107, 0.05) 45%, transparent 46% 100%);
  background-size: 280px 280px, 420px 420px;
  animation: bodyScan 18s linear infinite;
  opacity: 0.75;
}

.page-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(0.35rem, 1.4vw, 1.25rem);
}

.game-card {
  width: min(98vw, 920px);
  max-height: none;
  display: flex;
  flex-direction: column;
  gap: clamp(0.35rem, 1vh, 0.8rem);
  padding: clamp(0.6rem, 1.5vw, 1.15rem);
  border: 1px solid var(--panel-border);
  border-radius: clamp(18px, 3vw, 30px);
  background: linear-gradient(180deg, rgba(17, 24, 58, 0.94), rgba(5, 8, 20, 0.96));
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.55), 0 0 60px rgba(35, 220, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.09);
}

.game-header,
.hud,
.top-actions { display: flex; align-items: center; }

.game-header {
  justify-content: space-between;
  gap: 0.75rem;
}

.title-block { min-width: 0; }

h1, h2, p { margin: 0; }

h1 {
  font-size: clamp(1.5rem, 5.5vw, 3.2rem);
  line-height: 0.9;
  letter-spacing: -0.08em;
  text-shadow: 0 0 26px rgba(35, 220, 255, 0.38);
}

h2 {
  margin: 0.15rem 0 0.55rem;
  font-size: clamp(1.65rem, 5vw, 3rem);
  line-height: 0.96;
  letter-spacing: -0.06em;
}

.eyebrow {
  margin-bottom: 0.22rem;
  color: var(--blue);
  font-size: clamp(0.62rem, 1.5vw, 0.74rem);
  font-weight: 900;
  letter-spacing: 0.19em;
  text-transform: uppercase;
}

.eyebrow.danger { color: var(--red); }

.hud {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: clamp(0.32rem, 0.85vw, 0.65rem);
}

.hud-tile {
  min-width: 0;
  padding: clamp(0.42rem, 1vw, 0.68rem) clamp(0.45rem, 1vw, 0.75rem);
  border: 1px solid rgba(35, 220, 255, 0.24);
  border-radius: 16px;
  text-align: center;
  background: rgba(4, 10, 26, 0.76);
  box-shadow: 0 0 22px rgba(35, 220, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.hud-tile span,
.result-grid span {
  display: block;
  color: var(--muted);
  font-size: clamp(0.55rem, 1.1vw, 0.66rem);
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hud-tile strong {
  display: block;
  margin-top: 0.08rem;
  color: var(--yellow);
  font-size: clamp(1rem, 2.3vw, 1.55rem);
  line-height: 1;
  white-space: nowrap;
}

.hearts-tile strong {
  color: var(--red);
  letter-spacing: 0.04em;
  text-shadow: 0 0 12px rgba(255, 49, 95, 0.62);
}

.heart.is-empty { color: rgba(152, 166, 202, 0.27); text-shadow: none; }
.status-tile strong { color: var(--green); }
.dash-tile strong { color: var(--blue); }
.speed-tile strong { color: var(--purple); }

.meter {
  height: 5px;
  margin-top: 0.35rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(152, 166, 202, 0.22);
}

.meter-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
  box-shadow: 0 0 12px rgba(35, 220, 255, 0.8);
  transform-origin: left center;
}

.game-area {
  position: relative;
  height: clamp(350px, calc(100dvh - 232px), 620px);
  min-height: 300px;
  overflow: hidden;
  border: 1px solid rgba(121, 143, 255, 0.28);
  border-radius: clamp(16px, 2.3vw, 24px);
  background: radial-gradient(circle at 50% 100%, rgba(35, 220, 255, 0.19), transparent 18rem), linear-gradient(180deg, rgba(10, 16, 39, 0.98), rgba(3, 5, 15, 0.99));
  box-shadow: inset 0 0 70px rgba(0, 0, 0, 0.62), 0 0 44px rgba(35, 220, 255, 0.1);
}

.game-area::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(35, 220, 255, 0.08) 50%, transparent);
  mix-blend-mode: screen;
  animation: scanline 4.2s linear infinite;
}

.game-area.is-shaking { animation: shake 430ms linear; }

.starfield, .grid-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.starfield {
  opacity: 0.55;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 1px, transparent 1.5px), radial-gradient(circle, rgba(35, 220, 255, 0.9) 0 1px, transparent 1.5px);
  background-size: 80px 90px, 130px 150px;
  animation: starFall 12s linear infinite;
}

.grid-glow {
  opacity: 0.32;
  background-image: linear-gradient(rgba(80, 104, 255, 0.18) 1px, transparent 1px), linear-gradient(90deg, rgba(80, 104, 255, 0.18) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: linear-gradient(to bottom, transparent, black 17%, black 78%, transparent);
  animation: gridDrift 8s linear infinite;
}

.player, .hazard, .orb, .particle, .warning-lane { position: absolute; }
.player, .hazard, .orb { will-change: transform; }
.particle, .warning-lane { will-change: transform, opacity; }

.player {
  left: 0;
  bottom: 22px;
  width: 38px;
  height: 38px;
  border-radius: 12px 12px 16px 16px;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #a7fbff 0%, var(--blue) 42%, var(--blue-deep) 100%);
  clip-path: polygon(50% 0, 94% 72%, 70% 100%, 50% 82%, 30% 100%, 6% 72%);
  box-shadow: 0 0 19px var(--blue), 0 0 42px rgba(35, 220, 255, 0.76), inset 0 0 9px rgba(255, 255, 255, 0.72);
  z-index: 4;
}

.player::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 72%;
  width: 16px;
  height: 30px;
  border-radius: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(255, 228, 107, 0.88), rgba(35, 220, 255, 0.38) 45%, transparent 70%);
  filter: blur(2px);
}

.player.has-shield::before {
  content: "";
  position: absolute;
  inset: -12px;
  border: 2px solid rgba(68, 255, 200, 0.95);
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(68, 255, 200, 0.9), inset 0 0 16px rgba(68, 255, 200, 0.25);
  animation: shieldPulse 1.1s ease-in-out infinite;
}

.player.is-hit { animation: playerBlink 150ms steps(2) infinite; }
.player.is-dashing { filter: drop-shadow(0 0 18px var(--yellow)); }
.player.has-boost { filter: drop-shadow(0 0 18px var(--purple)) saturate(1.28); }

.hazard {
  border: 1px solid rgba(255, 174, 190, 0.48);
  border-radius: 12px;
  background: linear-gradient(135deg, #ff7893, var(--red) 48%, #8f1531);
  box-shadow: 0 0 22px rgba(255, 49, 95, 0.58), inset 0 0 12px rgba(255, 255, 255, 0.18);
  z-index: 2;
}

.hazard.line { border-radius: 8px; }
.hazard.diagonal { background: linear-gradient(135deg, #ffd4dc, var(--orange) 28%, var(--red) 75%); }
.hazard.wave { border-radius: 50%; background: radial-gradient(circle at 34% 28%, #fff0f4, var(--purple) 22%, var(--red) 70%); }
.hazard.block { background: linear-gradient(135deg, #ffa0b2, #ff315f 48%, #56152a); }

.orb {
  border-radius: 50%;
  z-index: 2;
}

.orb.energy {
  background: radial-gradient(circle at 32% 30%, white, var(--yellow) 28%, var(--orange) 72%);
  box-shadow: 0 0 21px rgba(255, 228, 107, 0.74);
}

.orb.bonus {
  background: radial-gradient(circle at 32% 30%, white, var(--blue) 32%, var(--blue-deep) 74%);
  box-shadow: 0 0 21px rgba(35, 220, 255, 0.72);
}

.orb.shield {
  border: 2px solid rgba(255, 255, 255, 0.65);
  background: radial-gradient(circle at 32% 30%, white, var(--green) 34%, #088e88 78%);
  box-shadow: 0 0 26px rgba(68, 255, 200, 0.9);
}

.orb.speed {
  border: 2px solid rgba(255, 255, 255, 0.6);
  background: radial-gradient(circle at 32% 30%, white, var(--purple) 32%, #5f28c9 76%);
  box-shadow: 0 0 26px rgba(185, 103, 255, 0.88);
}

.warning-lane {
  top: 0;
  height: 100%;
  border: 1px solid rgba(255, 228, 107, 0.55);
  background: repeating-linear-gradient(45deg, rgba(255, 228, 107, 0.22) 0 10px, rgba(255, 49, 95, 0.22) 10px 20px);
  box-shadow: inset 0 0 24px rgba(255, 49, 95, 0.22), 0 0 22px rgba(255, 228, 107, 0.3);
  opacity: 0;
  pointer-events: none;
  animation: warningPulse 0.8s ease-in-out infinite;
  z-index: 1;
}

.particle {
  border-radius: 50%;
  pointer-events: none;
  z-index: 5;
}

.oeeco-mark {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 0;
  transform: translate(-50%, -50%) rotate(-8deg);
  color: rgba(237, 244, 255, 0.055);
  font-size: clamp(4.8rem, 17vw, 9.5rem);
  font-weight: 1000;
  letter-spacing: 0.1em;
  text-transform: lowercase;
  pointer-events: none;
  user-select: none;
  text-shadow: 0 0 34px rgba(35, 220, 255, 0.2);
}

.level-toast {
  position: absolute;
  left: 50%;
  top: 16%;
  z-index: 6;
  transform: translate(-50%, -12px);
  padding: 0.42rem 0.8rem;
  border: 1px solid rgba(255, 228, 107, 0.55);
  border-radius: 999px;
  color: var(--yellow);
  background: rgba(3, 5, 15, 0.76);
  box-shadow: 0 0 24px rgba(255, 228, 107, 0.28);
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.level-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: clamp(0.7rem, 2vw, 1.2rem);
  pointer-events: none;
  opacity: 0;
  transition: opacity 160ms ease;
  background: radial-gradient(circle, rgba(7, 11, 30, 0.32), rgba(2, 3, 10, 0.78));
}

.overlay.is-visible { opacity: 1; pointer-events: auto; }

.overlay-panel {
  width: min(100%, 520px);
  max-height: 100%;
  overflow: auto;
  padding: clamp(1rem, 3vh, 1.55rem);
  border: 1px solid rgba(35, 220, 255, 0.34);
  border-radius: 24px;
  text-align: center;
  background: rgba(4, 9, 24, 0.92);
  box-shadow: 0 0 50px rgba(35, 220, 255, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.compact-panel { width: min(100%, 440px); }
.overlay-panel p { color: var(--muted); line-height: 1.45; }

.instruction-list {
  display: grid;
  gap: 0.45rem;
  margin: 0.85rem 0 1rem;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-weight: 700;
}

kbd {
  display: inline-block;
  min-width: 1.55rem;
  padding: 0.12rem 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-bottom-color: rgba(255, 255, 255, 0.42);
  border-radius: 7px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.28);
}

.primary-button,
.utility-button {
  border: 0;
  border-radius: 999px;
  color: #03101a;
  font-weight: 950;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.primary-button {
  padding: 0.78rem 1.25rem;
  background: linear-gradient(135deg, var(--yellow), var(--green));
  box-shadow: 0 0 24px rgba(68, 255, 200, 0.34);
}

.utility-button {
  padding: 0.55rem 0.8rem;
  color: var(--text);
  background: linear-gradient(135deg, rgba(35, 220, 255, 0.22), rgba(185, 103, 255, 0.22));
  border: 1px solid rgba(35, 220, 255, 0.35);
}

.primary-button:hover,
.utility-button:hover { transform: translateY(-1px); }

.primary-button:focus-visible,
.utility-button:focus-visible {
  outline: 3px solid rgba(255, 228, 107, 0.78);
  outline-offset: 3px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  margin: 0.85rem 0;
}

.result-grid div {
  padding: 0.65rem;
  border: 1px solid rgba(35, 220, 255, 0.24);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
}

.result-grid strong {
  display: block;
  margin-top: 0.2rem;
  color: var(--yellow);
  font-size: clamp(1.15rem, 4vw, 1.6rem);
}

.new-best { margin-bottom: 0.75rem; color: var(--green) !important; font-weight: 900; }

.countdown {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  font-size: clamp(4rem, 20vw, 9rem);
  font-weight: 1000;
  color: var(--yellow);
  text-shadow: 0 0 35px rgba(255, 228, 107, 0.95), 0 0 80px rgba(35, 220, 255, 0.45);
  pointer-events: none;
}

.countdown.is-subtle {
  z-index: 1;
  align-items: start;
  padding-top: 17%;
  color: rgba(237, 244, 255, 0.18);
  font-size: clamp(2.2rem, 9vw, 4.8rem);
  text-shadow: 0 0 24px rgba(35, 220, 255, 0.2);
}

.controls-hint {
  color: var(--muted);
  text-align: center;
  font-size: clamp(0.72rem, 1.6vw, 0.9rem);
  line-height: 1.45;
}

@media (max-width: 760px) {
  .game-header { align-items: flex-start; }
  .hud { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hud-tile { padding: 0.42rem 0.48rem; }
  .game-area { height: clamp(330px, calc(100dvh - 285px), 560px); }
  .overlay-panel { padding: clamp(0.85rem, 2.4vh, 1.2rem); }
  .result-grid { grid-template-columns: 1fr; }
  .controls-hint { text-align: left; }
}

@media (max-width: 520px) {
  .game-card { width: min(100%, 920px); }
  .hud { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hud-tile strong { font-size: clamp(0.95rem, 5vw, 1.18rem); }
  .game-area { height: clamp(320px, 58dvh, 500px); }
  .game-header { flex-direction: column; gap: 0.45rem; }
  .top-actions { width: 100%; justify-content: flex-end; }
  .instruction-list { font-size: 0.9rem; }
}

@media (max-height: 760px) and (min-width: 761px) {
  .page-shell { align-items: start; padding-top: 0.35rem; padding-bottom: 0.35rem; }
  .game-card { gap: 0.35rem; padding: 0.58rem; border-radius: 20px; }
  .eyebrow { margin-bottom: 0.05rem; }
  h1 { font-size: clamp(1.45rem, 3.3vw, 2.25rem); }
  .hud-tile { padding: 0.38rem 0.45rem; border-radius: 12px; }
  .hud-tile strong { font-size: 1.05rem; }
  .meter { margin-top: 0.2rem; }
  .game-area { height: calc(100dvh - 176px); min-height: 330px; }
  .controls-hint { font-size: 0.72rem; }
}

@media (max-width: 880px) and (min-width: 761px) {
  .hud { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-height: 620px) {
  .page-shell { place-items: start center; }
  .game-area { height: clamp(300px, calc(100dvh - 170px), 340px); }
}

@media (max-width: 520px) and (max-height: 700px) {
  .game-area { height: 320px; }
}

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

@keyframes bodyScan { to { transform: translate3d(180px, 180px, 0); } }
@keyframes starFall { to { background-position: 0 360px, 0 520px; } }
@keyframes gridDrift { to { background-position: 0 76px, 76px 0; } }
@keyframes scanline { from { transform: translateY(-100%); } to { transform: translateY(100%); } }
@keyframes shieldPulse { 50% { transform: scale(1.13); opacity: 0.6; } }
@keyframes warningPulse { 50% { opacity: 0.72; } }
@keyframes playerBlink { 50% { opacity: 0.25; } }
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-10px, 6px); }
  30% { transform: translate(9px, -5px); }
  45% { transform: translate(-7px, -4px); }
  60% { transform: translate(7px, 5px); }
  75% { transform: translate(-4px, 3px); }
}
