:root {
  --bg: #f3efe6;
  --surface: #fbf9f4;
  --surface-2: #f4f0e6;
  --ink: #1d2620;
  --muted: #67705f;
  --line: #e2dccd;
  --land: #e2e5d3;
  --land-2: #edefe1;
  --land-line: #fbf9f4;
  --woj-line: #a3aa8f;
  --land-hover: #cadab2;
  --accent: #2f6b4a;
  --accent-ink: #fff;
  --accent-soft: #cfe1c4;
  --win: #5fa46f;
  --grass: #7ea866;
  --grass-hi: #95bd7b;
  --grass-edge: #648f50;
  --sand: #f2e9d4;
  --sand-edge: #e0d3b3;
  --danger: #d4472f;
  --danger-soft: #f7cdc1;
  --n1: #2f6fb5; --n2: #3a8a3f; --n3: #c8442f; --n4: #5a3f9e;
  --n5: #8f3a2b; --n6: #23807f; --n7: #2b2b2b; --n8: #6d6d6d;
  --shadow: 0 1px 2px rgb(40 35 20 / .06), 0 8px 28px rgb(40 35 20 / .12);
  --radius: 16px;
  --font-display: "Chakra Petch", ui-sans-serif, system-ui, sans-serif;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1411;
    --surface: #161c18;
    --surface-2: #1c241f;
    --ink: #e7ebe2;
    --muted: #9aa494;
    --line: #2a332d;
    --land: #212a23;
    --land-2: #29332b;
    --land-line: #0f1411;
    --woj-line: #4f5b4f;
    --land-hover: #344530;
    --accent: #8fd0a0;
    --accent-ink: #0f1411;
    --accent-soft: #2c4733;
    --win: #3f8a52;
    --grass: #4c7840;
    --grass-hi: #5d8b4f;
    --grass-edge: #3a5f31;
    --sand: #2a2a23;
    --sand-edge: #39372d;
    --danger: #ff7b5e;
    --danger-soft: #57261d;
    --n1: #7fb1ff; --n2: #7fd08a; --n3: #ff8a73; --n4: #b9a2ff;
    --n5: #ffad8a; --n6: #6fd9d4; --n7: #e7ebe2; --n8: #b0b0b0;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 32px rgb(0 0 0 / .45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

a { color: inherit; }
button { font: inherit; color: inherit; }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: relative;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  white-space: nowrap;
}
.brand-name { font: 700 21px/1 var(--font-display); letter-spacing: -.01em; }
.brand-dim { color: var(--muted); font-weight: 500; }
.logo { width: 32px; height: 32px; flex: none; color: var(--ink); }
.logo-flag { fill: #e5432c; }
.brand:hover .logo-flag { animation: wave .6s ease-in-out; }
@keyframes wave { 30% { transform: scaleX(.8) skewY(-8deg); } 65% { transform: scaleX(1.05) skewY(4deg); } }
.logo-flag { transform-box: fill-box; transform-origin: left center; }

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
}
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs span { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.crumbs i { font-style: normal; opacity: .5; }

/* szerokość i krawędzie jak treść prawego panelu (380px - 2 × 24px) */
.search { position: relative; width: 332px; margin-right: 8px; }
.search input {
  width: 100%;
  height: 38px;
  padding: 0 14px 0 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2) url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2367705f' stroke-width='2' stroke-linecap='round'><circle cx='7' cy='7' r='5'/><path d='m11 11 3.5 3.5'/></svg>") no-repeat 13px 50%;
  color: var(--ink);
  font: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#search-results {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: 100%;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
#search-results li { padding: 8px 10px; border-radius: 9px; cursor: pointer; }
#search-results li b { display: block; font-weight: 600; }
#search-results li span { font-size: 12.5px; color: var(--muted); }
#search-results li[aria-selected="true"], #search-results li:hover:not(.empty) { background: var(--accent-soft); }
#search-results .empty { color: var(--muted); cursor: default; }

/* ---------- layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  min-height: 0;
}

.map {
  position: relative;
  overflow: hidden;
  min-height: 0;
  background-color: var(--bg);
  background-image: radial-gradient(color-mix(in srgb, var(--woj-line) 35%, transparent) 1px, transparent 1.2px);
  background-size: 22px 22px;
}

.panel {
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--surface);
  overscroll-behavior: contain;
}
.panel-inner { padding: 26px 24px 30px; animation: panel-in .45s cubic-bezier(.2, .8, .2, 1) both; }

@keyframes panel-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- mapa ---------- */

.map-svg {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: grab;
}
.map-svg:active { cursor: grabbing; }

.powiat {
  fill: var(--land);
  stroke: var(--land-line);
  stroke-width: .8;
  vector-effect: non-scaling-stroke;
  transition: fill .2s, opacity .5s;
  cursor: pointer;
}
.map[data-level="pl"] .powiat:hover { fill: var(--land-hover); }
.powiat.has-wins { fill: color-mix(in srgb, var(--win) var(--done, 40%), var(--land)); }
.map[data-level="pl"] .powiat.has-wins:hover { fill: color-mix(in srgb, var(--win) var(--done, 40%), var(--land-hover)); }
.map[data-level="powiat"] .powiat { opacity: .5; }
.map[data-level="powiat"] .powiat:hover { opacity: .8; }
.map[data-level="game"] .powiat { opacity: .35; pointer-events: none; }

.woj-border {
  fill: none;
  stroke: var(--woj-line);
  stroke-width: 1.2;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
.map:not([data-level="pl"]) .woj-border { opacity: .45; }

.gmina {
  fill: var(--land-2);
  stroke: var(--woj-line);
  stroke-width: 1;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: fill .2s, opacity .5s;
}
.gmina.won { fill: color-mix(in srgb, var(--win) 55%, var(--land-2)); }
.map[data-level="powiat"] .gmina:hover, .gmina.hover { fill: var(--accent-soft); }
.map[data-level="game"] .gmina { pointer-events: none; }
.map[data-level="game"] .gmina:not(.selected) { opacity: .4; }
.map[data-level="pl"] .gmina { opacity: 0; pointer-events: none; }

.gmina-outline {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
  opacity: .55;
  animation: fade-in .8s .3s both;
}
.map[data-level="game"] .gmina.selected { fill: var(--land-2); animation: scan 1.6s ease-in-out infinite; }
.map[data-level="game"]:has(.board) .gmina.selected { animation: none; }

@keyframes scan { 50% { fill: var(--accent-soft); } }
@keyframes fade-in { from { opacity: 0; } }

.map-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.map-labels.hidden { display: none; }
.map-label {
  position: absolute;
  left: 0;
  top: 0;
  font: 600 11.5px/1.1 var(--font);
  color: var(--ink);
  white-space: nowrap;
  text-shadow: 0 0 3px var(--land-2), 0 0 3px var(--land-2), 0 0 6px var(--land-2);
  transition: opacity .25s;
  animation: fade-in .6s .5s both;
}
.map-label.tiny { opacity: 0; }
.map-label.won::before { content: "✓ "; color: var(--accent); }

.tooltip {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  padding: 7px 11px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  line-height: 1.3;
  opacity: 0;
  transition: opacity .12s;
  white-space: nowrap;
  z-index: 5;
}
.tooltip.visible { opacity: 1; }
.tooltip strong { display: block; font-weight: 600; }
.tooltip span { opacity: .7; font-size: 12px; }

.map-controls {
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.map-controls button {
  width: 38px; height: 38px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  font-size: 19px;
  cursor: pointer;
}
.map-controls button:last-child { border: 0; font-size: 16px; }
.map-controls button:hover { background: var(--surface-2); }

.splash {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transition: opacity .4s;
}
body.ready .splash { opacity: 0; pointer-events: none; }
.spin { display: block; animation: bob 1s ease-in-out infinite alternate; }
.logo.big { width: 56px; height: 56px; }
@keyframes bob { to { transform: translateY(-8px) rotate(6deg); } }

/* ---------- plansza ---------- */

.tile { cursor: pointer; }
.tile-in {
  transform-box: fill-box;
  transform-origin: center;
  animation: tile-enter .5s cubic-bezier(.25, 1.4, .4, 1) var(--d, 0ms) both;
}
@keyframes tile-enter { from { opacity: 0; transform: scale(.3); } }

.face {
  fill: var(--grass);
  stroke: var(--grass-edge);
  stroke-width: 1.4;
  transition: fill .22s ease var(--rd, 0ms), stroke .22s ease var(--rd, 0ms);
}
.tile:not(.open):hover .face { fill: var(--grass-hi); transition-delay: 0ms; }
body.flag-mode .tile:not(.open) { cursor: crosshair; }

.label {
  font: 800 17px/1 var(--font-display);
  text-anchor: middle;
  pointer-events: none;
  opacity: 0;
}
.badge {
  font: 700 8.5px/1 var(--font);
  text-anchor: end;
  fill: var(--ink);
  pointer-events: none;
}

.tile.flag .label { opacity: 1; font-size: 15px; animation: flag-drop .3s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes flag-drop { from { transform: translateY(-6px) scale(.6); opacity: 0; } }

.tile.open { cursor: default; }
.tile.open .tile-in { animation: tile-flip .4s ease var(--rd, 0ms) both; }
@keyframes tile-flip { 45% { transform: scale(.78); } }
.tile.open .face { fill: var(--sand); stroke: var(--sand-edge); }
.tile.open .label { animation: pop .32s cubic-bezier(.3, 1.6, .5, 1) calc(var(--rd, 0ms) + 120ms) both; opacity: 1; }
@keyframes pop { from { opacity: 0; transform: scale(.3); } }
.label { transform-box: fill-box; transform-origin: center; }

.n1 .label { fill: var(--n1); } .n2 .label { fill: var(--n2); } .n3 .label { fill: var(--n3); }
.n4 .label { fill: var(--n4); } .n5 .label { fill: var(--n5); } .n6 .label { fill: var(--n6); }
.n7 .label { fill: var(--n7); } .n8 .label { fill: var(--n8); }

.tile.mine { cursor: pointer; }
.tile.mine .label { font-size: 17px; }
.tile.mine .face { fill: color-mix(in srgb, var(--c) 26%, var(--sand)); stroke: color-mix(in srgb, var(--c) 60%, var(--sand)); }
.tile.mine:hover .face { fill: color-mix(in srgb, var(--c) 40%, var(--sand)); }
.tile.boom .face { fill: var(--danger-soft); stroke: var(--danger); stroke-width: 2.4; }
.tile.boom .tile-in { animation: boom .6s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes boom {
  0% { transform: scale(1); }
  20% { transform: scale(1.35) rotate(-6deg); }
  40% { transform: scale(.95) rotate(4deg); }
  60% { transform: scale(1.08) rotate(-2deg); }
}
.tile.rest .tile-in { animation: rise .45s ease var(--rd, 0ms) both; }
@keyframes rise { from { opacity: .2; transform: scale(.6); } }
.tile.found .face { stroke-width: 2.4; }
.tile.wrong .face { fill: var(--surface-2); stroke: var(--danger); stroke-dasharray: 3 2.5; }
.tile.wrong .label { opacity: .5; }

.tile.pulse .face { animation: pulse 1.5s ease-out; }
@keyframes pulse {
  0%, 60% { stroke: var(--ink); stroke-width: 5; }
}

/* ---------- panel: treści ---------- */

.eyebrow {
  margin: 0 0 6px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.01em; }
h1 { margin: 0 0 12px; font-size: 32px; line-height: 1.05; font-weight: 800; }
h2 { margin: 0; font-size: 28px; line-height: 1.1; font-weight: 800; }
.kind { margin: 4px 0 18px; color: var(--muted); }
.lead { margin: 0 0 18px; color: color-mix(in srgb, var(--ink) 80%, var(--muted)); }
.hint { color: var(--muted); font-size: 13.5px; }
.hint.small { font-size: 12.5px; margin-top: 22px; }
.section-title { margin: 24px 0 10px; font-size: 16px; font-weight: 700; }

.legend { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; font-size: 13px; }
.legend li { display: flex; align-items: center; gap: 8px; line-height: 1.2; }
.legend-icon {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 26px; height: 26px;
  border-radius: 7px;
  background: color-mix(in srgb, var(--c) 22%, var(--surface));
  font-size: 14px;
}

.gmina-list { margin: 0 0 18px; padding: 0; list-style: none; display: grid; gap: 4px; }
.gmina-list li { display: flex; gap: 4px; }
.gmina-list li > a:first-child { flex: 1; min-width: 0; }
.gmina-list li.won > a:first-child { background: color-mix(in srgb, var(--win) 22%, var(--surface)); }
.gmina-list .plots {
  display: grid;
  place-items: center;
  padding: 0 10px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
}
.gmina-list .plots:hover { background: var(--accent-soft); color: var(--ink); }

.tuziemia {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  text-decoration: none;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.tuziemia:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }
.tuziemia > span:first-child { font-size: 22px; }
.tuziemia > span:nth-child(2) { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.tuziemia small { color: var(--muted); font-size: 12.5px; }
.tuziemia i { font-style: normal; color: var(--accent); font-weight: 700; }
#game-body + .tuziemia { margin: 20px 0 0; }
.tuziemia.in-card { margin: 0 20px 20px; }
.tuziemia + .related { margin: -8px 0 18px; }
#game-body ~ .related { margin-top: 8px; }
.related { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.related a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 10px;
  text-decoration: none;
  transition: background .15s;
}
.related a:hover { background: var(--surface-2); }
.related a > span:first-child { width: 22px; text-align: center; font-size: 15px; }
.related a > span:nth-child(2) { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.related b { font-weight: 600; font-size: 13.5px; }
.related small { color: var(--muted); font-size: 12px; }
.related i { font-style: normal; color: var(--muted); font-size: 13px; }
.won-note { color: var(--accent); font-weight: 600; }

.section-title .count { font: 600 12.5px var(--font); color: var(--muted); margin-left: 6px; }
.progress-total { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-bottom: 10px; }
.progress-total span { display: block; height: 100%; background: var(--win); border-radius: inherit; }
.history { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; max-height: 260px; overflow-y: auto; }
.history a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--win) 16%, var(--surface));
  text-decoration: none;
}
.history a:hover { background: color-mix(in srgb, var(--win) 30%, var(--surface)); }
.history-name { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.history-name small { color: var(--muted); font-size: 12px; }
.history-times { display: flex; gap: 6px; font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 600; }
.history-times em {
  font-style: normal;
  display: inline-grid;
  place-items: center;
  width: 16px; height: 16px;
  margin-right: 3px;
  border-radius: 4px;
  background: var(--win);
  color: #fff;
  font-size: 10px;
}
.gmina-list a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  text-decoration: none;
  background: var(--surface-2);
  transition: background .15s, transform .15s;
}
.gmina-list a:hover, .gmina-list a.hover { background: var(--accent-soft); transform: translateX(3px); }
.gmina-list span { font-weight: 600; }
.gmina-list small { color: var(--muted); font-size: 12px; }
.back { color: var(--muted); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--ink); }

.loading p { margin: 0 0 10px; font-weight: 600; }
.loading .hint { font-weight: 400; margin-top: 10px; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar span {
  display: block;
  height: 100%;
  width: 4%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--grass), var(--accent));
  transition: width .3s ease;
}
.error { padding: 14px; border-radius: 12px; background: var(--danger-soft); }
.error p { margin: 0 0 8px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px;
  border-radius: 12px;
  background: var(--surface-2);
  text-align: center;
  min-width: 0;
}
.stat b { font: 800 21px/1.1 var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat b.lives { font-size: 17px; line-height: 1.3; letter-spacing: -.04em; }
.stat span { font-size: 11px; color: var(--muted); line-height: 1.2; }
.lives i { font-style: normal; margin: 0 1px; color: var(--danger); transition: color .3s, transform .3s; display: inline-block; }
.lives i.lost { color: var(--line); transform: scale(.8); }

.status { min-height: 42px; margin: 12px 0; font-size: 14px; }
.status[data-state="won"] { color: var(--accent); font-weight: 600; }
.status[data-state="lost"] { color: var(--danger); font-weight: 600; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; gap: 4px; border-radius: 12px; background: var(--surface-2); }
.seg button {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 7px 4px;
  border: 0;
  border-radius: 9px;
  background: none;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
}
.seg button small { font-weight: 400; font-size: 11px; color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }

.actions { display: flex; gap: 8px; margin-top: 10px; }
.btn {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }

.found details { border-radius: 10px; background: var(--surface-2); margin-bottom: 5px; overflow: hidden; }
.found summary {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  cursor: pointer;
  list-style: none;
  font-size: 13.5px;
  font-weight: 600;
}
.found summary::-webkit-details-marker { display: none; }
.found summary span:nth-child(2) { flex: 1; line-height: 1.2; }
.found summary b { font-variant-numeric: tabular-nums; color: var(--muted); }
.found ul { margin: 0; padding: 0 8px 8px 45px; list-style: none; }
.found li button {
  display: block;
  width: 100%;
  padding: 4px 6px;
  border: 0;
  border-radius: 6px;
  background: none;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
}
.found li button:hover { background: var(--accent-soft); }

/* ---------- karta obiektu ---------- */

.card {
  position: fixed;
  z-index: 30;
  right: 16px;
  top: 72px;
  width: 348px;
  max-height: calc(100dvh - 96px);
  display: flex;
  opacity: 0;
  transform: translateY(14px) scale(.98);
  transition: opacity .22s ease, transform .3s cubic-bezier(.2, .9, .3, 1.2);
  pointer-events: none;
}
.card.visible { opacity: 1; transform: none; pointer-events: auto; }
.card-box {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-box.hit { animation: shake .45s ease .05s; }
@keyframes shake {
  20% { transform: translateX(-7px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(2px); }
}
.card-close {
  position: absolute;
  right: 10px; top: 10px;
  width: 32px; height: 32px;
  border: 0;
  border-radius: 99px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  cursor: pointer;
  z-index: 1;
}
.card-close:hover { background: var(--surface-2); }
.card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 46px 16px 20px;
  background: color-mix(in srgb, var(--c, var(--grass)) 20%, var(--surface));
}
.summary.won .card-head { --c: var(--grass); }
.summary.lost .card-head { --c: var(--danger); }
.card-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 54px; height: 54px;
  border-radius: 15px;
  background: var(--surface);
  font-size: 30px;
  box-shadow: 0 2px 8px rgb(0 0 0 / .08);
  animation: icon-in .5s cubic-bezier(.3, 1.6, .5, 1) .1s both;
}
@keyframes icon-in { from { transform: scale(.4) rotate(-12deg); opacity: 0; } }
.card-kicker { margin: 0 0 3px; font-size: 12.5px; font-weight: 600; color: color-mix(in srgb, var(--ink) 70%, var(--c, var(--muted))); }
.card-head h3 { margin: 0; font-size: 20px; line-height: 1.15; }
.quip { margin: 0; padding: 12px 20px; font-style: italic; border-bottom: 1px solid var(--line); }
.card-body { padding: 4px 20px 16px; overflow-y: auto; min-height: 0; }
.card-body article + article { border-top: 1px dashed var(--line); }
.card-body article { padding: 12px 0 4px; }
.card-body h4 { margin: 0 0 4px; font-size: 15.5px; font-weight: 600; }
.card-cat { margin: 0 0 6px; font-size: 12.5px; color: var(--muted); }
.card-body dl { margin: 8px 0; display: grid; gap: 5px; font-size: 13.5px; }
.card-body dl div { display: grid; grid-template-columns: 42% 1fr; gap: 10px; }
.card-body dt { color: var(--muted); }
.card-body dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.notes {
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 13.5px;
  white-space: pre-line;
}
.card-links { display: flex; justify-content: space-between; gap: 10px; margin: 8px 0 4px; font-size: 13px; color: var(--muted); }
.card-links a { color: var(--accent); font-weight: 600; text-decoration: none; }
.card-links a:hover { text-decoration: underline; }
.summary .actions { padding: 0 20px 20px; margin: 0; }
.summary-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 13.5px; }
.summary-list li { display: flex; align-items: center; gap: 10px; }
.summary-list b { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ---------- toast, stopka ---------- */

.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  top: 70px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  box-shadow: var(--shadow);
  transform: translate(-50%, -12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .3s cubic-bezier(.2, .9, .3, 1.2);
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

.credits {
  position: fixed;
  left: 14px;
  bottom: 10px;
  z-index: 3;
  font-size: 11.5px;
  color: var(--muted);
  padding: 4px 9px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
}
.credits a { color: inherit; }

/* ---------- telefon ---------- */

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 8px 16px; }
  .brand-name { font-size: 18px; }
  .logo { width: 28px; height: 28px; }
  .search { display: none; }
  .crumbs { font-size: 13px; }

  .layout { display: block; position: relative; }
  .map { position: absolute; inset: 0; }
  .panel {
    position: absolute;
    left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom));
    max-height: 42dvh;
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
    z-index: 6;
  }
  .panel[data-mode="game"] { max-height: 36dvh; }
  .panel-inner { padding: 16px 16px 20px; }
  h1 { font-size: 25px; }
  h2 { font-size: 22px; }
  .kind { margin-bottom: 12px; }
  .legend { grid-template-columns: 1fr; }
  .stat b { font-size: 18px; }
  .status { min-height: 0; }
  .map-controls { top: 10px; right: 10px; }
  .credits { display: none; }

  .card {
    left: 8px; right: 8px; top: auto;
    bottom: calc(8px + env(safe-area-inset-bottom));
    width: auto;
    max-height: 62dvh;
  }
  .toast { top: auto; bottom: calc(45dvh + 8px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}
