:root {
  --bg: #0b0e1f;
  --panel: #161a33;
  --ink: #fffefa;
  --accent: #ffd75e;
  --accent2: #7c5cff;
  --mint: #2de1a7;
  --danger: #ff5d6c;
  --muted: #9aa0c3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 800px at 50% -10%, #1c2150 0%, var(--bg) 60%) fixed;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", Verdana, sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

#app {
  width: min(560px, 100vw);
  padding: 12px 12px 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#topbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.startng-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 8px 8px;
  border-radius: 999px;
  background: #232647;
  border: 1px solid #343a6e;
  color: var(--ink);
  box-shadow: 0 4px 18px rgba(0, 0, 0, .35);
}

.startng-card img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.startng-card .who { flex: 1; min-width: 0; }
.startng-card b { display: block; font-size: 16px; }
.startng-card span { font-size: 12px; opacity: .7; }

.startng-card button {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  background: var(--accent);
  color: #231a00;
  font-weight: 700;
  cursor: pointer;
}

.startng-card button:hover { filter: brightness(1.08); }

#hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.hud-item {
  background: var(--panel);
  border: 1px solid #2a2f5e;
  border-radius: 12px;
  padding: 8px 4px;
  text-align: center;
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--muted);
}

.hud-item b {
  display: block;
  font-size: 18px;
  color: var(--ink);
  letter-spacing: 0;
}

.hud-item.lives b { color: var(--danger); }

#stage {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #343a6e;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}

#game {
  display: block;
  width: 100%;
  height: auto;
  background: #0b0e1f;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  background: rgba(8, 10, 26, .82);
  backdrop-filter: blur(3px);
  padding: 24px;
}

.overlay[hidden] { display: none; }

.overlay h1 {
  margin: 0;
  font-size: 52px;
  line-height: 1;
  letter-spacing: .06em;
  background: linear-gradient(180deg, #fff6c9, var(--accent) 55%, #ff9d5c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 34px rgba(255, 215, 94, .25);
}

.overlay .tag { font-size: 18px; margin: 0; }
.gold { color: var(--accent); font-weight: 700; }
.danger { color: var(--danger); font-weight: 700; }

.controls-hint { color: var(--muted); font-size: 13px; }

button.big {
  border: 0;
  border-radius: 999px;
  padding: 14px 40px;
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(180deg, #ffe58a, var(--accent));
  color: #231a00;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(255, 215, 94, .35);
}

button.big:hover { filter: brightness(1.07); }
button.big:active { transform: translateY(1px); }

.best { color: var(--mint); margin: 0; }

#final-stats {
  display: flex;
  gap: 16px;
  font-size: 15px;
}

#final-stats b {
  display: block;
  font-size: 28px;
  color: var(--accent);
}

#save-message { min-height: 1.4em; color: var(--mint); margin: 0; }
#save-message.warn { color: var(--accent); }

.row { display: flex; gap: 10px; }

#board-panel {
  background: var(--panel);
  border: 1px solid #2a2f5e;
  border-radius: 16px;
  padding: 14px 16px;
}

#board-panel h2 { margin: 0 0 2px; font-size: 18px; }
.board-note { margin: 0 0 10px; color: var(--muted); font-size: 13px; }

#board {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#board li {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 8px 10px;
  background: #1e2342;
  border-radius: 10px;
  font-size: 14px;
}

#board li.me {
  outline: 2px solid var(--accent);
}

#board li .rank {
  font-weight: 800;
  color: var(--accent);
  min-width: 2.2em;
}

#board li .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#board li .sc { color: var(--muted); font-size: 13px; }
#board li.muted { background: none; color: var(--muted); }

footer { text-align: center; color: var(--muted); font-size: 12px; }
footer a { color: var(--accent); }
