:root {
  color-scheme: light;
  --paper: #f7f7f0;
  --sheet: #fffefa;
  --ink: #282777;
  --muted: #617480;
  --line: #cbd8da;
  --sea: #edf8fa;
  --sea-cell: #fbffff;
  --hit: #cf594a;
  --miss: #b4cbd1;
  --accent: #38319c;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-synthesis: none;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { min-width: 320px; min-height: 100vh; margin: 0; background: repeating-linear-gradient(0deg, transparent 0 31px, #afcde555 32px), repeating-linear-gradient(90deg, transparent 0 31px, #afcde555 32px), var(--paper); color: var(--ink); }
button, input { font: inherit; }
button { min-height: 44px; padding: 10px 15px; border: 0; border-radius: 9px; cursor: pointer; color: var(--ink); font-weight: 700; touch-action: manipulation; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, summary:focus-visible { outline: 3px solid #de985f; outline-offset: 2px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(30px, 6vw, 42px); line-height: 1; letter-spacing: -.045em; }
h2 { margin-bottom: 8px; font-size: 22px; line-height: 1.15; letter-spacing: -.025em; }
h3 { margin: 16px 0 8px; font-size: 16px; }
.app-shell { width: min(100%, 920px); margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 14px max(36px, env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 17px; padding: 5px 2px 15px; border-bottom: 2px solid var(--ink); }
.eyebrow { margin: 0 0 5px; color: var(--accent); font-size: 10px; font-weight: 850; letter-spacing: .16em; }
.connection { padding: 7px 10px; border: 1px solid #a9c9b7; border-radius: 999px; background: #eaf6ec; color: #286444; font-size: 11px; font-weight: 750; white-space: nowrap; }
.connection::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #3da66c; }
.connection.offline { border-color: #e0a9a4; background: #fff0eb; color: #9b403b; }
.connection.offline::before { background: var(--hit); }
.panel { margin-bottom: 14px; padding: 18px; border: 1px solid #b5b4dd; border-radius: 13px; background: var(--sheet); box-shadow: 0 4px 0 #d9d9ed; }
.muted, .board-help { margin-bottom: 14px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.notice, .error { margin: 0 0 14px; padding: 12px 14px; border-radius: 9px; font-size: 14px; line-height: 1.4; }
.notice { border: 1px solid #9fc6b7; background: #eaf6ec; color: #285d43; }
.error { border: 1px solid #e7a9a0; background: #fff0eb; color: #973e36; }
.primary { background: var(--accent); color: white; }
.secondary { border: 1px solid #a7bdc1; background: #e9f1f0; color: var(--ink); }
.quiet { background: transparent; color: var(--muted); }
.danger-text { color: #a2463b; }
.wide { width: 100%; margin-top: 12px; }
.lobby { padding: 22px; }
.mode-list { display: grid; gap: 10px; margin-top: 18px; }
.mode-card { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 83px; padding: 13px 15px; border: 1px solid #b7c9c9; background: #f4faf7; text-align: left; }
.mode-card:first-child { border-color: #85b7ad; background: #e6f4eb; }
.mode-card > span:nth-child(2) { flex: 1; }
.mode-card strong, .mode-card small { display: block; }
.mode-card strong { margin-bottom: 3px; font-size: 16px; }
.mode-card small { color: var(--muted); font-size: 12px; line-height: 1.35; font-weight: 500; }
.mode-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border: 1px solid #a4c8bd; border-radius: 9px; background: #fffef8; color: var(--accent); font-size: 23px; }
.mode-arrow { color: var(--accent); font-size: 24px; }
.invite-list { margin-top: 12px; }
.incoming-invite { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: #f0f6f4; }
.incoming-invite span { flex: 1; font-size: 13px; }
.incoming-invite button { min-height: 38px; padding: 8px 11px; font-size: 12px; }
.game-heading { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; border-left: 5px solid var(--accent); }
.game-heading h2 { margin: 0; }
.status-pill { padding: 8px 11px; border-radius: 7px; background: #dcefea; color: #136272; font-size: 12px; font-weight: 800; }
.turn-message { grid-column: 1 / -1; margin: 8px 0 0; font-size: 15px; line-height: 1.4; font-weight: 650; }
.score { display: flex; flex-wrap: wrap; gap: 7px 18px; grid-column: 1 / -1; margin-top: 12px; padding-top: 10px; border-top: 1px dashed #bdcdd0; color: var(--muted); font-size: 12px; }
.score strong { color: var(--ink); font-size: 16px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.section-heading h2 { margin-bottom: 0; }
.manual-placement { margin-top: 16px; padding-top: 14px; border-top: 1px dashed #b8caca; }
.manual-placement summary { cursor: pointer; color: var(--accent); font-size: 14px; font-weight: 800; }
.manual-placement[open] summary { margin-bottom: 14px; }
.ship-picker { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0; }
.ship-choice { min-height: 38px; padding: 7px 10px; border: 1px solid #adc5c8; background: #edf5f4; font-size: 12px; }
.ship-choice.selected { border-color: var(--accent); background: #d8ede7; color: var(--ink); }
.placement-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.placement-tools button { min-height: 38px; padding: 7px 10px; font-size: 12px; }
.board { display: grid; grid-template-columns: 23px repeat(10, minmax(0, 1fr)); gap: 0; width: 100%; max-width: 460px; margin: 12px auto 0; padding: 4px; border: 2px solid #4542ad; border-radius: 3px; background: #eff9fb; touch-action: manipulation; }
.axis { display: grid; place-items: center; color: #4740a6; font-size: 11px; font-weight: 800; user-select: none; }
.axis.corner { color: transparent; }
.cell { display: grid; place-items: center; min-width: 0; min-height: 0; aspect-ratio: 1; padding: 0; border: 1px solid #8cc8d8; border-radius: 0; background: var(--sea-cell); color: var(--ink); font-size: clamp(13px, 3.8vw, 23px); font-weight: 900; line-height: 1; }
.board-placement .cell { cursor: crosshair; }
.ship-cell { background: #e4ecfb; }
.hit-cell { position: relative; z-index: 3; background: #f2c5b7cc !important; color: #b53930; }
.miss-cell { background: #e2ecee !important; color: #477589; }
.sunk-cell { background: #e7aa9b66 !important; color: #a82f29; }
.near-cell { background: repeating-linear-gradient(135deg, #e5e6f6 0 3px, #f7f8ff 3px 6px) !important; }
.ship-art { position: relative; z-index: 2; min-width: 0; min-height: 0; pointer-events: none; align-self: stretch; justify-self: stretch; }
.ship-art img { display: block; width: 100%; height: 100%; object-fit: fill; }
.ship-art.vertical img { position: absolute; top: 50%; left: 50%; width: calc(var(--ship-length) * 100%); height: calc(100% / var(--ship-length)); transform: translate(-50%, -50%) rotate(90deg); }
.ship-art.destroyed { opacity: .76; filter: saturate(.5); }
.target-board .cell:not(:disabled) { cursor: pointer; }
.target-board .cell:disabled { opacity: 1; }
.target-board .cell:not(:disabled):active { background: #beddd9; }
.boards-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.board-panel { min-width: 0; padding: 16px; }
.target-panel { border-top: 4px solid var(--accent); }
.own-panel { border-top: 4px solid #829ca7; }
.board-help { min-height: 40px; margin: 0; font-size: 13px; }
.board-legend { display: flex; gap: 15px; margin: 12px 0 0; color: var(--muted); font-size: 12px; }
.board-legend span { display: inline-flex; align-items: center; gap: 6px; }
.board-legend i { display: inline-block; width: 12px; height: 12px; border: 1px solid #7da7b0; }
.legend-hit { background: #f2c5b7; }
.legend-miss { background: #e2ecee; }
.legend-blocked { background: repeating-linear-gradient(135deg, #e5e6f6 0 3px, #f7f8ff 3px 6px); }
.board-legend { flex-wrap: wrap; }
.placement-help { margin-top: 14px; margin-bottom: 8px; }
.action-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 5px 0; }
.back-link { padding-left: 0; }
.confirm-dialog { width: min(calc(100% - 32px), 380px); padding: 22px; border: 2px solid #477487; border-radius: 12px; background: var(--sheet); color: var(--ink); box-shadow: 0 20px 70px #102b3b66; }
.confirm-dialog::backdrop { background: #183247aa; }
.confirm-dialog h2 { margin-bottom: 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
@media (max-width: 680px) {
  .app-shell { padding-left: 10px; padding-right: 10px; }
  .topbar { margin-bottom: 14px; }
  .boards-layout { grid-template-columns: 1fr; }
  .board-panel { padding: 12px; }
  .board { max-width: 440px; }
  .cell { font-size: clamp(14px, 4.4vw, 20px); }
}
@media (max-width: 360px) {
  .panel { padding: 13px; }
  .connection { padding: 6px 7px; font-size: 10px; }
  .board { grid-template-columns: 18px repeat(10, minmax(0, 1fr)); padding: 2px; }
  .axis { font-size: 9px; }
}
