:root {
  --bg: #0a0c10;
  --surface: #171c25;
  --text: #eef2f6;
  --muted: #9aa8b8;
  --accent: #e8b84a;
  --deep: #3d8f9e;
  --border: #2a3340;
  --ember: #c45c3a;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(61, 143, 158, 0.18), transparent 55%),
    var(--bg);
  line-height: 1.5;
}

.shell {
  max-width: 64rem;
  margin: 0 auto;
  padding: 1rem 1rem 2.5rem;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.titles { text-align: center; flex: 1; }
.titles h1 { margin: 0; font-size: clamp(1.25rem, 3vw, 1.75rem); }
.tag {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--deep);
}

.back {
  color: #8ec8e0;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  min-width: 4.5rem;
}
.back:hover { color: var(--accent); }
.home { text-align: right; }

.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1.1rem;
  justify-content: center;
  margin-bottom: 0.65rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.hud strong {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.stage-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: #0d1218;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(6, 8, 12, 0.8);
  padding: 1rem;
  overflow-y: auto;
}
.overlay.hidden { display: none; }

.panel {
  max-width: 24rem;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem 1.15rem;
  text-align: center;
}

.panel h2 { margin: 0 0 0.45rem; font-size: 1.3rem; }
.panel p { margin: 0 0 0.75rem; color: var(--muted); font-size: 0.95rem; }

.mode-pick { display: grid; gap: 0.5rem; margin-bottom: 0.85rem; }
.mode-label {
  margin: 0 0 0.15rem !important;
  font-size: 0.8rem !important;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--deep) !important;
}

.btn-mode {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  background: #121820;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.btn-mode span {
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--muted);
}
.btn-mode:hover,
.btn-mode:focus-visible {
  border-color: var(--deep);
  outline: none;
}

.controls {
  list-style: none;
  margin: 0 0 0.85rem;
  padding: 0;
  color: var(--muted);
  font-size: 0.86rem;
  text-align: left;
}
.controls li { margin: 0.22rem 0; }
kbd {
  display: inline-block;
  padding: 0.08rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #0f141c;
  color: var(--text);
  font-size: 0.78rem;
}

.exit-times {
  text-align: left;
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0 0 0.85rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  background: #0f141c;
  border: 1px solid var(--border);
}
.exit-times strong { color: var(--accent); }

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.4rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  color: #111;
  background: var(--accent);
}
.btn:hover { filter: brightness(1.06); }
.btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.btn[hidden] { display: none !important; }

.touch {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin-top: 0.75rem;
}
.touch button {
  min-height: 2.85rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.touch button:active { background: #243040; }

@media (max-width: 720px), (pointer: coarse) {
  .touch:not([hidden]) { display: grid; }
}

.ladder {
  margin-top: 1.5rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(23, 28, 37, 0.85);
}
.ladder h2 { margin: 0 0 0.65rem; font-size: 1.1rem; }
.ladder h3 {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  color: var(--deep);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.ladder-cols {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.ladder-cols-3 {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.ladder-sub {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.week-box {
  text-align: left;
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f141c;
}
.week-list {
  margin: 0.35rem 0 0;
  padding-left: 1.15rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.week-list li { margin: 0.25rem 0; }
.week-list .done { color: #7dcea0; }
.week-list .miss { color: var(--muted); }

.toast {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  z-index: 5;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  background: rgba(15, 20, 28, 0.92);
  border: 1px solid var(--deep);
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.toast[hidden] { display: none !important; }

.hud-week strong { color: var(--deep); }

.initials-box {
  margin: 0 0 0.85rem;
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0f141c;
}
.initials-hint {
  margin: 0.25rem 0 0.65rem !important;
  font-size: 0.82rem !important;
  color: var(--muted) !important;
}
.initials-row {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 0.5rem;
}
.init-slot {
  width: 3rem;
  height: 3.25rem;
  border-radius: 10px;
  border: 2px solid var(--deep);
  background: #121820;
  color: var(--accent);
  font-size: 1.6rem;
  font-weight: 800;
  font-family: "Segoe UI", system-ui, monospace;
  cursor: pointer;
  line-height: 1;
}
.init-slot:hover,
.init-slot:focus-visible {
  border-color: var(--accent);
  outline: none;
}
.init-slot.active {
  box-shadow: 0 0 0 2px var(--accent);
}

.board {
  font-variant-numeric: tabular-nums;
  font-family: "Segoe UI", system-ui, monospace;
}
.board li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.2rem 0;
  border-bottom: 1px solid rgba(42, 51, 64, 0.6);
}
.board .tag-name {
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.08em;
  min-width: 2.4rem;
}
.board .rank {
  color: var(--muted);
  min-width: 1.5rem;
}
.muted { color: var(--muted); font-weight: 500; font-size: 0.9rem; }
.ladder ol {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text);
  font-size: 0.92rem;
}
.ladder li { margin: 0.25rem 0; font-variant-numeric: tabular-nums; }
.ladder .empty {
  color: var(--muted);
  list-style: none;
  margin-left: -1.2rem;
}
.hint {
  margin: 0.85rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}
