:root {
  --ink: #0b0a10;
  --ink-2: #12101a;
  --panel: rgba(14, 12, 21, 0.86);
  --line: rgba(245, 238, 230, 0.1);
  --paper: #f5eee6;
  --muted: rgba(245, 238, 230, 0.58);
  --neon: #ff2f6d;
  --amber: #ffb03a;
  --cyan: #35e6ff;
  --gold: #ffc24b;
  --green: #3ef08a;
  --glass: rgba(18, 16, 26, 0.62);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: "Manrope", "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: var(--ink);
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(120% 90% at 50% 45%, transparent 42%, rgba(5, 4, 9, 0.55) 100%);
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: calc(10px + env(safe-area-inset-top)) 12px 0 calc(10px + env(safe-area-inset-left));
  gap: 10px;
}

.stat-card {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 12px 9px;
  min-width: 136px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.35);
}

.money {
  font-family: "Chakra Petch", sans-serif;
  font-weight: 700;
  font-size: 22px;
  line-height: 1;
  color: var(--gold);
  letter-spacing: 0.5px;
  display: flex;
  align-items: baseline;
  gap: 2px;
}
.money .cur { font-size: 14px; opacity: 0.8; }

.hp {
  margin-top: 8px;
  height: 6px;
  border-radius: 4px;
  background: rgba(245, 238, 230, 0.13);
  overflow: hidden;
}
.hp i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #2bd47c, #7cf0a8);
  transition: width 0.18s linear, background 0.3s;
}

.stars {
  margin-top: 7px;
  display: flex;
  gap: 3px;
  height: 13px;
}
.stars svg {
  width: 13px;
  height: 13px;
  fill: rgba(245, 238, 230, 0.16);
  transition: fill 0.2s;
}
.stars svg.on {
  fill: var(--neon);
  filter: drop-shadow(0 0 4px rgba(255, 47, 109, 0.8));
}

.hud-right {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  pointer-events: auto;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--glass);
  color: var(--paper);
  display: grid;
  place-items: center;
  padding: 0;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { transform: scale(0.95); }

.map-wrap {
  width: 104px;
  height: 104px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(9, 8, 14, 0.72);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
#minimap { width: 100%; height: 100%; display: block; }

.mission {
  position: absolute;
  top: calc(74px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(20, 15, 12, 0.82);
  border: 1px solid rgba(255, 194, 75, 0.4);
  font-family: "Chakra Petch", sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.mission-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
  animation: blink 1.1s infinite;
}
.bearing {
  display: flex;
  width: 14px;
  height: 14px;
  will-change: transform;
}
.bearing svg {
  width: 14px;
  height: 14px;
  fill: var(--gold);
  filter: drop-shadow(0 0 4px rgba(255, 194, 75, 0.7));
}
.mission .timer {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
@keyframes blink { 50% { opacity: 0.25; } }

#toasts {
  position: absolute;
  top: calc(112px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 88%;
  pointer-events: none;
}
.toast {
  background: rgba(12, 10, 18, 0.9);
  border: 1px solid rgba(245, 238, 230, 0.12);
  color: var(--paper);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 10px;
  animation: toastIn 0.22s ease-out;
  max-width: 100%;
  text-align: center;
}
.toast.gold { color: var(--gold); border-color: rgba(255, 194, 75, 0.35); }
.toast.bad { color: #ff7d9b; border-color: rgba(255, 47, 109, 0.35); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } }

.stick {
  position: fixed;
  width: 124px;
  height: 124px;
  margin: -62px 0 0 -62px;
  border-radius: 50%;
  border: 2px solid rgba(245, 238, 230, 0.16);
  background: radial-gradient(circle, rgba(245, 238, 230, 0.05), rgba(245, 238, 230, 0.02));
  pointer-events: none;
  z-index: 6;
}
.knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(245, 238, 230, 0.16);
  border: 2px solid rgba(245, 238, 230, 0.45);
  box-shadow: 0 0 18px rgba(53, 230, 255, 0.25);
}

.action {
  position: fixed;
  right: calc(18px + env(safe-area-inset-right));
  bottom: calc(26px + env(safe-area-inset-bottom));
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(150deg, #ff3372, #ff8a3d);
  color: #1a0c10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  pointer-events: auto;
  z-index: 7;
  box-shadow: 0 0 0 6px rgba(255, 47, 109, 0.13), 0 10px 30px rgba(255, 47, 109, 0.34);
}
.action:active { transform: scale(0.94); }
.action-icon { display: grid; place-items: center; height: 30px; }
.action-icon svg { width: 30px; height: 30px; }
.action-label {
  font-family: "Chakra Petch", sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.action.idle {
  background: rgba(20, 18, 28, 0.9);
  color: rgba(245, 238, 230, 0.5);
  box-shadow: 0 0 0 1px var(--line);
}

.hint {
  position: absolute;
  bottom: calc(130px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--muted);
  background: rgba(10, 9, 15, 0.7);
  padding: 6px 12px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.4s;
  white-space: nowrap;
  max-width: 90vw;
}
.hint.show { opacity: 1; }

/* ---------- Screens ---------- */

.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: calc(28px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
}

.start {
  justify-content: space-between;
  background:
    linear-gradient(180deg, rgba(11, 10, 16, 0.55) 0%, rgba(11, 10, 16, 0.2) 38%, rgba(11, 10, 16, 0.88) 100%);
}

.skyline {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 34%;
  color: var(--neon);
  pointer-events: none;
  opacity: 0.4;
  mask-image: linear-gradient(180deg, transparent, #000 60%);
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 60%);
}
.skyline svg { width: 100%; height: 100%; display: block; }

.brand { position: relative; margin-top: 4vh; }

.kicker {
  font-family: "Chakra Petch", sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--cyan);
  opacity: 0.85;
  margin-bottom: 10px;
}

.brand h1 {
  margin: 0;
  font-family: "Chakra Petch", sans-serif;
  font-weight: 700;
  font-size: clamp(54px, 17vw, 92px);
  line-height: 0.9;
  letter-spacing: 0.06em;
  color: var(--paper);
  text-shadow: 0 0 26px rgba(255, 47, 109, 0.5), 0 0 60px rgba(255, 47, 109, 0.25);
}

.tagline {
  margin-top: 14px;
  font-size: 14px;
  color: var(--muted);
  max-width: 320px;
  line-height: 1.45;
}

.menu {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 380px;
}

.profile-line {
  margin-top: 14px;
  font-size: 12px;
  color: rgba(245, 238, 230, 0.42);
  text-align: center;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--glass);
  color: var(--paper);
  font-family: "Chakra Petch", sans-serif;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 14px 18px;
  border-radius: 12px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 0.1s, background 0.2s;
}
.btn:active { transform: scale(0.98); background: rgba(40, 36, 52, 0.9); }

.btn.primary {
  background: linear-gradient(100deg, #ff2f6d, #ff7a3d);
  border: none;
  color: #1b0b10;
  box-shadow: 0 10px 30px rgba(255, 47, 109, 0.28);
}

.panel-screen {
  background: rgba(7, 6, 11, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  justify-content: center;
  align-items: center;
}

.panel {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  max-height: 88vh;
  overflow-y: auto;
  animation: panelIn 0.24s ease-out;
}
.panel.wide { max-width: 440px; }
@keyframes panelIn { from { opacity: 0; transform: translateY(12px); } }

.panel h2 {
  margin: 0 0 16px;
  font-family: "Chakra Petch", sans-serif;
  font-weight: 700;
  font-size: 24px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.panel .btn { width: 100%; margin-top: 10px; }

.rules {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 11px;
  font-size: 13.5px;
  line-height: 1.45;
  color: rgba(245, 238, 230, 0.78);
}
.rules li { padding-left: 16px; position: relative; }
.rules li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--neon);
}
.rules b { color: var(--paper); }

.lead-head {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 4px 8px;
  border-bottom: 1px solid var(--line);
}
.leaders { margin: 6px 0 2px; max-height: 44vh; overflow-y: auto; }
.leader-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid rgba(245, 238, 230, 0.05);
  font-size: 13px;
}
.leader-row .place {
  font-family: "Chakra Petch", sans-serif;
  font-weight: 700;
  width: 22px;
  color: var(--muted);
}
.leader-row.me { background: rgba(255, 47, 109, 0.08); border-radius: 8px; }
.leader-row.me .place { color: var(--neon); }
.leader-row .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-row .sum { font-family: "Chakra Petch", sans-serif; font-weight: 600; color: var(--gold); }
.leader-row .sub { font-size: 10.5px; color: var(--muted); }
.empty { padding: 18px 4px; color: var(--muted); font-size: 13px; }

.pause-stats {
  display: flex;
  gap: 18px;
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
}
.pause-stats b { display: block; color: var(--gold); font-family: "Chakra Petch", sans-serif; font-size: 18px; }

.bust-text { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0 0 8px; }