:root {
  color-scheme: dark;
  --bg: #070c16;
  --bg-2: #0d1320;
  --surface: rgba(10, 15, 30, 0.9);
  --surface-2: rgba(12, 20, 36, 0.96);
  --surface-3: rgba(18, 28, 48, 0.98);
  --line: rgba(133, 167, 194, 0.16);
  --text: #f5f7fb;
  --muted: #9aabc0;
  --amber: #ffbf47;
  --cyan: #5ee1ff;
  --pink: #ff6ca8;
  --mint: #76f0c2;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --display: "Avenir Next Condensed", "Franklin Gothic Medium", "Arial Narrow", sans-serif;
  --title: "Avenir Next", "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", "Roboto Mono", "Menlo", monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--title);
  background:
    radial-gradient(circle at 15% 0%, rgba(94, 225, 255, 0.16), transparent 24%),
    radial-gradient(circle at 85% 0%, rgba(255, 108, 168, 0.14), transparent 22%),
    linear-gradient(180deg, #111628 0%, #090d17 45%, #05070e 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

body::before {
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: 0.45;
}

body::after {
  background:
    linear-gradient(180deg, transparent 0%, transparent 72%, rgba(255, 108, 168, 0.08) 100%),
    radial-gradient(circle at bottom center, rgba(255, 191, 71, 0.16), transparent 36%);
}

button {
  font: inherit;
  border: 0;
  cursor: pointer;
}

.arcade-shell {
  width: min(1040px, calc(100% - 16px));
  margin: 0 auto;
  padding: 10px 0 26px;
}

.appbar,
.game-rail,
.cabinet,
.footer-strip {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 14px;
  border: 1px solid rgba(255, 191, 71, 0.34);
  background:
    linear-gradient(145deg, rgba(255, 191, 71, 0.18), rgba(255, 191, 71, 0.04)),
    rgba(255, 255, 255, 0.02);
  color: var(--amber);
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0;
  color: var(--amber);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.brand-copy h1 {
  margin: 4px 0 0;
  font-family: var(--display);
  font-size: clamp(1.8rem, 9vw, 3rem);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 12px 16px;
  border-radius: 12px;
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease;
}

.action:hover,
.game-pill:hover,
.stage-button:hover,
.pixel-pad:hover {
  transform: translateY(-2px);
}

.action-install,
.action-secondary {
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.action-primary {
  color: #120d03;
  background: linear-gradient(145deg, var(--amber), #ffd86c);
  box-shadow: 0 14px 24px rgba(255, 191, 71, 0.2);
}

.statusline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 1rem;
  padding: 10px 4px 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.statusline span:empty {
  display: none;
}

.game-rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(140px, 1fr);
  gap: 10px;
  overflow-x: auto;
  padding: 10px;
  margin-top: 12px;
  border-radius: 18px;
  scroll-snap-type: x proximity;
}

.game-rail::-webkit-scrollbar {
  display: none;
}

.game-pill {
  display: grid;
  gap: 6px;
  min-height: 74px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
  color: var(--text);
  text-align: left;
  scroll-snap-align: start;
}

.game-pill span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.game-pill strong {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.game-pill.is-active {
  border-color: rgba(255, 191, 71, 0.34);
  background:
    linear-gradient(145deg, rgba(255, 191, 71, 0.2), rgba(255, 108, 168, 0.1)),
    rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 191, 71, 0.16);
}

.cabinet {
  margin-top: 12px;
  padding: 14px;
  border-radius: 22px;
}

.cabinet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.cabinet-head h2 {
  margin: 6px 0 0;
  font-family: var(--display);
  font-size: clamp(2rem, 9vw, 4.2rem);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.score-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.score-box {
  display: grid;
  gap: 6px;
  min-width: 116px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.score-box span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.score-box strong {
  color: var(--amber);
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cabinet-controls {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.hintline {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.stage-frame {
  margin-top: 14px;
  padding: 12px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background:
    linear-gradient(180deg, rgba(16, 25, 42, 0.94), rgba(10, 16, 28, 0.98));
}

.stage {
  min-height: 430px;
}

.footer-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 16px;
}

.footer-strip span,
.stage-chip,
.score-pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 191, 71, 0.16);
  background: rgba(255, 191, 71, 0.08);
  color: #ffe3a2;
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dom-stage,
.canvas-stage,
.target-stage,
.meter-stage {
  position: relative;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.dom-stage {
  display: grid;
  gap: 12px;
}

.score-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.touch-controls {
  display: grid;
  gap: 10px;
}

.touch-row {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.touch-spacer {
  flex: 1 1 0;
  min-width: 76px;
}

.touch-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  min-height: 56px;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    rgba(10, 16, 28, 0.98);
  color: var(--text);
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  touch-action: manipulation;
  box-shadow: inset 0 -10px 16px rgba(0, 0, 0, 0.2);
}

.touch-button.is-accent {
  color: #140d03;
  border-color: rgba(255, 191, 71, 0.38);
  background:
    linear-gradient(180deg, rgba(255, 216, 108, 1), rgba(255, 191, 71, 0.92));
  box-shadow: 0 12px 24px rgba(255, 191, 71, 0.16);
}

.touch-button:active {
  transform: translateY(1px) scale(0.98);
}

.score-pill strong {
  margin-left: 8px;
  color: var(--amber);
  font-family: var(--display);
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.merge-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border-radius: 18px;
  background: #151f31;
  touch-action: none;
  user-select: none;
}

.merge-cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: #0b1220;
  font-family: var(--display);
  font-size: clamp(1rem, 4vw, 1.5rem);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.merge-cell[data-value="2"] { background: #f4eee0; }
.merge-cell[data-value="4"] { background: #e5d7ae; }
.merge-cell[data-value="8"] { background: #ffc56a; }
.merge-cell[data-value="16"] { background: #ff9c58; }
.merge-cell[data-value="32"] { background: #ff6c63; color: #fff; }
.merge-cell[data-value="64"] { background: #ff4d72; color: #fff; }
.merge-cell[data-value="128"] { background: #95f0d3; }
.merge-cell[data-value="256"] { background: #5ee1ff; }
.merge-cell[data-value="512"] { background: #49b0ff; color: #fff; }
.merge-cell[data-value="1024"] { background: #7568ff; color: #fff; }
.merge-cell[data-value="2048"] { background: linear-gradient(145deg, #ffd86c, #ffbf47); }

.pixel-pads {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.pulse-cue {
  display: grid;
  place-items: center;
  min-height: 52px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(94, 225, 255, 0.2);
  background:
    linear-gradient(180deg, rgba(94, 225, 255, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(10, 16, 28, 0.94);
  color: var(--text);
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
}

.pixel-pad {
  position: relative;
  display: block;
  min-height: 136px;
  border-radius: 18px;
  border: 2px solid transparent;
  box-shadow:
    inset 0 -12px 22px rgba(0, 0, 0, 0.18),
    0 10px 18px rgba(0, 0, 0, 0.18);
  transition:
    transform 0.18s ease,
    filter 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    opacity 0.18s ease;
}

.pixel-pad.is-lit {
  transform: scale(1.04);
  filter: brightness(1.36) saturate(1.18);
  border-color: rgba(255, 255, 255, 0.96);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.18),
    0 0 0 2px rgba(255, 255, 255, 0.18),
    0 0 38px rgba(255, 255, 255, 0.42),
    0 14px 28px rgba(0, 0, 0, 0.2);
}

.pixel-pad.is-dim {
  opacity: 0.42;
  filter: saturate(0.72) brightness(0.58);
}

.pixel-pad[data-color="pink"] { background: linear-gradient(160deg, #ff6ca8, #ffb6d5); }
.pixel-pad[data-color="cyan"] { background: linear-gradient(160deg, #5ee1ff, #b7f1ff); }
.pixel-pad[data-color="amber"] { background: linear-gradient(160deg, #ffbf47, #ffe39b); }
.pixel-pad[data-color="mint"] { background: linear-gradient(160deg, #76f0c2, #d0ffe9); }

.target-stage,
.meter-stage,
.comet-stage {
  min-height: 380px;
  overflow: hidden;
  border-radius: 18px;
  background:
    radial-gradient(circle at center, rgba(255, 191, 71, 0.1), transparent 34%),
    linear-gradient(0deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, #0f1730, #080d1a);
  background-size: auto, 34px 34px, 34px 34px, auto;
}

.target-stage::before,
.comet-stage::before {
  content: "";
  position: absolute;
  inset: 50%;
  width: 84%;
  height: 84%;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

.target-stage::after,
.comet-stage::after {
  content: "";
  position: absolute;
  inset: 50%;
  width: 48%;
  height: 48%;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.target-dot,
.comet-dot {
  position: absolute;
  width: 64px;
  height: 64px;
  border-radius: 999px;
  border: 2px solid rgba(255, 191, 71, 0.24);
  background: radial-gradient(circle at center, rgba(255, 191, 71, 0.28), rgba(255, 255, 255, 0.94) 62%);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.26);
  z-index: 1;
  touch-action: manipulation;
}

.target-dot::after,
.comet-dot::after {
  content: "";
  display: block;
  width: 56%;
  height: 56%;
  margin: 22%;
  border-radius: 999px;
  background: rgba(255, 28, 88, 0.86);
}

.comet-dot {
  width: 54px;
  height: 54px;
}

.comet-dot::after {
  background: rgba(94, 225, 255, 0.88);
}

.comet-stage {
  position: relative;
}

.comet-stage .stage-chip {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
}

.meter-stage {
  display: grid;
  place-items: center;
  padding: 24px;
}

.meter-wrap {
  width: min(100%, 420px);
  display: grid;
  gap: 16px;
}

.meter-track {
  position: relative;
  width: 100%;
  height: 26px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.meter-target {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(145deg, rgba(118, 240, 194, 0.9), rgba(94, 225, 255, 0.8));
}

.meter-cursor {
  position: absolute;
  top: -6px;
  width: 18px;
  height: 38px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffbf47, #ff6ca8);
  box-shadow: 0 10px 20px rgba(255, 108, 168, 0.2);
}

.canvas-stage canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: linear-gradient(180deg, #0f1730, #080d1a);
  touch-action: none;
}

@media (max-width: 900px) {
  .cabinet-head,
  .cabinet-controls {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: flex-start;
  }

  .cabinet-head {
    display: grid;
  }

  .cabinet-controls {
    display: grid;
  }
}

@media (max-width: 640px) {
  .arcade-shell {
    width: min(100% - 10px, 100%);
  }

  .appbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .game-rail {
    grid-auto-columns: minmax(124px, 70%);
  }

  .target-stage,
  .meter-stage,
  .comet-stage,
  .stage {
    min-height: 360px;
  }

  .pixel-pad {
    min-height: 118px;
  }

  .touch-button {
    flex: 1 1 0;
    min-width: 0;
    min-height: 54px;
    padding: 12px;
  }

  .touch-spacer {
    min-width: 0;
  }
}
