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

/* Cozy collection: menus scroll independently of the touch-controlled canvas. */
.wallet { display:flex; justify-content:space-between; gap:10px; margin:0 4px 12px; font-size:.76rem; color:#d4c6ad; }
.wallet strong { color:#ffe3a0; font-size:1rem; }
.storage-notice { padding:10px; border:1px solid #ffd49b55; border-radius:10px; color:#ffd49b; font: .8rem/1.4 system-ui,sans-serif; }
.intro-card { max-height:calc(100% - 12px); overflow-y:auto; overscroll-behavior:contain; scrollbar-width:thin; scrollbar-color:#826e72 transparent; }
.overlay { padding:12px; }
.overlay-card { background:linear-gradient(145deg,#352d3cf5,#211c2cf5); border-color:#d9b69333; }
.intro-card h1 { font-size:clamp(1.8rem,7.2vw,2.7rem); }
.intro-card h2 { font-size:clamp(1.5rem,6vw,2rem); letter-spacing:-.055em; }
.menu-tabs { display:flex; gap:4px; padding:4px; margin:0 0 19px; border-radius:12px; background:#0f0c1780; }
.menu-tabs button { flex:1; min-height:42px; padding:6px 3px; border:0; border-radius:8px; background:transparent; color:#b9aebe; cursor:pointer; font-size:.67rem; font-weight:800; }
.menu-tabs button[aria-pressed="true"] { background:#e0ba8e; color:#332332; box-shadow:0 3px 8px #0003; }
.menu-description { font:.8rem/1.5 system-ui,sans-serif; color:#c8bac7; margin:12px 0; }
.home-preview { margin:16px 0 10px; overflow:hidden; border-radius:12px; border:2px solid #d9b69344; }
.home-preview canvas { aspect-ratio:2; width:100%; height:auto; cursor:default; touch-action:auto; }
.cat-switch { display:flex; gap:8px; }
.cat-switch button { flex:1; min-height:40px; border-radius:8px; border:1px solid #a191a155; background:#17131f; color:#e5d6c9; font-size:.75rem; cursor:pointer; }
.cat-switch button[aria-pressed="true"] { border-color:#b9d99c; background:#b9d99c1c; }
.shop-notice { min-height:1.2em; color:#c9e4a7; font-size:.7rem; }
#shopItems h3 { margin:20px 0 10px; text-align:left; font-size:.72rem; color:#dec09e; letter-spacing:.08em; text-transform:uppercase; }
.shop-card { display:flex; gap:10px; margin-bottom:9px; padding:12px 10px; text-align:left; border:1px solid #d8b9a022; border-radius:12px; background:#120f1a66; }
.shop-card.equipped { border-color:#bad79466; }
.shop-icon { display:grid; place-items:center; width:42px; height:45px; flex-shrink:0; border-radius:9px; background:#614c423d; font-size:1.6rem; }
.shop-icon.kitchen { background:#91b59d33; } .shop-icon.balcony { background:#c3d8ad33; }
.shop-icon canvas { width:42px; height:45px; border-radius:8px; touch-action:auto; cursor:default; }
.menu-tabs { position:sticky; top:-1px; z-index:2; background:#231d2c; }
.shop-card strong { font-size:.77rem; }
.shop-card p { margin:5px 0 9px; color:#bdafc0; font:.73rem/1.45 system-ui,sans-serif; }
.shop-card button { min-height:38px; padding:6px 10px; border:1px solid #e5c08d80; border-radius:8px; color:#ffe0b3; background:#d69d6722; font-size:.7rem; cursor:pointer; }
.shop-card button:disabled { cursor:default; border-color:#ffffff18; color:#9c91a3; background:#ffffff05; }
.shop-card.equipped button { color:#c4df9e; }
.mission-card { text-align:left; margin:12px 0; padding:16px; border-radius:13px; background:#17131f80; border:1px solid #d9b6932b; }
.mission-card h3 { margin:0 0 10px; font-size:.85rem; }
.mission-card p { font:.78rem/1.45 system-ui,sans-serif; color:#d2c3ce; }
.mission-card progress { display:block; width:100%; height:9px; border:0; border-radius:8px; overflow:hidden; background:#443749; accent-color:#bdd695; }
.mission-card progress::-webkit-progress-bar { background:#443749; }
.mission-card progress::-webkit-progress-value { background:#bdd695; }
.mission-card small { display:block; margin-top:10px; font-size:.67rem; color:#e3c698; }
.equipped-note { margin:12px 0 0; font-size:.61rem; color:#c8b895; }
.round-coins { position:absolute; right:13px; top:14px; color:#ffe0a0; font-size:.85rem; font-weight:bold; pointer-events:none; text-shadow:0 2px 3px #000; }
.round-rewards { margin:12px 0 18px; padding:12px; border-radius:10px; background:#b6d69a13; color:#cce4ab; }
.round-rewards p { margin:0; font:.85rem/1.45 system-ui,sans-serif; }
.round-rewards small { display:block; margin-top:6px; font-size:.7rem; }
.result-card { max-height:calc(100% - 12px); overflow-y:auto; overscroll-behavior:contain; }
.result-card h2 { font-size:clamp(1.5rem,6vw,2.3rem); }
.result-card .final-score { margin-top:14px; padding:8px; }
.result-card .record { margin-bottom:10px; }
.character-option { min-height:100px; }
.machine { border-color:#78616a; }
.marquee { background:#463540; }
.hud, .cabinet-footer { background:#332b3b; }
@media (max-width:350px) {
  .arcade { padding-inline:8px; }
  .intro-card { padding:12px; }
  .menu-tabs button { font-size:.61rem; }
  .wallet { font-size:.65rem; }
}

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