:root {
  --bg-top: #102542;
  --bg-bottom: #1f6f78;
  --panel: rgba(8, 17, 34, 0.72);
  --panel-border: rgba(255, 255, 255, 0.14);
  --text-main: #f7fbff;
  --text-soft: #b9d6ea;
  --accent: #ffd166;
  --accent-2: #ff5d73;
  --shadow: rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at top, rgba(255, 209, 102, 0.2), transparent 25%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.layout {
  width: min(960px, 100%);
  display: grid;
  justify-items: center;
}

.game-shell,
.leaderboard-panel {
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 24px 60px var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.game-shell {
  position: relative;
}

.leaderboard-panel {
  width: min(960px, 100%);
  background: rgba(7, 17, 34, 0.78);
  backdrop-filter: blur(10px);
  padding: 20px;
  margin-top: 18px;
}

.leaderboard-head h2,
.leaderboard-head p {
  margin: 0;
}

.leaderboard-head p {
  margin-top: 6px;
  color: var(--text-soft);
}

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

.leaderboard-block h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  color: var(--text-main);
}

.leaderboard-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.leaderboard-entry {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
}

.leaderboard-rank {
  color: var(--text-soft);
  font-weight: 700;
  line-height: 1.4;
  text-align: right;
  padding-top: 6px;
}

.leaderboard-card {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-soft);
}

.leaderboard-entry.empty {
  grid-template-columns: 1fr;
}

.leaderboard-card strong {
  color: var(--text-main);
}

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

.hud {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 2;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.hud > div {
  min-width: 116px;
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
}

.label,
.value {
  margin: 0;
}

.label {
  color: var(--text-soft);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.value {
  margin-top: 4px;
  font-size: 1.5rem;
  font-weight: 700;
}

.value.small {
  font-size: 0.95rem;
  font-weight: 600;
}

#effect-timers {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  font-size: 0.82rem;
  line-height: 1.15;
}

.controls {
  margin-left: auto;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  background: linear-gradient(180deg, #48bfe3 0%, #90e0ef 58%, #caf0f8 100%);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  text-align: center;
  padding: 24px;
  background: rgba(4, 10, 22, 0.42);
  backdrop-filter: blur(6px);
}

.overlay.hidden {
  display: none;
}

.overlay h1,
.overlay h2,
.overlay p {
  margin: 0;
}

.overlay h1 {
  font-size: clamp(2.4rem, 4vw, 4rem);
  line-height: 1;
}

.overlay p {
  font-size: 1.05rem;
}

.overlay-help {
  color: var(--accent);
  font-weight: 700;
}

.overlay-subtle {
  color: var(--text-soft);
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.overlay-toggle {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(7, 17, 34, 0.76);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
}

.overlay-toggle:hover,
.overlay-toggle:focus-visible {
  border-color: rgba(255, 209, 102, 0.72);
  outline: none;
}

.overlay-toggle.is-active {
  border-color: rgba(255, 209, 102, 0.82);
  background: rgba(26, 47, 80, 0.94);
  box-shadow: 0 0 0 1px rgba(255, 209, 102, 0.22) inset;
}

.mode-actions {
  margin-top: 2px;
  margin-bottom: 4px;
}

.upgrade-grid {
  width: min(820px, 100%);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.upgrade-card {
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(7, 17, 34, 0.76);
  color: var(--text-main);
  text-align: left;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.upgrade-card:hover,
.upgrade-card:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(255, 209, 102, 0.72);
  background: rgba(17, 32, 58, 0.88);
  outline: none;
}

.upgrade-card h2,
.upgrade-card p {
  margin: 0;
}

.upgrade-card h2 {
  font-size: 1.15rem;
}

.upgrade-card .hotkey {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
}

.upgrade-card .desc {
  margin-top: 8px;
  color: var(--text-soft);
}

.effect-chip {
  display: block;
  width: 100%;
  padding: 4px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.82rem;
  line-height: 1.15;
  white-space: nowrap;
}

.effect-chip.shield {
  background: rgba(123, 223, 242, 0.18);
}

.effect-chip.slow {
  background: rgba(168, 218, 220, 0.18);
}

.effect-chip.auto {
  background: rgba(255, 209, 102, 0.18);
}

.effect-chip.aura {
  background: rgba(255, 107, 53, 0.2);
}

.effect-chip.bonus {
  background: rgba(189, 178, 255, 0.22);
}

.effect-chip.warning {
  border-color: rgba(255, 209, 102, 0.8);
  box-shadow: 0 0 0 1px rgba(255, 209, 102, 0.2);
  animation: timerPulse 0.7s ease-in-out infinite alternate;
}

@keyframes timerPulse {
  from {
    opacity: 0.88;
    filter: brightness(1);
  }

  to {
    opacity: 1;
    filter: brightness(1.2);
  }
}

.name-form {
  width: min(360px, 100%);
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.name-form input,
.name-form button {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 12px 14px;
  font: inherit;
}

.name-form input {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.name-form button {
  background: var(--accent);
  color: #0b1728;
  font-weight: 700;
  cursor: pointer;
}

.name-form button:hover,
.name-form button:focus-visible {
  filter: brightness(1.05);
  outline: none;
}

@media (max-width: 720px) {
  .page {
    padding: 12px;
  }

  .game-shell,
  .leaderboard-panel {
    border-radius: 20px;
  }

  .hud {
    top: 10px;
    left: 10px;
    right: 10px;
  }

  .hud > div {
    min-width: 100px;
    padding: 10px 12px;
  }

  .controls {
    margin-left: 0;
  }

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

  .leaderboard-list {
    grid-template-columns: 1fr;
  }
}
