:root {
  --bg: #0b1020;
  --board-bg: #0e1426;
  --panel: #141a2e;
  --border: #232b45;
  --border-strong: #2c3554;
  --line: #1f2740;
  --text: #e6e9f2;
  --text-2: #c7cee0;
  --muted: #9aa3b8;
  --faint: #8a93ab;
  --dim: #6b7593;
  --accent: #38bdf8;
  --danger: #f87171;
  --display: 'Space Grotesk', system-ui, sans-serif;
  --sans: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text-2); text-decoration: none; }
a:hover { color: #fff; }

button { font-family: var(--sans); }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

kbd {
  display: inline-block;
  min-width: 24px;
  padding: 3px 6px;
  text-align: center;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  font: 12px var(--sans);
  color: var(--text);
}

/* ───────── boot / errors ───────── */

.boot {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--muted);
  font-size: 14px;
}
.boot .logo-mark { transform: scale(2); animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse { 50% { opacity: 0.4; } }

#blazor-error-ui {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 12px 20px;
  background: #3b1520;
  color: #fff;
}
#blazor-error-ui .reload { color: #fff; text-decoration: underline; margin-left: 8px; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 16px; }

/* ───────── layout ───────── */

.page { min-height: 100vh; display: flex; flex-direction: column; }

.site-header { border-bottom: 1px solid var(--line); }
.site-header .inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo { display: flex; align-items: center; gap: 10px; color: var(--text); }
.logo:hover { color: var(--text); }
.logo-text { font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: 0.08em; }
.logo-mark { display: grid; grid-template-columns: repeat(3, 10px); grid-auto-rows: 10px; gap: 2px; }
.logo-mark i { display: block; border-radius: 2px; background: #a855f7; }

.site-nav { display: flex; flex-wrap: wrap; gap: 28px; font-size: 15px; font-weight: 500; }
.site-nav a.active { color: #fff; }
.site-nav { margin-left: auto; }

.lang-switch { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lang-switch button {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font: 600 12px/1 var(--display, inherit); letter-spacing: 0.06em; padding: 7px 9px;
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button[aria-pressed="true"] { background: var(--panel); color: var(--accent); }

.site-main { flex-grow: 1; }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 18px 24px;
  text-align: center;
  font-size: 13px;
  color: var(--faint);
}

/* ───────── shared bits ───────── */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.panel.lg { padding: 16px 18px; }

.label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.label .hint { color: var(--dim); text-transform: none; letter-spacing: 0; font-weight: 500; }

.value {
  font-family: var(--display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}
.value.xl { font-size: 36px; }
.value.lg { font-size: 26px; }
.value.md { font-size: 18px; margin-top: 0; }
.value .of { font-size: 16px; color: var(--muted); font-weight: 500; }

.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.btn {
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  text-align: center;
}
.btn:hover:not(:disabled) { background: #1a2139; color: var(--text); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { border: 0; background: var(--accent); color: var(--bg); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); color: var(--bg); }
.btn.link { border: 0; color: var(--text-2); }
.btn.link:hover { background: transparent; color: #fff; }
.btn.square { width: 48px; padding: 0; flex: 0 0 auto; }
.btn.block { width: 100%; }

/* ───────── game page ───────── */

.play { display: flex; flex-direction: column; }

.game {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 24px;
  padding: 40px 24px;
}

.side { width: 220px; display: flex; flex-direction: column; gap: 12px; transition: opacity 0.2s; }
.side.dimmed { opacity: 0.5; }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.actions .row { display: flex; gap: 8px; }
.actions .row .btn:first-child { flex-grow: 1; }

.center { display: flex; gap: 10px; justify-content: center; }

.board-wrap {
  position: relative;
  background: var(--board-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
}

.board { display: block; width: 318px; height: 638px; }

.preview-next { display: block; width: 100px; height: 162px; margin: 14px auto 0; }
.preview-hold { display: block; width: 100px; height: 42px; margin: 14px auto 0; }

.controls { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; font-size: 14px; color: var(--text-2); }
.controls > div { display: flex; justify-content: space-between; align-items: center; }
.controls .keys { display: flex; gap: 4px; }

.clear-popup {
  position: absolute;
  left: 50%;
  top: 26%;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(168, 85, 247, 0.16);
  border: 1px solid rgba(168, 85, 247, 0.45);
  color: #e9d5ff;
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  pointer-events: none;
  animation: popup 1.6s ease-out forwards;
}

@keyframes popup {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(0.92); }
  12% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -12px); }
}

/* overlays on the board */

.overlay {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background: rgba(11, 16, 32, 0.84);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.dialog {
  width: 100%;
  margin: auto;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 26px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.dialog h1 { margin: 0; font-family: var(--display); font-size: 30px; font-weight: 700; }
.dialog .sub { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.dialog .hint { margin: 12px 0 0; font-size: 13px; color: var(--faint); }
.dialog .stack { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 18px; }

.pause-icon {
  width: 56px;
  height: 56px;
  margin-bottom: 8px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modes { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 18px; }
.mode {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--board-bg);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.mode strong { font-size: 15px; font-weight: 600; }
.mode span { font-size: 13px; color: var(--muted); }
.mode.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.final-label { margin-top: 18px; }
.final-value { font-family: var(--display); font-size: 48px; font-weight: 700; line-height: 1.1; color: var(--accent); font-variant-numeric: tabular-nums; }
.final-rank { margin-top: 4px; font-size: 13px; color: var(--muted); }
.final-rank.new { color: #facc15; font-weight: 600; }

.final-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; width: 100%; margin-top: 16px; }
.final-stats > div { background: var(--board-bg); border-radius: 8px; padding: 8px 4px; }
.final-stats .k { font-size: 11px; color: var(--muted); }
.final-stats .v { font-weight: 600; font-size: 16px; font-variant-numeric: tabular-nums; }

.save-form { width: 100%; margin-top: 18px; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.save-form label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.save-form .row { display: flex; gap: 6px; }
.save-form input {
  flex-grow: 1;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--board-bg);
  color: var(--text);
  font: 400 15px var(--sans);
}
.save-form input::placeholder { color: #7d87a3; }
.save-form button {
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #1d2540;
  color: var(--text);
  font: 600 14px var(--sans);
  cursor: pointer;
}
.saved-note { margin-top: 18px; font-size: 14px; color: #4ade80; }

/* mobile-only parts */

.mobile-bar, .mobile-stats, .mobile-side, .touch { display: none; }

@media (max-width: 760px) {
  .page:has(.play) .site-header,
  .page:has(.play) .site-footer { display: none; }

  .play {
    min-height: 100vh;
    min-height: 100dvh;
    padding: 16px 16px max(24px, env(safe-area-inset-bottom));
    gap: 14px;
    max-width: 430px;
    margin: 0 auto;
  }

  .mobile-bar { display: flex; align-items: center; justify-content: space-between; }
  .mobile-bar .logo-text { font-size: 20px; }
  .mobile-bar .btn { width: 44px; height: 44px; padding: 0; }

  .mobile-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .mobile-stats .panel { border-radius: 10px; padding: 8px 12px; }
  .mobile-stats .label { font-size: 11px; }
  .mobile-stats .value { font-size: 20px; margin-top: 0; }

  .game { padding: 0; gap: 0; }
  .side { display: none; }

  .board-wrap { border-radius: 12px; padding: 6px; }
  .overlay { border-radius: 12px; padding: 10px; }
  .dialog { padding: 20px 14px; }
  .dialog h1 { font-size: 26px; }
  .final-value { font-size: 38px; }
  .board { width: min(248px, calc(100vw - 32px - 12px - 86px)); height: auto; aspect-ratio: 248 / 498; }

  .mobile-side { display: flex; flex-direction: column; gap: 8px; width: 76px; }
  .mobile-side .panel {
    border-radius: 10px;
    padding: 10px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    font: 600 11px var(--sans);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .mobile-side button.panel { cursor: pointer; touch-action: manipulation; }
  .mobile-side canvas[data-role="next"] { width: 64px; height: 104px; }
  .mobile-side canvas[data-role="hold"] { width: 64px; height: 28px; }

  .touch { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
  .touch .row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
  .touch button {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: var(--panel);
    color: var(--text);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }
  .touch button.pressed { background: #1f2742; }
  .touch .drop { height: 52px; border: 0; background: var(--accent); color: var(--bg); font: 600 16px var(--sans); }
  .touch .drop.pressed { background: var(--accent); filter: brightness(0.9); }
}

/* ───────── content pages ───────── */

.content { max-width: 1040px; margin: 0 auto; padding: 48px 24px; display: flex; flex-direction: column; gap: 24px; }
.content h1 { margin: 0; font-family: var(--display); font-size: 40px; font-weight: 700; }
.content h2 { margin: 0 0 12px; font-family: var(--display); font-size: 22px; font-weight: 700; }
.content .lead { margin: 6px 0 0; font-size: 15px; color: var(--muted); }
.content p, .content li { color: var(--text-2); line-height: 1.6; font-size: 15px; }
.content ul { margin: 0; padding-left: 20px; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }

.tabs { display: flex; gap: 4px; padding: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.tabs button {
  height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font: 500 14px var(--sans);
  cursor: pointer;
}
.tabs button[aria-selected="true"] { background: #2a3354; color: #fff; font-weight: 600; }

.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; overflow-x: auto; }
table.scores { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 15px; }
table.scores th {
  padding: 16px 8px;
  text-align: right;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
table.scores td { padding: 12px 8px; text-align: right; color: var(--text-2); border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
table.scores th:first-child, table.scores td:first-child { padding-left: 20px; text-align: left; width: 56px; }
table.scores th:nth-child(2), table.scores td:nth-child(2) { text-align: left; }
table.scores th:last-child, table.scores td:last-child { padding-right: 20px; }
table.scores td.name { color: var(--text); font-weight: 500; }
table.scores td.main { color: var(--text); font-family: var(--display); font-weight: 700; font-size: 17px; }
table.scores td.date { color: var(--muted); }
table.scores tr.latest { background: rgba(56, 189, 248, 0.08); box-shadow: inset 3px 0 0 var(--accent); }
table.scores .empty { text-align: center; color: var(--muted); padding: 32px; }

.rank {
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-2);
}
.rank.r1 { background: #facc15; color: var(--bg); font-weight: 700; }
.rank.r2 { background: #cbd5e1; color: var(--bg); font-weight: 700; }
.rank.r3 { background: #fb923c; color: var(--bg); font-weight: 700; }

.center-row { display: flex; justify-content: center; }
.note { font-size: 13px; color: var(--faint); text-align: center; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.cards .panel { padding: 20px 22px; }

.keys-table { display: flex; flex-direction: column; gap: 10px; font-size: 15px; color: var(--text-2); }
.keys-table > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.keys-table .keys { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

.setting { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.setting .top { display: flex; justify-content: space-between; font-size: 14px; color: var(--text-2); }
.setting .top strong { color: var(--text); font-variant-numeric: tabular-nums; }
.setting input[type="range"] { width: 100%; accent-color: var(--accent); }
.setting small { color: var(--faint); font-size: 12px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); margin-bottom: 12px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

@media (max-width: 760px) {
  .content { padding: 32px 16px; }
  .content h1 { font-size: 32px; }
  .site-nav { gap: 18px; }
}

.row-links { display: flex; justify-content: center; gap: 4px; }
.row-links .btn { height: 40px; padding: 0 12px; font-size: 14px; }

/* ───────── replay viewer ───────── */

.replay-name { margin-top: 6px; font-weight: 600; font-size: 15px; }
.replay-title { font-size: 13px; color: var(--muted); }

.replay-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: 760px;
  width: calc(100% - 48px);
  margin: -16px auto 40px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.replay-bar input[type="range"] { flex: 1 1 200px; accent-color: var(--accent); }
.replay-time { font-size: 14px; color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 92px; text-align: center; }
.replay-bar .speeds button { height: 36px; padding: 0 10px; }

@media (max-width: 760px) {
  .replay-bar { width: 100%; margin: 0; padding: 8px; gap: 8px; }
  .replay .touch { display: none; }
}

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
table.scores td.play-cell { width: 48px; }
.replay-link {
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  color: var(--text-2);
}
.replay-link:hover { border-color: var(--accent); color: var(--accent); }
.saved-note.warn { color: #facc15; font-size: 13px; }

.tab-groups { display: flex; flex-wrap: wrap; gap: 10px; }
table.scores td.gap { text-align: center; color: var(--dim); letter-spacing: 0.3em; padding: 6px 20px; }
table.scores .real-name { color: var(--muted); font-weight: 400; }

/* ───────── online: lobby ───────── */

.online-name { display: flex; flex-direction: column; gap: 8px; max-width: 480px; }
.online-name .row { display: flex; gap: 10px; align-items: center; }
.online input[type="text"], .select {
  height: 44px;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--board-bg);
  color: var(--text);
  font: 400 15px var(--sans);
}
.online-name input { flex: 1; }
.select { width: 100%; margin-top: 8px; height: 40px; font-size: 14px; }
.elo-chip { padding: 8px 12px; border-radius: 999px; background: var(--board-bg); border: 1px solid var(--border); font-size: 13px; color: var(--muted); white-space: nowrap; }
.elo-chip strong { color: var(--text); }

.mode-card { display: flex; flex-direction: column; gap: 8px; }
.mode-card h2 { margin: 4px 0 0; }
.mode-card p { margin: 0; flex: 1; }
.mode-card .stack { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.badge { align-self: flex-start; padding: 3px 10px; border-radius: 999px; background: #2a3354; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; color: #fff; }
.badge.muted { background: var(--board-bg); color: var(--muted); }

.room-code { color: var(--accent); }
table.members { min-width: 480px; }
table.members td:nth-child(3), table.members th:nth-child(3) { text-align: right; }
.tag { margin-left: 8px; padding: 2px 8px; border-radius: 999px; background: var(--board-bg); border: 1px solid var(--border); font-size: 11px; color: var(--muted); font-weight: 500; }
.ready { color: var(--muted); }
.ready.on { color: #4ade80; font-weight: 600; }
tr.empty-slot td { color: var(--dim); }
.lobby-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.form-error { color: var(--danger); text-align: center; margin: 0; }

/* ───────── online: in game ───────── */

.game-bar {
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px 24px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-2);
}
.chip strong { color: #fff; font-weight: 600; }
.chip.strong { background: #2a3354; border-color: #2a3354; color: #fff; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; }
.num { font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #4ade80; }
.dot.off { background: var(--danger); }
.btn.small { height: 36px; padding: 0 14px; font-size: 14px; }
.muted { color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }

.board-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 26px; font-size: 14px; }
.board-head .who { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.incoming-text { color: var(--danger); font-size: 13px; font-weight: 500; }
.with-meter { display: flex; gap: 6px; align-items: stretch; }
.meter { width: 9px; border-radius: 6px; background: var(--panel); border: 1px solid var(--border); display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; }
.meter div { background: var(--danger); transition: height 0.15s; }
.board-wrap.accent { border: 2px solid var(--accent); }
.my-board, .opp-board { display: flex; flex-direction: column; gap: 8px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: #fb923c; color: var(--bg); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; font-style: normal; text-transform: uppercase; }

.overlay.soft { background: rgba(11, 16, 32, 0.6); }
.overlay.countdown { background: rgba(11, 16, 32, 0.55); }
.count { font-family: var(--display); font-size: 96px; font-weight: 700; color: var(--accent); animation: pulse 1s ease-in-out infinite; }
.ko { font-family: var(--display); font-size: 22px; font-weight: 700; color: var(--danger); }
ol.places { list-style: none; padding: 0; margin: 14px 0 0; width: 100%; display: flex; flex-direction: column; gap: 4px; text-align: left; }
ol.places li { padding: 8px 12px; border-radius: 8px; background: var(--board-bg); font-size: 14px; color: var(--text-2); }
ol.places li span { display: inline-block; width: 28px; font-weight: 700; color: var(--text); }
ol.places li.me { box-shadow: inset 3px 0 0 var(--accent); color: var(--text); }

/* duel */
.duel { max-width: 1320px; margin: 0 auto; padding: 24px; display: flex; flex-wrap: nowrap; justify-content: center; align-items: flex-start; gap: 20px; overflow-x: auto; }
.duel-pieces { flex: 0 0 100px; display: flex; flex-direction: column; gap: 12px; padding-top: 34px; }
.duel-pieces .panel { padding: 12px 8px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.duel-pieces canvas[data-role="next"] { width: 80px; height: 126px; }
.duel-pieces canvas[data-role="hold"] { width: 80px; height: 34px; }
.duel .my-board .board { width: clamp(240px, 24vw, 330px); height: auto; aspect-ratio: 318 / 638; }
.duel .opp-board .board { width: clamp(200px, 19vw, 270px); height: auto; aspect-ratio: 318 / 638; }
.duel-center { flex: 0 0 220px; display: flex; flex-direction: column; gap: 16px; padding-top: 34px; }
.score-box { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 16px; }
.versus { display: flex; align-items: center; gap: 14px; font-family: var(--display); font-weight: 700; }
.versus span { font-size: 44px; }
.versus .mine { color: var(--accent); }
.versus .theirs { color: #fb923c; }
.versus small { font-size: 18px; color: var(--dim); }
.dots { display: flex; justify-content: space-between; width: 100%; }
.dots span { display: flex; gap: 4px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--border-strong); }
.dots i.mine { background: var(--accent); border-color: var(--accent); }
.dots i.theirs { background: #fb923c; border-color: #fb923c; }
.timer { font-size: 15px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.compare { display: flex; flex-direction: column; gap: 14px; }
.cmp { display: flex; flex-direction: column; gap: 6px; }
.cmp-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; font-variant-numeric: tabular-nums; }
.cmp-top span { font-size: 12px; color: var(--muted); }
.cmp-bar { display: flex; gap: 2px; height: 6px; }
.cmp-bar i { display: block; transition: width 0.3s; }
.cmp-bar i.mine { background: var(--accent); border-radius: 3px 0 0 3px; }
.cmp-bar i.theirs { background: #fb923c; border-radius: 0 3px 3px 0; }
.opp-foot { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.opp-foot canvas { width: 43px; height: 21px; }
.opp-foot .push { margin-left: auto; }
.duel .clear-popup, .battle .clear-popup { top: 18%; }

/* battle */
.battle { max-width: 1320px; margin: 0 auto; padding: 24px; display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 24px; }
.battle-stats { width: 200px; display: flex; flex-direction: column; gap: 12px; }
.accent-border { border-color: var(--accent); }
.kv { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.kv > div { display: flex; justify-content: space-between; }
.kv span { color: var(--muted); }
.preview-next.small { width: 100px; height: 90px; margin-top: 12px; }
.opponents { flex: 1 1 480px; max-width: 520px; display: flex; flex-direction: column; gap: 12px; }
.opponents h2 { margin: 0; font-family: var(--display); font-size: 20px; }
.opp-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.opp-card { position: relative; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.opp-card.danger { border-color: var(--danger); }
.opp-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.opp-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.place { display: inline-flex; min-width: 24px; height: 22px; padding: 0 6px; align-items: center; justify-content: center; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--border); color: var(--text-2); }
.place.p1 { background: #facc15; color: var(--bg); }
.place.p2 { background: #cbd5e1; color: var(--bg); }
.mini-wrap { align-self: center; background: var(--board-bg); border-radius: 6px; padding: 4px; }
canvas.mini { display: block; width: 119px; height: 239px; }
.opp-foot2 { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.opp-foot2 strong { color: var(--text); font-weight: 600; }
.ko-cover { position: absolute; inset: 0; border-radius: 12px; background: rgba(11, 16, 32, 0.72); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; color: var(--text-2); }
.danger-tag { position: absolute; top: 40px; left: 50%; transform: translateX(-50%); padding: 2px 8px; border-radius: 999px; background: var(--danger); color: var(--bg); font-size: 11px; font-weight: 700; letter-spacing: 0.05em; }

@media (max-width: 760px) {
  .online.in-game { padding-bottom: 16px; display: flex; flex-direction: column; gap: 12px; }
  .online.in-game .touch { padding: 0 16px; }
  .game-bar { padding: 12px 16px 0; }
  .chip { height: 30px; font-size: 12px; padding: 0 10px; }
  .duel { flex-wrap: wrap; padding: 8px 16px; gap: 12px; }
  .duel-pieces, .duel-center { display: none; }
  .duel .my-board .board { width: min(220px, 55vw); }
  .duel .opp-board .board { width: min(120px, 28vw); }
  .battle { padding: 8px 16px; gap: 12px; }
  .battle-stats { display: none; }
  .battle .my-board .board { width: min(240px, 62vw); height: auto; aspect-ratio: 318 / 638; }
  .opponents { flex-basis: 100%; }
  .opp-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  canvas.mini { width: 79px; height: 159px; }
}

/* ───────── match replay ───────── */

.content.narrow { padding-bottom: 24px; }
.match-boards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.match-board { display: flex; flex-direction: column; gap: 8px; padding: 10px; }
.match-board .board { width: 150px; height: 301px; }
.ko.small { font-size: 14px; }
.match-replay .replay-bar { margin-top: 0; }
.danger-tag { white-space: nowrap; }

/* online game on phones: no site header, boards side by side, controls pinned to the bottom */
@media (max-width: 760px) {
  .page:has(.online.in-game) .site-header,
  .page:has(.online.in-game) .site-footer { display: none; }
  .online.in-game { min-height: 100vh; min-height: 100dvh; }
  .online.in-game .chips .chip:nth-child(n+3) { display: none; }
  .online.in-game .game-bar { flex-wrap: nowrap; }
  .duel { flex-wrap: nowrap; justify-content: center; gap: 8px; padding: 8px; overflow: visible; }
  .duel .my-board .board { width: min(210px, 54vw); }
  .duel .opp-board .board { width: min(110px, 27vw); }
  .duel .opp-foot { display: none; }
  .duel .board-head, .battle .board-head { font-size: 12px; min-height: 20px; }
  .duel .avatar { width: 20px; height: 20px; font-size: 11px; }
  .meter { width: 6px; }
  .online.in-game .touch {
    position: sticky;
    bottom: 0;
    margin-top: auto;
    padding: 8px 16px max(12px, env(safe-area-inset-bottom));
    background: var(--bg);
  }
}
.btn.small { white-space: nowrap; }
@media (max-width: 760px) {
  .online.in-game .game-bar { align-items: flex-start; }
  .duel .opp-board .board-head .muted { display: none; }
  .duel .opp-board .board-head .who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
}
