@font-face {
  font-family: "Fraunces";
  src: url("assets/fonts/fraunces-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 600 800;
  font-display: swap;
}

@font-face {
  font-family: "Fraunces";
  src: url("assets/fonts/fraunces-italic-latin.woff2") format("woff2");
  font-style: italic;
  font-weight: 600 800;
  font-display: swap;
}

@font-face {
  font-family: "Nunito Sans";
  src: url("assets/fonts/nunito-sans-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 500 900;
  font-display: swap;
}

:root {
  --viewport-height: 100svh;
  --ink: #211f1a;
  --ink-soft: #5d574c;
  --paper: #f4eddd;
  --paper-light: #fbf7ec;
  --paper-deep: #e6dac1;
  --blue: #244f78;
  --blue-light: #dce8ef;
  --red: #a23d32;
  --red-light: #f0ded8;
  --gold: #bf872b;
  --wood-dark: #241a14;
  --wood-mid: #493225;
  --maple: #e5c690;
  --paper-border: rgba(74, 55, 33, 0.3);
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-ui: "Nunito Sans", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --board-size: min(calc(var(--viewport-height) - 32px), calc(100vw - 286px), 820px);
  --shadow: 0 22px 60px rgba(48, 35, 21, 0.2);
  color-scheme: light;
  font-family: var(--font-display);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 17% 8%, rgba(255, 254, 247, 0.96) 0 9%, transparent 38%),
    radial-gradient(ellipse at 92% 17%, rgba(166, 91, 63, 0.12), transparent 29%),
    radial-gradient(ellipse at 13% 91%, rgba(31, 72, 105, 0.16), transparent 33%),
    radial-gradient(ellipse at 76% 92%, rgba(170, 129, 71, 0.11), transparent 32%),
    repeating-linear-gradient(88deg, rgba(72, 55, 34, 0.025) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(2deg, rgba(255, 255, 255, 0.19) 0 1px, transparent 1px 7px),
    linear-gradient(120deg, #f4eddf 0%, #e9dfce 48%, #f1e8d9 100%);
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(105deg, transparent 0 42%, rgba(104, 76, 43, 0.035) 43%, transparent 45% 72%, rgba(255,255,255,0.22) 73%, transparent 76%),
    repeating-linear-gradient(14deg, transparent 0 18px, rgba(89, 64, 38, 0.012) 19px, transparent 20px 38px);
  mix-blend-mode: multiply;
}

.background-still-life {
  position: fixed;
  z-index: 0;
  top: -38px;
  right: 0;
  width: clamp(280px, 30vw, 430px);
  height: auto;
  opacity: 0.9;
  filter: drop-shadow(0 18px 18px rgba(47, 33, 20, 0.19)) saturate(0.88);
  pointer-events: none;
  user-select: none;
}

.background-cloth {
  position: fixed;
  z-index: 0;
  left: -118px;
  bottom: -148px;
  width: clamp(280px, 28vw, 420px);
  aspect-ratio: 1.5;
  border-radius: 18% 72% 22% 0;
  background:
    linear-gradient(142deg, transparent 0 26%, rgba(255,255,255,0.12) 27%, transparent 31%),
    repeating-linear-gradient(7deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 5px),
    linear-gradient(125deg, #172b3b 0%, #244f6e 44%, #132634 100%);
  box-shadow: 18px -18px 38px rgba(42, 30, 19, 0.13), inset -16px 20px 35px rgba(255,255,255,0.06);
  clip-path: polygon(0 15%, 52% 0, 100% 34%, 76% 100%, 0 100%);
  transform: rotate(5deg) skewX(-4deg);
  opacity: 0.88;
  pointer-events: none;
}

.background-cloth::after {
  content: "";
  position: absolute;
  inset: 13% 4% 4% 18%;
  border-radius: 60% 34% 22% 18%;
  border-top: 2px solid rgba(228, 216, 190, 0.17);
  transform: rotate(-7deg);
}

.background-cloth::before {
  content: "";
  position: absolute;
  inset: 18% -7% 8% 23%;
  border-radius: 58% 8% 30% 16%;
  background: linear-gradient(145deg, rgba(255,255,255,0.13), transparent 24% 54%, rgba(5,17,25,0.24));
  border-left: 1px solid rgba(238,226,204,0.13);
  transform: rotate(11deg);
}

button,
input {
  font: inherit;
}

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

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible + span {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.ink-cloud {
  display: none;
}

.ink-cloud-one {
  left: -5vw;
  top: 8vh;
  transform: rotate(-11deg);
}

.ink-cloud-two {
  right: -6vw;
  bottom: 4vh;
  transform: rotate(165deg);
}

.page-shell {
  position: relative;
  z-index: 1;
  height: var(--viewport-height);
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.site-header {
  min-height: 58px;
  padding: 9px clamp(14px, 3vw, 38px) 4px;
  display: flex;
  align-items: center;
}

.site-logo {
  display: inline-flex;
  align-items: center;
  width: clamp(148px, 16vw, 205px);
  min-height: 44px;
}

.site-logo img {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 2px 1px rgba(255, 255, 255, 0.75));
}

.site-footer {
  flex-shrink: 0;
  min-height: 32px;
  padding: 6px 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font: 0.86rem/1.2 var(--font-ui);
  color: var(--ink-soft);
}

.site-footer a {
  color: var(--blue);
  font-weight: 700;
}

.game-main,
.menu-screen,
.play-screen {
  min-height: 0;
}

.menu-screen {
  width: min(1000px, calc(100% - 32px));
  height: 100%;
  margin: 0 auto;
  padding: clamp(5px, 1.5vh, 18px) 0;
  display: grid;
  grid-template-columns: minmax(0, 0.96fr) minmax(500px, 1.04fr);
  align-items: center;
  gap: clamp(18px, 1.6vw, 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.menu-hero {
  position: relative;
  padding: 10px 0 10px clamp(8px, 2vw, 24px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--red);
  font: 800 0.76rem/1.2 var(--font-ui);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 16px;
  font-size: clamp(2.65rem, 5.2vw, 4.2rem);
  line-height: 0.94;
  letter-spacing: -0.045em;
  font-family: var(--font-display);
  font-weight: 650;
}

@media (min-width: 701px) {
  h1 {
    white-space: nowrap;
  }
}

h2,
h3 {
  font-family: var(--font-display);
}

h1 span {
  display: block;
  margin-top: 0.1em;
  color: var(--blue);
  font-style: italic;
  font-size: 0.56em;
  line-height: 1.05;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.hero-copy {
  width: min(430px, 95%);
  margin-bottom: 18px;
  color: var(--ink-soft);
  font: 1.03rem/1.5 var(--font-ui);
}

.menu-piece-display {
  position: relative;
  width: 330px;
  height: 116px;
  margin: 2px 0 0 12px;
  pointer-events: none;
}

.menu-piece-display .menu-piece {
  position: absolute;
  z-index: 2;
  width: 92px;
}

.menu-piece-display .menu-piece:nth-child(1) {
  left: 20px;
  top: 18px;
}

.menu-piece-display .menu-piece:nth-child(2) {
  left: 114px;
  top: 0;
  width: 106px;
}

.menu-piece-display .menu-piece:nth-child(3) {
  left: 220px;
  top: 20px;
}

.menu-piece-rail {
  position: absolute;
  left: 18px;
  right: 8px;
  bottom: 8px;
  height: 17px;
  border: 1px solid #281a12;
  border-radius: 4px 5px 9px 3px;
  background: linear-gradient(#684734, #2d2018 68%, #160f0b);
  box-shadow: 0 9px 14px rgba(42, 26, 15, 0.2), inset 0 2px rgba(255, 255, 255, 0.12);
}

.menu-card {
  padding: clamp(20px, 3vw, 34px);
  border: 1px solid rgba(74, 55, 33, 0.38);
  border-radius: 4px 18px 5px 16px;
  background:
    radial-gradient(ellipse at 94% 7%, rgba(162, 61, 50, 0.075), transparent 29%),
    linear-gradient(112deg, rgba(255,255,255,0.82), transparent 34% 70%, rgba(36,79,120,0.045)),
    repeating-linear-gradient(4deg, rgba(70, 48, 24, 0.014) 0 1px, transparent 1px 6px),
    rgba(253, 249, 239, 0.96);
  box-shadow:
    0 24px 52px rgba(48, 35, 21, 0.24),
    0 3px 7px rgba(48, 35, 21, 0.12),
    inset 0 0 0 3px rgba(255,255,255,0.28);
  position: relative;
}

.menu-card::before,
.menu-card::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.menu-card::before {
  z-index: 0;
  height: 10px;
  top: -1px;
  left: 12px;
  right: 12px;
  border-radius: 0 0 5px 5px;
  background:
    repeating-linear-gradient(2deg, rgba(255,255,255,0.04) 0 1px, transparent 1px 5px),
    linear-gradient(90deg, #172c3c 0 7%, var(--wood-dark) 8%, var(--wood-mid) 48%, var(--wood-dark) 91%, #7f302a 92% 100%);
  box-shadow: inset 0 -2px 2px rgba(0,0,0,0.28), 0 2px 4px rgba(44,29,17,0.13);
}

.menu-card::after {
  width: 34px;
  height: 34px;
  right: 0;
  bottom: 0;
  border-radius: 0 0 4px 0;
  background: linear-gradient(135deg, transparent 0 48%, rgba(151, 121, 82, 0.16) 49% 51%, rgba(222, 207, 179, 0.58) 52% 100%);
  box-shadow: -2px -2px 5px rgba(67,48,27,0.06);
}

.menu-card > * {
  position: relative;
  z-index: 1;
}

.menu-card-header {
  margin: 1px 0 20px;
  padding: 0 0 15px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(74, 55, 33, 0.2);
  box-shadow: 0 1px 0 rgba(255,255,255,0.76);
}

.menu-card-header p,
.menu-card-header h2 {
  margin: 0;
}

.menu-card-header p {
  color: var(--red);
  font: 800 0.65rem/1.2 var(--font-ui);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.menu-card-header h2 {
  margin-top: 2px;
  font-size: 1.45rem;
  line-height: 1;
  letter-spacing: -0.025em;
}

.choice-group {
  padding: 0;
  margin: 0 0 20px;
  border: 0;
}

.choice-group legend {
  margin-bottom: 9px;
  font: 800 0.82rem/1.2 var(--font-ui);
  letter-spacing: 0.04em;
}

.segmented-control,
.difficulty-options {
  display: grid;
  gap: 8px;
}

.segmented-control {
  grid-template-columns: 1fr 1fr;
}

.difficulty-options {
  grid-template-columns: repeat(3, 1fr);
}

.segmented-control label,
.difficulty-options label {
  min-width: 0;
  cursor: pointer;
}

.segmented-control input,
.difficulty-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span,
.difficulty-options label > span {
  min-height: 52px;
  padding: 8px 10px;
  border: 1px solid var(--paper-border);
  border-radius: 7px;
  background:
    radial-gradient(circle at 82% 15%, rgba(164, 61, 49, 0.06), transparent 28%),
    linear-gradient(180deg, rgba(255,255,255,0.82), transparent 44%),
    linear-gradient(180deg, #fbf2df, #dfceb0);
  box-shadow: 0 4px 0 #a9926f, 0 7px 12px rgba(53,37,21,0.13), inset 0 1px 0 #fff, inset 0 0 0 1px rgba(255,255,255,0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font: 700 0.9rem/1.2 var(--font-ui);
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.difficulty-options label > span {
  flex-direction: column;
}

.mode-choice .segmented-control span {
  gap: 10px;
}

.mode-icon {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.88;
}

.difficulty-options small {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 600;
}

.segmented-control input:checked + span,
.difficulty-options input:checked + span {
  color: var(--paper-light);
  border-color: #153d5d;
  background:
    radial-gradient(circle at 32% 18%, rgba(255,255,255,0.34), transparent 27%),
    linear-gradient(180deg, #3977a2, #215579 72%, #173f5e);
  box-shadow: 0 4px 0 #12334e, 0 8px 13px rgba(29,63,89,0.2), inset 0 1px 1px rgba(255,255,255,0.42);
  transform: translateY(-1px);
}

.difficulty-options input:checked + span small {
  color: #eaf3f7;
}

.difficulty-choice.is-disabled {
  opacity: 0.42;
}

.menu-actions {
  margin-top: 4px;
}

.primary-button,
.secondary-button,
.text-button,
.danger-text-button,
.close-button {
  border: 0;
  cursor: pointer;
}

.primary-button {
  min-height: 50px;
  padding: 11px 25px;
  color: #fffaf0;
  border: 1px solid #6f2923;
  border-radius: 8px;
  background:
    radial-gradient(circle at 26% 8%, rgba(255,255,255,0.28), transparent 22%),
    radial-gradient(circle at 83% 115%, rgba(85,25,25,0.28), transparent 42%),
    linear-gradient(180deg, #c75b4b, #a13a31 69%, #7c2924);
  box-shadow: 0 6px 0 #58201c, 0 13px 24px rgba(111, 41, 35, 0.24), inset 0 1px 1px rgba(255,255,255,0.42), inset 0 0 0 1px rgba(84,22,18,0.18);
  font: 800 1rem/1 var(--font-ui);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.menu-actions > .primary-button {
  width: 100%;
  position: relative;
}

.menu-actions > .primary-button::after {
  content: "›";
  position: absolute;
  right: 20px;
  top: 50%;
  font: 700 1.55rem/1 var(--font-display);
  transform: translateY(-53%);
  opacity: 0.8;
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 0 #61241f, 0 13px 22px rgba(111, 41, 35, 0.22), inset 0 1px 1px rgba(255,255,255,0.35);
}

.primary-button:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #61241f, inset 0 1px 3px rgba(62,20,17,0.25);
}

.secondary-actions {
  margin-top: 13px;
  display: flex;
  justify-content: center;
  gap: 22px;
}

.text-button,
.danger-text-button {
  min-height: 44px;
  padding: 8px 13px;
  color: var(--blue);
  border: 1px solid rgba(69,50,31,0.28);
  border-radius: 6px;
  background:
    radial-gradient(circle at 80% 10%, rgba(36,79,120,0.07), transparent 35%),
    linear-gradient(180deg, rgba(255,255,255,0.85), rgba(225,210,183,0.78));
  box-shadow: 0 3px 0 #a99575, 0 6px 10px rgba(50,35,21,0.1), inset 0 1px 0 #fff;
  text-decoration: none;
  font: 750 0.88rem/1 var(--font-ui);
}

.danger-text-button {
  color: var(--red);
}

.fullscreen-button {
  position: fixed;
  z-index: 60;
  top: max(12px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  width: 46px;
  height: 46px;
  padding: 10px;
  display: grid;
  place-items: center;
  color: #2c2119;
  border: 3px solid var(--wood-mid);
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 23%, rgba(255,255,255,0.82), transparent 25%),
    linear-gradient(180deg, #fff9ea, #ddceb3);
  box-shadow: 0 4px 0 #241812, 0 8px 15px rgba(45,30,18,0.18), inset 0 1px 1px #fff;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.fullscreen-icon {
  grid-area: 1 / 1;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fullscreen-icon-exit,
.fullscreen-button[aria-pressed="true"] .fullscreen-icon-enter {
  display: none;
}

.fullscreen-button[aria-pressed="true"] .fullscreen-icon-exit {
  display: block;
}

/* Gameplay */

.page-shell.is-playing {
  display: block;
}

.page-shell.is-playing .site-header,
.page-shell.is-playing .site-footer {
  display: none;
}

.page-shell.is-playing .game-main,
.page-shell.is-playing .play-screen {
  height: 100%;
}

.play-screen {
  width: 100%;
  padding: 10px clamp(10px, 2vw, 24px);
  display: grid;
  grid-template-columns: max-content 224px;
  justify-content: center;
  align-items: center;
  gap: clamp(12px, 2vw, 28px);
  overflow: auto;
  overscroll-behavior: contain;
}

.board-stage {
  width: var(--board-size);
  justify-self: center;
  position: relative;
}

.board-heading {
  position: absolute;
  z-index: 8;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.turn-badge {
  min-height: 34px;
  padding: 7px 13px;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(58, 39, 25, 0.42);
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(108, 72, 38, 0.04), transparent 28% 70%, rgba(108, 72, 38, 0.05)),
    linear-gradient(180deg, #f8e7c9, #ddbd87);
  box-shadow: 0 4px 0 #8b633d, 0 8px 17px rgba(40, 28, 17, 0.2), inset 0 1px 0 rgba(255,255,255,0.75);
  white-space: nowrap;
  font: 800 0.78rem/1 var(--font-ui);
}

.turn-dot,
.summary-color {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid #143b59;
  background: linear-gradient(145deg, #4b83aa, #1e5278 68%, #153b58);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.55), 0 1px 2px rgba(32,24,17,0.18);
}

.turn-red .turn-dot,
.red-summary .summary-color {
  border-color: #6e2923;
  background: linear-gradient(145deg, #c66557, #9d3a31 68%, #712a24);
}

.thinking-text {
  min-height: 16px;
  margin-top: 4px;
  color: var(--ink-soft);
  font: italic 0.72rem/1.2 var(--font-ui);
}

.board-coordinate-wrap {
  --board-inset: 24px;
  --frame-inset: 5px;
  width: 100%;
  aspect-ratio: 1;
  position: relative;
}

.board-coordinate-wrap::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: var(--frame-inset);
  border: 1px solid #160f0c;
  border-radius: 4px 7px 5px 6px;
  background:
    linear-gradient(92deg, transparent 0 9%, rgba(255, 221, 169, 0.07) 10%, transparent 11% 38%, rgba(0, 0, 0, 0.11) 39%, transparent 40% 72%, rgba(255, 223, 178, 0.06) 73%, transparent 74%),
    repeating-linear-gradient(2deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 7px),
    linear-gradient(135deg, var(--wood-mid), var(--wood-dark) 48%, #342219 72%, #1e1511);
  box-shadow:
    0 15px 30px rgba(42, 28, 17, 0.26),
    0 4px 7px rgba(42, 28, 17, 0.24),
    inset 0 2px 1px rgba(255, 234, 202, 0.15),
    inset 0 -3px 5px rgba(0, 0, 0, 0.32);
  pointer-events: none;
}

.board-coordinate-wrap::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: calc(var(--board-inset) - 4px);
  border: 4px solid rgba(25, 16, 12, 0.72);
  border-radius: 3px;
  box-shadow: inset 0 0 8px rgba(39, 24, 13, 0.45);
  pointer-events: none;
}

.board {
  position: absolute;
  z-index: 2;
  inset: var(--board-inset);
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  border: 1px solid #33251a;
  border-radius: 1px;
  overflow: hidden;
  background: var(--maple);
  box-shadow: inset 0 0 32px rgba(91, 57, 24, 0.2);
}

.board-cell {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-right: 1px solid rgba(45, 32, 22, 0.72);
  border-bottom: 1px solid rgba(45, 32, 22, 0.72);
  background:
    radial-gradient(ellipse at 25% 25%, rgba(255, 249, 223, 0.17), transparent 42%),
    repeating-linear-gradient(2deg, rgba(101, 62, 25, 0.025) 0 1px, transparent 1px 8px),
    linear-gradient(90deg, rgba(129, 78, 29, 0.025), transparent 20% 77%, rgba(104, 62, 25, 0.025)),
    rgba(239, 213, 165, 0.74);
  position: relative;
  display: grid;
  place-items: center;
  cursor: default;
}

.board-cell:nth-child(9n) {
  border-right: 0;
}

.board-cell:nth-last-child(-n + 9) {
  border-bottom: 0;
}

.board-cell.has-piece,
.board-cell.is-legal {
  cursor: pointer;
}

.board-cell.goal-blue,
.board-cell.goal-red {
  --goal-accent: 35 94 140;
  background:
    linear-gradient(45deg, transparent 0 43%, rgba(255, 246, 218, 0.2) 44% 56%, transparent 57%),
    linear-gradient(-45deg, transparent 0 43%, rgb(var(--goal-accent) / 0.1) 44% 56%, transparent 57%),
    radial-gradient(circle, rgba(255, 249, 224, 0.35) 0 40%, rgb(var(--goal-accent) / 0.12) 41% 63%, transparent 64%),
    rgba(224, 192, 137, 0.96);
}

.board-cell.goal-blue::before,
.board-cell.goal-red::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 17%;
  border: 2px solid rgb(var(--goal-accent) / 0.86);
  border-radius: 50%;
  background:
    radial-gradient(circle, #f8e8bd 0 30%, #d6ad68 31% 38%, transparent 39%),
    repeating-conic-gradient(
      from 11deg,
      rgb(var(--goal-accent) / 0.68) 0 10deg,
      rgba(249, 229, 188, 0.9) 10deg 22.5deg
    );
  box-shadow:
    0 0 0 3px rgba(111, 75, 39, 0.72),
    0 0 0 6px rgba(250, 230, 188, 0.7),
    0 3px 5px rgba(67, 42, 22, 0.28),
    inset 0 0 0 2px rgba(255, 249, 226, 0.52),
    inset 0 -4px 7px rgba(72, 43, 23, 0.22);
  transform: rotate(4deg);
}

.board-cell.goal-red {
  --goal-accent: 163 63 53;
}

.board-cell.goal-red::before {
  transform: rotate(-4deg);
}

.board-cell.last-from::after,
.board-cell.last-to::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 7%;
  border: 2px solid rgba(174, 116, 27, 0.82);
  pointer-events: none;
}

.board-cell.last-from {
  box-shadow:
    inset 0 0 0 2px rgba(174, 116, 27, 0.32),
    inset 0 0 22px rgba(210, 158, 55, 0.14);
}

.board-cell.last-from::after {
  border-style: dashed;
  opacity: 0.78;
}

.board-cell.last-to {
  box-shadow:
    inset 0 0 0 3px rgba(174, 116, 27, 0.72),
    inset 0 0 25px rgba(222, 171, 67, 0.23);
}

.board-cell.last-to::after {
  inset: 6%;
  border-width: 3px;
  border-color: rgba(174, 116, 27, 0.9);
}

.board-cell.is-legal::after {
  content: "";
  position: absolute;
  z-index: 3;
  inset: auto;
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  width: 18%;
  min-width: 8px;
  aspect-ratio: 1;
  border: 0;
  border-radius: 50% 45% 52% 42%;
  background: rgba(33, 31, 26, 0.48);
  box-shadow: 1px 0 0 rgba(33, 31, 26, 0.16);
  opacity: 1;
  transform: translate(-50%, -50%) rotate(17deg);
  transform-origin: center;
}

.board-cell.is-capture::after {
  width: 72%;
  background: transparent;
  border: 3px solid rgba(37, 31, 25, 0.9);
  box-shadow:
    0 0 0 2px rgba(255, 249, 232, 0.92),
    0 0 0 4px rgba(191, 135, 43, 0.72),
    0 3px 7px rgba(45, 31, 20, 0.2);
  opacity: 1;
}

.board-cell.is-selected {
  background: rgba(218, 185, 118, 0.94);
}

.board-cell.is-selected .piece-token {
  box-shadow:
    0 0 0 3px #e1ae46,
    0 6px 5px rgba(38, 24, 14, 0.28),
    0 11px 14px rgba(38, 24, 14, 0.19),
    inset 0 2px 2px rgba(255, 255, 255, 0.8),
    inset 0 -4px 5px rgba(26, 17, 11, 0.28);
  transform: translateY(-3px) rotate(var(--piece-rotate, 0deg));
}

.piece-token {
  position: relative;
  z-index: 4;
  width: 78%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid var(--glaze-deep);
  border-radius: 50% 47% 49% 46%;
  background:
    radial-gradient(circle at 34% 24%, rgba(255, 255, 255, 0.62) 0 4%, rgba(255,255,255,0.12) 5% 15%, transparent 16%),
    radial-gradient(circle closest-side, #fbf4e7 0 58%, #eadcc7 59% 64%, var(--glaze-soft) 65% 71%, var(--glaze) 72% 88%, var(--glaze-deep) 89% 100%);
  box-shadow:
    0 4px 3px rgba(38, 24, 14, 0.28),
    0 8px 11px rgba(38, 24, 14, 0.16),
    inset 0 2px 2px rgba(255, 255, 255, 0.8),
    inset 0 -4px 5px rgba(26, 17, 11, 0.3);
  transform: rotate(var(--piece-rotate, 0deg));
  transition: transform 130ms ease, box-shadow 130ms ease;
  pointer-events: none;
}

.board-cell.last-to .piece-token {
  box-shadow:
    0 0 0 3px rgba(225, 174, 70, 0.88),
    0 5px 4px rgba(38, 24, 14, 0.28),
    0 9px 12px rgba(38, 24, 14, 0.18),
    inset 0 2px 2px rgba(255, 255, 255, 0.8),
    inset 0 -4px 5px rgba(26, 17, 11, 0.3);
}

.piece-blue {
  --glaze-deep: #123957;
  --glaze: #235e8c;
  --glaze-soft: #719bb4;
  color: var(--blue);
}

.piece-red {
  --glaze-deep: #732b25;
  --glaze: #a33f35;
  --glaze-soft: #c87968;
  color: var(--red);
}

.piece-token svg {
  width: 67%;
  height: 67%;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.piece-papir svg {
  width: 59%;
  height: 68%;
}

.piece-sten svg {
  width: 65%;
}

.rank-labels,
.file-labels {
  z-index: 3;
  position: absolute;
  color: #ebd9b6;
  font: 800 0.72rem/1 var(--font-ui);
  text-transform: uppercase;
  text-shadow: 0 1px 1px #100a08;
}

.rank-labels {
  top: 24px;
  bottom: 24px;
  left: 0;
  width: 22px;
  display: grid;
  grid-template-rows: repeat(9, 1fr);
}

.file-labels {
  left: 24px;
  right: 24px;
  bottom: 6px;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
}

.rank-labels span,
.file-labels span {
  display: grid;
  place-items: center;
}

.capture-flash {
  position: absolute;
  z-index: 20;
  top: 0;
  left: 0;
  width: 13%;
  aspect-ratio: 1;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.25) rotate(-12deg);
}

.capture-flash::before,
.capture-flash::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 4px solid rgba(162, 61, 50, 0.8);
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 0 0 2px rgba(255, 248, 231, 0.72);
}

.capture-flash::after {
  inset: 20%;
  border-color: rgba(191, 135, 43, 0.72);
  box-shadow: none;
}

.capture-flash.is-active {
  animation: ink-impact 420ms ease-out both;
}

@keyframes ink-impact {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.25) rotate(-12deg); }
  28% { opacity: 0.95; transform: translate(-50%, -50%) scale(1.25) rotate(4deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.65) rotate(9deg); }
}

.game-hud {
  width: 224px;
  justify-self: start;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  border: 1px solid rgba(70, 50, 30, 0.3);
  border-radius: 3px 14px 4px 12px;
  background:
    radial-gradient(ellipse at 100% 0%, rgba(162,61,50,0.075), transparent 36%),
    linear-gradient(110deg, rgba(255,255,255,0.62), transparent 40% 75%, rgba(36,79,120,0.04)),
    repeating-linear-gradient(3deg, rgba(67, 47, 25, 0.015) 0 1px, transparent 1px 6px),
    rgba(253, 248, 237, 0.97);
  box-shadow: 0 18px 42px rgba(48, 33, 20, 0.24), 0 3px 7px rgba(48,33,20,0.11), inset 3px 0 0 rgba(36,79,120,0.13);
  position: relative;
}

.game-hud::before {
  content: "";
  position: absolute;
  top: 11px;
  bottom: 11px;
  left: 6px;
  width: 1px;
  background: rgba(100, 69, 38, 0.16);
  box-shadow: 2px 0 0 rgba(255,255,255,0.72);
}

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

.hud-brand small,
.hud-brand strong {
  display: block;
}

.hud-brand small {
  color: var(--ink-soft);
  font: 0.66rem/1.2 var(--font-ui);
}

.hud-brand strong {
  color: var(--blue);
  max-width: 138px;
  font-size: 0.95rem;
  line-height: 1.05;
  font-style: italic;
}

.brush-circle {
  width: 35px;
  height: 35px;
  border: 1px solid rgba(31, 20, 14, 0.64);
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--paper-light) 0 43%, #b69364 45% 57%, #3e2a20 59% 75%, #211713 77% 100%);
  box-shadow: 0 2px 3px rgba(41, 27, 17, 0.2), inset 0 1px 1px rgba(255,255,255,0.55);
}

.hud-section {
  padding: 12px 0;
  border-top: 1px solid rgba(75, 53, 31, 0.18);
  border-bottom: 1px solid rgba(75, 53, 31, 0.18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.65);
}

.summary-row {
  min-height: 43px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.summary-row + .summary-row {
  margin-top: 7px;
}

.summary-row strong,
.summary-row small {
  display: block;
  font-family: var(--font-ui);
}

.summary-row strong {
  font-size: 0.84rem;
}

.summary-row small {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 0.64rem;
}

.piece-count {
  font: 800 1rem/1 var(--font-ui);
}

.move-status {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink-soft);
  font: 0.75rem/1.2 var(--font-ui);
}

.move-status strong {
  color: var(--ink);
}

.hud-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.secondary-button {
  min-height: 44px;
  padding: 9px 13px;
  border: 1px solid rgba(33, 31, 26, 0.42);
  border-radius: 6px;
  background:
    radial-gradient(circle at 82% 10%, rgba(36,79,120,0.07), transparent 34%),
    linear-gradient(180deg, #fffaf0, #e2d1b4);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9), 0 3px 0 #a9916e, 0 6px 10px rgba(45,30,17,0.11);
  font: 750 0.8rem/1 var(--font-ui);
}

.secondary-button:hover {
  background: linear-gradient(180deg, #fffdf7, #e7d8bd);
}

/* Modals */

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  padding: 16px;
  display: grid;
  place-items: center;
  background: rgba(31, 28, 22, 0.6);
  backdrop-filter: blur(5px);
  overflow-y: auto;
}

.modal {
  width: min(760px, 100%);
  max-height: calc(var(--viewport-height) - 32px);
  padding: clamp(20px, 3vw, 34px);
  border: 1px solid var(--paper-border);
  border-radius: 5px 17px 5px 14px;
  background:
    repeating-linear-gradient(4deg, rgba(60, 45, 27, 0.016) 0 1px, transparent 1px 6px),
    linear-gradient(180deg, #fffaf0, #f3ead8);
  box-shadow: 0 25px 80px rgba(24, 20, 14, 0.42);
  overflow-y: auto;
  position: relative;
}

.modal::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 0;
  left: 13px;
  right: 13px;
  height: 8px;
  border-radius: 0 0 5px 5px;
  background:
    repeating-linear-gradient(2deg, rgba(255,255,255,0.04) 0 1px, transparent 1px 5px),
    linear-gradient(90deg, var(--wood-dark), var(--wood-mid) 50%, var(--wood-dark));
  box-shadow: inset 0 -2px 2px rgba(0,0,0,0.28), 0 2px 4px rgba(44,29,17,0.12);
  pointer-events: none;
}

.modal > * {
  position: relative;
  z-index: 1;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.modal h2 {
  margin-bottom: 18px;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  line-height: 1;
}

.close-button {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: #34251c;
  border: 2px solid var(--wood-mid);
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 23%, rgba(255,255,255,0.8), transparent 24%),
    linear-gradient(180deg, #fff9ec, #ded0b6);
  box-shadow: 0 3px 0 #2a1c15, 0 6px 10px rgba(42,27,16,0.15), inset 0 1px 1px #fff;
  font: 400 2rem/1 var(--font-ui);
}

.rules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.rules-grid article {
  min-height: 172px;
  padding: 16px 16px 12px;
  border: 1px solid rgba(82, 59, 34, 0.24);
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.58), transparent 35%),
    rgba(235, 222, 197, 0.58);
  box-shadow: 0 3px 0 rgba(154,130,94,0.5), 0 6px 10px rgba(55,38,21,0.07), inset 0 1px 0 #fff;
  position: relative;
}

.rules-grid h3 {
  margin: 0 0 6px 34px;
  font-size: 1.03rem;
}

.rules-grid p {
  margin-bottom: 10px;
  color: var(--ink-soft);
  font: 0.84rem/1.35 var(--font-ui);
}

.rule-number {
  position: absolute;
  top: 13px;
  left: 13px;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  color: #fffaf0;
  border: 1px solid #6f2923;
  border-radius: 50%;
  background: linear-gradient(145deg, #c76657, #96372f 68%, #702923);
  box-shadow: 0 2px 0 #5a211d, inset 0 1px 1px rgba(255,255,255,0.42);
  font: 800 0.78rem/1 var(--font-ui);
}

.mini-board {
  width: 73px;
  margin: 6px auto 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 4px solid var(--wood-mid);
  background: #e6c893;
  box-shadow: 0 3px 5px rgba(49,32,18,0.14);
}

.mini-board > * {
  aspect-ratio: 1;
  border-right: 1px solid rgba(33, 31, 26, 0.4);
  border-bottom: 1px solid rgba(33, 31, 26, 0.4);
  position: relative;
}

.mini-board > *:nth-child(3n) { border-right: 0; }
.mini-board > *:nth-last-child(-n + 3) { border-bottom: 0; }
.mini-board i::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-soft);
  inset: 0;
  margin: auto;
}
.mini-board b::after {
  content: "";
  position: absolute;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--blue);
  inset: 0;
  margin: auto;
}

.rule-cycle,
.goal-diagram,
.quiet-diagram {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--blue);
  font: 800 0.75rem/1 var(--font-ui);
}

.rule-cycle span {
  color: var(--red);
  font-size: 1.4rem;
}

.goal-diagram span {
  padding: 8px;
  border: 2px double currentColor;
}

.goal-diagram span:last-child {
  color: var(--red);
}

.goal-diagram i,
.quiet-diagram i {
  width: 60px;
  height: 2px;
  background: var(--ink-soft);
  position: relative;
}

.goal-diagram i::after,
.quiet-diagram i::after {
  content: "";
  position: absolute;
  right: -1px;
  top: -4px;
  border-left: 7px solid var(--ink-soft);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

.quiet-diagram strong {
  color: var(--red);
  font-size: 1.1rem;
}

.rules-note {
  margin: 14px 0;
  text-align: center;
  color: var(--ink-soft);
  font: 0.82rem/1.4 var(--font-ui);
}

.modal-done {
  display: block;
  margin: 0 auto;
}

.stats-modal {
  width: min(600px, 100%);
}

.stats-table {
  display: grid;
  gap: 8px;
}

.stats-row {
  min-height: 58px;
  padding: 9px 13px;
  display: grid;
  grid-template-columns: minmax(130px, 1fr) repeat(3, minmax(50px, 0.5fr));
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(78,56,33,0.16);
  border-radius: 6px;
  background: rgba(255,252,244,0.48);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.72);
  font: 0.78rem/1.2 var(--font-ui);
  text-align: center;
}

.stats-row.stats-head {
  min-height: 32px;
  padding-top: 0;
  color: #5d4b37;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stats-row > :first-child {
  text-align: left;
}

.stats-row strong {
  font-size: 0.88rem;
}

.modal-actions {
  margin-top: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compact-button {
  min-height: 44px;
  padding: 10px 22px;
}

.confirm-modal,
.result-modal {
  width: min(490px, 100%);
  text-align: center;
}

.confirm-mark {
  width: 58px;
  height: 58px;
  margin: 0 auto 15px;
  display: grid;
  place-items: center;
  color: #fffaf0;
  border: 2px solid #6d2923;
  border-radius: 50%;
  background:
    radial-gradient(circle at 33% 22%, rgba(255,255,255,0.42), transparent 22%),
    linear-gradient(145deg, #c66153, #96372f 70%, #702923);
  box-shadow: 0 4px 0 #5a211d, 0 9px 14px rgba(73,31,24,0.18), inset 0 1px 1px rgba(255,255,255,0.38);
  font: 800 1.8rem/1 var(--font-ui);
  transform: rotate(-5deg);
}

.confirm-modal p,
.result-modal > p:not(.eyebrow) {
  color: var(--ink-soft);
  font: 0.95rem/1.5 var(--font-ui);
}

.centered-actions {
  justify-content: center;
}

.result-backdrop {
  background: rgba(31, 28, 22, 0.54);
  backdrop-filter: blur(2px);
}

.result-art {
  --result-accent: 36 79 120;
  width: 116px;
  height: 88px;
  margin: 0 auto 7px;
  position: relative;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.result-art::before,
.result-art::after {
  content: "";
  position: absolute;
  inset: 7px 21px;
  border-radius: 50%;
  background:
    radial-gradient(circle, #fbf4e6 0 55%, #d8c19a 56% 68%, #4a3427 70% 74%, transparent 75%);
  box-shadow: 0 5px 10px rgba(39, 26, 16, 0.2);
  transform: rotate(-4deg);
}

.result-art::after {
  inset: 13px 27px;
  background: rgba(var(--result-accent) / 0.1);
  box-shadow: inset 0 0 0 1px rgba(var(--result-accent) / 0.25);
}

.result-art.result-goal::before {
  background:
    radial-gradient(circle, #fbf4e6 0 48%, #d8c19a 49% 59%, transparent 60%),
    repeating-conic-gradient(from 4deg, rgba(var(--result-accent) / 0.2) 0 8deg, transparent 8deg 17deg);
}

.result-art.result-red {
  --result-accent: 162 61 50;
}

.result-art .result-piece {
  width: 68px;
  z-index: 2;
  transform: rotate(-4deg);
}

.result-art.result-red .result-piece {
  transform: rotate(4deg);
}

.result-art.result-draw {
  width: 136px;
}

.result-art.result-draw::before,
.result-art.result-draw::after {
  display: none;
}

.result-draw .result-piece {
  z-index: 1;
  position: absolute;
  top: 9px;
  width: 65px;
}

.result-draw .result-piece:first-child {
  left: 15px;
  transform: rotate(-8deg);
}

.result-draw .result-piece:last-child {
  right: 15px;
  transform: rotate(8deg);
}

body.has-modal .site-header,
body.has-modal .site-footer {
  visibility: hidden;
}

/* Wide, low screens */

@media (max-height: 650px) and (min-width: 760px) {
  .background-still-life {
    width: 270px;
    top: -64px;
    right: -4px;
    opacity: 0.72;
  }

  .background-cloth {
    bottom: -175px;
    opacity: 0.68;
  }

  .site-header {
    min-height: 48px;
    padding-top: 4px;
    padding-bottom: 0;
  }

  .site-logo {
    width: 142px;
    min-height: 40px;
  }

  .site-footer {
    min-height: 28px;
    padding: 3px 10px;
    font-size: 0.75rem;
  }

  .menu-screen {
    grid-template-columns: minmax(0, 0.78fr) minmax(460px, 1.22fr);
    gap: 28px;
    padding: 3px 0;
  }

  h1 {
    margin-bottom: 9px;
    font-size: clamp(2.3rem, 4.8vw, 3.65rem);
  }

  .hero-copy {
    margin-bottom: 9px;
    font-size: 0.9rem;
    line-height: 1.35;
  }

  .menu-piece-display {
    width: 270px;
    height: 84px;
    margin-top: 0;
  }

  .menu-piece-display .menu-piece:nth-child(1) {
    left: 18px;
    top: 12px;
    width: 68px;
  }

  .menu-piece-display .menu-piece:nth-child(2) {
    left: 95px;
    width: 80px;
  }

  .menu-piece-display .menu-piece:nth-child(3) {
    left: 184px;
    top: 13px;
    width: 68px;
  }

  .menu-piece-rail {
    left: 12px;
    right: 6px;
    bottom: 5px;
    height: 13px;
  }

  .menu-card {
    padding: 14px 20px;
  }

  .menu-card-header {
    display: none;
  }

  .choice-group {
    margin-bottom: 10px;
  }

  .choice-group legend {
    margin-bottom: 5px;
    font-size: 0.74rem;
  }

  .segmented-control span,
  .difficulty-options label > span {
    min-height: 44px;
    padding: 5px 8px;
    font-size: 0.8rem;
  }

  .difficulty-options small {
    font-size: 0.66rem;
  }

  .primary-button {
    min-height: 44px;
  }

  .secondary-actions {
    margin-top: 5px;
  }

  .modal {
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .rules-grid article {
    min-height: 135px;
    padding-top: 12px;
  }

  .rules-grid p {
    margin-bottom: 4px;
  }
}

@media (max-width: 820px), (orientation: portrait) and (max-width: 1024px) {
  :root {
    --board-size: min(calc(100vw - 18px), calc(var(--viewport-height) - 154px), 790px);
  }

  .play-screen {
    padding: 6px 8px 8px;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, auto) auto;
    align-content: center;
    gap: 5px;
  }

  .board-stage {
    justify-self: center;
  }

  .game-hud {
    width: min(var(--board-size), 100%);
    min-height: 112px;
    padding: 8px 12px;
    justify-self: center;
    display: grid;
    grid-template-columns: auto minmax(220px, 1fr) auto;
    align-items: center;
    gap: 10px;
  }

  .hud-brand {
    display: none;
  }

  .hud-section {
    border: 0;
    padding: 0;
  }

  .player-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .summary-row + .summary-row {
    margin-top: 0;
  }

  .move-status {
    grid-column: 1;
    grid-row: 1;
    display: block;
    width: 88px;
    text-align: center;
  }

  .move-status span,
  .move-status strong {
    display: block;
  }

  .move-status strong {
    margin-top: 4px;
  }

  .hud-actions {
    grid-column: 3;
    grid-row: 1;
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .hud-actions .secondary-button {
    min-width: 82px;
    min-height: 44px;
  }

}

@media (orientation: portrait) and (max-width: 1024px) {
  .fullscreen-button {
    display: none;
  }
}

@media (max-width: 700px) {
  .background-still-life {
    width: 210px;
    top: -72px;
    right: -18px;
    opacity: 0.58;
  }

  .background-cloth {
    width: 280px;
    left: -145px;
    bottom: -180px;
    opacity: 0.52;
  }

  .site-header {
    min-height: 52px;
    padding: 6px 12px 0;
  }

  .site-logo {
    width: 145px;
  }

  .fullscreen-button {
    display: none;
  }

  .menu-screen {
    width: min(520px, calc(100% - 22px));
    grid-template-columns: 1fr;
    align-content: start;
    gap: 8px;
    padding: 4px 0 12px;
  }

  .menu-hero {
    padding: 4px 4px 0;
    text-align: center;
  }

  .eyebrow {
    margin-bottom: 4px;
  }

  h1 {
    margin-bottom: 7px;
    font-size: clamp(2.25rem, 11vw, 3.6rem);
  }

  h1 span {
    font-size: 0.53em;
  }

  .hero-copy {
    width: 100%;
    margin-bottom: 6px;
    font-size: 0.86rem;
    line-height: 1.3;
  }

  .menu-piece-display {
    width: 250px;
    height: 84px;
    margin: 0 auto;
  }

  .menu-piece-display .menu-piece:nth-child(1) {
    left: 15px;
    top: 14px;
    width: 62px;
  }

  .menu-piece-display .menu-piece:nth-child(2) {
    left: 88px;
    top: 2px;
    width: 74px;
  }

  .menu-piece-display .menu-piece:nth-child(3) {
    left: 171px;
    top: 15px;
    width: 62px;
  }

  .menu-piece-rail {
    left: 10px;
    right: 5px;
    bottom: 5px;
    height: 12px;
  }

  .menu-card {
    padding: 15px;
  }

  .menu-card-header {
    margin-bottom: 13px;
    padding-bottom: 11px;
  }

  .menu-card-header h2 {
    font-size: 1.2rem;
  }

  .choice-group {
    margin-bottom: 11px;
  }

  .difficulty-options label > span {
    padding-left: 3px;
    padding-right: 3px;
  }

  .site-footer {
    min-height: 30px;
    font-size: 0.72rem;
  }

  :root {
    --board-size: min(calc(100vw - 8px), calc(var(--viewport-height) - 142px));
  }

  .board-coordinate-wrap {
    --board-inset: 20px;
    --frame-inset: 4px;
  }

  .rank-labels { top: 20px; bottom: 20px; width: 19px; }
  .file-labels { left: 20px; right: 20px; bottom: 4px; }

  .game-hud {
    width: calc(100% - 2px);
    min-height: 100px;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .player-summary {
    grid-column: 1;
    grid-row: 1;
    gap: 5px;
  }

  .summary-row {
    min-height: 36px;
    gap: 5px;
  }

  .summary-row small {
    display: none;
  }

  .move-status {
    display: none;
  }

  .hud-actions {
    grid-column: 2;
  }

  .rules-grid {
    grid-template-columns: 1fr;
  }

  .rules-grid article {
    min-height: 132px;
  }

  .modal-actions {
    flex-wrap: wrap;
  }
}

/* På smalle telefoner bevarer hvert af de ni felter et reelt 44 px trykområde.
   Spillefladen må derfor rulle ganske lidt vandret, som standarden tillader på mobil. */
@media (max-width: 430px) {
  :root {
    --board-size: 412px;
  }

  .play-screen {
    padding-left: 0;
    padding-right: 0;
    justify-content: start;
    overflow-x: auto;
  }

  .board-stage {
    width: 412px;
    justify-self: start;
  }

  .board-coordinate-wrap {
    --board-inset: 7px;
    --frame-inset: 0px;
  }

  .rank-labels {
    top: 7px;
    bottom: 7px;
    width: 8px;
  }

  .file-labels {
    left: 7px;
    right: 7px;
    bottom: -6px;
  }

  .game-hud {
    width: calc(100vw - 10px);
    justify-self: start;
    margin-left: 5px;
  }
}

@media (max-height: 500px) and (min-width: 760px) {
  :root {
    --board-size: min(calc(var(--viewport-height) - 12px), calc(100vw - 244px));
  }

  .play-screen {
    padding-top: 3px;
    padding-bottom: 3px;
    grid-template-columns: max-content 206px;
    justify-content: center;
    gap: 8px;
  }

  .game-hud {
    width: 206px;
    padding: 12px;
    gap: 8px;
  }

  .hud-section {
    padding: 7px 0;
  }

  .board-coordinate-wrap {
    --board-inset: 20px;
    --frame-inset: 4px;
  }

  .rank-labels { top: 20px; bottom: 20px; width: 19px; }
  .file-labels { left: 20px; right: 20px; bottom: 4px; }
}

@media (max-height: 430px) {
  .menu-screen,
  .play-screen {
    overflow-y: auto;
  }

  .menu-screen {
    align-items: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .capture-flash {
    display: none;
  }
}
