/* Warcaby przez internet: poczekalnia (online.html) i strona partii (gra.html). */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Motywy: jasny = jasne drewno i białe karty, ciemny = ciemne drewno i ciemne karty (plansza w obu taka sama) */
:root {
  --strona: radial-gradient(ellipse at 50% 0%, #fbf4e8 0%, #f3e5cf 60%, #ead7b8 100%) fixed; --strona-dol: #ead7b8;
  --strona-ink: #2b1a0f; --akcent: #5a3a22; --alert: #9a3412; --mine: #166534;
  --cream: #fffdf8; --ink: #2b1a0f; --soft: #6b5442; --line: #e6d7c2; --accent: #8b5a2b; --accent-txt: #7a4a20; --h2: #5a3a22;
  --pole: #fff; --seg: #ede2d2; --seg-on: #fff; --sec: #ede2d2; --chip: rgba(90,58,34,.12); --chip-ink: #2b1a0f;
  --ctl-primary: #8b5a2b; --ctl-primary-ink: #fff; --link: #7c2d12; --fokus: #1d4ed8; --cien: rgba(90,58,34,.18);
  --card: var(--cream); --ink-soft: var(--soft); --brand: var(--accent-txt); /* okienko „Aa” (js/wyglad.js) */
  --txt: 1; --fadj: 1; --font: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  color-scheme: light;
}
html.dark {
  --strona: radial-gradient(ellipse at 50% 0%, #4a2f1c 0%, #2b1a0f 60%, #1d1109 100%) fixed; --strona-dol: #2b1a0f;
  --strona-ink: #fdf6e9; --akcent: #fde7c4; --alert: #fdba74; --mine: #86efac;
  --cream: #2f1e12; --ink: #fdf6e9; --soft: #d9c7ad; --line: #5a3a22; --accent: #8b5a2b; --accent-txt: #fde7c4; --h2: #fde7c4;
  --pole: #3a2616; --seg: #4a2f1c; --seg-on: #7a4f2c; --sec: #4a2f1c; --chip: rgba(0,0,0,.3); --chip-ink: #fff;
  --ctl-primary: #fdf6e9; --ctl-primary-ink: #3b2416; --link: #fde7c4; --fokus: #fbbf24; --cien: rgba(0,0,0,.35);
  color-scheme: dark;
}
/* Czcionka i rozmiar tekstu (okienko „Aa”, js/wyglad.js); Atkinson +6%, bo ma niższe małe litery */
@font-face { font-family: 'Atkinson Hyperlegible Next'; font-weight: 200 800; font-display: swap; src: url('/fonts/atkinson-hyperlegible-next-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Atkinson Hyperlegible Next'; font-weight: 200 800; font-display: swap; src: url('/fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
html[data-font="wyrazna"] { --font: 'Atkinson Hyperlegible Next', system-ui, sans-serif; --fadj: 1.06; }
html[data-size="wiekszy"] { --txt: 1.125; }
html[data-size="najwiekszy"] { --txt: 1.25; }
html { font-size: calc(100% * var(--txt) * var(--fadj)); background: var(--strona-dol); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
:focus-visible { outline: 3px solid var(--fokus); outline-offset: 2px; }
.sq:focus-visible { outline: 4px solid var(--fokus); outline-offset: -4px; z-index: 1; }
.bar-btns { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.wyglad { position: relative; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 0 8px; border: 0; border-radius: 12px; background: transparent; color: var(--akcent); font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: var(--chip); }
.icon-btn svg { width: 1.25rem; height: 1.25rem; }
.icon-btn .sun { display: none; color: #fbbf24; }
html.dark .icon-btn .sun { display: block; }
html.dark .icon-btn .moon { display: none; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; } }
body {
  font-family: var(--font);
  background: var(--strona);
  color: var(--strona-ink); min-height: 100vh; line-height: 1.5;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
[hidden] { display: none !important; }
a { color: inherit; }
.muted { color: var(--soft); }
.small { font-size: 0.8125rem; }
.error { color: var(--alert); font-weight: 600; }
.error:empty { display: none; }

.logo-disc { width: 22px; height: 22px; border-radius: 50%; display: inline-block; background: radial-gradient(circle at 35% 30%, #fffaf0, #e2d4ba); box-shadow: 7px 0 0 -1px #222, 7px 0 0 0 #555; margin-right: 8px; vertical-align: -4px; }
.mini { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0,0,0,.4); flex-shrink: 0; }
.mini.w { background: #f4ead6; } .mini.b { background: #262626; border-color: #777; }

/* ---------- Poczekalnia ---------- */
.home-wrap { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.home-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.home-head h1 { font-size: 1.5rem; }
.home-head h1 .sub { font-weight: 500; color: var(--akcent); font-size: 1.125rem; }
.home-head a { font-size: 0.875rem; color: var(--link); }
.home-head .right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tagline { color: var(--akcent); }
.card { background: var(--cream); color: var(--ink); border-radius: 16px; padding: 18px 18px 20px; box-shadow: 0 8px 24px var(--cien); }
.card h2 { font-size: 1.1875rem; margin-bottom: 10px; color: var(--h2); }
.card a, .panel a { color: var(--link); }
form label { display: grid; gap: 4px; font-weight: 600; margin-bottom: 10px; font-size: 0.9375rem; }
form label .muted { font-weight: 400; }
input[type=text], input:not([type]), input[type=email], textarea {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--pole); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 100%;
}
label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 600; }
label.check input { margin-top: 5px; width: 18px; height: 18px; flex-shrink: 0; }
.seg { display: flex; gap: 4px; background: var(--seg); border-radius: 11px; padding: 3px; margin-bottom: 10px; }
.seg button { flex: 1; font: inherit; border: 0; background: transparent; color: var(--ink); padding: 8px 6px; font-size: 0.875rem; border-radius: 8px; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--seg-on); color: var(--accent-txt); box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.lbl { font-size: 0.8125rem; font-weight: 700; color: var(--soft); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .4px; }
button.primary, .button.primary, button.btn {
  font: inherit; font-weight: 700; border: 0; border-radius: 10px; padding: 10px 18px; cursor: pointer; background: var(--accent); color: #fff; text-decoration: none; display: inline-block;
}
button.btn.sec { background: var(--sec); color: var(--ink); }
button.primary, .button.primary, button.btn, .share button, .seg button { min-height: 44px; }
button:disabled { opacity: .5; cursor: default; }
.consent { margin: 4px 0 12px; }
form.inline { display: flex; gap: 8px; }
form.inline input { flex: 1; text-transform: uppercase; letter-spacing: 2px; }
ul.games { list-style: none; display: grid; gap: 6px; }
ul.games li a { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; background: var(--pole); color: var(--ink); }
ul.games li a:hover { border-color: var(--accent); }
ul.games .name { font-weight: 700; }
ul.games .info { color: var(--soft); font-size: 0.8125rem; margin-left: auto; text-align: right; }
.site-footer { text-align: center; color: var(--akcent); font-size: 0.75rem; line-height: 1.7; margin-top: 4px; }
/* linki jak na ivoca.org */
.site-footer a { color: var(--link); font-weight: 500; text-decoration: underline 2px transparent; text-underline-offset: .25em; border-radius: 4px; transition: text-decoration-color .15s; }
.site-footer a:hover, .site-footer a:focus-visible { text-decoration-color: currentColor; }

/* ---------- Strona partii ---------- */
.topbar { max-width: 1100px; margin: 0 auto 8px; display: flex; align-items: center; gap: 10px; }
.brand { font-weight: 700; font-size: 1.125rem; text-decoration: none; white-space: nowrap; }
.game-title { flex: 1; min-width: 0; font-size: 0.875rem; color: var(--akcent); display: flex; align-items: center; gap: 6px; }
#game-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-title .code, .game-title .badge { flex-shrink: 0; }
.code { font-family: ui-monospace, monospace; background: var(--chip); padding: 1px 6px; border-radius: 6px; letter-spacing: 1px; }
.badge { background: var(--akcent); color: var(--strona-dol); border-radius: 999px; font-size: 0.6875rem; padding: 1px 7px; font-weight: 700; }
.conn { width: 10px; height: 10px; border-radius: 50%; background: #dc2626; flex-shrink: 0; }
.conn.on { background: #22c55e; }

.layout { max-width: 1100px; margin: 0 auto; display: grid; gap: 14px; }
@media (min-width: 900px) { .layout { grid-template-columns: minmax(0, 1fr) 330px; align-items: start; } }
.play { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.status { font-size: 1rem; font-weight: 700; color: var(--akcent); text-align: center; min-height: 24px; }
.status.mine { color: var(--mine); }
.status.alert { color: var(--alert); }
.deadline { font-size: 0.8125rem; color: var(--akcent); text-align: center; }
.deadline.urgent { color: var(--alert); font-weight: 700; }
.banner { background: var(--cream); color: var(--ink); border-radius: 12px; padding: 10px 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; font-weight: 600; box-shadow: 0 6px 18px var(--cien); }
.banner button { padding: 7px 14px; }
.board-wrap { width: 100%; display: flex; justify-content: center; }
.players-bar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.pchip { background: var(--chip); color: var(--chip-ink); border-radius: 999px; padding: 4px 12px; display: inline-flex; gap: 6px; align-items: center; font-size: 0.875rem; border: 2px solid transparent; }
.pchip.turn { border-color: #ca8a04; }
.pchip .dot { width: 8px; height: 8px; border-radius: 50%; background: #6b7280; }
.pchip .dot.on { background: #22c55e; }
.pchip .me { color: var(--akcent); font-size: 0.75rem; }
.controls { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.controls button, .controls a {
  font: inherit; font-size: 0.875rem; font-weight: 600; border: 0; border-radius: 10px; padding: 8px 12px; cursor: pointer;
  background: var(--chip); color: var(--chip-ink); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center;
}
.controls .primary { background: var(--ctl-primary); color: var(--ctl-primary-ink); }

.side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel { background: var(--cream); color: var(--ink); border-radius: 14px; padding: 14px 16px; box-shadow: 0 6px 18px var(--cien); }
.panel h2 { font-size: 1rem; color: var(--h2); margin-bottom: 8px; }
.share { display: flex; gap: 6px; margin: 6px 0 10px; }
.share input { flex: 1; min-width: 0; font-size: 0.8125rem; }
.share button { font: inherit; font-weight: 700; font-size: 0.875rem; border: 0; border-radius: 10px; padding: 8px 12px; background: var(--accent); color: #fff; cursor: pointer; }
.log { list-style: none; max-height: 300px; overflow-y: auto; font-size: 0.875rem; display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }
.log li { line-height: 1.35; overflow-wrap: anywhere; }
.log .sys { color: var(--soft); font-size: 0.8125rem; }
.log .mv { font-family: ui-monospace, monospace; font-size: 0.8125rem; }
.log .who { font-weight: 700; }
#chat-form input { text-transform: none; letter-spacing: 0; }

.fatal-msg { background: var(--cream); color: var(--ink); border-radius: 14px; padding: 20px; text-align: center; font-weight: 600; max-width: 520px; margin: 30px auto 14px; }
body.fatal .layout { display: block; text-align: center; }

.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: rgba(15,23,42,.94); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 0.875rem; z-index: 3000; max-width: 90vw; text-align: center; pointer-events: none; opacity: 0; transition: opacity .2s; }
.toast.show { opacity: 1; }
.toast.error { background: #991b1b; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { background: var(--cream); color: var(--ink); border-radius: 16px; padding: 20px 22px; max-width: 360px; width: 100%; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.45); }
.dialog .btns { display: flex; gap: 8px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }

/* ---------- Plansza (jak w grze z komputerem) ---------- */
.board { position: relative; border: 6px solid #5a3a22; border-radius: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.5); background: #ecd9b6; touch-action: manipulation; cursor: pointer; }
.squares { position: absolute; inset: 0; display: grid; }
.sq { position: relative; }
.sq.d { background: #a8744f; }
.sq.last { background: #c49a5a; }
.sq.last-from { background: #b88a58; }
.sq .dot { position: absolute; inset: 34%; border-radius: 50%; background: rgba(34,197,94,.85); box-shadow: 0 0 0 3px rgba(255,255,255,.35); pointer-events: none; }
.sq .ring { position: absolute; inset: 22%; border-radius: 50%; border: 3px dashed rgba(34,197,94,.9); pointer-events: none; }
/* współrzędne w CSS (nie w treści pola): nazwa pola dla czytnika to „a8, …”, a widoczny tekst nie może jej przeczyć */
.sq[data-cl]::before, .sq[data-cn]::after { position: absolute; font-size: 0.5625rem; font-weight: 700; color: rgba(255,240,215,.75); pointer-events: none; line-height: 1; }
.sq[data-cl]::before { content: attr(data-cl); left: 2px; top: 2px; }
.sq[data-cn]::after { content: attr(data-cn); right: 2px; bottom: 2px; }
.sq:not(.d)[data-cl]::before, .sq:not(.d)[data-cn]::after { color: rgba(110,70,40,.7); }
.pieces { position: absolute; inset: 0; pointer-events: none; }
.piece { position: absolute; display: flex; align-items: center; justify-content: center; transition: left .16s ease-in-out, top .16s ease-in-out, opacity .2s; }
.disc { width: 80%; height: 80%; border-radius: 50%; position: relative; display: flex; align-items: center; justify-content: center; box-shadow: 0 3px 4px rgba(0,0,0,.45); }
.piece.w .disc { background: radial-gradient(circle at 35% 30%, #fffdf7 0%, #f2e7d1 55%, #d7c6a5 100%); border: 1px solid #a8977a; }
.piece.b .disc { background: radial-gradient(circle at 35% 30%, #5b5b5b 0%, #2a2a2a 55%, #111 100%); border: 1px solid #000; }
.disc::before { content: ''; position: absolute; inset: 16%; border-radius: 50%; border: 2px solid rgba(0,0,0,.14); }
.piece.b .disc::before { border-color: rgba(255,255,255,.12); }
.piece.k .disc::after { content: '♛\FE0E'; font-size: calc(var(--sq) * .44); line-height: 1; color: #c8961e; text-shadow: 0 1px 0 rgba(0,0,0,.35); position: relative; }
.piece.b.k .disc::after { color: #f5c542; }
.piece.can .disc { box-shadow: 0 0 0 3px #fb923c, 0 3px 4px rgba(0,0,0,.45); }
.piece.sel .disc { box-shadow: 0 0 0 4px #22c55e, 0 6px 10px rgba(0,0,0,.5); transform: scale(1.06); }
.piece.moving { z-index: 5; }
.piece.moving .disc { box-shadow: 0 10px 16px rgba(0,0,0,.5); transform: scale(1.1); }
.piece.gone { opacity: 0; }
.piece.shake .disc { animation: shake .3s; }
@keyframes shake { 0%,100% { translate: 0; } 25% { translate: -4px; } 75% { translate: 4px; } }
