:root {
  --bg: #111214;
  --bg-elevated: #191b1e;
  --surface: #242629;
  --accent: #8a9bae;
  --accent-dim: #5a6a7a;
  --text: #c8ccd2;
  --text-dim: #6b7280;
  --text-bright: #eef0f4;
  --red: #c0392b;
  --red-glow: #e74c3c;
  --green: #5ea65e;
}

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

body {
  font-family: "DM Sans", sans-serif;
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 32px 20px;
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(138, 155, 174, 0.04) 0%, transparent 60%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
  pointer-events: none;
  z-index: 9999;
}

#app {
  width: 100%;
  max-width: 1000px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

/* ---- Header ---- */

.header h1 {
  font-family: "DM Sans", sans-serif;
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--text-bright);
  text-transform: uppercase;
}

/* ---- Start Screen ---- */

.start-screen {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 28px;
  align-items: center;
  animation: fadeUp 0.6s ease-out both;
}

.start-screen p {
  color: var(--text-dim);
  max-width: 420px;
  line-height: 1.7;
  font-size: 1.05rem;
  font-weight: 400;
}

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

.hud {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: fadeUp 0.3s ease-out both;
}

.timer-ring-container {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-ring {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}

.timer-ring-track {
  fill: none;
  stroke: var(--surface);
  stroke-width: 3;
}

.timer-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
}

.timer-ring-fill.urgent {
  stroke: var(--red-glow);
}

.prompt {
  font-family: "DM Mono", monospace;
  font-size: 2rem;
  font-weight: 500;
  color: var(--text-bright);
  letter-spacing: 0.05em;
  position: relative;
  z-index: 1;
}

.hud-bar {
  display: flex;
  align-items: center;
  gap: 20px;
}

.strikes {
  display: flex;
  gap: 8px;
}

.strike {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--text-dim);
  transition: all 0.3s ease;
}

.strike.used {
  background: var(--red);
  border-color: var(--red);
  box-shadow: 0 0 8px rgba(192, 57, 43, 0.4);
}

.score-display {
  font-family: "DM Sans", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.message {
  font-family: "DM Sans", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  min-height: 1.4em;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: opacity 0.2s ease;
}

.message.correct {
  color: var(--green);
}

.message.wrong {
  color: var(--red-glow);
}

/* ---- Board ---- */

.board-container {
  width: 100%;
  max-width: 900px;
  animation: fadeUp 0.5s ease-out 0.1s both;
}

.shudan-goban {
  --shudan-board-border-width: 0.3em;
  --shudan-board-border-color: #a07c28;
  --shudan-board-background-color: #d4a843;
  --shudan-board-foreground-color: #6b4513;
  --shudan-black-background-color: #1a1a1a;
  --shudan-black-foreground-color: #eee;
  --shudan-white-background-color: #f8f5ee;
  --shudan-white-foreground-color: #222;
}

.shudan-vertex:hover {
  cursor: pointer;
}

/* ---- Game Over ---- */

.game-over {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
  animation: fadeUp 0.5s ease-out both;
}

.final-score {
  font-family: "DM Sans", sans-serif;
  font-size: 4rem;
  font-weight: 800;
  color: var(--text-bright);
}

.final-score span {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.rank-info {
  color: var(--text-dim);
  font-size: 1rem;
  font-weight: 500;
}

.name-input {
  display: flex;
  gap: 10px;
  align-items: center;
}

.name-input input {
  font-family: "DM Mono", monospace;
  background: var(--bg);
  border: 1px solid var(--surface);
  color: var(--text-bright);
  padding: 10px 14px;
  font-size: 0.95rem;
  width: 180px;
  transition: border-color 0.2s ease;
}

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

.name-input input:focus {
  outline: none;
  border-color: var(--accent-dim);
}

/* ---- Buttons ---- */

.btn {
  font-family: "DM Sans", sans-serif;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.1em;
  background: var(--text-bright);
  color: var(--bg);
  border: 2px solid var(--text-bright);
  padding: 10px 32px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
}

.btn:hover {
  background: transparent;
  color: var(--text-bright);
}

.btn-ghost {
  background: transparent;
  border-color: var(--surface);
  color: var(--text-dim);
}

.btn-ghost:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--surface);
}

/* ---- Leaderboard ---- */

.leaderboard {
  width: 100%;
  max-width: 380px;
  animation: fadeUp 0.5s ease-out 0.2s both;
}

.leaderboard h2 {
  font-family: "DM Sans", sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 16px;
  text-align: center;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.leaderboard table {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard th,
.leaderboard td {
  padding: 8px 12px;
  text-align: left;
  font-size: 0.85rem;
}

.leaderboard th {
  color: var(--text-dim);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-bottom: 2px solid var(--surface);
}

.leaderboard td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  font-family: "DM Mono", monospace;
  font-size: 0.8rem;
}

.leaderboard .rank {
  color: var(--text-dim);
  width: 36px;
}

.leaderboard .name {
  color: var(--text);
}

.leaderboard .score {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--accent-dim);
}

.leaderboard tbody tr {
  transition: background 0.15s ease;
}

.leaderboard tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* ---- Animations ---- */

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
