* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(900px 480px at 50% -8%, #9ad8ff 0%, transparent 55%),
    linear-gradient(180deg, #3aa0d8 0%, #1a6fa8 42%, #0e4a78 100%);
  color: #0b3a5c;
  font-family: 'Fredoka', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  overflow: hidden;
}

#game {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 0;
}

#ui {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 2;
}

#scoreboard {
  display: flex;
  gap: 8px;
}

.score-item {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.82);
  color: #0b3a5c;
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: 0 8px 24px rgba(8, 48, 80, 0.18);
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.score-item .label {
  opacity: 0.7;
  font-size: 13px;
}
.score-item span:last-child {
  font-weight: 700;
  font-size: 20px;
}

#next-bar {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.82);
  border-radius: 12px;
  padding: 8px 8px;
  box-shadow: 0 8px 24px rgba(8, 48, 80, 0.18);
  display: flex;
  align-items: center;
  gap: 8px;
}
#next-list {
  display: flex;
  align-items: center;
  gap: 6px;
}
.next-token {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.08);
}

#controls { pointer-events: auto; display: flex; gap: 8px; align-items: center; }
#restart, #play, #changeMode, #homeBtn, .home-link {
  cursor: pointer;
  border: none;
  background: linear-gradient(180deg, #2db8d4, #1a8fb0);
  color: white;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  box-shadow: 0 8px 24px rgba(12, 90, 120, 0.35);
}
#restart:hover, #play:hover, #changeMode:hover, #homeBtn:hover, .home-link:hover { filter: brightness(1.05); }
#restart:active, #play:active, #changeMode:active, #homeBtn:active, .home-link:active { filter: brightness(0.95); }
#homeBtn, .home-link {
  background: linear-gradient(180deg, #ff7eb6, #e85a9a);
  box-shadow: 0 8px 24px rgba(200, 60, 120, 0.28);
}
#controls .btn.ghost, #changeMode.ghost {
  background: rgba(255,255,255,0.85);
  color: #0b3a5c;
  box-shadow: 0 8px 24px rgba(8, 48, 80, 0.12);
  border: 1px solid rgba(11, 58, 92, 0.15);
  text-decoration: none;
  display: inline-block;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
}
#overlay .panel .tagline { margin: 0 0 14px; opacity: 0.85; }
.mode-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.mode-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  border: 2px solid rgba(11, 58, 92, 0.12);
  background: rgba(235, 248, 255, 0.95);
  color: #0b3a5c;
  border-radius: 14px;
  padding: 14px 12px;
  font: inherit;
  box-shadow: none;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}
.mode-card:hover {
  border-color: rgba(26, 143, 176, 0.55);
  transform: translateY(-1px);
  filter: none;
}
.mode-card.selected {
  border-color: #1a8fb0;
  background: linear-gradient(180deg, #e8f8ff, #d5f0fb);
}
.mode-card .mode-title {
  font-weight: 700;
  font-size: 18px;
}
.mode-card .mode-desc {
  font-size: 13px;
  line-height: 1.35;
  opacity: 0.78;
}
.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
@media (max-width: 480px) {
  .mode-picker { grid-template-columns: 1fr; }
}

#overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(6, 40, 70, 0.28);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 3;
}
#overlay.show { opacity: 1; pointer-events: auto; }
#overlay .panel {
  background: rgba(255, 255, 255, 0.96);
  color: #0b3a5c;
  width: min(520px, calc(100vw - 32px));
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(8, 48, 80, 0.35);
}
#overlay h1 { margin: 0 0 8px; }
#overlay p { opacity: 0.85; line-height: 1.45; }

@media (max-width: 600px) {
  #ui { flex-wrap: wrap; }
  #next-bar { order: 3; width: 100%; justify-content: center; }
}
