:root {
  color-scheme: dark;
  --bg: #050816;
  --panel: rgba(8, 14, 34, 0.86);
  --line: rgba(132, 201, 255, 0.28);
  --accent: #7ef9ff;
  --accent-strong: #ffd166;
  --text: #edf6ff;
  --muted: #95a8c7;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overscroll-behavior: none;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(29, 71, 150, 0.35), transparent 35%),
    radial-gradient(circle at bottom, rgba(255, 209, 102, 0.12), transparent 25%),
    linear-gradient(180deg, #03040b 0%, #071224 100%);
  color: var(--text);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body.dashboard-page {
  overflow-x: hidden;
  overflow-y: auto;
}

.game-shell {
  width: min(1080px, calc(100vw - 32px));
  margin: 24px auto;
}

.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  background: var(--panel);
  backdrop-filter: blur(8px);
}

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

.brand__title {
  font-size: clamp(1.5rem, 4vw, 2.4rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.brand__subtitle {
  color: var(--muted);
  font-size: 0.88rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.scoreboard {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

#pauseButton {
  margin-top: 0;
  padding: 10px 16px;
  font-size: 0.85rem;
  min-width: 0;
  box-shadow: 0 8px 18px rgba(105, 238, 248, 0.22);
}

.scoreboard__item {
  display: grid;
  justify-items: end;
  gap: 4px;
}

.scoreboard strong {
  font-size: 2rem;
  color: var(--accent-strong);
}

.scoreboard__item--target strong {
  font-size: 1.2rem;
  color: var(--text);
}

.playfield {
  position: relative;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 24px 24px;
  overflow: hidden;
  background: #020611;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  touch-action: none;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  background:
    radial-gradient(circle at center, rgba(18, 29, 57, 0.8), rgba(4, 8, 18, 1)),
    #020611;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 18px;
  padding: 24px;
  text-align: center;
  background: rgba(2, 6, 17, 0.84);
}

.overlay[hidden] {
  display: none;
}

.touch-controls {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
  z-index: 2;
}

.touch-zone {
  position: absolute;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  width: min(32vw, 156px);
  height: min(32vw, 156px);
  border-radius: 28px;
  background: rgba(6, 15, 37, 0.42);
  border: 1px solid rgba(126, 249, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
}

.touch-zone--move {
  left: 18px;
}

.touch-zone--fire {
  right: 18px;
  display: grid;
  place-items: center;
}

.touch-zone.is-active {
  background: rgba(10, 24, 58, 0.7);
  border-color: rgba(126, 249, 255, 0.4);
}

.touch-zone__label {
  position: absolute;
  top: 12px;
  left: 14px;
  color: rgba(237, 246, 255, 0.8);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.touch-zone__stick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(126, 249, 255, 0.2);
  background: rgba(126, 249, 255, 0.08);
}

.touch-zone__nub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, rgba(126, 249, 255, 0.95), rgba(184, 255, 218, 0.85));
  box-shadow: 0 0 18px rgba(126, 249, 255, 0.35);
}

.touch-zone--fire::after {
  content: "";
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 209, 102, 0.82), rgba(255, 107, 107, 0.42));
  box-shadow: 0 0 24px rgba(255, 107, 107, 0.28);
}

.touch-zone--fire.is-active::after {
  transform: scale(0.94);
  filter: brightness(1.15);
}

.overlay h1 {
  margin: 0;
  font-size: clamp(2.2rem, 6vw, 4rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff3bf;
  text-shadow: 0 0 22px rgba(255, 209, 102, 0.18);
}

.overlay p {
  margin: 0;
  max-width: 54ch;
  color: var(--muted);
  line-height: 1.7;
}

.overlay__lead {
  color: #f6f1da;
  margin-top: 4px;
  margin-bottom: 4px;
}

.overlay__controls {
  display: grid;
  gap: 12px;
  justify-items: center;
  margin: 2px 0 8px;
}

.overlay__control-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  color: #f7e7ad;
  font-size: 1.08rem;
  font-weight: 600;
}

.overlay__control-keys {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.overlay__control-text {
  color: #c3d0ea;
  font-weight: 700;
}

.overlay__control-sep,
.overlay__control-slash {
  color: #98a8c8;
  font-weight: 700;
}

.overlay__mobile {
  color: var(--text);
  font-size: 1.12rem;
  line-height: 1.6;
}

.player-form {
  display: grid;
  gap: 8px;
  justify-items: center;
  margin: 4px 0 2px;
}

.player-form__label {
  color: #ffd166;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.player-form__input {
  width: min(320px, 82vw);
  border: 1px solid rgba(255, 209, 102, 0.34);
  border-radius: 999px;
  padding: 14px 18px;
  background: rgba(13, 20, 43, 0.92);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  text-align: center;
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.player-form__input:focus {
  border-color: rgba(255, 209, 102, 0.64);
  box-shadow: 0 0 0 4px rgba(255, 209, 102, 0.12);
}

.overlay__actions {
  display: grid;
  gap: 10px;
  justify-items: center;
}

.overlay__link {
  color: #ffd166;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

.overlay__link:hover {
  color: #fff0bf;
}


.dashboard {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto;
  display: grid;
  gap: 22px;
}

.dashboard__hero,
.dashboard__player,
.dashboard__panel,
.stat-card {
  border: 1px solid var(--line);
  background: rgba(8, 14, 34, 0.84);
  backdrop-filter: blur(10px);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.3);
}

.dashboard__hero {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  padding: 24px 26px;
  border-radius: 24px;
}

.dashboard__eyebrow {
  margin: 0 0 8px;
  color: #ffd166;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.dashboard__title {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.2rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff3bf;
}

.dashboard__subtitle {
  margin: 10px 0 0;
  max-width: 60ch;
  color: var(--muted);
  line-height: 1.6;
}

.dashboard__actions {
  display: flex;
  align-items: center;
}

.dashboard__back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 14px 20px;
  background: linear-gradient(135deg, rgba(126, 249, 255, 0.16), rgba(184, 255, 218, 0.14));
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

.dashboard__player {
  display: grid;
  gap: 8px;
  padding: 18px 20px;
  border-radius: 20px;
  justify-items: start;
}

.dashboard__cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.stat-card {
  padding: 18px;
  border-radius: 18px;
}

.stat-card__label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stat-card__value {
  display: block;
  margin-top: 10px;
  font-size: clamp(1.5rem, 4vw, 2.3rem);
  color: #ffd166;
  line-height: 1.1;
  overflow-wrap: anywhere;
  word-break: break-word;
}

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

.dashboard__panel {
  padding: 20px;
  border-radius: 22px;
}

.dashboard__panel h2 {
  margin: 0 0 16px;
  font-size: 1.2rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff3bf;
}

.leaderboard {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.leaderboard__item,
.leaderboard__empty {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(12, 20, 43, 0.84);
  border: 1px solid rgba(126, 249, 255, 0.12);
}

.leaderboard__empty {
  grid-template-columns: 1fr;
  color: var(--muted);
}

.leaderboard__rank {
  color: #ffd166;
  font-weight: 800;
}

.leaderboard__main {
  display: grid;
  gap: 4px;
}

.leaderboard__main strong {
  color: var(--text);
}

.leaderboard__main span {
  color: var(--muted);
  font-size: 0.92rem;
}

.leaderboard__score {
  color: #fff3bf;
  font-size: 1.1rem;
  font-weight: 800;
}

.overlay__accent {
  color: #ffd166;
  font-weight: 800;
}

kbd {
  display: inline-block;
  margin: 0 0.22rem;
  padding: 0.32rem 0.78rem;
  border: 1px solid rgba(255, 209, 102, 0.62);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 209, 102, 0.34), rgba(255, 209, 102, 0.12));
  box-shadow:
    inset 0 1px 0 rgba(255, 244, 194, 0.28),
    0 0 18px rgba(255, 209, 102, 0.12),
    0 6px 18px rgba(0, 0, 0, 0.22);
  color: #fff6d8;
  font: inherit;
  font-size: 1em;
  font-weight: 800;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

@media (max-width: 1200px) {
  .overlay__control-row {
    gap: 10px;
    font-size: 1rem;
  }

  .dashboard {
    width: min(100vw - 16px, 1180px);
    margin: 8px auto 20px;
  }

  .dashboard__hero {
    flex-direction: column;
    align-items: start;
    padding: 20px 18px;
  }

  .dashboard__cards,
  .dashboard__grid {
    grid-template-columns: 1fr;
  }

  .stat-card__value {
    font-size: clamp(1.35rem, 7vw, 2rem);
  }
}

button {
  justify-self: center;
  margin-top: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 14px 24px;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #04111a;
  background: linear-gradient(135deg, #69eef8, #a9f5c6);
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(105, 238, 248, 0.32);
  opacity: 1;
}

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

@media (max-width: 1200px) {
  body.dashboard-page {
    min-height: auto;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body.dashboard-page .dashboard {
    width: min(100vw - 16px, 1180px);
    margin: 8px auto 20px;
    min-height: auto;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .game-shell {
    width: min(100vw, 1080px);
    margin: 0 auto;
    min-height: 100dvh;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .hud {
    padding: 12px 14px;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .scoreboard strong {
    font-size: 1.35rem;
  }

  .scoreboard {
    gap: 10px;
  }

  .scoreboard__item--target {
    display: none;
  }

  #pauseButton {
    padding: 8px 12px;
    font-size: 0.78rem;
  }

  .brand__subtitle {
    display: none;
  }

  .playfield {
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: 0;
    min-height: calc(100dvh - 74px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }

  canvas {
    width: 100%;
    height: calc(100dvh - 74px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    aspect-ratio: auto;
  }

  .overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: calc(22px + env(safe-area-inset-top, 0px)) 18px calc(180px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
  }

  .overlay h1 {
    order: 1;
  }

  .overlay__lead {
    order: 2;
  }

  .player-form {
    order: 3;
  }

  .overlay__actions {
    order: 4;
    gap: 12px;
    margin-top: 4px;
    width: 100%;
    padding: 0;
    position: static;
    bottom: auto;
    background: none;
  }

  .overlay__actions button {
    min-width: 220px;
    padding: 16px 24px;
  }

  .overlay__controls {
    order: 5;
  }

  .overlay__mobile {
    order: 6;
  }

  .touch-controls {
    display: block;
  }

  .touch-zone {
    width: clamp(112px, 26vw, 150px);
    height: clamp(112px, 26vw, 150px);
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .touch-zone--move {
    left: max(12px, env(safe-area-inset-left, 0px));
  }

  .touch-zone--fire {
    right: max(12px, env(safe-area-inset-right, 0px));
  }

  .touch-zone__label {
    font-size: 0.66rem;
  }
}

@media (max-height: 820px) {
  .game-shell {
    width: min(100vw, 1080px);
    margin: 0 auto;
    min-height: 100dvh;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .hud {
    padding: 12px 14px;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .scoreboard {
    gap: 10px;
  }

  .scoreboard strong {
    font-size: 1.35rem;
  }

  .scoreboard__item--target {
    display: none;
  }

  .brand__subtitle {
    display: none;
  }

  .playfield {
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: 0;
    min-height: calc(100dvh - 74px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }

  canvas {
    width: 100%;
    height: calc(100dvh - 74px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    aspect-ratio: auto;
  }

  .overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: calc(22px + env(safe-area-inset-top, 0px)) 18px calc(180px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
  }

  .overlay h1 {
    order: 1;
  }

  .overlay__lead {
    order: 2;
  }

  .player-form {
    order: 3;
  }

  .overlay__actions {
    order: 4;
    gap: 12px;
    margin-top: 4px;
    width: 100%;
    padding: 0;
    position: static;
    bottom: auto;
    background: none;
  }

  .overlay__actions button {
    min-width: 220px;
    padding: 16px 24px;
  }

  .overlay__controls {
    order: 5;
  }

  .overlay__mobile {
    order: 6;
  }

  .touch-controls {
    display: block;
  }
}

@media (max-width: 900px) and (max-height: 820px) {
  .overlay {
    gap: 12px;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 14px calc(144px + env(safe-area-inset-bottom, 0px));
  }

  .overlay h1 {
    font-size: clamp(1.8rem, 5.8vw, 2.9rem);
  }

  .overlay p {
    line-height: 1.45;
  }

  .player-form {
    gap: 6px;
    margin: 2px 0 0;
  }

  .player-form__input {
    padding: 11px 16px;
  }

  .overlay__controls {
    gap: 8px;
    margin: 0;
  }

  .overlay__control-row {
    gap: 8px;
    font-size: 0.98rem;
  }

  .overlay__mobile {
    font-size: 1rem;
    line-height: 1.45;
  }

  .overlay__actions {
    gap: 8px;
    margin-top: 2px;
  }

  .overlay__actions button {
    min-width: 196px;
    padding: 14px 20px;
  }

  kbd {
    padding: 0.26rem 0.66rem;
  }
}

@media (max-width: 430px) {
  body.dashboard-page .dashboard {
    width: min(100vw - 12px, 1180px);
  }

  .brand__title {
    font-size: 1.15rem;
  }

  .scoreboard {
    gap: 8px;
  }

  .scoreboard strong {
    font-size: 1.15rem;
  }

  .touch-zone {
    width: clamp(108px, 31vw, 138px);
    height: clamp(108px, 31vw, 138px);
  }

  .touch-zone__stick {
    width: 64px;
    height: 64px;
  }

  .touch-zone--fire::after {
    width: 60px;
    height: 60px;
  }

  .overlay {
    padding: calc(16px + env(safe-area-inset-top, 0px)) 14px calc(200px + env(safe-area-inset-bottom, 0px));
    gap: 14px;
  }

  .overlay__actions button {
    min-width: 200px;
    padding: 15px 20px;
  }
}
