/* Warstwa web gry w sumy — czysty CSS, bez frameworka. */

:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --text: #1c2333;
  --muted: #66708a;
  --line: #d9deea;
  --accent: #2f6fed;
  --accent-soft: #dbe6ff;
  --kept: #2f6fed;
  --kept-text: #ffffff;
  --removed: #eef0f6;
  --removed-text: #aab1c5;
  --done: #1d9e57;
  --over: #d64545;
  --cell: 44px; /* nadpisywane przez JS pod viewport */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151d;
    --panel: #1a1f2b;
    --text: #e8ebf4;
    --muted: #8d96ad;
    --line: #2b3245;
    --accent: #5b8dff;
    --accent-soft: #23304f;
    --kept: #3b6fd6;
    --removed: #232838;
    --removed-text: #596079;
  }
}

* {
  box-sizing: border-box;
}

/* Globalna skala UI: +20% (16px -> 19.2px bazy; wszystko w rem idzie za tym). */
html {
  font-size: 120%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header.site {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

header.site .inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 8px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 16px;
}

header.site .brand {
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  color: var(--text);
}

header.site nav {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  font-size: 0.88rem;
}

header.site nav a {
  color: var(--muted);
  text-decoration: none;
}

header.site nav a:hover,
header.site nav a[aria-current='page'] {
  color: var(--accent);
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 12px 14px 40px;
  text-align: center;
  font-size: 0.85rem;
}

footer.site {
  max-width: 880px;
  margin: 0 auto;
  padding: 14px 14px 28px;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--line);
  text-align: center;
}

h1 {
  font-size: 1.05rem;
  margin: 0.3em 0 0.5em;
  text-align: center;
}

h2 {
  font-size: 0.95rem;
  margin: 1.4em 0 0.4em;
}

article p,
article ul {
  max-width: 68ch;
  margin-left: auto;
  margin-right: auto;
}

article ul {
  list-style-position: inside;
  padding-left: 0;
}

/* Strony prawne: długi tekst czyta się lepiej wyrównany do lewej. */
article.legal {
  max-width: 68ch;
  margin: 0 auto;
  text-align: left;
}

article.legal h2 {
  text-align: left;
}

article.legal ul {
  list-style-position: outside;
  padding-left: 1.4em;
}

article.legal .updated {
  color: var(--muted);
  font-size: 0.8rem;
}

/* --- gra --- */

.game {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-meta {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}

.badge {
  font-size: 0.76rem;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.badge-easy { background: #d9f2e4; color: #187a44; }
.badge-medium { background: #fdeed2; color: #a26b0c; }
.badge-hard { background: #fbdcdc; color: #b03434; }
.badge-expert { background: #e8dcfb; color: #6d34b0; }

.lives {
  font-size: 1.05rem;
  letter-spacing: 2px;
}

.heart { color: var(--over); }
.heart.lost { color: var(--line); }

.grid {
  display: grid;
  gap: 3px;
  width: fit-content;
  margin: 0 auto;
}

.corner {
  width: var(--cell);
  height: var(--cell);
}

.target {
  width: var(--cell);
  height: var(--cell);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.target .t {
  font-weight: 800;
  font-size: calc(var(--cell) * 0.36);
}

.target .s {
  font-size: calc(var(--cell) * 0.26);
  color: var(--muted);
  font-weight: 600;
}

.target[data-status='done'] {
  border-color: var(--done);
  background: color-mix(in srgb, var(--done) 12%, var(--panel));
}
.target[data-status='done'] .t,
.target[data-status='done'] .s { color: var(--done); }
.target[data-status='over'] {
  border-color: var(--over);
}
.target[data-status='over'] .s { color: var(--over); }

.cell {
  position: relative;
  width: var(--cell);
  height: var(--cell);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: calc(var(--cell) * 0.44);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  transition: background 0.12s, color 0.12s, opacity 0.25s, transform 0.06s;
  font-variant-numeric: tabular-nums;
}

.cell:active {
  transform: scale(0.94);
}

.cell.kept {
  background: var(--kept);
  border-color: var(--kept);
  color: var(--kept-text);
}

.cell.removed {
  background: var(--removed);
  border-color: transparent;
  color: var(--removed-text);
}

.cell.removed .v {
  text-decoration: line-through;
}

.cell.flash-auto {
  animation: fadeout 0.5s;
}

@keyframes fadeout {
  from { opacity: 1; }
  to { opacity: 0.35; }
}

.cell.flash-bad {
  animation: shake 0.35s;
  outline: 3px solid var(--over);
  outline-offset: 1px;
}

.cell.flash-hint {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.game.won .cell.kept {
  background: var(--done);
  border-color: var(--done);
}

/* Regiony: pastelowe tło per region przez zmienną --rg, żeby stan kept
   mógł je ZACHOWAĆ (mocna obwódka zamiast wypełnienia — kolor regionu
   pozostaje widoczny i nie traci się orientacji). */
.rg-0 { --rg: #fde2e0; }
.rg-1 { --rg: #e0ecfd; }
.rg-2 { --rg: #e2f7e2; }
.rg-3 { --rg: #fdf3d8; }
.rg-4 { --rg: #f0e2fb; }
.rg-5 { --rg: #dff5f5; }
.rg-6 { --rg: #fbe6f2; }
.rg-7 { --rg: #eef0d9; }
.rg-8 { --rg: #e5e7f9; }
.rg-9 { --rg: #f4e7dc; }

@media (prefers-color-scheme: dark) {
  .rg-0 { --rg: #4b302e; }
  .rg-1 { --rg: #2c3a52; }
  .rg-2 { --rg: #2e4530; }
  .rg-3 { --rg: #4c4224; }
  .rg-4 { --rg: #3f2f4e; }
  .rg-5 { --rg: #294343; }
  .rg-6 { --rg: #4a3040; }
  .rg-7 { --rg: #3f4128; }
  .rg-8 { --rg: #323654; }
  .rg-9 { --rg: #4a3a2c; }
}

.game.has-regions .cell {
  background: var(--rg);
}

.game.has-regions .cell.kept {
  background: var(--rg);
  color: var(--text);
  box-shadow: inset 0 0 0 3px var(--kept);
  border-color: var(--kept);
  font-weight: 800;
}

.game.has-regions .cell.removed {
  background: var(--rg);
  opacity: 0.35;
  color: var(--text);
}

.game.has-regions .cell.removed .v {
  text-decoration: line-through;
}

.game.has-regions.won .cell.kept {
  box-shadow: inset 0 0 0 3px var(--done);
  border-color: var(--done);
}

.rtarget {
  position: absolute;
  top: 1px;
  left: 3px;
  font-size: calc(var(--cell) * 0.24);
  font-weight: 800;
  color: var(--muted);
  line-height: 1;
}

.rtarget[data-status='done'] { color: var(--done); }
.rtarget[data-status='over'] { color: var(--over); }

/* --- pasek narzędzi --- */

.toolbar {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  padding: 7px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 0.92rem;
  cursor: pointer;
}

.btn-tool.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-hint {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
  font-weight: 600;
}

.btn-retry {
  background: var(--over);
  border-color: var(--over);
  color: #fff;
}

.status {
  margin: 10px auto 0;
  color: var(--muted);
  min-height: 2.2em;
  max-width: 60ch;
  font-size: 0.8rem;
  text-align: center;
}

/* Sloty pod display ads (AdSense / H5). Puste sloty są niewidoczne, więc
   layout nie ma dziur ani CLS dopóki reklam nie ma. Wdrożenie: wstaw kod
   reklamy do środka slotu i dodaj klasę .active, która rezerwuje
   wysokość z góry (zero przeskoków treści przy ładowaniu). */
.ad-slot {
  display: none;
}

.ad-slot.active {
  display: block;
  margin: 14px auto;
  max-width: 728px;
  min-height: 92px;
}

/* Boczne skyscrapery (rail-left/rail-right): wyłącznie szeroki desktop,
   przypięte po bokach kolumny treści (880px + 2x160px + marginesy).
   Na mobile/tablecie nie istnieją. */
.ad-rail {
  display: none;
}

@media (min-width: 1280px) {
  .ad-rail.active {
    display: block;
    position: fixed;
    top: 90px;
    width: 160px;
    min-height: 600px;
    margin: 0;
    max-width: none;
  }

  .ad-rail-left {
    left: calc(50% - 620px);
  }

  .ad-rail-right {
    right: calc(50% - 620px);
  }
}

/* --- archiwum --- */

.archive-picker {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin: 12px 0 20px;
}

.date-select {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

/* --- strona odpowiedzi --- */

table.solution {
  border-collapse: collapse;
  margin: 14px auto;
}

table.solution td {
  width: 46px;
  height: 46px;
  text-align: center;
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

table.solution td.kept {
  background: var(--accent-soft);
  font-weight: 700;
}

table.solution td.out {
  color: var(--removed-text);
  text-decoration: line-through;
}

table.solution td.head {
  font-weight: 700;
  border: none;
  color: var(--muted);
}

ol.walkthrough {
  max-width: 74ch;
  margin-left: auto;
  margin-right: auto;
  list-style-position: inside;
  padding-left: 0;
}

ol.walkthrough li {
  margin-bottom: 6px;
}

ol.walkthrough .tech {
  display: inline-block;
  min-width: 2.2em;
  font-weight: 700;
  color: var(--accent);
}
