:root {
  color-scheme: light;
  --page: #f4f3ef;
  --surface: #fbfaf6;
  --surface-muted: #f0eee8;
  --surface-strong: #ffffff;
  --ink: #171918;
  --muted: #6c706b;
  --quiet: #9a9d97;
  --line: rgba(23, 25, 24, 0.12);
  --line-strong: rgba(23, 25, 24, 0.22);
  --dark: #1c211f;
  --dark-hover: #101412;
  --accent: #8c6b49;
  --accent-soft: #ebe2d7;
  --danger: #973f49;
  --light-square: #d8d2c2;
  --dark-square: #5c6e62;
  --focus: rgba(140, 107, 73, 0.34);
  --shadow: 0 18px 42px rgba(23, 25, 24, 0.08);
  --soft-shadow: 0 10px 24px rgba(23, 25, 24, 0.08);
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

html {
  max-width: 100%;
  overflow-x: hidden;
  background: var(--page);
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
  background:
    linear-gradient(90deg, rgba(23, 25, 24, 0.025) 1px, transparent 1px),
    linear-gradient(180deg, #fbfaf6 0%, var(--page) 58%, #ededE8 100%);
  background-size: 44px 44px, auto;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 3rem;
  font-weight: 560;
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.52rem;
  font-weight: 560;
  line-height: 1.1;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: uppercase;
}

.app-shell {
  width: min(1240px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 18px 18px;
}

.hero-bar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--line);
}

.hero-bar > div {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: uppercase;
}

.global-actions {
  display: flex;
  min-width: 0;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.52);
}

.global-action,
.ghost-button,
.primary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  border-radius: 5px;
  padding: 0 11px;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, opacity 140ms ease, transform 140ms ease;
}

.global-action {
  min-width: 104px;
  background: transparent;
  color: var(--muted);
}

.global-action.active {
  background: var(--dark);
  color: #fbfaf6;
}

.global-action.active:disabled {
  cursor: default;
  opacity: 1;
}

.global-action:not(.active):hover {
  background: rgba(23, 25, 24, 0.055);
  color: var(--ink);
}

.primary-button {
  border: 1px solid var(--dark);
  background: var(--dark);
  color: #fbfaf6;
}

.primary-button:hover {
  background: var(--dark-hover);
  border-color: var(--dark-hover);
}

.ghost-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.48);
  color: var(--ink);
}

.ghost-button:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.82);
}

.danger-button {
  width: 100%;
  margin-top: 14px;
  border: 1px solid rgba(151, 63, 73, 0.22);
  background: rgba(151, 63, 73, 0.06);
  color: var(--danger);
}

.danger-button:hover {
  border-color: rgba(151, 63, 73, 0.38);
  background: rgba(151, 63, 73, 0.09);
}

.btn-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.btn-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(318px, 360px);
  gap: 20px;
  min-width: 0;
  align-items: start;
}

.board-wrap {
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: 8px;
  min-width: 0;
}

.board-frame {
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
  padding: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.42);
  box-shadow: var(--shadow);
}

.board-with-coords {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) 20px;
  width: min(100%, calc(100vh - 226px), 690px);
  max-width: 100%;
  aspect-ratio: 1;
  min-width: 0;
}

.board {
  display: grid;
  grid-column: 2;
  grid-row: 1;
  grid-template-columns: repeat(8, 1fr);
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(23, 25, 24, 0.34);
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 22px 48px rgba(23, 25, 24, 0.14);
}

.rank-coords {
  display: grid;
  grid-column: 1;
  grid-row: 1;
  grid-template-rows: repeat(8, 1fr);
  padding-block: 1px;
}

.file-coords {
  display: grid;
  grid-column: 2;
  grid-row: 2;
  grid-template-columns: repeat(8, 1fr);
  padding-inline: 1px;
}

.rank-coords span,
.file-coords span {
  display: grid;
  place-items: center;
  color: rgba(23, 25, 24, 0.42);
  font-size: 0.7rem;
  font-weight: 650;
  line-height: 1;
  text-transform: uppercase;
}

.square {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  border-radius: 0;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}

.square.readonly {
  cursor: default;
}

.square.light {
  background: var(--light-square);
}

.square.dark {
  background: var(--dark-square);
}

.square.selected {
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.64), inset 0 0 0 7px rgba(140, 107, 73, 0.72);
}

.square.last {
  background-image: linear-gradient(rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.24));
}

.square.target::after {
  content: "";
  width: 20%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(23, 25, 24, 0.32);
}

.square.capture-target::after {
  content: "";
  position: absolute;
  inset: 13%;
  border: 4px solid rgba(151, 63, 73, 0.44);
  border-radius: 50%;
}

.piece {
  z-index: 1;
  display: block;
  width: 94%;
  height: 94%;
  overflow: visible;
  object-fit: contain;
  filter: drop-shadow(0 2px 2px rgba(23, 25, 24, 0.24));
  pointer-events: none;
  user-select: none;
}

.piece.white {
  filter: drop-shadow(0 2px 2px rgba(23, 25, 24, 0.3));
}

.under-board {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  padding: 0;
  background: transparent;
}

.icon-button {
  min-width: 36px;
  padding: 0 9px;
  line-height: 1;
}

.under-board .icon-button .btn-label {
  display: none;
}

.cursor-label {
  min-width: 86px;
  min-height: 40px;
  display: grid;
  place-items: center;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.42);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: none;
  overflow: visible;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(251, 250, 246, 0.72);
  box-shadow: none;
}

.panel-section {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-section:last-child {
  border-bottom: 0;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.status-label,
.mini-label {
  color: var(--quiet);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-pill {
  border: 1px solid rgba(140, 107, 73, 0.16);
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--accent-soft);
  color: #55402a;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

#statusDetail {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.control-grid,
.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.play-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.52);
}

.analysis-mode-switch {
  grid-template-columns: repeat(3, 1fr);
}

.mode-choice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  transition: transform 140ms ease;
}

.mode-choice.active {
  background: var(--dark);
  color: #fbfaf6;
}

.mode-choice:not(.active):hover {
  background: rgba(23, 25, 24, 0.055);
  color: var(--ink);
}

.full-button {
  width: 100%;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

select,
input[type="text"],
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background-color: rgba(255, 255, 255, 0.58);
  color: var(--ink);
  font-weight: 600;
  transition: border-color 140ms ease, background-color 140ms ease;
}

select {
  appearance: none;
  padding: 0 38px 0 11px;
  background-image:
    linear-gradient(45deg, transparent 50%, #343835 50%),
    linear-gradient(135deg, #343835 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 18px,
    calc(100% - 12px) 18px;
  background-size:
    5px 5px,
    5px 5px;
  background-repeat: no-repeat;
}

input[type="text"],
textarea {
  padding: 0 11px;
}

select:hover,
input[type="text"]:hover,
textarea:hover {
  border-color: var(--line-strong);
  background-color: rgba(255, 255, 255, 0.9);
}

textarea {
  min-height: 112px;
  padding-block: 10px;
  resize: vertical;
  line-height: 1.35;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: fit-content;
  min-height: 34px;
  padding: 5px 0;
  color: var(--ink);
  cursor: pointer;
}

input[type="checkbox"] {
  appearance: none;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  margin: 0;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
}

input[type="checkbox"]::before {
  content: "";
  width: 9px;
  height: 9px;
  background: var(--dark);
  transform: scale(0);
  transition: transform 120ms ease;
}

input[type="checkbox"]:checked::before {
  transform: scale(1);
}

input[type="checkbox"]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.setup-controls {
  margin-bottom: 12px;
}

.setup-screen .captures-section,
.setup-screen .move-section {
  display: none;
}

.game-summary {
  display: grid;
  gap: 9px;
}

.game-summary > div {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  background: transparent;
}

.game-summary > div:first-child {
  border-top: 0;
  padding-top: 0;
}

.game-summary strong {
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 560;
}

.clock-rail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100%, 690px);
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
}

.clock-rail strong {
  font-variant-numeric: tabular-nums;
  font-size: 1.08rem;
  font-weight: 650;
}

.clock-rail.active {
  border-color: rgba(140, 107, 73, 0.32);
  background: var(--accent-soft);
}

.clock-rail.flagged {
  border-color: rgba(151, 63, 73, 0.36);
  background: rgba(151, 63, 73, 0.08);
  color: var(--danger);
}

.hidden {
  display: none;
}

.eval-card {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 12px;
  align-items: stretch;
}

.eval-bar {
  position: relative;
  min-height: 76px;
  border-radius: 999px;
  overflow: hidden;
  background: #1f2422;
}

.eval-bar span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 50%;
  background: #faf7ec;
  transition: height 220ms ease;
}

.eval-score {
  font-size: 1.28rem;
  font-weight: 560;
}

.best-line {
  color: var(--muted);
  line-height: 1.4;
}

.engine-line {
  display: grid;
  grid-template-columns: 22px 58px minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: start;
  width: 100%;
  padding: 7px 0;
  border: 0;
  border-top: 1px solid rgba(23, 25, 24, 0.1);
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: default;
}

.engine-line:first-child {
  border-top: 0;
  padding-top: 0;
}

.engine-line:disabled {
  opacity: 1;
}

.engine-rank {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: #55402a;
  font-size: 0.72rem;
  font-weight: 650;
}

.engine-eval {
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
}

.engine-pv {
  min-width: 0;
  color: var(--muted);
  font-weight: 560;
  overflow-wrap: anywhere;
}

.engine-depth {
  color: var(--quiet);
  font-size: 0.74rem;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.fen-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.fen-tools input {
  grid-column: 1 / -1;
}

.fen-tools textarea {
  grid-column: 1 / -1;
}

.current-fen-tools input {
  color: var(--muted);
  font-size: 0.76rem;
}

.captures {
  display: grid;
  gap: 10px;
}

.captured-line {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  min-height: 30px;
  padding-top: 4px;
}

.captured-piece {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
}

.captured-piece .piece {
  width: 22px;
  height: 22px;
  filter: none;
}

.move-section {
  min-height: 180px;
  max-height: none;
  overflow: visible;
}

.move-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 8px;
  margin: 0;
  padding-left: 0;
  color: var(--ink);
  font-weight: 560;
  list-style: none;
  overflow: visible;
}

.move-list li {
  padding: 5px 7px;
  border: 1px solid rgba(23, 25, 24, 0.08);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.42);
}

.move-list li.current {
  border-color: rgba(140, 107, 73, 0.26);
  background: var(--accent-soft);
}

.move-list li.future-move {
  color: var(--quiet);
  opacity: 0.58;
}

.move-list li.branch-label {
  grid-column: 1 / -1;
  border: 0;
  background: transparent;
  color: var(--quiet);
  font-size: 0.72rem;
  font-weight: 650;
  text-transform: uppercase;
}

.move-list li.branch-move {
  border-color: rgba(151, 63, 73, 0.16);
  background: rgba(151, 63, 73, 0.05);
}

.promotion-dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.promotion-dialog::backdrop {
  background: rgba(23, 25, 24, 0.32);
}

.promotion-dialog p {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: uppercase;
}

.promotion-options {
  display: flex;
  gap: 8px;
}

.promotion-options button {
  width: 54px;
  height: 54px;
  border-radius: 5px;
  background: var(--dark);
  color: #fbfaf6;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  cursor: pointer;
  box-shadow: var(--soft-shadow);
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--quiet);
  font-size: 0.75rem;
  line-height: 1.35;
}

.app-footer a {
  color: var(--muted);
  font-weight: 600;
}

.focus-quit {
  display: none;
}

.game-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
}

.game-tools .ghost-button {
  flex: 0 1 auto;
}

.game-tools .cursor-label {
  flex: 1 1 86px;
  min-width: 76px;
}

@media (max-width: 920px) {
  .app-shell {
    padding: 14px 12px;
  }

  .hero-bar,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .hero-bar {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .global-actions {
    justify-content: stretch;
  }

  .global-action {
    flex: 1;
    min-width: 0;
  }

  .game-layout {
    display: grid;
  }

  .panel {
    max-height: none;
    overflow: visible;
  }

  .board-with-coords {
    width: 100%;
    max-width: min(690px, calc(100vw - 68px));
  }
}

.game-focus {
  width: 100%;
  max-width: none;
  padding: 14px;
}

.game-focus .hero-bar,
.game-focus .app-footer {
  display: none;
}

.game-focus .game-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 0;
}

.game-focus .board-wrap {
  display: grid;
  grid-template-rows: auto auto auto auto;
  place-items: center;
  padding-top: 58px;
}

.game-focus .board-frame {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.game-focus .board-with-coords {
  width: min(calc(100vw - 36px), calc(100vh - 190px), 880px);
  max-width: calc(100vw - 36px);
}

.game-focus .clock-rail {
  width: min(calc(100vw - 36px), calc(100vh - 190px), 880px);
  max-width: calc(100vw - 36px);
}

.game-focus .board {
  box-shadow: 0 26px 60px rgba(23, 25, 24, 0.16);
}

.game-focus .under-board {
  position: fixed;
  z-index: 30;
  top: 14px;
  left: 50%;
  display: grid;
  grid-template-columns: minmax(62px, auto) minmax(62px, auto);
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  width: min(880px, calc(100vw - 28px));
  padding: 0;
  transform: translateX(-50%);
}

.game-focus #backBtn,
.game-focus #forwardBtn,
.game-focus #cursorLabel,
.game-focus #undoBtn {
  display: none;
}

.game-focus .focus-quit,
.game-focus #flipBtn {
  display: inline-flex;
}

.game-focus .focus-quit {
  width: auto;
  margin-top: 0;
  background: rgba(255, 255, 255, 0.82);
}

.game-focus #flipBtn {
  min-width: 62px;
  background: rgba(255, 255, 255, 0.82);
}

.game-focus .panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: min(880px, calc(100vw - 28px));
  max-height: none;
  margin: 0 auto 18px;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.game-focus .panel-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(251, 250, 246, 0.9);
}

.game-focus .status-section,
.game-focus .game-section,
.game-focus .captures-section {
  min-height: 148px;
}

.game-focus .move-section {
  grid-column: 1 / -1;
  min-height: 92px;
}

.game-focus .move-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  color: var(--quiet);
  font-size: 0.78rem;
  font-weight: 560;
}

.game-focus .move-list li {
  border: 0;
  padding: 0;
  background: transparent;
}

.game-focus .move-list li.current {
  color: var(--muted);
  background: transparent;
  box-shadow: none;
}

.game-focus #quitBtn {
  display: none;
}

@media (max-width: 880px) {
  .game-focus .panel {
    grid-template-columns: 1fr;
  }

  .game-focus .status-section,
  .game-focus .game-section,
  .game-focus .captures-section {
    min-height: 0;
  }
}

@media (max-width: 560px) {
  .game-focus {
    padding: 8px;
  }

  .game-focus .game-layout,
  .game-focus .board-wrap,
  .game-focus .board-frame {
    min-height: auto;
  }

  .game-focus .board-wrap {
    place-items: start center;
    padding-top: 58px;
  }

  .game-focus .board-frame {
    padding-top: 0;
  }

  .game-focus .board-with-coords {
    max-width: calc(100vw - 18px);
    width: min(calc(100vw - 18px), calc(100vh - 176px));
  }

  .game-focus .clock-rail {
    max-width: calc(100vw - 18px);
    width: min(calc(100vw - 18px), calc(100vh - 176px));
    min-height: 34px;
  }

  .clock-rail strong {
    font-size: 0.98rem;
  }

  .game-focus .under-board {
    top: 8px;
    width: calc(100vw - 16px);
    grid-template-columns: 74px 74px;
    gap: 6px;
  }

  .game-focus .focus-quit,
  .game-focus #flipBtn {
    min-width: 74px;
    padding: 0 8px;
  }

  .game-focus .panel {
    grid-template-columns: 1fr;
    width: calc(100vw - 16px);
    gap: 8px;
    margin-bottom: 8px;
  }

  .game-focus .status-section,
  .game-focus .game-section,
  .game-focus .captures-section {
    min-height: 0;
  }

  .game-focus .move-section {
    min-height: 88px;
  }

  .game-tools {
    gap: 6px;
  }

}

@media (max-width: 560px) {
  .app-shell {
    width: 100%;
    padding: 10px;
  }

  body {
    background-size: 34px 34px, auto;
  }

  .hero-bar {
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 12px;
  }

  .eyebrow {
    font-size: 0.68rem;
  }

  h1 {
    font-size: 2.16rem;
    line-height: 1;
  }

  h2 {
    font-size: 1.34rem;
  }

  .global-actions {
    width: 100%;
  }

  .global-action {
    padding: 0 10px;
  }

  .game-layout {
    gap: 10px;
  }

  .board-frame {
    padding: 7px;
  }

  .board-with-coords {
    grid-template-columns: 14px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 14px;
    max-width: calc(100vw - 44px);
  }

  .rank-coords {
    padding-block: 1px;
  }

  .file-coords {
    padding-inline: 1px;
  }

  .rank-coords span,
  .file-coords span {
    font-size: 0.56rem;
  }

  .control-grid,
  .choice-grid,
  .fen-tools {
    grid-template-columns: 1fr;
  }

  .under-board {
    display: grid;
    grid-template-columns: 36px minmax(52px, 1fr) 36px minmax(52px, 1fr) minmax(52px, 1fr);
    gap: 6px;
  }

  .under-board button {
    min-width: 0;
    padding: 0 6px;
  }

  .icon-button {
    min-width: 0;
    font-size: 1.16rem;
  }

  .cursor-label {
    min-width: 0;
    padding: 0 2px;
    font-size: 0.7rem;
    align-self: center;
  }

  .board {
    border-radius: 4px;
  }

  .piece {
    width: 96%;
    height: 96%;
  }

  .panel-section {
    padding: 13px;
  }

  .move-list,
  .engine-line {
    grid-template-columns: 1fr;
  }

  .engine-line {
    gap: 4px;
  }

  .engine-rank,
  .engine-eval,
  .engine-depth {
    justify-self: start;
  }

  .app-footer {
    flex-direction: column;
    padding-top: 10px;
  }
}

@media (max-width: 380px) {
  .app-shell {
    padding: 7px;
  }

  .board-frame {
    padding: 5px;
  }

  .board-with-coords {
    max-width: calc(100vw - 34px);
  }

  .under-board {
    grid-template-columns: 34px minmax(44px, 1fr) 34px minmax(48px, 1fr) minmax(48px, 1fr);
    gap: 5px;
  }

  .global-action,
  .ghost-button,
  .primary-button,
  .danger-button {
    min-height: 38px;
    font-size: 0.92rem;
  }
}
