/* Reversi 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 = jasnozielone tło i białe karty, ciemny = granat (jak gra z komputerem) */
:root {
  --strona: #dff0e5; --strona-dol: #dff0e5;
  --strona-ink: #0f172a; --akcent: #14532d; --alert: #9a3412; --mine: #166534;
  --cream: #ffffff; --ink: #0f172a; --soft: #475569; --line: #cbd5e1; --accent: #1d4ed8; --accent-txt: #1d4ed8; --h2: #14532d;
  --pole: #fff; --seg: #e2e8f0; --seg-on: #fff; --sec: #e2e8f0; --chip: rgba(20,83,45,.12); --chip-ink: #0f172a;
  --ctl-primary: #1d4ed8; --ctl-primary-ink: #fff; --link: #1d4ed8; --fokus: #1d4ed8; --cien: rgba(15,23,42,.15);
  --plansza: #2e8b57; --siatka: #1f6b43; --rama: #14532d; --ost: #ef4444; --fok1: #0f172a; --fok2: #ffffff;
  --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: #0f172a; --strona-dol: #0f172a;
  --strona-ink: #f1f5f9; --akcent: #86efac; --alert: #fdba74; --mine: #86efac;
  --cream: #1e293b; --ink: #f1f5f9; --soft: #cbd5e1; --line: #334155; --accent: #2563eb; --accent-txt: #93c5fd; --h2: #bbf7d0;
  --pole: #0f172a; --seg: #334155; --seg-on: #0f172a; --sec: #334155; --chip: rgba(0,0,0,.3); --chip-ink: #fff;
  --ctl-primary: #f1f5f9; --ctl-primary-ink: #0f172a; --link: #93c5fd; --fokus: #fbbf24; --cien: rgba(0,0,0,.35);
  --plansza: #1f6b43; --siatka: #14452c; --rama: #86efac; --ost: #f87171; --fok1: #ffffff; --fok2: #0f172a;
  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; }
.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%, #4b5563, #030712 70%); border: 2px solid #000; box-shadow: 8px 0 0 -2px #fff, 8px 0 0 0 #64748b; margin-right: 12px; 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: #f8fafc; border-color: #64748b; } .mini.b { background: #030712; border-color: #000; }

/* ---------- 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; }
.move-timer { font-size: 0.875rem; font-weight: 600; color: var(--akcent); text-align: center; font-variant-numeric: tabular-nums; }
.move-timer.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; zmieniać oba) ---------- */
.rboard {
  width: min(100%, calc(100vh - 260px), 640px); min-width: 260px; aspect-ratio: 1; display: grid;
  grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  background: var(--plansza); border: 3px solid var(--rama); border-radius: 10px; overflow: hidden; box-shadow: 0 10px 30px var(--cien);
}
.k { position: relative; display: block; width: 100%; height: 100%; padding: 0; border: 0; border-right: 1px solid var(--siatka); border-bottom: 1px solid var(--siatka); background: transparent; cursor: pointer; }
.k:nth-child(8n) { border-right-width: 0; }
.k:nth-child(n+57) { border-bottom-width: 0; }
.k .d { position: absolute; inset: 11%; border-radius: 50%; pointer-events: none; display: none; }
.k.c .d, .k.b .d { display: block; box-shadow: 0 2px 3px rgba(0,0,0,.4); }
.k.c .d { background: radial-gradient(circle at 35% 30%, #4b5563, #030712 70%); border: 2px solid #000; }
.k.b .d { background: radial-gradient(circle at 35% 30%, #ffffff, #cbd5e1 80%); border: 2px solid #64748b; }
.k.nowy .d { animation: poloz .25s ease-out both; }
.k.obr .d { animation: obrot .4s ease-in-out both; animation-delay: var(--d, 0s); }
@keyframes poloz { from { transform: scale(.3); opacity: 0; } }
@keyframes obrot { 0% { transform: scaleX(1); } 50% { transform: scaleX(.05); } 100% { transform: scaleX(1); } }
.k.mozl::after { content: ''; position: absolute; inset: 34%; border-radius: 50%; border: 3px solid #fff; background: rgba(255,255,255,.35); pointer-events: none; }
.k.ost .d::after { content: ''; position: absolute; inset: 36%; border-radius: 50%; background: var(--ost); }
.k:focus { outline: none; }
.k:focus-visible { outline: 3px solid var(--fok1); outline-offset: -3px; box-shadow: inset 0 0 0 6px var(--fok2); z-index: 1; }
/* Powrót na stronę główną ivoca.org: kwadratowy znaczek „i”, skrajnie po lewej w pasku u góry */
a.ivoca-dom { display: inline-grid; place-items: center; flex: none; width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 12px; background: #2563eb; color: #fff; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; line-height: 1; text-decoration: none; }
a.ivoca-dom::before { content: "i"; font-size: 1.25rem; font-weight: 700; }
a.ivoca-dom:hover { background: #1d4ed8; }
a.ivoca-dom:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }
/* Układ paska ze znaczkiem powrotu */
.home-head { justify-content: flex-start; row-gap: 4px; }
.home-head .right { margin-left: auto; }
@media (max-width: 1023px) { .home-head h1 .logo-disc { display: none; } }
/* Partia na telefonie: z nazwy gry zostaje samo logo (link do poczekalni), żeby zmieściły się nazwa i kod partii */
@media (max-width: 480px) { .topbar .brand { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; font-size: 0; } .topbar .brand .logo-disc { margin: 0 7px 0 0; } }

.log .report { margin-left: 8px; padding: 0 6px; font-size: .75em; line-height: 1.6; background: none; border: 1px solid currentColor; border-radius: 4px; color: inherit; opacity: .6; cursor: pointer; }
.log .report:hover:not(:disabled), .log .report:focus-visible { opacity: 1; }
.log .report:disabled { cursor: default; }
