* {
  box-sizing: border-box;
}

:root {
  --bg: #050511;
  --panel: rgba(8, 10, 30, .78);
  --line: rgba(125, 249, 255, .24);
  --ink: #ffffff;
  --muted: #b9c0e9;
  --cyan: #25e7ff;
  --pink: #ff43d1;
  --gold: #ffe66d;
  --green: #65ffa8;
  --violet: #8f5bff;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 12%, rgba(255, 67, 209, .26), transparent 28%),
    radial-gradient(circle at 85% 24%, rgba(37, 231, 255, .24), transparent 30%),
    linear-gradient(135deg, #04040f 0%, #140021 50%, #03192d 100%);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255,255,255,.035) 50%, rgba(0,0,0,.04) 50%) 0 0 / 100% 4px,
    radial-gradient(circle at 50% 65%, transparent 35%, rgba(0,0,0,.35));
  opacity: .72;
}

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

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 4px;
}

.game-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100vw - 28px));
  height: 100vh;
  margin: 0 auto;
  padding: 18px 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
}

.top-bar,
.status-strip {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  background: rgba(4, 6, 20, .72);
  box-shadow: 0 18px 48px rgba(0,0,0,.28), inset 0 0 28px rgba(37,231,255,.05);
  backdrop-filter: blur(16px);
}

.home-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 1px solid rgba(37,231,255,.32);
  border-radius: 999px;
  color: #eaffff;
  text-decoration: none;
  font-weight: 950;
  background: rgba(37,231,255,.09);
}

.title-block h1 {
  margin: 0;
  font-size: clamp(24px, 4vw, 44px);
  line-height: .92;
  letter-spacing: -.04em;
  text-transform: uppercase;
  text-shadow: 0 0 22px rgba(37,231,255,.42), 0 0 36px rgba(255,67,209,.22);
}

.title-block p {
  margin: 4px 0 0;
  color: var(--gold);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .22em;
  text-transform: uppercase;
}

.score-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(82px, 1fr));
  gap: 8px;
}

.score-panel div,
.status-strip > div {
  min-height: 54px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  background: rgba(255,255,255,.06);
}

.score-panel span,
.status-strip span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 950;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.score-panel b,
.status-strip b {
  font-size: 22px;
  line-height: 1;
}

.stage-shell {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 86%, rgba(37,231,255,.16), transparent 34%),
    linear-gradient(180deg, rgba(8,10,30,.62), rgba(3,4,14,.92));
  box-shadow: 0 28px 80px rgba(0,0,0,.42), inset 0 0 62px rgba(255,67,209,.06);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.lane-controls {
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: min(620px, calc(100% - 24px));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  pointer-events: none;
}

.lane-button {
  height: 58px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  color: #06101f;
  cursor: pointer;
  font-size: 20px;
  font-weight: 1000;
  background: linear-gradient(100deg, var(--cyan), #ffffff, var(--pink));
  box-shadow: 0 12px 30px rgba(0,0,0,.26), 0 0 24px rgba(37,231,255,.22);
  opacity: .72;
  pointer-events: auto;
  transition: transform .08s ease, filter .08s ease, opacity .08s ease;
}

.lane-button.is-hit {
  transform: translateY(3px) scale(.98);
  filter: brightness(1.25);
  opacity: 1;
}

.menu-panel,
.result-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(720px, calc(100% - 32px));
  transform: translate(-50%, -50%);
  padding: clamp(20px, 3vw, 34px);
  text-align: center;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(7,10,32,.92), rgba(25,6,44,.86));
  box-shadow: 0 0 70px rgba(37,231,255,.16), 0 0 110px rgba(255,67,209,.12), inset 0 0 46px rgba(255,255,255,.04);
  backdrop-filter: blur(18px);
}

.hidden {
  display: none !important;
}

.eyebrow {
  display: inline-flex;
  margin: 0 0 12px;
  padding: 7px 12px;
  border: 1px solid rgba(37,231,255,.38);
  border-radius: 999px;
  color: #eaffff;
  background: rgba(37,231,255,.10);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.menu-panel h2,
.result-panel h2 {
  margin: 0;
  font-size: clamp(38px, 8vw, 86px);
  line-height: .88;
  letter-spacing: -.06em;
  text-transform: uppercase;
  text-shadow: 0 0 28px rgba(37,231,255,.5), 0 0 50px rgba(255,67,209,.25);
}

.menu-panel p {
  max-width: 560px;
  margin: 14px auto 0;
  color: #dce8ff;
  font-size: 17px;
  font-weight: 700;
}

.difficulty-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 10px;
  max-width: 470px;
  margin: 18px auto 0;
}

.difficulty-button {
  min-height: 66px;
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 8px;
  color: #eef8ff;
  cursor: pointer;
  background: rgba(255,255,255,.08);
  box-shadow: inset 0 0 18px rgba(255,255,255,.035);
}

.difficulty-button strong,
.difficulty-button span {
  display: block;
}

.difficulty-button strong {
  font-size: 16px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.difficulty-button span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.difficulty-button.active {
  color: #06101f;
  border-color: rgba(255,255,255,.6);
  background: linear-gradient(100deg, var(--cyan), #ffffff, var(--pink));
  box-shadow: 0 0 26px rgba(37,231,255,.25);
}

.difficulty-button.active span {
  color: rgba(6,16,31,.76);
}

.track-meta {
  display: inline-flex;
  justify-content: center;
  min-width: 210px;
  padding: 8px 12px;
  border: 1px solid rgba(255,230,109,.28);
  border-radius: 999px;
  color: var(--gold) !important;
  background: rgba(255,230,109,.08);
  font-size: 12px !important;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.rules,
.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 22px 0;
}

.rules div,
.result-grid div {
  min-height: 86px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 8px;
  background: rgba(255,255,255,.07);
}

.rules strong,
.result-grid b {
  color: #fff;
  font-size: 20px;
}

.rules span,
.result-grid span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.main-button,
.small-button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 950;
  text-transform: uppercase;
}

.main-button {
  min-height: 56px;
  padding: 0 28px;
  color: #06101f;
  font-size: 17px;
  letter-spacing: .08em;
  background: linear-gradient(100deg, var(--cyan), #ffffff, var(--pink));
  box-shadow: 0 0 34px rgba(37,231,255,.30);
}

.menu-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
}

.small-button {
  min-height: 42px;
  padding: 0 16px;
  color: #eaffff;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.10);
}

.toast {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  min-width: 140px;
  padding: 10px 16px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  color: #fff;
  text-align: center;
  font-weight: 950;
  letter-spacing: .12em;
  text-transform: uppercase;
  background: rgba(0,0,0,.42);
  box-shadow: 0 0 30px rgba(37,231,255,.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 6px);
}

.status-strip {
  grid-template-columns: 1fr 2fr 1fr;
}

.meter {
  display: block;
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
}

.meter em {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--gold), var(--pink));
  box-shadow: 0 0 18px rgba(255,230,109,.55);
  transition: width .12s linear;
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .game-shell {
    min-height: 100vh;
    height: auto;
    grid-template-rows: auto minmax(560px, 70vh) auto;
  }

  .top-bar {
    grid-template-columns: 1fr;
  }

  .score-panel,
  .difficulty-row,
  .rules,
  .result-grid,
  .status-strip {
    grid-template-columns: 1fr;
  }

  .lane-controls {
    bottom: 12px;
    gap: 7px;
  }

  .lane-button {
    height: 54px;
  }
}

@media (max-height: 680px) and (min-width: 821px) {
  .game-shell {
    padding: 10px 0;
    gap: 8px;
  }

  .menu-panel,
  .result-panel {
    padding: 20px;
  }

  .rules,
  .result-grid {
    margin: 14px 0;
  }

  .rules div,
  .result-grid div {
    min-height: 68px;
  }
}

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