:root {
  --bg: #0b1020;
  --ink: #f4f1ea;
  --mute: #9aa3b8;
  --line: #243049;
  --card: #141a2e;
  --accent: #ff3b6b;
  --accent-2: #00e5c0;
  --warn: #ffd400;
  --font: "Nunito", ui-sans-serif, system-ui, sans-serif;
  --pixel: "Pixelify Sans", ui-monospace, monospace;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 20% -10%, #1a2450 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
}
body { min-height: 100svh; }
body.play {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  overflow: auto;
}
a { color: var(--accent-2); }
.skip {
  position: absolute;
  left: -999px;
}
.skip:focus { left: 8px; top: 8px; background: #fff; color: #000; padding: 6px 10px; z-index: 9; }
.top {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.45rem 0.7rem;
  padding: 0.4rem 0.7rem 0.45rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, #000);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  gap: 0.08rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--pixel);
  font-size: 1.35rem;
  letter-spacing: 0.02em;
}
.brand img { width: 32px; height: 32px; flex: none; }
.brand .wordmark { display: inline; font-weight: 800; }
.balance {
  margin: 0 0 0 calc(32px + 0.5rem);
  font-weight: 800;
  color: var(--warn);
  font-size: 0.72rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
  max-width: 16rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.live-count {
  margin: 0 0.2rem 0 auto;
  color: var(--mute);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  opacity: 0.85;
}
.live-count[hidden] { display: none; }
.head-icons {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: none;
  margin-left: 0;
}
.head-icons .ico {
  display: grid;
  place-items: center;
  width: 2.55rem;
  height: 2.55rem;
  margin: 0;
  padding: 0;
  color: var(--ink);
  border-radius: 12px;
  text-decoration: none;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.28);
  transition: transform 0.12s ease, filter 0.12s ease;
}
.head-icons .ico svg { display: block; border-radius: 10px; }
.head-icons .ico:hover { transform: translateY(-1px) scale(1.04); filter: brightness(1.08); }
.head-icons .ico.on {
  outline: 2px solid var(--warn);
  outline-offset: 2px;
}
.bomb-timer {
  position: absolute;
  top: 0.55rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  padding: 0.28rem 0.8rem 0.28rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 212, 0, 0.22);
  background: rgba(11, 16, 32, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #ffe48a;
  font-size: 0.82rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}
.bomb-timer[hidden] { display: none; }
.bomb-timer .sand {
  width: 0.48rem;
  height: 0.48rem;
  flex: none;
  border-radius: 1px;
  background: #ffd400;
  box-shadow: 0 0 8px rgba(255, 212, 0, 0.55);
  animation: sand-pulse 1.6s ease-in-out infinite;
}
#bombTimerText {
  color: #ffe48a;
  font-size: 0.82rem;
  font-weight: 800;
}
@keyframes sand-pulse {
  0%, 100% { opacity: 0.45; transform: scale(0.86); }
  50% { opacity: 1; transform: scale(1); }
}
.btn.buy-fab {
  position: absolute;
  right: 5.4rem;
  bottom: 0.7rem;
  z-index: 5;
  min-height: 2.15rem;
  padding: 0.35rem 0.9rem;
  font-size: 0.9rem;
  background: var(--accent);
  border: 0;
  color: #fff;
  box-shadow: 0 8px 22px rgba(255, 59, 107, 0.35);
}
.tagline {
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.03em;
  flex: 1 1 12rem;
}
.top-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-left: auto;
}
nav a {
  color: var(--mute);
  text-decoration: none;
  margin-left: 0.7rem;
  font-weight: 700;
}
nav a:hover, nav a:focus-visible { color: var(--ink); }
.rule {
  margin: 0;
  padding: 0.28rem 0.7rem;
  text-align: center;
  background: #151b33;
  border-bottom: 1px solid var(--line);
  font-weight: 800;
  font-size: 0.92rem;
}
.stage {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.55rem 0.7rem 1.2rem;
  height: auto;
  flex: 1 1 auto;
}
.map-wrap {
  background: #070b16;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  flex: 0 0 auto;
  width: min(100%, calc(min(52svh, 560px) * 3 / 2));
  max-width: 100%;
  aspect-ratio: 3 / 2;
  height: auto;
  min-height: 0;
  margin-inline: auto;
  position: relative;
  touch-action: none;
}
#map {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  background: #070b16;
}
.map-hud {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem 0.6rem;
  padding: 0.55rem 0.65rem;
  background: linear-gradient(180deg, transparent, rgba(7, 11, 22, 0.88) 38%);
  border-top: 0;
}
.map-hud p { margin: 0; color: var(--mute); font-size: 0.88rem; flex: 1 1 8rem; }
.how-line {
  color: #fff !important;
  font-weight: 800;
  font-size: 0.92rem !important;
  line-height: 1.25;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.65);
}
.how {
  position: absolute;
  left: 0.7rem;
  bottom: 0.7rem;
  z-index: 5;
  max-width: min(18rem, calc(100% - 7.5rem));
  padding: 0.7rem 0.85rem 0.75rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(11, 16, 32, 0.88);
  color: var(--ink);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}
.how[hidden] { display: none; }
.how p { margin: 0; }
.how ol {
  margin: 0.35rem 0 0.45rem;
  padding-left: 1.15rem;
}
.how li {
  margin: 0.18rem 0;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.3;
}
.how em { font-style: normal; color: var(--warn); }
.how-sub { color: var(--mute); font-size: 0.78rem; margin-bottom: 0.5rem !important; }
.how .btn { margin-top: 0.15rem; padding: 0.28rem 0.7rem; font-size: 0.8rem; }
.btn.join-cta {
  background: var(--accent);
  color: #fff;
  min-height: 2.7rem;
}
.ranks-fixed {
  flex: 0 0 auto;
  max-height: none;
  overflow: visible;
}
.ranks-fixed h2 {
  margin: 0 0 0.25rem;
  font-family: var(--pixel);
  font-size: 1.05rem;
}
.side { display: flex; flex-direction: column; gap: 0.75rem; }
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.85rem;
}
.panel h2 {
  margin: 0 0 0.6rem;
  font-family: var(--pixel);
  font-size: 1.05rem;
}
.board, .feed { list-style: none; margin: 0; padding: 0; }
.board li {
  border-bottom: 1px solid #1c243c;
  padding: 0;
}
.board li:last-child { border-bottom: 0; }
.rank-card {
  display: grid;
  grid-template-columns: 2.1rem 2.7rem 1fr auto;
  gap: 0.55rem;
  align-items: center;
  padding: 0.72rem 0.15rem;
  min-height: 3.6rem;
  color: inherit;
  text-decoration: none;
  border-radius: 10px;
}
a.rank-card:hover, a.rank-card:focus-visible {
  background: #1a223c;
}
.board .rank-n {
  width: 2.05rem;
  height: 2.05rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.18);
}
.who .crown {
  font-size: 0.95rem;
  margin-right: 0.15rem;
}
.feed li {
  display: grid;
  grid-template-columns: 1.5rem 1.6rem 1fr auto;
  gap: 0.4rem;
  align-items: center;
  padding: 0.35rem 0;
  border-bottom: 1px solid #1c243c;
}
.board button, .feed button {
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.board .px { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--warn); white-space: nowrap; }
.who { display: flex; flex-direction: column; gap: 0.12rem; min-width: 0; }
.who button, .who .name { font-weight: 800; font-size: 1.02rem; }
.tag, .clicks {
  color: var(--mute);
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.clicks { color: #9ad4ff; display: block; }
.avatar {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  overflow: hidden;
  flex: none;
}
.board .avatar {
  width: 2.7rem;
  height: 2.7rem;
  border-radius: 8px;
  font-size: 1.35rem;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.crown { color: var(--warn); }
.btn {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.btn:focus-visible, .icon-btn:focus-visible, a:focus-visible, button:focus-visible {
  outline: 3px solid var(--warn);
  outline-offset: 2px;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.blast {
  position: absolute;
  right: 0.7rem;
  bottom: 0.7rem;
  z-index: 5;
  background: var(--accent-2);
  color: #071018;
  min-width: unset;
  min-height: 2.15rem;
  padding: 0.35rem 1rem;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 800;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}
.map-wrap.has-player .map-hud { display: none; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.icon-btn {
  background: #1a223c;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 999px;
  width: 2.4rem;
  height: 2.4rem;
  cursor: pointer;
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 16, 0.72);
  display: grid;
  place-items: center;
  z-index: 40;
  padding: 1rem;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.2rem;
  width: min(28rem, 100%);
  max-height: 90svh;
  overflow: auto;
  box-shadow: var(--shadow);
}
label { display: block; margin: 0.55rem 0; font-weight: 700; }
input, select {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0d1324;
  color: var(--ink);
  font: inherit;
}
.palette { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.palette button {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
}
.palette button.on { border-color: #fff; }
.palette button.taken { opacity: 0.35; }
.palette button.taken::after { content: ""; }
.packs { display: grid; gap: 0.5rem; margin: 0.8rem 0; }
.pack {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #10162a;
  color: inherit;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  width: 100%;
  transition: background 0.12s ease, color 0.12s ease, transform 0.08s ease, border-color 0.12s ease;
}
.pack:hover { border-color: var(--accent); }
.pack:active, .pack.on {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: scale(0.98);
  box-shadow: 0 8px 18px rgba(255, 59, 107, 0.28);
}
footer {
  padding: 1.2rem;
  color: var(--mute);
  text-align: center;
  margin-top: auto;
  flex-shrink: 0;
}
.page {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.2rem 1rem 3rem;
  line-height: 1.55;
}
.page h1 { font-family: var(--pixel); margin: 0; }
.page-head {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 0 0 1rem;
}
.page-head .back-map {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
}
.king-day {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.38rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  width: fit-content;
  max-width: 100%;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--mute);
}
.king-day[hidden] { display: none; }
a.king-day { text-decoration: none; }
a.king-day:hover { color: var(--ink); }
.king-day .crown { font-size: 0.9rem; }
.king-day .name { color: var(--ink); font-weight: 800; }
.color-locked {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0.7rem 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #10162a;
}
.color-locked .swatch {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 8px;
  flex: none;
  border: 2px solid rgba(255,255,255,0.25);
}
.color-locked small { display: block; color: var(--mute); font-weight: 650; }
.color-any { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.45rem; }
.color-any input[type="color"] {
  width: 2.4rem;
  height: 2rem;
  padding: 0;
  border: 0;
  background: none;
}
.logo-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.logo-prev {
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0d1324;
}
.logo-prev img { width: 100%; height: 100%; object-fit: cover; }
.file-name { display: block; color: var(--mute); font-size: 0.82rem; font-weight: 650; margin-top: 0.2rem; }
label.check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
  margin: 0.55rem 0 0.8rem;
}
label.check input { width: auto; margin: 0; }
.notify-bar {
  margin: 0 0.7rem 0.8rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}
.notify-bar[hidden] { display: none; }
.notify-bar p { margin: 0 0 0.55rem; }
.notify-actions { display: flex; gap: 0.5rem; justify-content: flex-end; flex-wrap: wrap; }
.you-row { display: flex; gap: 0.6rem; align-items: center; }
.delta.up { color: #7dff4d; }
.delta.down { color: var(--accent); }
.sheets { display: none; }
.side #youPanel, .side #feedPanel { display: none; }
.side.show-you #youPanel,
.side.show-feed #feedPanel { display: block; }
body.play footer { display: block; padding-bottom: 1.5rem; }
@media (max-width: 900px) {
  .top { padding: 0.32rem 0.45rem 0.38rem; gap: 0.4rem; }
  .tagline { display: none; }
  .brand .wordmark { display: inline; font-size: 1.08rem; }
  .balance {
    font-size: 0.66rem;
    max-width: 11.5rem;
  }
  .head-icons { gap: 0.28rem; }
  .head-icons .ico { width: 2.35rem; height: 2.35rem; }
  .rule { font-size: 0.8rem; padding: 0.22rem 0.5rem; }
  .stage {
    height: auto;
    padding: 0.35rem 0.4rem 1.4rem;
    gap: 0.4rem;
  }
  .map-wrap {
    width: 100%;
    aspect-ratio: 3 / 2;
    min-height: 0;
  }
  .ranks-fixed { max-height: none; overflow: visible; padding: 0.55rem 0.65rem; }
  .ranks-fixed h2 { font-size: 0.95rem; }
  .rank-card { padding: 0.78rem 0.1rem; gap: 0.5rem; min-height: 3.8rem; }
  .board .clicks { display: block; }
  .map-hud { padding: 0.45rem 0.5rem; }
  .btn.join-cta {
    width: 100%;
    min-height: 2.5rem;
    font-size: 0.95rem;
  }
  .btn.blast {
    width: auto;
    min-height: 2.2rem;
    font-size: 0.95rem;
    bottom: 0.55rem;
    right: 0.55rem;
  }
  .how {
    left: 0.45rem;
    bottom: 3.1rem;
    max-width: calc(100% - 0.9rem);
    padding: 0.55rem 0.7rem;
  }
  .how li { font-size: 0.82rem; }
  .btn.buy-fab { right: 5.1rem; bottom: 0.55rem; min-height: 2.2rem; }
  .bomb-timer { top: 0.4rem; font-size: 0.68rem; }
  .sheets { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
