* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg: #030308;
  --panel: rgba(8, 10, 18, 0.82);
  --line: rgba(255, 255, 255, 0.16);
  --text: #f7f7fb;
  --muted: #a8adc1;
  --gold: #ffd700;
  --gold-soft: #f2b84b;
  --purple: #df49ff;
  --cyan: #55e8ff;
  --danger: #ff5577;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Trebuchet MS", "Arial Narrow", Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font: inherit;
}

.game {
  position: fixed;
  inset: 0;
  min-width: 320px;
  background: #030308;
}

.canvas-container {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.scanline {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background:
    linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
    linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
  background-size: 100% 3px, 6px 100%;
}

.hud {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100dvh;
  padding: clamp(12px, 2vw, 24px);
  pointer-events: none;
}

.hud > * {
  pointer-events: auto;
}

.scoreboard,
.boost-row,
.gamebar {
  width: min(1120px, 100%);
  margin-inline: auto;
}

.scoreboard {
  display: grid;
  grid-template-columns: minmax(128px, 1fr) minmax(160px, auto) minmax(128px, 1fr);
  align-items: start;
  gap: clamp(8px, 2vw, 22px);
}

.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(12px);
}

.score-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 84px;
  padding: 14px;
  border-radius: 8px;
}

.score-card--gold {
  border-color: rgba(255, 215, 0, 0.46);
  box-shadow: 0 0 18px rgba(255, 215, 0, 0.22);
}

.score-card--purple {
  justify-content: flex-end;
  text-align: right;
  border-color: rgba(223, 73, 255, 0.46);
  box-shadow: 0 0 18px rgba(223, 73, 255, 0.22);
}

.score-stripe {
  width: 10px;
  height: 48px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.score-stripe--gold {
  background: linear-gradient(#fff1a5, #b87506);
  box-shadow: 0 0 14px var(--gold);
}

.score-stripe--purple {
  background: linear-gradient(#f7adff, #5e1283);
  box-shadow: 0 0 14px var(--purple);
}

.score-name,
.boost-label,
.controls strong,
.modal-kicker {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0;
}

.score-name--gold,
.boost-label--gold {
  color: var(--gold);
}

.score-name--purple,
.boost-label--purple {
  color: var(--purple);
}

.score-value {
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(2.1rem, 5vw, 4.5rem);
  line-height: 0.92;
}

.score-value--gold,
.gold-glow {
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.76), 0 0 28px rgba(184, 134, 11, 0.46);
}

.score-value--purple,
.purple-glow {
  color: #ec93ff;
  text-shadow: 0 0 12px rgba(224, 102, 255, 0.76), 0 0 28px rgba(139, 0, 139, 0.46);
}

.score-limit {
  color: var(--muted);
  font-size: 0.78rem;
}

.brand {
  text-align: center;
}

.brand-title {
  margin: 0;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(1.2rem, 3vw, 2.6rem);
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0;
  color: #ffffff;
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.42);
}

.brand-title span {
  color: var(--cyan);
}

.round-status {
  margin-top: 8px;
  min-height: 18px;
  color: var(--cyan);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.countdown {
  align-self: center;
  justify-self: center;
  text-align: center;
  pointer-events: none;
}

.countdown[hidden] {
  display: none;
}

.countdown span {
  display: block;
  min-width: 220px;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(4rem, 12vw, 9rem);
  color: var(--gold);
  text-shadow: 0 0 32px rgba(255, 215, 0, 0.76);
}

.boost-row {
  align-self: center;
  display: flex;
  justify-content: space-between;
  min-height: 180px;
}

.boost-meter {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.boost-track {
  display: flex;
  align-items: end;
  width: 10px;
  height: 140px;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
}

.boost-fill {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  transition: height 80ms linear;
}

.boost-fill--gold {
  background: linear-gradient(0deg, #bd7407, #fff1a5);
}

.boost-fill--purple {
  background: linear-gradient(0deg, #5d1283, #f7adff);
}

.gamebar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.toolbar,
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
}

.controls {
  max-width: 660px;
  color: #d6daee;
  font-size: 0.76rem;
}

.controls div {
  min-width: 180px;
}

.controls [hidden] {
  display: none;
}

.btn {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 4px;
  background: rgba(19, 23, 38, 0.92);
  color: var(--text);
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}

.btn:hover,
.btn:focus-visible {
  filter: brightness(1.18);
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.btn--gold {
  color: #1a1100;
  border-color: rgba(255, 215, 0, 0.65);
  background: linear-gradient(90deg, #ffd95b, #b87506, #ffd95b);
}

.btn--purple {
  color: #fbeaff;
  border-color: rgba(223, 73, 255, 0.52);
}

.btn--cyan {
  color: var(--cyan);
  border-color: rgba(85, 232, 255, 0.52);
}

.btn--pink {
  color: #ff93d9;
  border-color: rgba(255, 147, 217, 0.52);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.86);
  backdrop-filter: blur(12px);
}

.modal[hidden] {
  display: none;
}

.modal-panel {
  width: min(620px, 100%);
  padding: clamp(22px, 4vw, 40px);
  border-radius: 8px;
  text-align: center;
}

.modal-logo {
  display: block;
  width: min(420px, 100%);
  height: auto;
  margin: 0 auto 18px;
}

.modal-title {
  margin: 0;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(2rem, 7vw, 4.2rem);
  line-height: 0.96;
  text-transform: uppercase;
}

.modal-subtitle {
  max-width: 460px;
  margin: 12px auto 0;
  color: #d4d7e8;
  font-size: 1rem;
}

.leaderboard {
  margin: 18px auto 0;
  padding: 14px;
  border: 1px solid rgba(85, 232, 255, 0.28);
  border-radius: 8px;
  background: rgba(3, 7, 14, 0.72);
  text-align: left;
}

.leaderboard-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.leaderboard h3 {
  margin: 0;
  color: var(--cyan);
  font-size: 0.86rem;
  text-transform: uppercase;
}

.leaderboard-head span,
.leaderboard-submit p {
  color: var(--muted);
  font-size: 0.76rem;
}

.leaderboard-list {
  display: grid;
  gap: 4px;
  min-height: 28px;
  max-height: 138px;
  margin: 0;
  padding-left: 24px;
  overflow: auto;
}

.player-auth {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}

.player-auth-head,
.player-auth-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.player-auth-head span {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.player-auth-row {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 8px;
}

.player-auth input,
.leaderboard-submit input {
  min-height: 36px;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font: inherit;
  font-weight: 900;
}

.player-auth input[name="player_name"],
.leaderboard-submit input {
  text-transform: uppercase;
}

.player-auth-logout {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
}

.player-auth-logout[hidden] {
  display: none;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  color: #eef8ff;
  font-size: 0.82rem;
}

.leaderboard-score {
  color: var(--gold);
  font-weight: 900;
}

.leaderboard-submit {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.leaderboard-submit[hidden] {
  display: none;
}

.leaderboard-submit label {
  display: block;
  margin-bottom: 6px;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.leaderboard-submit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

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

.mode-btn {
  min-height: 104px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.mode-btn[aria-pressed="true"] {
  border-color: var(--cyan);
  box-shadow: 0 0 18px rgba(85, 232, 255, 0.22);
}

.mode-btn strong {
  display: block;
  color: var(--gold);
  font-weight: 900;
  text-transform: uppercase;
}

.mode-btn span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.touch-controls {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  padding: 18px;
  pointer-events: none;
}

.touch-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.touch-cluster[hidden] {
  display: none;
}

.touch-btn {
  width: 62px;
  height: 62px;
  border: 2px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  background: rgba(10, 12, 20, 0.68);
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 900;
}

.touch-btn--boost {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  font-size: 0.72rem;
}

@media (pointer: coarse) {
  .touch-controls {
    display: flex;
  }
}

@media (max-width: 760px) {
  .scoreboard {
    grid-template-columns: 1fr 1fr;
  }

  .brand {
    grid-column: 1 / -1;
    grid-row: 1;
    order: -1;
  }

  .score-card {
    min-height: 76px;
    padding: 10px;
  }

  .score-stripe {
    display: none;
  }

  .gamebar {
    align-items: stretch;
    flex-direction: column;
    margin-bottom: 92px;
  }

  .controls {
    display: none;
  }

  .mode-grid {
    grid-template-columns: 1fr;
  }
}
