:root {
  color-scheme: dark;
  --ink: #100d1c;
  --panel: #1a152b;
  --panel-light: #29213f;
  --cream: #fff4df;
  --muted: #bdb4ce;
  --orange: #ff914d;
  --pink: #ff5c91;
  --lime: #c9f85a;
  --cyan: #5ae7e0;
  --red: #ff475c;
  font-family: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, monospace;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--ink);
}

body {
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  color: var(--cream);
  background:
    linear-gradient(135deg, transparent 0 49.4%, #ffffff08 49.5% 50.5%, transparent 50.6%) 0 0 / 38px 38px,
    radial-gradient(circle at 50% -20%, #5b3569 0, var(--ink) 54%);
}

button { font: inherit; }

button:focus-visible,
canvas:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.ambient {
  position: fixed;
  z-index: 0;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.15;
  pointer-events: none;
}

.ambient-one {
  top: 10%;
  left: -180px;
  background: var(--orange);
}

.ambient-two {
  right: -160px;
  bottom: 4%;
  background: var(--cyan);
}

.arcade {
  position: relative;
  z-index: 1;
  width: min(100%, 560px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 4px 14px;
}

.brand { display: grid; gap: 3px; }

.brand-kicker {
  color: var(--orange);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.brand-name {
  font-size: clamp(1.05rem, 4.5vw, 1.4rem);
  font-weight: 950;
  letter-spacing: -0.035em;
}

.sound-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid #ffffff22;
  border-radius: 12px;
  color: var(--cream);
  background: #ffffff0c;
  box-shadow: inset 0 -3px #00000035;
  cursor: pointer;
}

.sound-button.muted { color: #7c738e; }

.machine {
  position: relative;
  overflow: hidden;
  border: 3px solid #3c3254;
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 26px 70px #00000070, inset 0 0 0 2px #0d0a17;
}

.marquee {
  display: flex;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 2px solid #0d0a17;
  background: #241d36;
}

.marquee i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 10px var(--orange);
  animation: blink 1.2s steps(1) infinite;
}

.marquee i:nth-child(even) {
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  animation-delay: 0.6s;
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 2px solid #0d0a17;
  background: var(--panel-light);
}

.hud-cell {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 10px 13px 9px;
}

.hud-cell + .hud-cell { border-left: 1px solid #ffffff12; }

.hud-cell span {
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hud-cell strong {
  color: var(--cream);
  font-size: clamp(1.1rem, 5vw, 1.55rem);
  font-variant-numeric: tabular-nums;
}

.hud-center { text-align: center; }
.hud-center strong { color: var(--lime); }
.hud-right { text-align: right; }

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: #191523;
  isolation: isolate;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

canvas:active { cursor: grabbing; }

.lives {
  position: absolute;
  z-index: 3;
  top: 12px;
  left: 13px;
  display: flex;
  gap: 4px;
  color: var(--pink);
  font-size: 1.05rem;
  filter: drop-shadow(0 2px 0 #541934);
  pointer-events: none;
}

.lives span.lost {
  color: #645d71;
  filter: none;
}

.toast {
  position: absolute;
  z-index: 7;
  top: 18%;
  left: 50%;
  padding: 8px 12px;
  border: 2px solid currentColor;
  border-radius: 9px;
  color: var(--lime);
  background: #100d1de8;
  font-size: clamp(0.8rem, 3.6vw, 1rem);
  font-weight: 900;
  letter-spacing: 0.05em;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 15px) scale(0.9);
}

.toast.show { animation: toast-pop 0.75s steps(6) both; }

.overlay {
  position: absolute;
  z-index: 6;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(14px, 5vw, 28px);
  background: #100d1cbd;
  backdrop-filter: blur(7px);
}

.overlay-card {
  width: min(100%, 390px);
  padding: clamp(20px, 6vw, 30px);
  border: 2px solid #ffffff1f;
  border-radius: 22px;
  text-align: center;
  background:
    linear-gradient(135deg, #ffffff0c 25%, transparent 25%) 0 0 / 14px 14px,
    #201a31ef;
  box-shadow: 0 20px 55px #00000066;
}

.intro-card { padding: clamp(16px, 4.5vw, 24px); }

.character-prompt {
  margin: 15px 0 8px;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.character-select {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.character-option {
  position: relative;
  display: grid;
  min-width: 0;
  padding: 7px 5px 8px;
  overflow: hidden;
  place-items: center;
  border: 2px solid #ffffff1a;
  border-radius: 13px;
  color: var(--cream);
  background: #120f1f99;
  box-shadow: inset 0 -3px #0000002e;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.character-option::before {
  content: "";
  position: absolute;
  inset: 12% 18% 36%;
  border-radius: 50%;
  background: var(--orange);
  filter: blur(20px);
  opacity: 0.17;
}

.character-option:nth-child(2)::before { background: var(--cyan); }

.character-option img {
  position: relative;
  width: min(100%, 92px);
  height: 58px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 5px 0 #09060faa);
}

.character-option span {
  position: relative;
  display: grid;
  gap: 1px;
}

.character-option strong {
  font-size: 0.78rem;
  line-height: 1;
}

.character-option small {
  color: #958ba5;
  font-size: 0.52rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.character-option b {
  position: absolute;
  top: 5px;
  right: 6px;
  display: grid;
  width: 17px;
  height: 17px;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  background: var(--lime);
  font-size: 0.62rem;
  opacity: 0;
  transform: scale(0.5);
  transition: 140ms ease;
}

.character-option.selected {
  border-color: var(--lime);
  background: #c9f85a12;
  box-shadow: inset 0 0 0 1px #c9f85a33, 0 0 18px #c9f85a18;
}

.character-option.selected b {
  opacity: 1;
  transform: none;
}

.character-option:active { transform: translateY(2px); }

.overline {
  margin: 0 0 8px;
  color: var(--orange);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-weight: 950;
  letter-spacing: -0.065em;
  line-height: 0.98;
}

h1 { font-size: clamp(2rem, 9vw, 3.5rem); }
h2 { font-size: clamp(1.85rem, 8vw, 3rem); }

.instructions {
  max-width: 34ch;
  margin: 12px auto 15px;
  color: #d1c9dc;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(0.78rem, 3.2vw, 0.94rem);
  line-height: 1.42;
}

.primary-button,
.secondary-button {
  min-height: 49px;
  border-radius: 12px;
  font-weight: 950;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.primary-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 0 17px;
  border: 2px solid #ffbd8f;
  color: #211025;
  background: var(--orange);
  box-shadow: 0 6px 0 #963e2c;
}

.primary-button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #963e2c;
}

.primary-button b { font-size: 0.9rem; }

.secondary-button {
  padding: 0 16px;
  border: 2px solid #ffffff25;
  color: var(--cream);
  background: #ffffff0a;
}

.control-hint {
  margin: 15px 0 0;
  color: #9d94ad;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.control-hint span { color: var(--cyan); }

.final-score {
  display: grid;
  gap: 2px;
  margin: 25px auto 5px;
  padding: 15px;
  border-block: 2px solid #ffffff13;
}

.final-score span,
.record {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.final-score strong {
  color: var(--lime);
  font-size: clamp(2.4rem, 12vw, 4.2rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.05em;
}

.record { margin: 0 0 22px; }

.result-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.result-actions .primary-button { grid-column: 1 / -1; }

.result-actions .secondary-button {
  min-width: 0;
  padding-inline: 8px;
  font-size: 0.72rem;
}

.zoomies {
  position: absolute;
  z-index: 4;
  right: 13px;
  bottom: 14px;
  width: 112px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 160ms ease;
}

.zoomies.active {
  opacity: 1;
  transform: none;
}

.zoomies span {
  display: block;
  margin-bottom: 4px;
  color: var(--cyan);
  font-size: 0.65rem;
  font-weight: 950;
  letter-spacing: 0.14em;
  text-align: right;
}

.zoomies div {
  height: 7px;
  overflow: hidden;
  border: 1px solid #ffffff33;
  border-radius: 99px;
  background: #100d1cbb;
}

.zoomies i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--lime));
  transform-origin: left;
}

.cabinet-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 3.2vw, 20px);
  padding: 12px 8px 14px;
  border-top: 2px solid #0d0a17;
  color: #a9a0b9;
  background: var(--panel-light);
  font-size: clamp(0.57rem, 2.7vw, 0.72rem);
  font-weight: 800;
  text-transform: uppercase;
}

.legend {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-radius: 2px;
  vertical-align: 0;
}

.legend.fish { background: var(--orange); }
.legend.mouse { background: #d6cfdb; }
.legend.drumstick {
  border: 1px solid var(--cream);
  background: #c45f43;
}
.legend.laser {
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
}

.footer-note {
  margin: 13px 0 0;
  color: #82798f;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-align: center;
  text-transform: uppercase;
}

.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 blink { 50% { opacity: 0.28; } }

@keyframes toast-pop {
  0% { opacity: 0; transform: translate(-50%, 16px) scale(0.85); }
  18%, 68% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -22px) scale(0.95); }
}

@media (min-width: 700px) {
  .arcade { padding-top: 28px; padding-bottom: 28px; }
}

@media (max-height: 760px) and (orientation: landscape) {
  .arcade {
    width: min(100%, 370px);
    padding-block: 8px;
  }

  .topbar,
  .footer-note,
  .marquee,
  .cabinet-footer { display: none; }

  .machine { border-radius: 16px; }
  .stage { max-height: calc(100dvh - 62px); }
}

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