:root {
  color-scheme: dark;
  --ink: #f0eee5;
  --muted: #a8b6b3;
  --quiet: #8b9c98;
  --page: #0d1416;
  --panel: #131e20;
  --field: #0e1719;
  --line: #293a3a;
  --brass: #d6ac62;
  --brass-light: #ffe5a7;
  --red: #ec938b;
  --blue: #8cbcf0;
  --body-font: "Noto Sans KR", "Noto Sans CJK KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --heading-font: "Noto Serif KR", "Noto Serif CJK KR", "Nanum Myeongjo", "Batang", Georgia, serif;
  --number-font: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 35% 0%, #1d2c29 0%, transparent 42rem),
    var(--page);
  color: var(--ink);
  font: 400 1rem/1.5 var(--body-font);
  -webkit-font-smoothing: antialiased;
}

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

img,
canvas {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: .5;
}

button,
input,
select,
a {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--brass-light);
  outline-offset: 3px;
}

::selection {
  background: var(--brass);
  color: #211a0d;
}

button {
  min-width: 0;
  color: inherit;
}

input,
select {
  width: 100%;
  min-height: 2.875rem;
  padding: .625rem .8rem;
  border: 1px solid #314442;
  border-radius: .375rem;
  background: var(--field);
  color: var(--ink);
}

input::placeholder {
  color: #788a85;
}

input:focus,
select:focus {
  border-color: var(--brass);
  outline-offset: 2px;
}

select {
  appearance: none;
  padding-right: 2.2rem;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 16px) calc(50% + 1px) / 5px 5px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 11px) calc(50% + 1px) / 5px 5px no-repeat,
    var(--field);
}

label {
  color: #d5ddd4;
}

dialog {
  width: min(100% - 2rem, 28rem);
  max-height: calc(100% - 2rem);
  padding: 1.5rem;
  border: 1px solid #665537;
  border-radius: .75rem;
  background:
    radial-gradient(ellipse at top left, #27352e, transparent 75%),
    #151f21;
  box-shadow: 0 2rem 6rem #000b;
  color: var(--ink);
}

dialog::backdrop {
  background: #080c0fe0;
  backdrop-filter: blur(5px);
}

dialog h2 {
  color: var(--ink);
  font: 700 1.45rem/1.4 var(--heading-font);
}

dialog p {
  margin-top: .5rem;
  color: var(--muted);
}

dialog form {
  display: grid;
  gap: 1rem;
}

dialog label {
  display: grid;
  gap: .4rem;
  font-size: .875rem;
}

.app-shell {
  width: min(100% - 3rem, 81rem);
  margin-inline: auto;
}

.topbar {
  display: flex;
  min-height: 4.375rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
}

.top-left {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .85rem;
}

.brand {
  display: inline-flex;
  flex: 0 1 auto;
  align-items: center;
  gap: .625rem;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 2.35rem;
  height: 2.35rem;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #8e7041;
  border-radius: .35rem;
  background: linear-gradient(145deg, #514326, #2c2b21);
  box-shadow: inset 0 0 0 3px #191c17;
  color: var(--brass-light);
  font: 1.45rem/1 Georgia, serif;
}

.brand-text {
  display: grid;
  gap: .05rem;
  color: #eddfbe;
  font-weight: 800;
  line-height: 1.25;
}

.brand-text strong {
  font-family: var(--heading-font);
  letter-spacing: -.045em;
}

.brand-text small {
  color: #c1a77a;
  font: 600 .75rem/1.3 var(--number-font);
  letter-spacing: .1em;
}

.language-picker {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: .15rem;
  padding: .15rem;
  border: 1px solid var(--line);
  border-radius: .4rem;
  background: var(--field);
}

.language-picker button[data-language] {
  min-height: 2rem;
  padding: .23rem .45rem;
  border: 1px solid transparent;
  border-radius: .25rem;
  background: transparent;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 650;
  white-space: nowrap;
}

.language-picker button[data-language]:hover {
  color: var(--ink);
}

.language-picker button[data-language][aria-pressed="true"] {
  border-color: #695734;
  background: #3a3020;
  color: var(--brass-light);
}

.arcade-return {
  display: inline-flex;
  min-height: 2.25rem;
  align-items: center;
  padding-inline: .35rem;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.arcade-return:hover,
.arcade-return:focus-visible {
  color: var(--brass-light);
  text-decoration: underline;
}

.top-actions,
.panel-actions,
.dialog-actions,
.room-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .625rem;
}

.top-actions {
  justify-content: flex-end;
}

.connection {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: .45rem;
  padding-inline: .375rem;
  color: var(--muted);
  font-size: .875rem;
}

.connection i {
  width: .425rem;
  height: .425rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--brass);
}

.connection.is-online i {
  background: #72b695;
  box-shadow: 0 0 .625rem #72b6957a;
}

.connection.is-offline i {
  background: var(--red);
  box-shadow: 0 0 .625rem #ec938b66;
}

.btn {
  display: inline-flex;
  min-height: 2.5rem;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .52rem .85rem;
  border: 1px solid transparent;
  border-radius: .35rem;
  background: transparent;
  font-size: .875rem;
  font-weight: 750;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.btn-primary {
  border-color: #d6ae66;
  background: linear-gradient(180deg, #e4be78, #c59b51);
  color: #241c0f;
}

.btn-primary:hover:not(:disabled) {
  border-color: #fae3aa;
  background: #eac57d;
}

.btn-secondary {
  border-color: #665735;
  background: #302d21;
  color: #f1d69e;
}

.btn-secondary:hover:not(:disabled) {
  border-color: #b39554;
  background: #433923;
}

.btn-ghost {
  border-color: #354744;
  color: #dae1d9;
}

.btn-ghost:hover:not(:disabled) {
  border-color: #687c72;
  background: #25322f;
}

.help-trigger [aria-hidden="true"] {
  display: inline-grid;
  width: 1.05rem;
  height: 1.05rem;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #8d784d;
  border-radius: 50%;
  color: var(--brass-light);
  font: 700 .75rem/1 var(--number-font);
}

.help-trigger[aria-expanded="true"] {
  border-color: #8d784d;
  background: #302a1f;
  color: var(--brass-light);
}

.page-heading {
  position: relative;
  display: grid;
  min-height: 8rem;
  align-content: center;
  justify-items: start;
  gap: .35rem;
  margin-block: .85rem 1.1rem;
  isolation: isolate;
}

.page-heading h1 {
  color: #f5ebd7;
  font: 800 clamp(2.2rem, 4.3vw, 3.7rem)/1.15 var(--heading-font);
  letter-spacing: -.07em;
  text-wrap: balance;
}

.page-subtitle {
  color: var(--muted);
  font-size: .95rem;
  text-wrap: pretty;
}

.heading-copy {
  display: grid;
  gap: .5rem;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 2.26fr) minmax(19.5rem, 1fr);
  align-items: start;
  gap: 1.1rem;
}

.play-column,
.sidebar {
  display: grid;
  min-width: 0;
  gap: .875rem;
}

.arena,
.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: .65rem;
  background: var(--panel);
  box-shadow: 0 14px 35px #0003;
}

.arena {
  overflow: hidden;
}

.arena-topbar,
.arena-footer {
  position: relative;
  display: flex;
  min-height: 3.5rem;
  align-items: center;
  justify-content: space-between;
  gap: .625rem 1rem;
  padding: .65rem 1.05rem;
  background: #152023;
}

.arena-topbar {
  border-bottom: 1px solid #293c3a;
}

.arena-footer {
  flex-wrap: wrap;
  border-top: 1px solid #293c3a;
  color: var(--muted);
  font-size: .875rem;
}

.arena-topbar .turn-label {
  color: #f0d49b;
  font-size: .9rem;
  font-weight: 750;
}

.elapsed {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  color: var(--muted);
  font-size: .875rem;
}

.elapsed :is(strong, time) {
  color: #eee5d4;
  font: 600 1rem/1 var(--number-font);
  font-variant-numeric: tabular-nums;
}

.arena-content {
  display: grid;
  justify-items: center;
  padding: .875rem clamp(.625rem, 2.5vw, 1.5rem);
  background:
    radial-gradient(ellipse at 52% 60%, #425141 0%, #273732 27%, transparent 68%),
    repeating-linear-gradient(135deg, #13232600 0 11px, #6377540b 11px 12px),
    linear-gradient(180deg, #142022, #192724 54%, #142023);
}

.player-card {
  --team: var(--muted);
  display: grid;
  width: min(100%, 45.25rem);
  min-height: 3.75rem;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .65rem;
  padding: .45rem .65rem;
  border: 1px solid #344440;
  border-radius: .45rem;
  background: #111e20de;
  box-shadow: 0 5px 12px #0002;
}

.team-red {
  --team: var(--red);
}

.team-blue {
  --team: var(--blue);
}

.player-card.is-turn {
  border-color: #a88b50;
  background: linear-gradient(105deg, #3b3825, #172323 58%);
  box-shadow: 0 0 0 1px #d6ac621a, 0 5px 16px #0003;
}

.player-avatar {
  display: grid;
  width: 2.65rem;
  height: 2.65rem;
  flex: 0 0 auto;
  overflow: hidden;
  place-items: center;
  border: 1px solid #495553;
  border-radius: .35rem;
  background: #263332;
  color: var(--team);
  font: 1.45rem/1 Georgia, serif;
}

.team-red .player-avatar {
  border-color: #734642;
  background: #46302f;
}

.team-blue .player-avatar {
  border-color: #3c5972;
  background: #2b3b4a;
}

.player-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.player-details {
  display: grid;
  min-width: 0;
  gap: .1rem;
}

.player-team {
  color: var(--team);
  font-size: .82rem;
  font-weight: 700;
}

.player-name {
  overflow: hidden;
  color: #f0eee5;
  font-size: .96rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-timer {
  min-width: 4.5rem;
  padding: .4rem .55rem;
  border: 1px solid #394743;
  border-radius: .3rem;
  background: #0c1618;
  color: #e0e5dc;
  font: 600 1.23rem/1.1 var(--number-font);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.is-turn .player-timer {
  border-color: #917444;
  background: #2c281b;
  color: var(--brass-light);
}

.player-timer.is-low {
  border-color: #b16a60;
  color: #ffd3c8;
}

.board-viewport {
  position: relative;
  width: min(100%, 45.25rem);
  margin: .125rem auto;
  isolation: isolate;
}

#board {
  width: 100%;
  height: auto;
  aspect-ratio: 76 / 57;
  touch-action: manipulation;
}

.arena-topbar .turn-label,
.arena-footer > :first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.panel {
  padding: 1rem;
  background:
    radial-gradient(ellipse at 100% 0%, #26332a, transparent 80%),
    var(--panel);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  margin-bottom: .875rem;
}

.panel-heading > :last-child {
  min-width: 0;
}

.panel-icon {
  display: grid;
  width: 2.2rem;
  height: 2.2rem;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #574c33;
  border-radius: .35rem;
  background: #302d22;
  color: #ddb871;
  font: 1rem/1 Georgia, serif;
}

.panel-heading :is(h2, h3) {
  color: #f0e9dc;
  font: 750 1rem/1.35 var(--heading-font);
}

.panel-heading p {
  margin-top: .2rem;
  color: var(--muted);
  font-size: .875rem;
}

.room-list {
  display: grid;
  max-height: 20rem;
  gap: .45rem;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  scrollbar-color: #58635b transparent;
}

.room-row {
  display: grid;
  width: 100%;
  min-height: 3.55rem;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .625rem;
  padding: .55rem .65rem;
  border: 1px solid #30403d;
  border-radius: .375rem;
  background: #0f191bcf;
  color: var(--ink);
  text-align: left;
}

.room-row:focus-within {
  border-color: #958252;
  background: #242b23;
}

.room-symbol {
  display: grid;
  width: 1.85rem;
  height: 1.85rem;
  place-items: center;
  border: 1px solid #4b4431;
  border-radius: .3rem;
  background: #29291e;
  color: #d8b36e;
  font: 1rem/1 Georgia, serif;
}

.room-meta {
  display: grid;
  min-width: 0;
  gap: .15rem;
  color: var(--muted);
  font-size: .85rem;
  overflow-wrap: anywhere;
}

.room-name {
  color: var(--ink);
  font-size: .92rem;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.empty-state {
  padding: .8rem .7rem;
  border: 1px dashed #40514d;
  border-radius: .375rem;
  background: #111c1c;
  color: var(--muted);
  font-size: .875rem;
  text-align: center;
  overflow-wrap: anywhere;
}

.panel-actions {
  margin-top: .8rem;
}

.panel-actions .btn {
  flex: 1 1 auto;
}

.room-controls:not(:empty) {
  margin-top: .75rem;
}

.arena-footer .room-controls {
  margin-top: 0;
}

.level-picker {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .35rem;
}

.level-btn {
  min-height: 2.6rem;
  padding: .4rem .15rem;
  border: 1px solid #3b4a45;
  border-radius: .35rem;
  background: #121b1e;
  color: #cdd6cd;
  font: 650 1rem/1 var(--number-font);
}

.level-btn:hover:not(:disabled) {
  border-color: #d6ac62;
  color: #f6e1b5;
}

.level-btn:is(.is-active, .is-selected, [aria-pressed="true"], [data-active="true"]) {
  border-color: #b79757;
  background: #433720;
  color: #f7d994;
}

.npc-details {
  display: grid;
  min-height: 3.6rem;
  align-content: center;
  gap: .15rem;
  margin-top: .6rem;
  padding: .4rem .65rem;
  border-left: 2px solid #9a7843;
  background: #121d1dc2;
  color: var(--muted);
  font-size: .875rem;
}

.difficulty-name {
  color: #e8c685;
  font-weight: 750;
}

.moves-list {
  display: grid;
  max-height: 12.75rem;
  gap: .25rem;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  scrollbar-color: #58635b transparent;
}

.move-row {
  display: grid;
  min-height: 1.95rem;
  grid-template-columns: 2rem repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: .45rem;
  padding: .35rem .55rem;
  border-radius: .2rem;
  color: var(--muted);
  font: .85rem/1.42 var(--number-font);
  font-variant-numeric: tabular-nums;
}

.move-row:nth-child(odd) {
  background: #0f1a1c;
}

.move-red {
  color: var(--red);
}

.move-blue {
  color: var(--blue);
}

.site-footer {
  display: flex;
  min-height: 3.875rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1rem;
  padding-block: .65rem;
  color: var(--quiet);
  font-size: .875rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem .9rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}

.dialog-content {
  min-width: 0;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: .2rem;
}

.dialog-actions .btn {
  min-height: 2.65rem;
}

.form-field {
  min-width: 0;
}

.form-field small {
  color: var(--muted);
  font-size: .84rem;
}

.notice,
.game-over {
  padding: .65rem .8rem;
  border: 1px solid #665735;
  border-radius: .375rem;
  background: #2e2b20;
  color: #edd7a8;
  font-size: .9rem;
  overflow-wrap: anywhere;
}

.notice.is-error,
.notice[role="alert"] {
  border-color: #815851;
  background: #3a2726;
  color: #ffcbc5;
}

.toast {
  position: fixed;
  z-index: 10;
  right: clamp(.875rem, 4vw, 2.5rem);
  bottom: clamp(.875rem, 4vw, 2.5rem);
  width: fit-content;
  max-width: min(28rem, calc(100% - 1.75rem));
  padding: .8rem 1rem;
  border: 1px solid #8e7545;
  border-radius: .45rem;
  background: #28271f;
  box-shadow: 0 1rem 2rem #0007;
  color: #f3ddaa;
  font-size: .9rem;
  overflow-wrap: anywhere;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.status-dot,
.red-dot,
.blue-dot,
.muted-dot {
  display: inline-block;
  width: .45rem;
  height: .45rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--brass);
}

.turn-label {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.turn-label.is-playing .status-dot {
  background: #8bd2a6;
  box-shadow: 0 0 .55rem #8bd2a661;
}

.red-dot {
  background: var(--red);
}

.blue-dot {
  background: var(--blue);
}

.muted-dot {
  background: var(--quiet);
}

.clock-icon {
  position: relative;
  width: .85rem;
  height: .85rem;
  flex: 0 0 auto;
  border: 1px solid #9dab9d;
  border-radius: 50%;
}

.clock-icon::after {
  position: absolute;
  top: 20%;
  left: 46%;
  width: 30%;
  height: 36%;
  border: solid #9dab9d;
  border-width: 0 0 1px 1px;
  content: "";
}

.board-rules {
  flex: 0 0 auto;
  color: #c9b17e;
  white-space: nowrap;
}

.game-over {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .3rem .8rem;
  margin: .7rem;
}

.game-over strong {
  color: var(--brass-light);
}

.panel-count {
  display: grid;
  min-width: 1.65rem;
  height: 1.65rem;
  margin-left: auto;
  padding-inline: .3rem;
  place-items: center;
  border: 1px solid #564d36;
  border-radius: .3rem;
  background: #272b21;
  color: #e1c68b;
  font: 650 .8rem/1 var(--number-font);
}

.empty-state [aria-hidden="true"] {
  color: #b09256;
  font: 1.45rem/1 Georgia, serif;
}

.empty-state p {
  margin-top: .3rem;
}

.btn-outline {
  border-color: #826d41;
  background: #27281e;
  color: #f1d49a;
}

.btn-outline:hover:not(:disabled) {
  border-color: #c6a55e;
  background: #373225;
}

.npc-start {
  width: 100%;
  margin-top: .75rem;
}

.moves-empty {
  padding: .45rem .55rem;
  border-radius: .35rem;
  background: #0f191b;
  color: var(--muted);
  font-size: .875rem;
}

.room-panel .room-controls {
  display: grid;
  gap: .65rem;
  margin-top: 0;
}

.room-code-box,
.room-occupant {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: .55rem;
  padding: .55rem .65rem;
  border: 1px solid #34423d;
  border-radius: .35rem;
  background: #0f191b;
}

.room-occupant {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.room-code-box > :first-child {
  min-width: 0;
}

.room-code-box span,
.room-occupant {
  color: var(--muted);
  font-size: .875rem;
}

.room-code-box strong {
  display: block;
  color: var(--brass-light);
  font: 700 1rem/1.35 var(--number-font);
  letter-spacing: .12em;
  overflow-wrap: anywhere;
}

.room-code-box .btn {
  flex: 0 0 auto;
}

.room-occupants {
  display: grid;
  gap: .35rem;
}

.room-occupant strong {
  min-width: 0;
  color: #e0e6dc;
  overflow-wrap: anywhere;
}

.room-occupant small {
  font-size: .81rem;
}

.room-controls .panel-actions,
.room-controls .notice {
  margin: 0;
}

.dialog-close {
  position: absolute;
  top: .85rem;
  right: .85rem;
  display: grid;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  place-items: center;
  border: 1px solid #45534a;
  border-radius: .35rem;
  background: #172323;
  color: #e4e7dc;
  font-size: 1.375rem;
  line-height: 1;
}

.dialog-close:hover {
  border-color: #a38852;
  color: #f5d69a;
}

.dialog-content > h2 {
  padding-right: 2.2rem;
}

.dialog-content > h2 + p {
  margin-top: -.5rem;
}

.dialog > div.dialog-content {
  display: grid;
  gap: .9rem;
}

.dialog .notice {
  margin: 0;
}

body:has(.help-dialog[open]) {
  overflow: hidden;
}

body:has(.help-dialog[open]) .topbar {
  position: sticky;
  z-index: 13;
  top: 0;
  background: #192523;
}

.help-backdrop {
  position: fixed;
  z-index: 11;
  inset: var(--help-top, 4.375rem) 0 0;
  background: #080e10bd;
  backdrop-filter: blur(2px);
}

.help-dialog {
  position: fixed;
  z-index: 12;
  inset: calc(var(--help-top, 4.375rem) + .65rem) 0 .65rem;
  width: min(100% - 1.5rem, 38rem);
  height: fit-content;
  max-height: calc(100% - var(--help-top, 4.375rem) - 1.3rem);
  max-width: none;
  overflow: auto;
  overscroll-behavior: contain;
  padding: clamp(1rem, 3.5vw, 1.75rem);
  border-color: #8a7145;
  background:
    radial-gradient(ellipse at 5% 0%, #30382a, transparent 70%),
    #172222;
  scrollbar-color: #687367 #172222;
}

dialog.help-dialog > .help-content {
  gap: clamp(.75rem, 2.3vw, 1.1rem);
}

.help-intro {
  padding-inline-end: 2.5rem;
}

.help-intro h2 {
  color: #f2e7cc;
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  line-height: 1.25;
}

.help-intro p {
  margin-top: .42rem;
  font-size: .95rem;
  text-wrap: pretty;
}

.help-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .55rem;
}

.help-option {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: .48rem;
  padding: .75rem;
  border: 1px solid #3f4c40;
  border-radius: .45rem;
  background: linear-gradient(150deg, #202c27, #131e1d);
}

.help-option h3 {
  color: #f1e9d8;
  font: 750 .96rem/1.35 var(--heading-font);
}

.help-option p {
  margin-top: .25rem;
  font-size: .875rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.help-rules {
  margin: 0;
  padding: .65rem .8rem;
  border-left: 2px solid #ad8a52;
  border-radius: 0 .3rem .3rem 0;
  background: #242a21;
  color: #e3d5b9;
  font-size: .875rem;
  text-wrap: pretty;
}

.promotion-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .45rem;
}

.promotion-grid button {
  display: grid;
  min-height: 4.45rem;
  justify-items: center;
  align-content: center;
  gap: .35rem;
  padding: .4rem .2rem;
  border: 1px solid #5c5239;
  border-radius: .35rem;
  background: #202b28;
  color: #e6dfcc;
  font-size: .875rem;
}

.promotion-grid button:hover {
  border-color: #dcb974;
  background: #373423;
}

.promotion-grid img,
.promotion-grid .piece-icon {
  width: 2.5rem;
  height: 2.5rem;
  object-fit: contain;
}

@media (max-width: 62rem) {
  .app-shell {
    width: calc(100% - 2rem);
  }

  .game-layout {
    grid-template-columns: minmax(0, 1.7fr) minmax(18rem, 1fr);
    gap: .8rem;
  }
}

@media (max-width: 48rem) {
  .game-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .moves-panel {
    grid-column: 1 / -1;
  }

  .page-heading {
    min-height: 6.75rem;
    margin-block: .7rem .85rem;
  }
}

@media (max-width: 42rem) {
  .topbar {
    min-height: 0;
    gap: .6rem;
    padding-block: .65rem;
  }

  .top-left,
  .top-actions {
    flex-basis: 100%;
  }

  .top-actions {
    gap: .45rem;
  }

  .top-actions .connection {
    margin-inline-end: auto;
    padding-inline: 0;
    font-size: .79rem;
  }

  .top-actions .btn {
    padding-inline: .55rem;
  }
}

@media (max-width: 35rem) {
  .app-shell {
    width: calc(100% - 1.5rem);
  }

  .sidebar {
    grid-template-columns: minmax(0, 1fr);
  }

  .arena-content {
    padding-inline: .425rem;
  }

  .arena-topbar,
  .arena-footer {
    padding-inline: .65rem;
  }

  .arena-topbar {
    min-height: 3.05rem;
  }

  .elapsed {
    gap: .3rem;
  }

  .elapsed .clock-icon {
    display: none;
  }

  .player-card {
    gap: .45rem;
    padding-inline: .5rem;
  }

  .player-timer {
    min-width: 3.8rem;
    padding-inline: .4rem;
    font-size: 1.1rem;
  }

  .panel {
    padding: .8rem;
  }

  .help-options {
    grid-template-columns: minmax(0, 1fr);
  }

  .help-option {
    grid-template-columns: auto minmax(0, 1fr);
    gap: .2rem .65rem;
    padding: .65rem;
  }
}

@media (max-width: 26rem) {
  .top-actions:has(.help-trigger) .connection {
    flex-basis: 100%;
    margin-inline-end: 0;
  }

  .help-trigger [aria-hidden="true"] {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

.piece-icon {
  display: inline-block;
  width: 2.1rem;
  height: 2.1rem;
  flex: 0 0 auto;
  background-image: url("assets/chess-characters.png");
  background-position: var(--piece-x, 0%) var(--piece-y, 0%);
  background-repeat: no-repeat;
  background-size: 600% 200%;
}

.piece-icon.blue {
  --piece-y: 100%;
}

.piece-icon.rook {
  --piece-x: 20%;
}

.piece-icon.knight {
  --piece-x: 40%;
}

.piece-icon.bishop {
  --piece-x: 60%;
}

.piece-icon.queen {
  --piece-x: 80%;
}

.piece-icon.king {
  --piece-x: 100%;
}

#portrait-notice,
#chess-fullscreen {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  html,
  body {
    min-width: 0;
    min-height: 100dvh;
  }

  body {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior: none;
  }

  input,
  textarea,
  [contenteditable="true"] {
    -webkit-touch-callout: default;
    -webkit-user-select: text;
    user-select: text;
    font-size: 1rem;
  }

  .app-shell {
    width: 100%;
    min-height: 100dvh;
    padding: env(safe-area-inset-top) max(.4rem, env(safe-area-inset-right))
      max(.4rem, env(safe-area-inset-bottom)) max(.4rem, env(safe-area-inset-left));
  }

  .topbar {
    min-height: 0;
    padding-block: .4rem;
    gap: .35rem;
  }

  .top-left,
  .top-actions {
    gap: .3rem .5rem;
  }

  .top-actions .btn {
    min-height: 2.1rem;
    padding: .3rem .45rem;
    font-size: .8rem;
  }

  .page-heading {
    position: absolute;
    width: 1px;
    min-height: 0;
    height: 1px;
    margin: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .game-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: .65rem;
    padding-top: .45rem;
  }

  .arena-content {
    padding: .25rem;
  }

  .arena-topbar,
  .arena-footer {
    min-height: 2.45rem;
    padding: .35rem .5rem;
  }

  .player-card {
    min-height: 2.6rem;
    padding-block: .25rem;
  }

  #board {
    touch-action: none;
  }

  #chess-fullscreen:not([hidden]) {
    display: inline-flex;
  }
}

@media (hover: none) and (pointer: coarse) and (orientation: landscape) {
  .app-shell,
  .help-backdrop,
  .toast {
    display: none;
  }

  dialog[open],
  dialog[open]::backdrop {
    visibility: hidden;
  }

  #portrait-notice {
    display: grid;
    min-height: 100dvh;
    place-items: center;
    padding: 1.5rem;
    color: var(--brass-light);
    text-align: center;
    font: 700 1.15rem/1.5 var(--body-font);
  }
}
