:root {
  --bg: #10151f;
  --panel: #171e2c;
  --panel-2: #131a26;
  --line: #262f44;
  --text: #eceff5;
  --text-muted: #8a93a6;
  --gold: #f5a623;
  --silver: #c7ccd6;
  --bronze: #c98a4b;
  --pulse: #ff5d73;
  --font-ui: "Space Grotesk", system-ui, sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  min-height: 100vh;
  touch-action: manipulation;
}

button,
input {
  font-family: inherit;
  touch-action: manipulation;
}

a {
  color: var(--text-muted);
  text-decoration: none;
}
a:hover,
a:focus-visible {
  color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 1.75rem 0 1.25rem;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.wordmark {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  color: var(--text);
}

.tagline {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.about-link {
  font-size: 0.9rem;
}

.stage {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 2.5rem;
  padding: 2.5rem 0 3rem;
  align-items: start;
}

@media (max-width: 860px) {
  .stage {
    grid-template-columns: 1fr;
  }
}

.arena {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 3rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: 440px;
  justify-content: center;
}

/* --- name entry --- */

.entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  max-width: 420px;
}

.entry-title {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.entry-copy {
  color: var(--text-muted);
  margin: 0 0 0.5rem;
  line-height: 1.5;
  font-size: 0.95rem;
}

.name-input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 0.85rem 1rem;
  font-size: 1rem;
}

.name-input::placeholder {
  color: var(--text-muted);
}

.start-btn {
  width: 100%;
  background: var(--gold);
  color: #1a1204;
  border: none;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
}

.start-btn:hover {
  filter: brightness(1.08);
}

.start-btn:active {
  transform: scale(0.98);
}

.start-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.entry-error {
  color: var(--pulse);
  font-size: 0.88rem;
  margin: 0;
}

/* --- play view --- */

.play {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.75rem;
}

.player {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.player .flag {
  border-radius: 2px;
  display: block;
}

.player-name {
  color: var(--text);
  font-weight: 600;
}

.player-rank {
  font-family: var(--font-num);
  color: var(--gold);
  font-weight: 600;
}

.orb {
  position: relative;
  width: min(240px, 55vw);
  height: min(240px, 55vw);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #23304a, var(--panel-2) 70%);
  box-shadow: 0 0 0 2px var(--line), 0 0 60px -12px rgba(245, 166, 35, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  transition: transform 0.06s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.orb:hover {
  box-shadow: 0 0 0 2px var(--gold), 0 0 70px -10px rgba(245, 166, 35, 0.6);
}

.orb:active,
.orb.is-pressed {
  transform: scale(0.94);
}

.count {
  font-family: var(--font-num);
  font-size: clamp(2.4rem, 8vw, 3.4rem);
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.orb-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

.hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0;
}

.pop {
  position: absolute;
  font-family: var(--font-num);
  font-weight: 600;
  color: var(--gold);
  font-size: 1rem;
  pointer-events: none;
  animation: pop-float 0.6s ease-out forwards;
}

@keyframes pop-float {
  0% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -46px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pop {
    animation: none;
    display: none;
  }
  .orb {
    transition: none;
  }
}

/* --- leaderboard --- */

.board {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1.5rem;
}

.board-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.board-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

.tab-group {
  display: flex;
  gap: 1rem;
}

.tab-group-secondary {
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0 0 0.55rem;
  cursor: pointer;
}

.tab:hover {
  color: var(--text);
}

.tab.is-active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.board-head .tab {
  font-size: 0.8rem;
  padding-bottom: 0.15rem;
}

.who-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.who-meta {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.board-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.board-row {
  display: grid;
  grid-template-columns: 1.6rem 1fr auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.4rem;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
}

.board-row:last-child {
  border-bottom: none;
}

.board-row.rank-1 {
  border-left-color: var(--gold);
}
.board-row.rank-2 {
  border-left-color: var(--silver);
}
.board-row.rank-3 {
  border-left-color: var(--bronze);
}

.board-row.is-me {
  background: rgba(245, 166, 35, 0.08);
  border-radius: 6px;
}

.rank-num {
  font-family: var(--font-num);
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: right;
}

.board-row.rank-1 .rank-num {
  color: var(--gold);
}

.who {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.who .flag {
  flex: none;
  border-radius: 2px;
}

.who-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.92rem;
}

.score {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
  color: var(--text);
}

.board-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.doc {
  flex: 1;
  max-width: 640px;
  padding: 2.5rem 0 3rem;
  line-height: 1.65;
}

.doc h1 {
  font-size: clamp(1.6rem, 3vw, 2rem);
  margin: 0 0 1rem;
}

.doc h2 {
  font-size: 1.1rem;
  margin: 2rem 0 0.6rem;
  color: var(--text);
}

.doc p,
.doc li {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.doc a {
  color: var(--gold);
}

.footer {
  display: flex;
  gap: 1.25rem;
  padding: 1.5rem 0 2rem;
  font-size: 0.85rem;
}
