:root {
  --ink: #10243b;
  --muted: #51657d;
  --panel: #ffffffee;
  --panel-border: #d8e1ef;
  --panel-shadow: #0b25451f;
  --sun: #ffb84d;
  --mint: #5dd39e;
  --water: #55bfe8;
  --rose: #ef476f;
  --violet: #8f7af7;
  --hud-height: 76px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, #dce9ff 0%, #fff7dc 48%, #d9fff0 100%);
  padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
}

body[data-theme="neon"] {
  background: linear-gradient(135deg, #111a3a 0%, #27104a 55%, #10394a 100%);
}

body[data-theme="candy"] {
  background: linear-gradient(135deg, #fff1f7 0%, #e9f7ff 50%, #d7fff4 100%);
}

body[data-theme="stone"] {
  background: linear-gradient(135deg, #eef2f6 0%, #d7dee8 48%, #cfd8e3 100%);
}

body.is-game-active {
  overflow: hidden;
  padding: 0;
  background: #071424;
}

[hidden],
button[hidden] {
  display: none !important;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.app-shell.is-playing {
  width: 100vw;
  max-width: none;
  margin: 0;
}

.setup-screen {
  display: grid;
  gap: 14px;
}

.setup-hero,
.setup-panel,
.info-panel {
  background: var(--panel);
  border: 1px solid #ffffff;
  border-radius: 8px;
  box-shadow: 0 14px 34px var(--panel-shadow);
}

.setup-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 16px;
  padding: clamp(18px, 4vw, 34px);
}

.title-group {
  display: grid;
  gap: 6px;
}

.eyebrow,
.subtitle,
.panel-heading p,
.install-hint {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.eyebrow {
  color: #2d7595;
  text-transform: uppercase;
  font-size: 0.84rem;
}

h1,
h2,
p {
  margin-top: 0;
}

.setup-hero h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 4.4rem);
  line-height: 0.95;
}

.setup-records,
.stats,
.setup-actions,
.game-actions,
.overlay-actions,
.settings-menu {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.setup-records {
  justify-content: flex-end;
}

.setup-records p,
.stats p {
  margin: 0;
  background: #ffffff;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 900;
}

.setup-records span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.setup-records strong {
  font-size: 1.35rem;
}

.setup-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.panel-heading {
  display: grid;
  gap: 4px;
}

.panel-heading h2,
.info-panel h2 {
  margin: 0;
  font-size: 1.05rem;
}

.quick-settings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.quick-settings label,
.setup-toggles label,
.settings-menu label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 900;
}

.setup-toggles,
.settings-menu {
  gap: 10px;
}

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

.volume-settings label,
.volume-control {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 900;
}

.volume-settings span,
.volume-control span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.volume-settings input,
.volume-control input {
  width: 100%;
  accent-color: var(--sun);
}

.setup-toggles {
  display: flex;
  flex-wrap: wrap;
}

.setup-toggles label,
.settings-menu label {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
}

select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 7px 12px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
  font-weight: 900;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 1rem;
  font-weight: 900;
  color: #06213b;
  background: linear-gradient(120deg, var(--sun), #ffe084);
  cursor: pointer;
  box-shadow: 0 5px 12px #11111122;
}

button:hover {
  filter: brightness(1.04);
}

button:active {
  transform: translateY(1px);
}

.primary-btn {
  min-height: 48px;
  min-width: 180px;
  background: linear-gradient(120deg, #ffb84d, #ffe084);
}

.secondary-btn {
  background: linear-gradient(120deg, #9fe5ff, #d5f6ff);
}

.install-hint {
  color: #36557a;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.9fr 1.2fr;
  gap: 12px;
}

.info-panel {
  padding: 14px;
}

.legend-list,
.compact-stats,
.achievement-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.legend-list p,
.compact-stats p {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
  color: #284a70;
  font-weight: 900;
}

.legend-chip {
  min-width: 48px;
  border-radius: 8px;
  padding: 4px 8px;
  color: #06213b;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 900;
}

.laser {
  background: #ff93db;
}

.expand {
  background: #98f5b4;
}

.bigball {
  background: #ffcf70;
}

.multiball {
  background: #ffe680;
}

.multiball3 {
  background: #ffd166;
}

.multiball4 {
  background: #f6bd60;
}

.slow {
  background: #8ed8ff;
}

.life {
  background: #7ae582;
}

.shield {
  background: #67e8f9;
}

.magnet {
  background: #c084fc;
}

.pierce {
  background: #bef264;
}

.score2x {
  background: #facc15;
}

.attract {
  background: #38bdf8;
}

.bombball {
  background: #fb7185;
}

.timeslow {
  background: #93c5fd;
}

.shadow {
  background: #a7f3d0;
}

.bomb {
  background: #ff9f9f;
}

.steel {
  background: #c5d0dd;
}

.moving {
  background: #c9bdff;
}

.split {
  background: #c2f970;
}

.speed {
  background: #ffb86b;
}

.bounce {
  background: #7dd3fc;
}

.boss {
  background: #f87171;
}

.achievement {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid #dce7fa;
  border-radius: 8px;
  padding: 8px 10px;
  color: #284a70;
  background: #ffffff;
  font-weight: 800;
}

.achievement.locked {
  opacity: 0.48;
}

.achievement strong {
  color: var(--ink);
}

.game-screen {
  width: 100vw;
  min-height: 100dvh;
  margin: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #071424;
  color: #ffffff;
}

.game-hud {
  min-height: var(--hud-height);
  display: grid;
  grid-template-columns: minmax(140px, 0.7fr) minmax(260px, 1.2fr) auto;
  align-items: center;
  gap: 10px;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
  background: #0b2038f5;
  border-bottom: 1px solid #ffffff1c;
}

.game-title {
  min-width: 0;
}

.game-title h1 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1;
}

.game-title p {
  margin: 4px 0 0;
  color: #b8dbff;
  font-size: 0.9rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats {
  justify-content: center;
}

.stats p {
  color: #f3f8ff;
  background: #ffffff16;
  border-color: #ffffff24;
  padding: 7px 9px;
}

.stats span {
  color: #ffe084;
}

.game-actions {
  justify-content: flex-end;
}

.game-actions button {
  min-height: 40px;
  padding: 8px 11px;
}

.canvas-wrap {
  position: relative;
  width: 100vw;
  height: calc(100dvh - var(--hud-height));
  align-self: center;
  justify-self: center;
  overflow: hidden;
  background: #0c1c32;
  border: 1px solid #254366;
  box-shadow: 0 18px 40px #00000055;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  background: linear-gradient(180deg, #10345f, #122640 60%, #0c1c32);
}

.progress-wrap {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 12px;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  color: #ffffff;
  font-weight: 900;
  text-shadow: 0 1px 3px #001b33;
  pointer-events: none;
}

.progress-track {
  height: 10px;
  border: 1px solid #ffffff7a;
  border-radius: 8px;
  background: #001b3366;
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6be2b9, #ffe680, #ffb84d);
  transition: width 220ms ease;
}

.effect-hud {
  position: absolute;
  left: 14px;
  top: 36px;
  z-index: 2;
  display: grid;
  gap: 6px;
  width: min(260px, 42vw);
  pointer-events: none;
}

.effect-chip {
  display: grid;
  grid-template-columns: auto minmax(64px, 1fr) auto;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  border: 1px solid #ffffff38;
  border-radius: 8px;
  color: #ffffff;
  background: #061827bb;
  font-size: 0.78rem;
  font-weight: 900;
  text-shadow: 0 1px 2px #00101f;
}

.effect-chip i {
  width: 28px;
  border-radius: 6px;
  padding: 2px 4px;
  color: #06213b;
  font-style: normal;
  text-align: center;
  text-shadow: none;
}

.effect-bar {
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 999px;
  background: #ffffff2e;
  overflow: hidden;
}

.effect-fill {
  height: 100%;
  border-radius: inherit;
}

.overlay,
.rotate-prompt {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 12px;
  background: #071424d8;
  color: #ffffff;
  padding: 20px;
}

.overlay {
  z-index: 3;
  transition: opacity 250ms ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay h2,
.rotate-prompt h2 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 3rem);
}

.overlay p,
.rotate-prompt p {
  margin: 0;
  font-size: clamp(1rem, 2.2vw, 1.18rem);
  font-weight: 800;
}

.overlay.countdown h2 {
  font-size: clamp(2rem, 7vw, 4.4rem);
}

.overlay.countdown p {
  font-size: clamp(4rem, 18vw, 8rem);
  line-height: 1;
  color: #ffe084;
}

.overlay-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 8px;
  max-width: 460px;
}

.overlay-stats p {
  margin: 0;
  background: #ffffff1f;
  border: 1px solid #ffffff38;
  border-radius: 8px;
  padding: 8px 10px;
}

.settings-menu,
.version-panel {
  justify-content: center;
  background: #ffffff16;
  border: 1px solid #ffffff30;
  border-radius: 8px;
  padding: 10px;
}

.settings-menu {
  display: grid;
  grid-template-columns: repeat(3, auto);
}

.settings-menu .volume-control {
  grid-column: 1 / -1;
  min-width: min(360px, 76vw);
  color: #ffffff;
}

.settings-menu .settings-select {
  grid-column: 1 / -1;
  display: grid;
  min-width: min(360px, 76vw);
  color: #ffffff;
}

.settings-menu .settings-select select {
  min-height: 36px;
}

.version-panel {
  display: grid;
  justify-items: start;
  text-align: left;
  max-width: min(560px, 92vw);
}

.version-panel h3 {
  margin: 0;
  font-size: 1rem;
}

.version-panel ul {
  margin: 0;
  padding-left: 20px;
}

.rotate-prompt {
  z-index: 5;
  background: #020b14f2;
}

.rotate-prompt > div {
  display: grid;
  gap: 10px;
}

.control-stubs {
  display: none;
}

kbd {
  background: #fff;
  border: 1px solid #cedaf8;
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 6px;
  font-family: "Consolas", "Courier New", monospace;
}

@media (max-width: 860px) {
  body {
    padding-left: 10px;
    padding-right: 10px;
  }

  .setup-hero,
  .dashboard-grid,
  .game-hud {
    grid-template-columns: 1fr;
  }

  .setup-records,
  .stats,
  .game-actions {
    justify-content: flex-start;
  }

  .quick-settings {
    grid-template-columns: 1fr;
  }

  .volume-settings {
    grid-template-columns: 1fr;
  }

  .setup-actions button,
  .primary-btn {
    width: 100%;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  :root {
    --hud-height: 58px;
  }

  .game-hud {
    grid-template-columns: minmax(110px, 0.55fr) minmax(270px, 1fr) auto;
    gap: 6px;
    padding-top: max(5px, env(safe-area-inset-top));
    padding-bottom: 5px;
  }

  .game-title h1 {
    font-size: 1rem;
  }

  .game-title p {
    font-size: 0.78rem;
  }

  .stats {
    gap: 5px;
  }

  .stats p {
    padding: 5px 7px;
    font-size: 0.82rem;
  }

  .game-actions {
    gap: 5px;
  }

  .game-actions button {
    min-height: 34px;
    padding: 6px 8px;
    font-size: 0.86rem;
  }

  .progress-wrap {
    top: 8px;
    left: 10px;
    right: 10px;
    font-size: 0.84rem;
  }

  .effect-hud {
    top: 30px;
    left: 10px;
    width: min(220px, 40vw);
  }

  .effect-chip {
    padding: 4px 6px;
    font-size: 0.72rem;
  }

  .overlay-stats {
    display: none;
  }
}

@media (orientation: portrait) and (max-width: 760px) {
  body.is-game-active .game-hud {
    min-height: 68px;
  }

  body.is-game-active .canvas-wrap {
    width: 100vw;
    height: calc(100dvh - 68px);
  }
}
