:root {
  color-scheme: light;
  --paper: #f5f3eb;
  --panel: #fcfaf4;
  --ink: #123044;
  --muted: #4e6470;
  --navy: #102e43;
  --navy-soft: #25485d;
  --line: #cfd5d1;
  --accent: #b9442f;
  --accent-hover: #9f3525;
  --soft-accent: #fae9de;
  --chart-line: #a4b5ba;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { display: flex; flex-direction: column; min-height: 100vh; margin: 0; background: var(--paper); color: var(--ink); }
main { flex: 1; }
button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.wrap { width: min(1120px, calc(100% - 96px)); margin-inline: auto; }
.site-header { background: var(--navy); color: #fbf6ec; }
.topbar { min-height: 72px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.brand { display: inline-flex; align-items: center; justify-self: start; min-height: 44px; }
.brand-mark { position: relative; display: block; width: clamp(145px, 16vw, 192px); aspect-ratio: 4.6; overflow: hidden; }
.brand-mark img { position: absolute; width: 109%; height: auto; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.site-nav { display: flex; flex-wrap: wrap; gap: 5px; }
.site-nav a { display: grid; place-items: center; min-height: 44px; padding-inline: 14px; border-radius: 5px; text-decoration: none; white-space: nowrap; font-size: 14px; font-weight: 650; }
.site-nav a:hover, .site-nav a[aria-current="page"] { background: #29495c; }
.site-nav a[aria-current="page"] { color: #ffc5a9; }
.rules-link { justify-self: end; min-height: 44px; color: inherit; border: 0; background: none; padding: 8px 0 8px 8px; font-size: 14px; }
.rules-link span { margin-inline-start: 4px; color: #f7a38b; }
.rules-link:hover { text-decoration: underline; text-underline-offset: .3em; }
.topbar :focus-visible { outline-color: #f7a38b; }

.arcade { padding-block: clamp(36px, 6vw, 77px) 30px; }
.arcade-heading { margin-bottom: clamp(24px, 4vw, 41px); }
.arcade-heading h1 { font-size: clamp(40px, 7vw, 91px); line-height: .98; margin-bottom: 14px; }
.arcade-heading .intro { max-width: 52ch; margin-bottom: 0; }
.game-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(14px, 2.2vw, 26px); }
.game-card { display: grid; grid-template-rows: auto 1fr; overflow: hidden; text-decoration: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; transition: border-color .16s, box-shadow .16s; }
.game-card:hover { border-color: var(--navy-soft); box-shadow: 0 8px 24px #102e4310; }
.card-art { position: relative; overflow: hidden; aspect-ratio: 1.95; }
.card-art img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.game-card:hover .card-art img { transform: scale(1.025); }
.sea-art { background: var(--navy); }
.chess-art { background: #334d40; }
.checkers-art { background: #653e32; }
.dots-art { display: grid; place-items: center; background: #2e3653; }
.dots-art-field { --art-step: clamp(16px, 3vw, 32px); position: relative; display: grid; place-items: center; width: 82%; height: 76%; border: 1px solid #aeb9d371; background: linear-gradient(90deg, #b7c4e149 1px, transparent 1px) center / var(--art-step) var(--art-step), linear-gradient(#b7c4e149 1px, transparent 1px) center / var(--art-step) var(--art-step), #353f60; }
.dots-art-loop { position: relative; width: clamp(40px, 24%, 125px); aspect-ratio: 1; transform: rotate(45deg); border: 2px solid #9ccfff; background: #7db8f43c; }
.dots-art-loop i { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: #aad6ff; }
.dots-art-loop i:nth-child(1) { top: -5px; left: -5px; }
.dots-art-loop i:nth-child(2) { top: -5px; right: -5px; }
.dots-art-loop i:nth-child(3) { bottom: -5px; left: -5px; }
.dots-art-loop i:nth-child(4) { bottom: -5px; right: -5px; }
.dots-art-captive { position: absolute; width: clamp(8px, 2.5vw, 18px); aspect-ratio: 1; border: 2px solid #efac9e; border-radius: 50%; background: #9b423f; }
.card-copy { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: clamp(14px, 1.6vw, 19px); }
.card-copy h2 { margin: 0 0 5px; font-size: clamp(21px, 2vw, 28px); line-height: 1.05; letter-spacing: -.045em; }
.card-copy p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.card-arrow { display: grid; flex: none; place-items: center; width: clamp(29px, 4vw, 36px); aspect-ratio: 1; border: 1px solid var(--line); border-radius: 50%; font-size: 23px; }
.game-card:hover .card-arrow { background: var(--soft-accent); color: var(--accent-hover); border-color: #e6c7ba; }

.home { padding-block: clamp(42px, 7vw, 94px) 26px; }
.hero { display: grid; grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr); align-items: center; gap: clamp(28px, 5vw, 72px); }
.hero-copy { padding-block: 6px 12px; }
.eyebrow { display: flex; align-items: center; gap: 11px; margin: 0 0 23px; color: var(--muted); font: 700 11px/1.5 var(--mono); text-transform: uppercase; letter-spacing: .11em; }
.eyebrow > span { display: inline-block; width: 21px; height: 2px; background: var(--accent); }
h1, h2, p, figure { margin-block-start: 0; }
h1 { font-weight: 825; letter-spacing: -.053em; }
.hero h1 { font-size: clamp(58px, 8vw, 116px); line-height: .9; margin-block-end: 23px; }
.period { color: var(--accent); }
.intro { max-width: 33ch; color: var(--muted); line-height: 1.55; font-size: clamp(16px, 1.55vw, 20px); margin-bottom: 27px; }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .7em; padding: 10px 16px; border: 1px solid transparent; border-radius: 5px; text-decoration: none; color: inherit; font-size: 14px; line-height: 1.25; font-weight: 700; transition: background-color .16s, transform .16s; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled { opacity: .45; cursor: default; }
.primary { background: var(--accent); color: #fff; }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.secondary { border-color: var(--line); background: var(--panel); }
.secondary:hover:not(:disabled), .secondary[aria-pressed="true"] { background: #e6eeeb; border-color: #a5b5b3; }
.small { min-height: 40px; padding: 8px 13px; }
.hero-button { min-height: 56px; padding-inline: 22px; font-size: 16px; gap: 26px; }
.hero-button span { font-size: 19px; }
.hero-note { color: var(--muted); font-size: 13px; margin: 12px 0 0; }
.chart { margin: 0; overflow: hidden; background: var(--navy); color: #deebe9; border: 1px solid #203e53; border-radius: 8px; }
.chart img { display: block; width: 100%; height: auto; }
.chart figcaption { display: flex; justify-content: space-between; gap: 14px; padding: 14px 20px; border-top: 1px solid #3c5768; background: #143348; text-transform: uppercase; font: 650 10px/1.4 var(--mono); letter-spacing: .09em; }
.steps { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: clamp(36px, 6vw, 78px) 0 0; padding: 24px 0 2px; border-top: 1px solid var(--line); gap: 22px; }
.steps li { display: flex; align-items: baseline; gap: 13px; }
.step-number { font: 750 12px var(--mono); color: var(--accent); }
.steps strong { font-size: 16px; }
.steps p { color: var(--muted); margin: 5px 0 0; font-size: 14px; line-height: 1.45; }
.footer { display: flex; justify-content: space-between; gap: 16px; padding-block: 18px; margin-top: 24px; border-top: 1px solid var(--line); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font: 650 10px/1.4 var(--mono); }

.game { padding-block: 35px 15px; }
.game-heading { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 23px; }
.game-heading .eyebrow { margin-bottom: 7px; }
.game-heading h1 { font-size: clamp(37px, 6vw, 61px); line-height: 1; margin: 0; }
.player-badge, .fleet-counter { font: 700 11px/1.4 var(--mono); white-space: nowrap; text-transform: uppercase; }
.player-badge { color: var(--muted); margin-block-end: 4px; background: #e7ebe5; padding: 7px 10px; border-radius: 4px; }
.status { display: flex; align-items: center; gap: 13px; padding: 13px 17px; border: 1px solid var(--line); background: #ecf0e9; border-radius: 6px; min-height: 66px; }
.status[data-tone="active"] { background: var(--soft-accent); border-color: #e6c7ba; }
.status-mark { height: 10px; width: 10px; background: var(--navy-soft); border-radius: 100%; flex: none; align-self: start; margin-top: 6px; }
.status[data-tone="active"] .status-mark { background: var(--accent); }
.status-copy { flex: 1; }
.status-copy p { margin: 3px 0 0; font-size: 13px; line-height: 1.4; color: var(--muted); }
.message { margin: 13px 0 0; font-size: 14px; line-height: 1.4; }
.error { color: #922c20; }
.invite { padding: 12px 16px; margin-top: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.invite label { display: block; font-size: 13px; font-weight: 640; margin-bottom: 7px; }
.invite-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.invite input { flex: 1; min-width: 170px; border: 1px solid var(--line); background: #f5f6ef; color: var(--ink); border-radius: 5px; padding: 10px; font: 12px var(--mono); }

.boards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 18px; align-items: start; }
.board-panel { padding: clamp(12px, 2vw, 23px); min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.board-heading { display: flex; align-items: end; justify-content: space-between; gap: 8px; margin: 0 0 13px; }
.board-index { font: 750 10px/1.4 var(--mono); letter-spacing: .08em; color: var(--muted); }
.board-heading h2 { margin: 4px 0 0; font-size: clamp(18px, 3vw, 28px); letter-spacing: -.045em; line-height: 1.05; }
.fleet-counter { color: var(--muted); margin-block-end: 2px; }
.board { --label: clamp(17px, 2.4vw, 28px); display: grid; grid-template-columns: var(--label) repeat(10, minmax(0, 1fr)); grid-template-rows: var(--label) repeat(10, auto); gap: 1px; }
.coordinate { display: grid; place-items: center; font: 650 clamp(9px, 1.5vw, 12px)/1 var(--mono); color: var(--muted); }
.square { display: grid; place-items: center; min-width: 0; width: 100%; aspect-ratio: 1; padding: 0; border: 0; outline-offset: -2px; border-radius: 1px; color: var(--ink); background: #e4ece9; }
.foe-board .square { background: #e5ebed; }
.square[aria-disabled="true"] { cursor: default; }
.square[aria-disabled="false"]:hover { background: #cad9da; }
.foe-board .square[aria-disabled="false"] { cursor: crosshair; }
.foe-board .square[aria-disabled="false"]:hover { background: #f5cdba; box-shadow: inset 0 0 0 1px var(--accent); }
.square:focus-visible { z-index: 1; outline-color: var(--accent); }
.square.ship { background: #34596c; }
.square.ship:focus-visible, .square.sunk:focus-visible { outline-color: #fcfaf4; }
.square.preview { background: #b7d3cb; box-shadow: inset 0 0 0 1px #3e7565; }
.square.preview-invalid { background: #f6d2c7; box-shadow: inset 0 0 0 1px #a84533; }
.square.miss::before, .legend-miss { content: ""; width: 19%; height: 19%; min-width: 5px; min-height: 5px; border-radius: 50%; background: #5c7480; }
.square.hit, .foe-board .square.hit { background: #f1c3ad; color: #832918; }
.square.sunk, .foe-board .square.sunk { background: #a73928; color: #fff9f0; }
.square.hit::before, .square.sunk::before { content: "×"; font: 800 clamp(15px, 2.8vw, 28px)/1 system-ui, sans-serif; }
.square.last { box-shadow: inset 0 0 0 2px currentColor; }
.placement { margin-top: 13px; }
.placement p { margin: 0 0 9px; font-size: 14px; color: var(--muted); line-height: 1.5; }
.placement-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.placement-tools .button { min-height: 44px; }
#ready { width: 100%; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 15px; padding: 0; margin: 15px 0 0; list-style: none; font-size: 12px; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 11px; border-radius: 2px; }
.legend .legend-miss { border-radius: 50%; width: 6px; height: 6px; margin-inline: 2px; }
.legend-ship { background: #34596c; }
.legend-hit { background: #f1c3ad; border: 1px solid #832918; }
.legend-sunk { background: #a73928; }

dialog { max-width: min(480px, calc(100% - 32px)); padding: 27px; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; }
dialog::backdrop { background: #102e43a8; }
dialog .eyebrow { margin-bottom: 8px; }
dialog h2 { margin-bottom: 14px; font-size: 32px; letter-spacing: -.04em; }
.rules-list { padding-left: 21px; margin: 0 0 19px; line-height: 1.55; }
.rules-list li + li { margin-top: 9px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

@media (max-width: 1080px) {
  .game-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .wrap { width: calc(100% - 48px); }
  .hero { gap: 28px; }
  .hero h1 { font-size: clamp(54px, 10vw, 88px); }
}
@media (max-width: 680px) {
  .wrap { width: calc(100% - 32px); }
  .topbar { min-height: 60px; grid-template-columns: 1fr auto; row-gap: 0; padding-block: 7px; }
  .site-nav { grid-column: 1 / -1; grid-row: 2; }
  .site-nav a { padding-inline: 11px; }
  .rules-link { grid-column: 2; grid-row: 1; }
  .game-cards { grid-template-columns: minmax(0, 1fr); }
  .home { padding-top: 32px; }
  .hero, .boards, .steps { grid-template-columns: minmax(0, 1fr); }
  .hero h1 { font-size: clamp(63px, 15vw, 95px); }
  .hero-copy { padding-bottom: 0; }
  .chart { max-width: 480px; }
  .steps { gap: 13px; }
  .steps li { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
  .steps li:last-child { border-bottom: none; }
  .game { padding-top: 25px; }
  .board-panel { width: 100%; max-width: 540px; justify-self: center; }
  .board { --label: 20px; }
  .board-heading h2 { font-size: 23px; }
  .square.hit::before, .square.sunk::before { font-size: clamp(16px, 5.5vw, 28px); }
  .status { padding-inline: 12px; }
}
@media (max-width: 365px) {
  .site-nav a { padding-inline: 8px; }
  .board-heading h2 { font-size: 20px; }
  .fleet-counter { font-size: 9px; }
  .status { flex-wrap: wrap; }
  .status .button { margin-left: 23px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
