:root {
  --ink: #06263f;
  --panel: rgba(6, 30, 48, 0.72);
  --accent: #ffb020;
  --accent2: #23c3ff;
  --text: #eaf6ff;
  font-family: "Segoe UI", Roboto, -apple-system, system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a3a63;
  color: var(--text);
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------------- Top HUD ---------------- */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 12px;
  pointer-events: none;
  z-index: 10;
}

.stat {
  background: var(--panel);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 14px;
  padding: 8px 14px;
  min-width: 96px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.stat .label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.7;
}

.stat .value {
  display: block;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat.points .value { color: var(--accent); }

.pauseBtn {
  pointer-events: auto;
  margin-left: auto;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.pauseBtn:active { transform: scale(0.94); }

/* --------------- Floating score flash --------------- */
.flash {
  position: fixed;
  top: 34%;
  left: 50%;
  transform: translate(-50%, 0) scale(0.8);
  font-size: 34px;
  font-weight: 900;
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  z-index: 9;
}
.flash.show {
  animation: pop 0.9s ease-out forwards;
}
@keyframes pop {
  0%   { opacity: 0; transform: translate(-50%, 10px) scale(0.7); }
  25%  { opacity: 1; transform: translate(-50%, -6px) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -46px) scale(1); }
}

/* ---------------- Screens ---------------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
  background: radial-gradient(
    120% 90% at 50% 10%,
    rgba(4, 22, 38, 0.35),
    rgba(4, 22, 38, 0.72)
  );
}
.screen.hidden,
.hidden { display: none !important; }

.card {
  width: min(92vw, 380px);
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  padding: 30px 26px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.card h1 {
  font-size: 44px;
  font-weight: 900;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #fff, #9fd8ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.card h2 { font-size: 30px; font-weight: 800; margin-bottom: 8px; }

.tag {
  text-transform: uppercase;
  letter-spacing: 0.32em;
  font-size: 12px;
  opacity: 0.75;
  margin-top: 2px;
}
.sub { margin: 16px 0 4px; opacity: 0.85; font-size: 14px; }
.hint { margin-top: 14px; font-size: 12px; opacity: 0.6; }

.btn {
  margin-top: 20px;
  width: 100%;
  padding: 15px 20px;
  border: none;
  border-radius: 16px;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  color: #06263f;
  background: linear-gradient(180deg, #ffd36b, var(--accent));
  box-shadow: 0 8px 24px rgba(255, 176, 32, 0.35);
  transition: transform 0.08s ease;
}
.btn:active { transform: translateY(1px) scale(0.99); }

.btn.blue {
  display: block;
  box-sizing: border-box;
  width: auto;
  margin-top: 12px;
  padding: 10px 18px;
  font-size: 14px;
  text-align: center;
  text-decoration: none;
  color: #eaf4ff;
  background: linear-gradient(180deg, #3aa0ff, #1668c9);
  box-shadow: 0 8px 24px rgba(22, 104, 201, 0.35);
}

.badge {
  display: inline-block;
  margin: 6px 0 14px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  color: #06263f;
  background: linear-gradient(180deg, #b6ffd0, #3bff9d);
}

.stats { margin: 8px 0 4px; }
.statBig {
  font-size: 40px;
  font-weight: 900;
  color: var(--accent);
  margin-bottom: 10px;
}
.statRow {
  display: flex;
  justify-content: space-between;
  padding: 7px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 15px;
}
.statRow span { opacity: 0.75; }
.statRow b { font-variant-numeric: tabular-nums; }

/* ---------------- Leaderboard + name entry ---------------- */
.leaderboard {
  margin: 14px 0 4px;
  text-align: left;
}
.lbTitle {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.6;
  margin-bottom: 6px;
  text-align: center;
}
.lbEmpty {
  font-size: 13px;
  opacity: 0.6;
  text-align: center;
  padding: 6px 0;
}
.lbRow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 14px;
}
.lbRow:nth-child(even) { background: rgba(255, 255, 255, 0.05); }
.lbRow.me {
  background: linear-gradient(90deg, rgba(255, 176, 32, 0.28), rgba(255, 176, 32, 0.06));
  box-shadow: inset 0 0 0 1px rgba(255, 176, 32, 0.5);
}
.lbRank {
  width: 20px;
  font-weight: 800;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}
.lbName {
  flex: 1;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lbPts {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 700;
}

.nameEntry {
  margin: 10px 0 2px;
}
.nameLabel {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
}
.nameRow {
  display: flex;
  gap: 8px;
}
#nameInput {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-size: 16px; /* >=16px avoids iOS auto-zoom on focus */
  font-weight: 700;
}
#nameInput::placeholder { color: rgba(234, 246, 255, 0.4); }
#nameInput:focus {
  outline: none;
  border-color: var(--accent);
}
.btn.small {
  margin-top: 0;
  width: auto;
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 15px;
}

@media (max-width: 360px) {
  .stat .value { font-size: 22px; }
  .card h1 { font-size: 38px; }
}
