@property --field-bg {
  syntax: "<color>";
  inherits: true;
  initial-value: #f8f9fa;
}

@property --grid-dot {
  syntax: "<color>";
  inherits: true;
  initial-value: #e3e6e8;
}

:root {
  color-scheme: light;
  --cookie-banner-height: 0px;
  font-family: "VT323", ui-monospace, monospace;
  font-synthesis: none;
  --page-bg: #f5f6f7;
  --field-bg: #f8f9fa;
  --grid-dot: #e3e6e8;
  --ink: #161719;
  --muted: #73777d;
  --panel: rgb(255 255 255 / 78%);
  --button-ink: #fff;
  --button-bg: #111;
  --border: rgb(17 17 17 / 8%);
  --shadow: 0 28px 80px rgb(24 28 32 / 15%), 0 3px 12px rgb(24 28 32 / 8%);
  --neon-cyan: #00f3ff;
  --neon-magenta: #ff007f;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  overflow: hidden;
  background: var(--page-bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.app-layout {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(160px, 180px) minmax(0, 1fr) minmax(160px, 180px);
  align-items: center;
  gap: clamp(18px, 3vw, 48px);
  min-width: 0;
  padding: 0 clamp(12px, 2vw, 32px);
}

.game-column {
  position: relative;
  height: 100dvh;
  display: grid;
  justify-items: center;
  align-content: center;
  min-width: 0;
}

.game-shell {
  --field-bg: #f8f9fa;
  --grid-dot: #e3e6e8;
  --ink: #212529;
  --muted: #74787d;
  --panel: rgb(255 255 255 / 78%);
  --button-bg: #111;
  --button-ink: #fff;
  position: relative;
  width: 100%;
  height: 100dvh;
  aspect-ratio: auto;
  max-width: none;
  overflow: hidden;
  isolation: isolate;
  border: 0;
  border-radius: 0;
  background-color: var(--field-bg);
  background-image:
    radial-gradient(circle at 50% 115%, rgb(255 0 127 / 7%), transparent 45%),
    radial-gradient(circle at 50% -15%, rgb(0 243 255 / 6%), transparent 42%),
    radial-gradient(circle, var(--grid-dot) 1.25px, transparent 1.35px);
  background-repeat: no-repeat, no-repeat, repeat;
  background-position: center, center, 0 0;
  background-size: 100% 100%, 100% 100%, 22px 22px;
  box-shadow: var(--shadow);
  color: var(--ink);
  transition:
    --field-bg 1.5s ease,
    --grid-dot 1.5s ease,
    color 1.5s ease,
    box-shadow 1.5s ease;
  touch-action: none;
  user-select: none;
}

body.cookie-consent-visible .app-layout {
  align-items: start;
}

body.cookie-consent-visible .game-column {
  height: calc(100dvh - var(--cookie-banner-height));
}

body.cookie-consent-visible .game-shell {
  height: calc(100dvh - var(--cookie-banner-height));
}

.game-shell::before,
.game-shell::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
}

.game-shell::before {
  opacity: 0.16;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 3px,
    rgb(10 20 28 / 12%) 4px
  );
  mix-blend-mode: multiply;
  animation: scanline-drift 9s linear infinite;
}

.game-shell::after {
  z-index: 3;
  background: radial-gradient(ellipse at center, transparent 55%, rgb(3 7 14 / 16%) 110%);
}

.game-shell.is-dark {
  color-scheme: dark;
  --field-bg: #121212;
  --grid-dot: #2a2a2a;
  --ink: #f5f5f5;
  --muted: #aaa;
  --panel: rgb(27 27 27 / 80%);
  --button-bg: #fff;
  --button-ink: #111;
  box-shadow: 0 28px 80px rgb(0 0 0 / 38%), 0 3px 12px rgb(0 0 0 / 24%);
}

.game-shell.is-dark::before {
  opacity: 0.3;
  mix-blend-mode: screen;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 3px,
    rgb(0 243 255 / 5%) 4px
  );
}

.game-shell.is-dark::after {
  background: radial-gradient(ellipse at center, transparent 46%, rgb(0 0 0 / 48%) 110%);
}

.game-shell.is-rush {
  animation: rush-shell 900ms ease-in-out infinite alternate;
}

#game-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  z-index: 1;
}

.hud {
  position: absolute;
  z-index: 4;
  top: clamp(17px, 3.4%, 30px);
  left: clamp(18px, 6%, 34px);
  right: clamp(18px, 6%, 34px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  pointer-events: none;
  font-size: clamp(14px, 2.8vw, 20px);
  font-weight: 700;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: 0.1em;
  transition: color 1.5s ease;
}

.hud > :last-child {
  text-align: right;
}

.hud span {
  text-shadow: 0 0 7px #00f3ff, 0 0 16px #ff007f;
}

.screen {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  opacity: 1;
  visibility: visible;
  transition: opacity 220ms ease, visibility 220ms ease, background-color 1.5s ease;
}

.screen-start {
  background: rgb(8 13 24 / 82%);
  -webkit-backdrop-filter: blur(10px) saturate(130%);
  backdrop-filter: blur(10px) saturate(130%);
}

.screen-blur {
  background: rgb(8 13 24 / 84%);
  -webkit-backdrop-filter: blur(10px) saturate(130%);
  backdrop-filter: blur(10px) saturate(130%);
}

.game-shell.is-dark .screen-start,
.game-shell.is-dark .screen-blur {
  background: rgb(2 3 8 / 88%);
  -webkit-backdrop-filter: blur(10px) saturate(135%);
  backdrop-filter: blur(10px) saturate(135%);
}

.screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.panel {
  width: min(100%, 340px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: clamp(28px, 5vw, 48px);
  border: 2px solid var(--neon-cyan);
  border-radius: 4px;
  background: rgb(7 13 25 / 78%);
  box-shadow: 0 0 0 4px rgb(255 0 127 / 22%), 0 0 22px rgb(0 243 255 / 28%), 0 24px 80px rgb(0 0 0 / 42%);
  text-align: center;
  color: #fff;
  gap: 1.2rem;
  line-height: 1.35;
  transition: background-color 1.5s ease, border-color 1.5s ease;
}

.panel .eyebrow,
.panel .best-score,
.panel .record-message,
.panel .audio-toggle,
.panel .text-button {
  color: #aab8c7;
}

.screen-start .panel,
#pause-screen .panel,
#gameover-screen .panel {
  width: min(100%, 430px);
  padding: clamp(28px, 6vw, 52px) clamp(24px, 6vw, 48px);
}

.brand-panel {
  padding-top: 36px;
}

.pause-panel {
  width: min(100%, 390px);
  padding-top: clamp(30px, 6vw, 52px);
}

.pause-glyph {
  display: inline-flex;
  align-self: center;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 34px;
  height: 34px;
  margin: 0 auto;
  border: 0;
  border-radius: 2px;
  color: var(--neon-cyan);
  filter: drop-shadow(0 0 8px currentColor);
}

.pause-glyph span {
  width: 4px;
  height: 18px;
  border-radius: 4px;
  background: currentColor;
}

.pause-panel h2 {
  font-size: clamp(31px, 7vw, 44px);
  letter-spacing: -0.065em;
}

.audio-controls {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 0;
  font-family: "VT323", ui-monospace, monospace;
}

.pause-audio-controls {
  margin-top: 22px;
}

.audio-toggle {
  position: relative;
  min-height: 32px;
  padding: 0 0 0 13px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  font-weight: 800;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: 0.08em;
  word-spacing: -0.16em;
  transition: color 180ms ease, opacity 180ms ease;
}

.audio-toggle::before {
  content: "♫";
  position: absolute;
  top: 50%;
  left: 0;
  width: 11px;
  height: 18px;
  background: currentColor;
  transform: translateY(-50%);
  font-size: 18px;
  line-height: 18px;
  background: transparent;
}

.audio-toggle[data-audio-toggle="fx"]::before {
  content: "✦";
}

.audio-toggle.is-off {
  opacity: 0.42;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 18px;
  font-weight: 750;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: 0.22em;
  transition: color 1.5s ease;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
  letter-spacing: -0.055em;
  font-family: "Press Start 2P", ui-monospace, monospace;
}

h1 {
  font-size: clamp(34px, 9vw, 56px);
  font-weight: 850;
  white-space: nowrap;
  text-shadow: 0 0 6px #00f3ff, 0 0 15px #00f3ff, 0 0 28px #ff007f, -3px 0 #00f3ff, 3px 0 #ff007f;
}

h1 span {
  display: inline-block;
  color: var(--muted);
  font-weight: 500;
  transform: translateX(1px);
}

h2 {
  font-size: clamp(34px, 9vw, 48px);
  font-weight: 820;
}

.best-score,
.record-message {
  margin: 0;
  color: var(--muted);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-shadow: 0 0 8px #00f3ff, 0 0 18px #00f3ff;
}

.primary-button,
.secondary-button,
.text-button,
.sound-button {
  min-height: 48px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 750;
  letter-spacing: 0.09em;
  font-family: "Press Start 2P", ui-monospace, monospace;
  transition: transform 160ms ease, opacity 160ms ease, background-color 1.5s ease, color 1.5s ease;
}

.primary-button {
  position: relative;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--button-ink) 16%, transparent);
  background: var(--button-bg);
  color: var(--button-ink);
  box-shadow:
    0 9px 24px rgb(0 0 0 / 14%),
    -2px 0 0 rgb(0 243 255 / 42%),
    2px 0 0 rgb(255 0 127 / 36%);
  text-shadow: 0 0 7px currentColor;
}

.primary-button::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 28%, rgb(255 255 255 / 20%) 48%, transparent 68%);
  transform: translateX(-130%);
  transition: transform 420ms ease;
}

.primary-button:hover::after {
  transform: translateX(130%);
}

.secondary-button {
  margin-top: 10px;
  border: 1px solid color-mix(in srgb, currentColor 10%, transparent);
  background: color-mix(in srgb, currentColor 4%, transparent);
  color: currentColor;
}

.text-button,
.sound-button {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.text-button {
  margin-top: 0;
}

.legal-link {
  align-self: center;
  margin-top: 0.15rem;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  color: #a9bdd1;
  font-family: "VT323", ui-monospace, monospace;
  font-size: 16px;
  letter-spacing: 0.08em;
  text-decoration: underline;
  text-decoration-color: rgb(0 243 255 / 55%);
  text-underline-offset: 3px;
  transition: color 160ms ease, text-shadow 160ms ease;
}

.legal-link:hover,
.legal-link:focus-visible {
  color: #eafaff;
  text-shadow: 0 0 8px #00f3ff;
}

.game-legal-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  margin-top: 0.15rem;
}

.sound-button {
  display: inline-flex;
  align-items: center;
  align-self: center;
  gap: 8px;
  min-height: 42px;
  margin-top: 8px;
}

.sound-icon {
  position: relative;
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.sound-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -4px;
  width: 2px;
  height: 7px;
  border-radius: 2px;
  background: currentColor;
  transform: translateX(-50%);
}

button:hover {
  opacity: 0.88;
}

button:active {
  transform: scale(0.975);
}

button:focus-visible {
  outline: 3px solid color-mix(in srgb, currentColor 24%, transparent);
  outline-offset: 3px;
}

.gameover-panel {
  padding-top: 30px;
}

.final-score {
  margin: 12px 0 0;
  font-size: clamp(68px, 20vw, 112px);
  font-weight: 850;
  line-height: 1;
  letter-spacing: -0.06em;
  font-family: "VT323", ui-monospace, monospace;
  color: #fff;
  text-shadow: 0 0 8px #00f3ff, 0 0 20px #00f3ff, 0 0 34px #ff007f;
}

.gameover-panel h2,
.pause-panel h2 {
  color: #fff;
  text-shadow: 0 0 6px #00f3ff, 0 0 15px #00f3ff, 0 0 30px #ff007f;
}

.gameover-panel h2 {
  animation: neon-flicker 3.2s steps(1, end) infinite;
}

.record-message.is-record {
  color: #f2a900;
  animation: record-pulse 800ms ease-in-out infinite alternate;
}

#adsense-gameover-banner {
  width: 100%;
  min-height: 48px;
  margin-top: 14px;
  border: 0;
}

.ad-sidebar {
  width: min(160px, 100%);
  height: min(600px, 76dvh);
  border: 0;
}

.ad-left {
  justify-self: end;
}

.ad-right {
  justify-self: start;
}

.controls-hint {
  display: none;
}

.cookie-banner {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 16px clamp(18px, 4vw, 56px);
  border-top: 1px solid rgb(0 243 255 / 70%);
  background: rgb(5 9 18 / 96%);
  box-shadow: 0 -8px 30px rgb(0 0 0 / 28%), 0 0 22px rgb(0 243 255 / 12%);
  color: #eafaff;
  font-family: "VT323", ui-monospace, monospace;
}

.cookie-banner[hidden] {
  display: none;
}

.cookie-copy {
  min-width: 0;
  max-width: 780px;
}

.cookie-title {
  margin: 0 0 4px;
  color: #00f3ff;
  font-family: "Press Start 2P", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-shadow: 0 0 8px #00f3ff;
}

.cookie-copy > p:not(.cookie-title) {
  margin: 0;
  color: #c9d5e2;
  font-size: 18px;
  line-height: 1.12;
}

.cookie-copy .legal-link {
  display: inline-block;
  margin-top: 4px;
  font-size: 15px;
}

.cookie-actions {
  display: flex;
  flex-shrink: 0;
  gap: 10px;
}

.cookie-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgb(0 243 255 / 48%);
  border-radius: 2px;
  background: #00f3ff;
  color: #04101b;
  cursor: pointer;
  font-family: "Press Start 2P", ui-monospace, monospace;
  font-size: 9px;
  line-height: 1.3;
  text-shadow: none;
  transition: border-color 520ms ease, box-shadow 520ms ease, opacity 160ms ease;
}

.cookie-button-quiet {
  border-color: #718297;
  background: transparent;
  color: #d6e1ec;
}

.cookie-button:hover {
  opacity: 0.9;
  border-color: #00f3ff;
  box-shadow: 0 0 12px rgb(0 243 255 / 58%), 0 0 28px rgb(255 0 127 / 30%);
}

.cookie-button:focus-visible {
  border-color: #00f3ff;
  box-shadow: 0 0 12px rgb(0 243 255 / 58%), 0 0 28px rgb(255 0 127 / 30%);
}

.cookie-button-quiet:hover,
.cookie-button-quiet:focus-visible {
  border-color: #00f3ff;
}

.legal-page {
  min-height: 100dvh;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 28px 16px;
  background:
    radial-gradient(circle at 20% 20%, rgb(0 243 255 / 10%), transparent 34%),
    radial-gradient(circle at 80% 80%, rgb(255 0 127 / 10%), transparent 38%),
    #080d18;
  color: #eafaff;
}

.legal-card {
  width: min(100%, 720px);
  display: grid;
  gap: 1.25rem;
  padding: clamp(26px, 5vw, 48px);
  border: 2px solid #00f3ff;
  border-radius: 4px;
  background: rgb(7 13 25 / 90%);
  box-shadow: 0 0 0 4px rgb(255 0 127 / 20%), 0 0 36px rgb(0 243 255 / 20%);
}

.legal-card h1 {
  font-size: clamp(24px, 5vw, 42px);
}

.legal-card h2 {
  margin: 0 0 0.45rem;
  color: #b9ecff;
  font-family: "VT323", ui-monospace, monospace;
  font-size: 24px;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0.02em;
}

.legal-card p {
  margin: 0;
  color: #d3deea;
  font-family: "VT323", ui-monospace, monospace;
  font-size: 22px;
  line-height: 1.12;
}

.legal-card a:not(.primary-button) {
  color: #eafaff;
  text-decoration: underline;
  text-decoration-color: #00f3ff;
  text-underline-offset: 3px;
}

.legal-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-top: 0.5rem;
}

.legal-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  color: var(--button-ink);
  text-decoration: none;
}

.legal-card #cookie-settings {
  animation: cookie-settings-glow 2.8s ease-in-out infinite;
}

@keyframes cookie-settings-glow {
  0%, 100% {
    color: #a9bdd1;
    text-shadow: 0 0 0 transparent;
  }

  50% {
    color: #eafaff;
    text-shadow: 0 0 8px #00f3ff, 0 0 18px rgb(0 243 255 / 55%);
  }
}

.legal-modal {
  position: fixed;
  z-index: 25;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgb(2 5 12 / 74%);
  backdrop-filter: blur(18px) brightness(0.72);
}

.legal-modal.is-hidden {
  display: none;
}

.legal-modal-card {
  width: min(720px, 100%);
  max-height: min(760px, calc(100dvh - 48px));
  overflow: auto;
  display: grid;
  gap: 1.1rem;
  padding: clamp(24px, 5vw, 44px);
  border: 1px solid rgb(0 243 255 / 52%);
  border-radius: 6px;
  background: rgb(7 13 25 / 94%);
  box-shadow: 0 0 0 1px rgb(255 0 127 / 18%), 0 0 42px rgb(0 243 255 / 24%);
  color: #eafaff;
}

.legal-modal-card h2 {
  margin: 0;
  color: #fff;
  text-shadow: 0 0 8px #00f3ff, 0 0 22px rgb(255 0 127 / 55%);
}

.legal-modal-card h3 {
  margin: 0 0 0.35rem;
  color: #b9ecff;
  font-family: "VT323", ui-monospace, monospace;
  font-size: 22px;
  font-weight: 400;
  line-height: 1.05;
}

.legal-modal-card p {
  margin: 0;
  color: #d3deea;
  font-family: "VT323", ui-monospace, monospace;
  font-size: 21px;
  line-height: 1.1;
}

.legal-modal-card a {
  color: #eafaff;
  text-decoration-color: #00f3ff;
}

.legal-modal-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 1.25rem;
  margin-top: 0.25rem;
}

.game-legal-actions {
  gap: 5px;
  margin-top: 0.15rem;
}

@media (max-width: 560px) {
  .legal-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .legal-modal {
    padding: 12px;
  }

  .legal-modal-card {
    max-height: calc(100dvh - 24px);
  }

  .legal-modal-actions {
    justify-content: stretch;
    flex-direction: column-reverse;
    align-items: stretch;
  }
}

.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;
}

@keyframes record-pulse {
  to {
    transform: scale(1.04);
  }
}

@keyframes scanline-drift {
  to {
    transform: translateY(4px);
  }
}

@keyframes rush-shell {
  from {
    box-shadow: inset 0 0 34px rgb(0 243 255 / 7%), var(--shadow);
  }

  to {
    box-shadow: inset 0 0 70px rgb(255 0 127 / 12%), var(--shadow);
  }
}

@keyframes neon-flicker {
  0%, 18%, 22%, 63%, 65%, 100% { opacity: 1; }
  20%, 64% { opacity: 0.78; }
}

@media (max-width: 920px) {
  .app-layout {
    display: grid;
    grid-template-columns: 1fr;
    padding: 0;
  }

  .ad-sidebar {
    display: none;
  }

  .game-shell {
    width: auto;
    height: 100dvh;
    aspect-ratio: 9 / 16;
    max-width: 100%;
    border-radius: 0;
  }
}

@media (max-width: 560px) {
  .app-layout {
    padding: max(6px, env(safe-area-inset-top)) 6px max(6px, env(safe-area-inset-bottom));
  }

  .game-shell {
    width: min(calc(100vw - 12px), calc((100dvh - var(--cookie-banner-height) - 12px) * 9 / 16));
    height: auto;
    aspect-ratio: 9 / 16;
    max-height: calc(100dvh - var(--cookie-banner-height) - 12px);
    border-radius: 24px;
  }

  body.cookie-consent-visible .game-shell {
    height: auto;
  }

  .cookie-banner {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px max(14px, env(safe-area-inset-bottom));
  }

  .cookie-actions {
    width: 100%;
  }

  .cookie-button {
    flex: 1;
    padding: 0 8px;
    font-size: 8px;
  }
}

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