:root {
  color-scheme: light;
  --paper: #f7f5ee;
  --surface: #ffffff;
  --surface-sunk: #f1ece0;
  --line: #d8d2c4;
  --line-strong: #b9b09f;
  --ink: #1a1c20;
  --ink-soft: #5f625f;
  --ink-faint: #8a877d;
  --accent: #355c86;
  --accent-deep: #203d5d;
  --accent-tint: #e8f0f7;
  --good: #2f7d57;
  --good-soft: #e4f1e9;
  --bad: #b55343;
  --bad-soft: #f7e8e5;
  --wood-0: #f1d5a4;
  --wood-1: #e2b873;
  --wood-2: #c7964e;
  --grid: rgba(86, 57, 25, .58);
  --shadow: 0 18px 46px rgba(36, 33, 26, .10);
  --shadow-soft: 0 8px 20px rgba(36, 33, 26, .08);
  --r-sm: 7px;
  --r-md: 8px;
  --r-lg: 8px;
  --side: 244px;
  --board-max: min(62vh, 720px);
  --play-board-max: min(calc(100vw - var(--side) - 460px), calc(100vh - 36px), 1180px);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  letter-spacing: 0;
  overflow-x: hidden;
}

button, input {
  font: inherit;
}

button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--r-sm);
  min-height: 38px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

button:hover { border-color: var(--accent); }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(53, 92, 134, .28); outline-offset: 2px; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.ico {
  width: 18px;
  height: 18px;
  flex: none;
  display: block;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--side) 1fr;
  min-height: 100vh;
}

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  background: rgba(255, 255, 255, .82);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 20px;
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: url("/icon-180.png") center / cover no-repeat;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-soft);
}

.brand strong {
  display: block;
  font-size: 18px;
  line-height: 1.1;
}

.brand span:not(.brand-mark) {
  color: var(--ink-faint);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 7px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
  border-color: transparent;
  background: transparent;
  min-height: 46px;
  color: var(--ink-soft);
}

.nav-btn .ico {
  width: 26px;
  height: 26px;
  color: var(--accent);
}

.nav-btn.is-active {
  background: var(--accent-tint);
  color: var(--accent-deep);
  border-color: var(--accent-tint);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.main {
  min-width: 0;
  overflow-x: hidden;
}

.screen {
  display: none;
  min-height: 100vh;
  padding: 18px;
}

.screen.is-active { display: block; }

.is-hidden { display: none !important; }

.play-layout {
  width: 100%;
  min-height: calc(100vh - 36px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(300px, 22vw, 380px);
  grid-template-areas: "board rail";
  align-items: start;
  gap: 14px;
}

.play-topbar {
  margin-bottom: 0;
}

.play-board-stage {
  grid-area: board;
  width: 100%;
  margin: 0;
  min-height: calc(100vh - 36px);
  display: grid;
  place-items: center;
  position: relative;
}

.play-rail {
  grid-area: rail;
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 10px;
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 360px;
  gap: 22px;
  align-items: start;
}

.board-stage {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.play-rail .topbar {
  margin-bottom: 0;
}

.play-rail .topbar-title {
  gap: 9px;
}

.play-rail h1 {
  font-size: 24px;
}

.play-rail .screen-mark {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.screen-mark {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: url("/icon-180.png") center / cover no-repeat;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-soft);
}

.eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.12;
}

.seg {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  border: 1px solid var(--line-strong);
  background: var(--surface-sunk);
  border-radius: var(--r-sm);
  padding: 3px;
  min-width: 150px;
}

.seg-btn {
  border: 0;
  min-height: 32px;
  background: transparent;
  color: var(--ink-soft);
  gap: 6px;
  padding-inline: 10px;
}

.seg-btn .ico {
  width: 16px;
  height: 16px;
}

.seg-btn.is-active {
  background: var(--surface);
  color: var(--accent-deep);
  box-shadow: var(--shadow-soft);
}

.players {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.versus-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, .88);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.versus-players {
  grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 12px;
}

.vs-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
}

.player-card {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-soft);
}

.player-card.is-active {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.player-card b {
  display: block;
  font-size: 15px;
}

.player-card small {
  display: block;
  color: var(--ink-faint);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stone-mini {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  box-shadow: inset 0 1px 2px rgba(255,255,255,.25), 0 1px 3px rgba(0,0,0,.18);
}

.stone-mini.black { background: #17191d; }
.stone-mini.white { background: #fff; border: 1px solid #cfcabd; }

.play-tools {
  display: grid;
  grid-template-columns: minmax(280px, 1fr);
  gap: 10px;
  align-items: stretch;
  margin-bottom: 10px;
}

.play-rail .play-tools {
  grid-template-columns: 1fr;
  margin-bottom: 0;
}

.opponent-controls {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.opponent-controls.is-hidden {
  display: none;
}

.control-line {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}

.control-line span {
  color: var(--ink-faint);
  font-size: 12px;
  font-weight: 800;
}

.control-line b {
  color: var(--accent-deep);
}

.tool-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, .86);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.tool-card.is-hidden {
  display: none;
}

.tool-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px 0;
}

.tool-head span {
  color: var(--ink-faint);
  font-size: 12px;
  font-weight: 800;
}

.tool-head b {
  color: var(--accent-deep);
}

.tool-head .head-actions {
  align-items: center;
}

.tool-card .range-wide {
  margin-top: 10px;
}

.tool-card .ticks {
  padding-bottom: 8px;
}

.ai-meter.compact {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 0 15px 12px;
}

.ai-meter.compact span {
  grid-column: 1 / -1;
}

.ai-meter.compact small {
  color: var(--ink-faint);
  font-size: 12px;
  font-weight: 750;
}

.login-row,
.room-row {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) minmax(120px, 1fr) auto auto;
  gap: 8px;
  padding: 12px;
}

.room-row {
  grid-template-columns: auto auto minmax(180px, 1fr) auto auto;
  align-items: center;
}

.login-row input,
.room-row input {
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  background: var(--surface);
  color: var(--ink);
}

.user-badge {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  background: var(--accent-tint);
  color: var(--accent-deep);
  font-weight: 800;
  white-space: nowrap;
}

.turn-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 42px;
  border-radius: var(--r-md);
  background: var(--ink);
  color: #fff;
  margin-bottom: 12px;
}

.play-rail .turn-banner {
  margin-bottom: 0;
}

.turn-banner span:last-child {
  color: rgba(255,255,255,.68);
  font-size: 13px;
}

.turn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 0 rgba(255,255,255,.6);
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 8px rgba(255,255,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}

.goban-wrap {
  width: min(100%, var(--board-max));
  margin: 0 auto;
  padding: 12px;
  border-radius: var(--r-lg);
  background: linear-gradient(145deg, var(--wood-0), var(--wood-1) 58%, var(--wood-2));
  border: 1px solid rgba(95, 68, 33, .35);
  box-shadow: var(--shadow);
}

.goban-wrap.has-coordinates {
  padding: 28px 34px 30px;
}

.play-layout .goban-wrap {
  width: var(--play-board-max);
  margin-left: auto;
  margin-right: auto;
}

.goban {
  display: grid;
  grid-template-columns: repeat(19, minmax(0, 1fr));
  width: 100%;
  aspect-ratio: 1;
  position: relative;
}

.goban.mini { grid-template-columns: repeat(9, minmax(0, 1fr)); }

.coord-label {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  color: rgba(55, 41, 22, .72);
  font-size: clamp(10px, .7vw, 13px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 1px 0 rgba(255, 238, 196, .46);
}

.coord-label.file {
  left: calc(var(--coord-index) * 100% / 18);
  transform: translateX(-50%);
}

.coord-label.file.top { top: -20px; }
.coord-label.file.bottom { bottom: -22px; }

.coord-label.rank {
  top: calc(var(--coord-index) * 100% / 18);
  transform: translateY(-50%);
  min-width: 18px;
  text-align: center;
}

.coord-label.rank.left { left: -27px; }
.coord-label.rank.right { right: -27px; }

.point {
  position: relative;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

.point:before,
.point:after {
  content: "";
  position: absolute;
  background: var(--grid);
  z-index: 0;
}

.point:before {
  width: 1px;
  top: 0;
  bottom: 0;
  left: 50%;
}

.point:after {
  height: 1px;
  left: 0;
  right: 0;
  top: 50%;
}

.point.top:before { top: 50%; }
.point.bottom:before { bottom: 50%; }
.point.left:after { left: 50%; }
.point.right:after { right: 50%; }

.point .hoshi {
  position: absolute;
  width: 16%;
  height: 16%;
  border-radius: 50%;
  background: rgba(86, 57, 25, .58);
  top: 42%;
  left: 42%;
  z-index: 1;
}

.territory-mark {
  position: absolute;
  width: 24%;
  height: 24%;
  top: 38%;
  left: 38%;
  border-radius: 4px;
  z-index: 1;
  pointer-events: none;
  transform: rotate(45deg);
  box-shadow: 0 0 0 1px rgba(70, 52, 29, .22), 0 1px 3px rgba(25, 22, 18, .16);
}

.territory-mark.black {
  background: rgba(22, 24, 28, .72);
}

.territory-mark.white {
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 0 0 1px rgba(77, 73, 64, .32), 0 1px 3px rgba(25, 22, 18, .14);
}

.point.is-dead .territory-mark {
  width: 54%;
  height: 54%;
  top: 23%;
  left: 23%;
  opacity: .2;
  border-radius: 50%;
  transform: none;
}

.stone {
  position: absolute;
  inset: 9%;
  border-radius: 50%;
  z-index: 2;
  box-shadow: 0 2px 5px rgba(0,0,0,.24), inset 0 1px 2px rgba(255,255,255,.25);
}

.stone.black {
  background: radial-gradient(circle at 32% 28%, #444852, #15171b 70%);
}

.stone.white {
  background: radial-gradient(circle at 34% 28%, #fff, #efede6 72%);
  border: 1px solid rgba(86, 81, 68, .28);
}

.goban.is-scoring .point:not(:disabled) .stone {
  cursor: pointer;
  outline: 3px solid rgba(181, 83, 67, .28);
  outline-offset: -4px;
}

.stone.dead {
  opacity: .64;
  filter: grayscale(.12) saturate(.9);
}

.stone.dead::before,
.stone.dead::after {
  content: "";
  position: absolute;
  left: 21%;
  right: 21%;
  top: 47%;
  height: 6px;
  border-radius: 999px;
  background: rgba(181, 83, 67, .96);
  box-shadow: 0 0 0 2px rgba(255, 250, 238, .48), 0 1px 2px rgba(27, 26, 22, .22);
}

.stone.dead::before {
  transform: rotate(45deg);
}

.stone.dead::after {
  transform: rotate(-45deg);
}

.last .stone {
  outline: 3px solid rgba(53, 92, 134, .55);
  outline-offset: -4px;
}

.review-rec-marker {
  position: absolute;
  inset: 20%;
  z-index: 4;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, .92);
  box-shadow: 0 6px 14px rgba(32, 61, 93, .28);
  font-size: clamp(11px, 1.2vw, 16px);
  font-weight: 900;
  pointer-events: none;
}

.review-rec-marker.rank-2 {
  background: #2f7d57;
}

.review-rec-marker.rank-3 {
  background: #7a6043;
}

.ghost {
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  z-index: 2;
  border: 2px solid rgba(53, 92, 134, .75);
}

.point:disabled { cursor: default; }

.actionbar {
  width: 100%;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.actionbar button { white-space: nowrap; }

.score-result {
  width: 100%;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, .9);
  color: var(--ink);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: var(--shadow-soft);
}

.score-result strong {
  color: var(--accent-deep);
}

.score-result p {
  margin: 4px 0 10px;
  color: var(--ink-soft);
}

.score-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0 10px;
}

.score-actions button {
  min-width: 0;
}

.score-detail {
  color: var(--ink-faint);
  font-size: 12px;
}

.score-modal {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vw, 42px);
  background: rgba(33, 26, 18, .18);
  backdrop-filter: blur(1.5px);
}

.score-modal-card {
  width: min(420px, 92%);
  border: 1px solid rgba(64, 45, 25, .22);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, .96);
  color: var(--ink);
  padding: 22px;
  box-shadow: 0 24px 80px rgba(28, 24, 19, .28);
}

.score-modal-kicker {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-faint);
  font-size: 12px;
  font-weight: 850;
}

.score-modal-card strong {
  display: block;
  color: var(--accent-deep);
  font-size: 24px;
  line-height: 1.2;
}

.score-modal-card p {
  margin: 8px 0 14px;
  color: var(--ink-soft);
}

.score-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
  color: var(--ink-faint);
  font-size: 12px;
  font-weight: 800;
}

.score-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-marker {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  transform: rotate(45deg);
  box-shadow: 0 0 0 1px rgba(70, 52, 29, .22);
}

.legend-marker.black { background: rgba(22, 24, 28, .8); }

.legend-marker.white {
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 0 0 1px rgba(77, 73, 64, .36);
}

.legend-dead {
  position: relative;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(60, 52, 43, .16);
}

.legend-dead::before,
.legend-dead::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: 6px;
  height: 3px;
  border-radius: 999px;
  background: rgba(181, 83, 67, .96);
}

.legend-dead::before { transform: rotate(45deg); }
.legend-dead::after { transform: rotate(-45deg); }

.exit-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--ink);
  padding: 24px;
}

.exit-screen > div {
  width: min(420px, 100%);
  display: grid;
  gap: 10px;
  justify-items: center;
  text-align: center;
}

.exit-screen strong {
  font-size: 26px;
}

.exit-screen p {
  margin: 0;
  color: var(--ink-soft);
}

.mini-btn {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.panel-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 245, 238, .78);
}

.panel-head span {
  color: var(--ink-faint);
  font-size: 12px;
  font-weight: 800;
}

.panel-head b {
  color: var(--accent-deep);
}

.head-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.head-actions .mini-btn {
  min-height: 30px;
  padding: 5px 8px;
}

.panel > p, .coach {
  margin: 0;
  padding: 15px;
  color: var(--ink);
  line-height: 1.6;
  font-size: 14px;
}

.source-line {
  padding: 0 15px 14px;
  color: var(--ink-faint);
  font-size: 12px;
}

.record-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-sunk);
}

.record-tabs button {
  min-height: 24px;
  border: 0;
  border-radius: 5px;
  padding: 3px 8px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 11px;
  box-shadow: none;
}

.record-tabs button.is-active {
  background: var(--surface);
  color: var(--accent-deep);
  box-shadow: var(--shadow-soft);
}

body.large-buttons .record-tabs button {
  min-height: 24px;
}

body.large-buttons .puzzle-rank-tabs button {
  min-height: 38px;
}

.ai-meter {
  padding: 16px;
}

.ai-meter span {
  display: block;
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-sunk);
}

.ai-meter i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: inherit;
  transition: width .2s ease;
}

.ai-meter small {
  display: block;
  margin-top: 8px;
  color: var(--ink-faint);
}

.hint-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.hint-list li {
  display: grid;
  grid-template-columns: 24px 48px 1fr auto;
  gap: 9px;
  align-items: center;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.hint-list li:last-child { border-bottom: 0; }
.hint-list .num {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
}

.hint-list .coord { font-weight: 800; }
.hint-list .why { color: var(--ink-soft); }
.hint-list .delta { color: var(--good); font-weight: 800; }

.game-record-list {
  display: grid;
  max-height: 280px;
  overflow: auto;
}

.game-record-empty {
  padding: 14px 15px;
  color: var(--ink-faint);
  font-size: 13px;
}

.game-record-item {
  min-height: 58px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 0;
}

.game-record-item:last-child { border-bottom: 0; }

.game-record-main {
  min-width: 0;
  width: 100%;
  min-height: 58px;
  border: 0;
  border-radius: 0;
  padding: 10px 15px;
  background: transparent;
  display: grid;
  justify-items: start;
  align-content: center;
  gap: 3px;
  text-align: left;
}

.game-record-actions {
  display: grid;
  grid-template-columns: auto 32px 32px;
  align-items: center;
  gap: 5px;
  padding-right: 10px;
}

.record-icon-btn {
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--ink-faint);
}

.record-icon-btn .ico {
  width: 17px;
  height: 17px;
}

.record-icon-btn.favorite.is-on {
  color: #9a6a22;
  background: rgba(222, 178, 104, .18);
}

.record-icon-btn.danger:hover {
  color: var(--bad);
  border-color: rgba(181, 83, 67, .36);
}

.record-icon-btn:disabled {
  opacity: .32;
  cursor: default;
}

.game-record-main span,
.game-record-main small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-record-main span {
  color: var(--ink);
  font-weight: 800;
}

.game-record-main small {
  display: block;
  color: var(--ink-faint);
  font-size: 12px;
}

.game-record-actions b {
  color: var(--accent-deep);
  font-size: 12px;
  white-space: nowrap;
}

.game-record-item.is-active {
  background: var(--accent-tint);
  color: var(--accent-deep);
}

.game-record-item.is-active .game-record-main {
  color: var(--accent-deep);
}

.review-wrap { --board-max: min(62vh, 640px); }
.tsumego-wrap { --board-max: min(62vh, 560px); }

.scrub {
  width: min(100%, var(--board-max));
  margin: 14px auto 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  color: var(--ink-faint);
  font-size: 13px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.chart {
  width: 100%;
  height: 170px;
  display: block;
  padding: 8px 10px;
}

.chart-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--line);
}

.chart-stats span {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  background: var(--surface);
}

.chart-stats small {
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 800;
}

.chart-stats b {
  color: var(--accent-deep);
  font-size: 20px;
  line-height: 1;
}

.chart-stats em {
  color: var(--ink-soft);
  font-size: 11px;
  font-style: normal;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.review-panel-scrub {
  display: none;
}

.feedback {
  padding: 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  line-height: 1.55;
}

.feedback.ok {
  background: var(--good-soft);
  border-color: var(--good);
  color: #194b31;
}

.feedback.no {
  background: var(--bad-soft);
  border-color: var(--bad);
  color: #703126;
}

.puzzle-list {
  display: grid;
}

.puzzle-rank-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
}

.puzzle-rank-tabs button {
  min-height: 38px;
  padding: 7px 8px;
  font-size: 13px;
}

.puzzle-rank-tabs button.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.puzzle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  text-align: left;
}

.puzzle-item span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.puzzle-item small {
  color: var(--ink-faint);
  font-size: 11px;
}

.puzzle-item.is-active {
  color: var(--accent-deep);
  background: var(--accent-tint);
}

.settings {
  max-width: 980px;
  margin: 0 auto;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.range-wide {
  display: block;
  width: calc(100% - 30px);
  margin: 18px 15px 8px;
}

.ticks {
  display: flex;
  justify-content: space-between;
  padding: 0 15px 15px;
  color: var(--ink-faint);
  font-size: 12px;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 15px;
}

.choice {
  min-width: 0;
  gap: 6px;
  padding-inline: 8px;
}

.choice .ico {
  width: 16px;
  height: 16px;
}

.choice.is-active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
}

.toggle:last-child { border-bottom: 0; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }

.status-list {
  display: grid;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.status-row span { color: var(--ink-soft); }
.status-row b { color: var(--accent-deep); text-align: right; }
.status-row b.off { color: var(--bad); }
.status-row b.on { color: var(--good); }

.panel-action {
  width: calc(100% - 30px);
  margin: 0 15px 15px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 120%);
  opacity: 0;
  visibility: hidden;
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow);
  transition: transform .18s ease, opacity .18s ease, visibility 0s linear .18s;
  z-index: 140;
  max-width: min(520px, calc(100vw - 24px));
  font-weight: 800;
  text-align: center;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
  visibility: visible;
  transition: transform .18s ease, opacity .18s ease;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(120% 96% at 50% 8%, rgba(126, 82, 38, .72), rgba(54, 31, 14, .76) 62%, rgba(45, 25, 11, .94) 100%),
    linear-gradient(160deg, #6c421d 0%, #43260f 100%);
  overflow: auto;
}

.auth-stage {
  position: relative;
  width: min(88vw, calc(100svh - 44px), 1180px);
  min-width: min(100%, 330px);
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(38, 20, 7, .76);
  border-radius: 28px;
  background:
    repeating-linear-gradient(92deg, rgba(59, 34, 13, .16) 0 1px, transparent 1px 10px),
    repeating-linear-gradient(88deg, rgba(255, 231, 170, .08) 0 2px, transparent 2px 26px),
    radial-gradient(circle at 28% 12%, rgba(255, 219, 150, .34), transparent 38%),
    linear-gradient(145deg, #b88445 0%, #9a652f 52%, #774819 100%);
  box-shadow:
    0 42px 100px rgba(24, 12, 4, .58),
    inset 0 1px 0 rgba(255, 238, 196, .34),
    inset 0 0 0 12px rgba(77, 44, 16, .22);
}

.auth-stage::before {
  content: "";
  position: absolute;
  inset: 3.5%;
  border: 1px solid rgba(52, 31, 12, .42);
  border-radius: 18px;
  box-shadow: inset 0 0 0 1px rgba(231, 184, 111, .18);
  pointer-events: none;
  z-index: 2;
}

.auth-board-scene {
  --grid-inset: 8%;
  position: absolute;
  inset: 4.5%;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(49, 28, 10, .42);
  background:
    radial-gradient(circle at 46% 38%, rgba(255, 223, 157, .18), transparent 48%),
    repeating-linear-gradient(96deg, rgba(92, 57, 24, .20) 0 1px, transparent 1px 12px),
    linear-gradient(135deg, rgba(255, 220, 156, .12), transparent 34%, rgba(49, 24, 8, .16));
  z-index: 1;
}

.auth-board-grid {
  position: absolute;
  inset: var(--grid-inset);
  border: 1px solid rgba(45, 28, 12, .62);
  background:
    linear-gradient(90deg, transparent calc(100% - 1px), rgba(42, 26, 11, .56) 100%),
    linear-gradient(transparent calc(100% - 1px), rgba(42, 26, 11, .56) 100%);
  background-size: calc(100% / 18) calc(100% / 18);
  background-position: 0 0;
  pointer-events: none;
  z-index: 2;
}

.auth-board-grid::after {
  content: "";
  position: absolute;
  inset: -1px;
  background:
    linear-gradient(115deg, rgba(255, 247, 221, .16), transparent 30%, rgba(58, 32, 10, .10)),
    radial-gradient(circle at 36% 28%, rgba(255, 241, 198, .14), transparent 42%);
  pointer-events: none;
}

.scene-hoshi,
.scene-stone {
  position: absolute;
  left: calc(var(--grid-inset) + var(--x) * (100% - (var(--grid-inset) * 2)) / 18);
  top: calc(var(--grid-inset) + var(--y) * (100% - (var(--grid-inset) * 2)) / 18);
  transform: translate(-50%, -50%);
}

.scene-hoshi {
  width: clamp(5px, .85vmin, 9px);
  height: clamp(5px, .85vmin, 9px);
  border-radius: 50%;
  background: rgba(48, 31, 13, .66);
  box-shadow: 0 1px 1px rgba(255, 221, 147, .25);
  z-index: 3;
}

.scene-stone {
  width: clamp(20px, 4.35vmin, 52px);
  height: clamp(20px, 4.35vmin, 52px);
  border-radius: 50%;
  z-index: 4;
  opacity: .95;
}

.scene-stone.black {
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, .18), transparent 23%),
    radial-gradient(circle at 62% 70%, #050608, #2b2b2c 58%, #070708 100%);
  box-shadow:
    inset -5px -6px 10px rgba(0, 0, 0, .42),
    inset 3px 3px 6px rgba(255, 255, 255, .08),
    0 7px 12px rgba(22, 11, 3, .38);
}

.scene-stone.white {
  background:
    radial-gradient(circle at 30% 24%, #fffdf4, #eee8d8 52%, #c8bea9 100%);
  border: 1px solid rgba(140, 127, 103, .58);
  box-shadow:
    inset -5px -6px 9px rgba(137, 126, 103, .26),
    inset 4px 4px 7px rgba(255, 255, 255, .70),
    0 6px 12px rgba(22, 11, 3, .28);
}

.auth-veil {
  position: absolute;
  inset: 0;
  z-index: 5;
  background:
    radial-gradient(46% 38% at 50% 54%, rgba(255, 248, 226, .10), rgba(72, 41, 17, .08) 55%, rgba(40, 20, 6, .22) 100%),
    linear-gradient(180deg, rgba(255, 236, 187, .08), rgba(42, 22, 8, .26));
  pointer-events: none;
}

.auth-branding {
  position: absolute;
  top: 13.5%;
  left: 0;
  right: 0;
  z-index: 7;
  text-align: center;
  color: #fff3dc;
  text-shadow: 0 3px 12px rgba(42, 21, 6, .48);
  pointer-events: none;
}

.auth-branding h2 {
  margin: 0;
  font-family: "AppleMyungjo", "Nanum Myeongjo", "Noto Serif KR", serif;
  font-size: clamp(42px, 8vmin, 92px);
  line-height: .95;
  font-weight: 800;
  letter-spacing: .14em;
  text-indent: .14em;
}

.auth-branding p {
  margin: 16px 0 0;
  color: #f1dfbc;
  font-family: "AppleMyungjo", "Nanum Myeongjo", "Noto Serif KR", serif;
  font-size: clamp(14px, 2.1vmin, 26px);
  letter-spacing: .16em;
  text-indent: .16em;
}

.auth-card {
  position: absolute;
  left: 50%;
  top: 59%;
  transform: translate(-50%, -50%);
  z-index: 8;
  width: min(52%, 560px);
  min-width: 410px;
  display: grid;
  gap: 20px;
  padding: clamp(26px, 3.2vmin, 40px);
  border: 1px solid rgba(209, 199, 179, .92);
  border-radius: 16px;
  background: rgba(255, 255, 255, .97);
  box-shadow:
    0 28px 58px rgba(34, 18, 6, .42),
    0 1px 0 rgba(255, 255, 255, .92) inset;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  border: 1px solid #ded7ca;
  border-radius: 10px;
  background: #f4f1ea;
  box-shadow: inset 0 1px 2px rgba(56, 38, 18, .08);
}

.auth-tabs button {
  border: 0;
  border-radius: 7px;
  min-height: 58px;
  background: transparent;
  color: rgba(59, 51, 40, .68);
  font-size: clamp(16px, 2vmin, 25px);
  font-weight: 800;
  box-shadow: none;
}

.auth-tabs button.is-active {
  background: #fff;
  color: #17191d;
  box-shadow: 0 6px 15px rgba(36, 24, 12, .10), 0 1px 0 rgba(255, 255, 255, .9) inset;
}

.auth-feedback {
  border: 1px solid rgba(61, 111, 79, .32);
  border-radius: 10px;
  padding: 12px 14px;
  background: #eef8f0;
  color: #245737;
  font-size: clamp(14px, 1.65vmin, 21px);
  font-weight: 800;
  line-height: 1.45;
}

.auth-feedback.is-error {
  border-color: rgba(175, 68, 68, .34);
  background: #fff0ee;
  color: #8a2f25;
}

.auth-feedback.is-info {
  border-color: rgba(58, 99, 146, .28);
  background: #eef5ff;
  color: #315d8f;
}

.auth-field {
  display: grid;
  gap: 9px;
}

.auth-field span {
  color: rgba(47, 42, 34, .80);
  font-size: clamp(14px, 1.75vmin, 23px);
  font-weight: 800;
}

.auth-input-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: clamp(56px, 7vmin, 82px);
  border: 1px solid #d6cebf;
  border-radius: 10px;
  padding: 0 clamp(14px, 2.1vmin, 22px);
  background: #fffefa;
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset;
  transition: border-color .14s ease, box-shadow .14s ease, background .14s ease;
}

.auth-input-wrap:focus-within {
  border-color: #8f744b;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(97, 67, 34, .13);
}

.auth-input-icon {
  width: clamp(18px, 2.6vmin, 25px);
  height: clamp(18px, 2.6vmin, 25px);
  color: #b5ad9e;
}

.auth-card input:not([type="checkbox"]) {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font-size: clamp(17px, 2.25vmin, 28px);
}

.auth-card input::placeholder {
  color: #aaa69e;
}

.auth-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 2px;
}

.auth-remember {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #555047;
  font-size: clamp(14px, 1.85vmin, 22px);
  font-weight: 650;
}

.auth-remember input {
  width: clamp(18px, 2.4vmin, 24px);
  height: clamp(18px, 2.4vmin, 24px);
  accent-color: var(--accent);
}

.auth-link {
  border: 0;
  min-height: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  font-size: clamp(14px, 1.85vmin, 22px);
  font-weight: 800;
}

.auth-card .auth-submit {
  min-height: clamp(58px, 7.5vmin, 86px);
  margin-top: 4px;
  border: 0;
  border-radius: 10px;
  background: #3a2614;
  color: #fff3dc;
  font-size: clamp(18px, 2.35vmin, 30px);
  font-weight: 850;
  box-shadow: 0 14px 26px rgba(44, 28, 13, .18);
}

.auth-card .auth-submit:hover {
  background: #2f1e0f;
}

.auth-card .auth-submit:disabled {
  cursor: wait;
  opacity: .72;
}

body.large-buttons button { min-height: 44px; }
body.large-buttons .point { min-height: 0; }
body.large-buttons .actionbar button { min-height: 42px; }

body.high-contrast {
  --line: #a59d8f;
  --line-strong: #5e5a51;
  --ink-soft: #34373a;
  --ink-faint: #50545a;
  --grid: rgba(28, 22, 14, .9);
}

@media (min-width: 1121px) {
  .screen[data-panel="play"].is-active,
  .screen[data-panel="review"].is-active {
    height: 100vh;
    overflow: hidden;
  }

  .screen[data-panel="review"] {
    padding: 14px 18px;
  }

  .screen[data-panel="review"] .review-layout {
    --review-rail-min: clamp(480px, 35vw, 720px);
    --review-board-size: min(calc(100vh - 148px), calc(100vw - var(--side) - var(--review-rail-min) - 96px), 900px);
    height: calc(100vh - 28px);
    grid-template-columns: var(--review-board-size) minmax(var(--review-rail-min), 1fr);
    gap: 18px;
    align-items: stretch;
  }

  .screen[data-panel="review"] .board-stage {
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    align-content: stretch;
    justify-items: stretch;
  }

  .screen[data-panel="review"] .topbar {
    width: min(100%, var(--review-board-size));
  }

  .screen[data-panel="review"] .review-wrap {
    --board-max: var(--review-board-size);
    margin-left: 0;
    margin-right: 0;
    align-self: center;
  }

  .screen[data-panel="review"] .board-scrub {
    width: min(100%, var(--review-board-size));
    display: grid;
    margin: 10px 0 0;
  }

  .screen[data-panel="review"] .review-panel-scrub {
    width: 100%;
    display: grid;
    flex: none;
    margin: 0;
    padding: 0 16px 14px;
  }

  .screen[data-panel="review"] .panel-stack {
    height: calc(100vh - 28px);
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(170px, .58fr) minmax(312px, 1.14fr) minmax(250px, 1fr);
    grid-template-areas:
      "games games"
      "win recs"
      "explain explain";
    gap: 12px;
    overflow: hidden;
  }

  .screen[data-panel="review"] .review-games-panel { grid-area: games; }
  .screen[data-panel="review"] .winrate-panel { grid-area: win; }
  .screen[data-panel="review"] .recs-panel { grid-area: recs; }
  .screen[data-panel="review"] .explain-panel { grid-area: explain; }

  .screen[data-panel="review"] .panel {
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .screen[data-panel="review"] .panel-head {
    min-height: 48px;
    flex: none;
    padding: 9px 14px;
  }

  .screen[data-panel="review"] .review-games-panel .panel-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    min-height: 46px;
    padding: 7px 12px;
  }

  .screen[data-panel="review"] .review-games-panel .panel-head > span {
    justify-self: start;
  }

  .screen[data-panel="review"] .review-games-panel .panel-head > b {
    justify-self: end;
  }

  .screen[data-panel="review"] .review-games-panel .game-record-list,
  .screen[data-panel="review"] .hint-list,
  .screen[data-panel="review"] .coach {
    min-height: 0;
    flex: 1 1 auto;
    overflow: auto;
  }

  .screen[data-panel="review"] .review-games-panel .game-record-list {
    max-height: none;
  }

  .screen[data-panel="review"] .game-record-item {
    min-height: 48px;
  }

  .screen[data-panel="review"] .game-record-main {
    min-height: 48px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .screen[data-panel="review"] .chart {
    flex: 1 1 auto;
    height: auto;
    min-height: 210px;
    padding: 12px 12px 6px;
  }

  .screen[data-panel="review"] .chart-stats {
    flex: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .screen[data-panel="review"] .hint-list li {
    grid-template-columns: 28px 64px 1fr auto;
    padding: 12px 16px;
    font-size: 14px;
  }

  .screen[data-panel="review"] .source-line {
    flex: none;
    padding: 0 14px 11px;
  }

  .screen[data-panel="review"] .explain-panel .coach {
    padding: 18px 20px;
    font-size: 15px;
    line-height: 1.72;
  }
}

@media (max-width: 720px) {
  .auth-gate {
    padding: 0;
    place-items: start center;
  }
  .auth-stage {
    width: 100%;
    min-height: 100svh;
    aspect-ratio: auto;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .auth-stage::before {
    inset: 14px;
    border-radius: 18px;
  }
  .auth-board-scene {
    inset: 14px;
    border-radius: 18px;
  }
  .scene-stone {
    width: clamp(19px, 8.4vw, 36px);
    height: clamp(19px, 8.4vw, 36px);
  }
  .auth-branding {
    top: 44px;
  }
  .auth-branding h2 {
    font-size: clamp(48px, 15vw, 70px);
  }
  .auth-branding p {
    margin-top: 10px;
    font-size: clamp(14px, 4.2vw, 19px);
  }
  .auth-card {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    width: calc(100% - 34px);
    min-width: 0;
    margin: 210px auto 24px;
    padding: 22px;
    gap: 15px;
  }
  .auth-tabs button {
    min-height: 52px;
  }
  .auth-input-wrap {
    min-height: 54px;
  }
  .auth-options {
    align-items: flex-start;
  }
}

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 82px 1fr; }
  .side { padding: 16px 10px; }
  .brand div, .nav-btn b { display: none; }
  .brand { justify-content: center; padding: 8px 0; }
  .nav-btn { justify-content: center; padding: 8px; }
  .play-layout {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 320px);
  }
  .versus-players {
    grid-template-columns: 1fr;
  }
  .vs-badge {
    width: 100%;
    height: 24px;
    border-radius: var(--r-sm);
  }
}

@media (min-width: 901px) and (max-width: 1120px),
  (min-width: 901px) and (max-width: 1368px) and (min-height: 900px) {
  :root {
    --tablet-rail: clamp(236px, 25vw, 300px);
    --play-board-max: min(calc(100vw - 118px - var(--tablet-rail) - 12px), calc(100svh - 28px), 1040px);
  }
  .app-shell {
    grid-template-columns: 82px 1fr;
  }
  .side {
    padding: 16px 10px;
  }
  .brand div,
  .nav-btn b {
    display: none;
  }
  .brand {
    justify-content: center;
    padding: 8px 0;
  }
  .nav-btn {
    justify-content: center;
    padding: 8px;
  }
  .screen {
    min-height: 100svh;
    padding: 14px;
  }
  .play-layout {
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) var(--tablet-rail);
    grid-template-areas: "board rail";
    gap: 12px;
    align-items: start;
  }
  .play-board-stage {
    min-height: 0;
    display: grid;
    align-items: start;
    justify-items: center;
  }
  .play-layout .goban-wrap {
    width: min(100%, var(--play-board-max));
    max-width: var(--play-board-max);
  }
  .play-rail {
    width: 100%;
    max-width: var(--tablet-rail);
    margin: 0;
    grid-template-columns: 1fr;
    overflow: hidden;
  }
  .play-rail *,
  .play-rail button,
  .play-rail input {
    min-width: 0;
  }
  .play-rail .topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
  }
  .play-rail .seg {
    width: 100%;
    min-width: 0;
  }
  .play-rail .seg-btn {
    padding-inline: 6px;
  }
  .play-rail .players {
    margin-bottom: 0;
  }
  .play-rail .versus-players {
    grid-template-columns: 1fr;
    padding: 10px;
  }
  .play-rail .vs-badge {
    width: 100%;
    height: 24px;
    border-radius: var(--r-sm);
  }
  .play-rail .player-card {
    grid-template-columns: 24px minmax(0, 1fr) auto;
    padding: 10px;
    gap: 8px;
  }
  .play-rail .stone-mini {
    width: 22px;
    height: 22px;
  }
  .play-tools {
    margin-bottom: 0;
  }
  .play-rail .control-line {
    grid-template-columns: 1fr;
    padding: 0 10px;
  }
  .play-rail .control-line .mini-btn {
    width: 100%;
  }
  .play-rail .tool-head,
  .play-rail .ai-meter.compact {
    padding-left: 10px;
    padding-right: 10px;
  }
  .play-rail .range-wide {
    width: calc(100% - 20px);
    margin-left: 10px;
    margin-right: 10px;
  }
  .play-rail .ticks {
    padding-left: 10px;
    padding-right: 10px;
  }
  .play-rail .turn-banner {
    padding-inline: 8px;
  }
  .play-rail .actionbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }
  .play-rail .actionbar button {
    padding-inline: 7px;
  }
}

@media (max-width: 900px) {
  :root { --play-board-max: min(100%, calc(100svh - 180px)); }
  .app-shell { display: block; }
  .side {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: auto;
    height: 68px;
    z-index: 30;
    border-right: 0;
    border-top: 1px solid var(--line);
    padding: 8px 10px;
    flex-direction: row;
    align-items: center;
  }
  .brand { display: none; }
  .nav {
    width: 100%;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }
  .nav-btn {
    min-height: 50px;
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
  }
  .nav-btn b { display: block; }
  .screen {
    min-height: 100svh;
    padding: 18px 14px 88px;
  }
  .play-layout, .review-layout {
    grid-template-columns: 1fr;
  }
  .play-layout {
    grid-template-areas:
      "board"
      "rail";
    grid-template-columns: 1fr;
    max-width: none;
  }
  .play-rail .topbar {
    order: -1;
  }
  .play-rail { grid-area: rail; }
  .play-board-stage { grid-area: board; }
  .play-board-stage {
    min-height: 0;
    display: block;
  }
  .play-tools {
    grid-template-columns: 1fr;
  }
  .versus-players {
    grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr);
  }
  .vs-badge {
    width: 34px;
    height: 34px;
    border-radius: 50%;
  }
  .room-row {
    grid-template-columns: 1fr 1fr;
  }
  .room-row input {
    grid-column: 1 / -1;
  }
  .panel-stack {
    display: grid;
    grid-template-columns: 1fr;
  }
  .topbar h1 { font-size: 24px; }
  .actionbar { grid-template-columns: repeat(2, 1fr); }
  .play-layout .goban-wrap,
  .actionbar,
  .score-result {
    width: min(100%, var(--play-board-max));
    margin-left: auto;
    margin-right: auto;
  }
  .actionbar { margin-top: 12px; }
  .score-result { margin-top: 8px; }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .screen { padding-left: 10px; padding-right: 10px; }
  .players,
  .versus-players { grid-template-columns: 1fr; }
  .vs-badge {
    width: 100%;
    height: 24px;
    border-radius: var(--r-sm);
  }
  .goban-wrap { padding: 8px; }
  .login-row { grid-template-columns: 1fr; }
  .room-row { grid-template-columns: 1fr; }
  .hint-list li { grid-template-columns: 24px 44px 1fr; }
  .hint-list .delta { display: none; }
  .button-grid { grid-template-columns: 1fr; }
}
