/* =====================================================================
   Farma RPG — wygląd panelu bocznego
   Drewniane belki i ramy, pergaminowe wnętrza okien, złote akcenty.
   Wszystko z gradientów, cieni i obramowań (bez obrazków — CSP dodatku).
   ===================================================================== */

:root {
  /* rozmiar planszy w pikselach CSS (szerokość i wysokość mogą się różnić) i szerokość całego układu —
     ustawiane z JS (fitBoard w game.js); tu wartości startowe */
  --board-w: 384px;
  --board-h: 384px;
  --play-w: 400px;
  --app-w: 560px;

  /* tło panelu */
  --bg: #1b2416;
  --bg-deep: #131a0f;
  --text: #f6ecd2;
  --muted: #c4b593;

  /* drewno */
  --wood-hi: #a26b3a;
  --wood: #84542c;
  --wood-mid: #6b4322;
  --wood-lo: #4e2f16;
  --wood-dark: #2b180b;

  /* pergamin (wnętrza okien) */
  --parch-hi: #fdf5df;
  --parch: #f2e0b6;
  --parch-lo: #e3c890;
  --parch-line: #c9a467;
  --ink: #3a2614;
  --ink-soft: #66492c;
  --ink-faint: #8c7152;

  /* akcenty */
  --gold-hi: #ffe48f;
  --gold: #f2c443;
  --gold-mid: #d79a22;
  --gold-lo: #7a4f0c;
  --leaf-hi: #9ad65f;
  --leaf: #5fa336;
  --leaf-lo: #2d5a17;
  --water: #3d8ccc;
  --aqua: #9fdcff;
  --danger: #c9412f;
  --focus: #ffe48f;

  /* szerokość okien (sklepy, ekwipunek bazowo) — na dużym ekranie większa (niżej, @media) */
  --sheet-w: 520px;
  --wiki-w: 860px;

  /* sloty przedmiotów (nadpisywane zależnie od szerokości) */
  --slot: 40px;
  --slot-gap: 3px;
  --icon: 32px;

  /* tekstury */
  --grain: repeating-linear-gradient(180deg,
      transparent 0 6px, rgba(43, 24, 11, .10) 6px 7px,
      transparent 7px 13px, rgba(255, 236, 190, .07) 13px 14px);
  --plank: var(--grain), linear-gradient(180deg, var(--wood-hi), var(--wood) 55%, var(--wood-mid));
  --plank-dark: var(--grain), linear-gradient(180deg, #6e4524, #57361b 60%, #472a14);
  --parchment: radial-gradient(130% 70% at 50% 0%, rgba(255, 251, 238, .6), transparent 65%),
      linear-gradient(180deg, var(--parch), #e9d3a1);
  --card: linear-gradient(180deg, var(--parch-hi), #f6e7c3);
  --rivet: radial-gradient(circle at 45% 40%, #fff3c8 0 .7px, #e2bb62 1.3px, #8f651b 2.3px, #3a2210 2.9px, transparent 3.3px);

  /* cienie „wypukłego” drewna */
  --bevel: inset 0 1px 0 rgba(255, 236, 190, .32), inset 0 -3px 0 rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  display: flow-root; /* margines #app (wyśrodkowanie w pionie, fitBoard) nie „wypływa” poza body — bez przewijania */
  min-height: 100vh;
  background:
    radial-gradient(120% 55% at 50% 0%, rgba(84, 120, 58, .35), transparent 70%),
    linear-gradient(180deg, var(--bg), var(--bg-deep));
  color: var(--text);
  font: 13px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  user-select: none;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Układ: u góry belka i pora roku na całą szerokość, niżej scena — po lewej plansza w ramie, status i pasek,
   po prawej kolumna miejsc. Szerokość (--app-w) i rozmiar planszy liczy fitBoard() z szerokości ORAZ wysokości
   panelu (bez przewijania strony), mierząc prawdziwe elementy — marginesy i odstępy tutaj można zmieniać. */
#app {
  container: app / inline-size;
  width: var(--app-w);
  max-width: 100%;
  margin: 0 auto;
  padding: 8px 4px 12px;
}

.stage {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

/* lewa część: plansza, status, pasek — szerokość = plansza + rama (8 px na stronę), ale nie mniej niż przy planszy 1×,
   jeśli jest miejsce (--play-w z fitBoard) */
.play {
  container: play / inline-size;
  flex: none;
  align-self: flex-start;  /* własna wysokość (fitBoard ją mierzy); kolumna obok rozciąga się do niej */
  display: flex;
  flex-direction: column;
  width: var(--play-w, calc(var(--board-w) + 16px));
}

/* prawa kolumna: miejsca od góry (równo z górą planszy), pod nimi ekwipunek, wiki i nowa gra (na dole kolumny) */
.side {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

button { font: inherit; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* =====================================================================
   Górna belka: tytuł, monety, poziom, XP
   ===================================================================== */
.topbar {
  position: relative;
  margin-bottom: 8px;
  padding: 7px 10px 9px;
  border: 2px solid var(--wood-dark);
  border-radius: 10px;
  background:
    var(--rivet) left 3px top 3px / 7px 7px no-repeat,
    var(--rivet) right 3px top 3px / 7px 7px no-repeat,
    var(--rivet) left 3px bottom 3px / 7px 7px no-repeat,
    var(--rivet) right 3px bottom 3px / 7px 7px no-repeat,
    var(--plank);
  box-shadow: var(--bevel), 0 3px 0 var(--wood-dark), 0 7px 14px rgba(0, 0, 0, .35);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand { display: flex; align-items: center; gap: 7px; min-width: 0; }

/* kiełek narysowany pikselami (box-shadow) */
.brand-mark {
  position: relative;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #fff6da, #e7c98b);
  box-shadow: 0 0 0 2px var(--wood-dark), inset 0 -2px 0 rgba(120, 80, 30, .3);
}

.brand-mark::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 3px;
  width: 2px;
  height: 2px;
  box-shadow:
    14px 0 #5fa336, 16px 0 #5fa336,
    2px 2px #5fa336, 4px 2px #5fa336, 12px 2px #5fa336, 14px 2px #a6dc6a, 16px 2px #5fa336,
    0 4px #5fa336, 2px 4px #a6dc6a, 4px 4px #5fa336, 6px 4px #5fa336, 10px 4px #5fa336, 12px 4px #a6dc6a, 14px 4px #5fa336, 16px 4px #5fa336,
    0 6px #5fa336, 2px 6px #5fa336, 4px 6px #a6dc6a, 6px 6px #5fa336, 10px 6px #5fa336, 12px 6px #5fa336, 14px 6px #5fa336,
    2px 8px #3f7a22, 4px 8px #5fa336, 6px 8px #5fa336, 8px 8px #3f7a22, 10px 8px #5fa336, 12px 8px #3f7a22,
    8px 10px #3f7a22, 8px 12px #3f7a22,
    2px 14px #8a5a2c, 4px 14px #8a5a2c, 6px 14px #8a5a2c, 8px 14px #8a5a2c, 10px 14px #8a5a2c, 12px 14px #8a5a2c, 14px 14px #8a5a2c,
    0 16px #5e3a1b, 2px 16px #5e3a1b, 4px 16px #5e3a1b, 6px 16px #5e3a1b, 8px 16px #5e3a1b, 10px 16px #5e3a1b, 12px 16px #5e3a1b, 14px 16px #5e3a1b, 16px 16px #5e3a1b;
}

h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .3px;
  line-height: 1.1;
  color: var(--gold-hi);
  white-space: nowrap;
  text-shadow:
    0 2px 0 var(--wood-dark), 1px 0 0 var(--wood-dark), -1px 0 0 var(--wood-dark),
    0 -1px 0 var(--wood-dark), 1px 2px 0 var(--wood-dark), -1px 2px 0 var(--wood-dark);
}

.hud { display: flex; align-items: center; gap: 6px; flex: none; }

/* plakietki: monety i poziom */
.coins, .level {
  position: relative;
  display: flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  border-radius: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.coins {
  padding: 0 11px 0 4px;
  border: 1px solid var(--wood-dark);
  background: linear-gradient(180deg, #2a180b, #3a2412);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, .55), 0 1px 0 rgba(255, 236, 190, .28);
  color: var(--gold-hi);
}

.coins img { width: 16px; height: 16px; image-rendering: pixelated; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .6)); }
.coins b { min-width: 14px; font-size: 14px; font-weight: 800; text-shadow: 0 1px 0 #000; }

.level {
  padding: 0 10px 0 8px;
  border: 1px solid #14304d;
  background: linear-gradient(180deg, #5b9bd3, #33689c 60%, #2a5785);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), inset 0 -2px 0 rgba(0, 0, 0, .22), 0 1px 0 rgba(255, 236, 190, .25);
  color: #e3f2ff;
}

.level::before {
  content: '★';
  font-size: 13px;
  line-height: 1;
  color: var(--gold-hi);
  text-shadow: 0 1px 0 #7a4f0c, 0 0 1px #7a4f0c;
}

.lv-label { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; opacity: .9; }
.level b { font-size: 14px; font-weight: 800; color: #fff; text-shadow: 0 1px 0 #14304d; }
.level.levelup { animation: glow 1.4s ease-out; }

@keyframes glow {
  0%   { box-shadow: 0 0 0 0 rgba(255, 214, 90, .95), inset 0 0 0 2px var(--gold-hi); }
  100% { box-shadow: 0 0 0 14px rgba(255, 214, 90, 0), inset 0 0 0 2px transparent; }
}

/* pasek doświadczenia z połyskiem; liczby na pasku */
.xp { position: relative; margin-top: 7px; }

/* strona www w zwykłym oknie przeglądarki (≥ 720 px): belka w jednym rzędzie — tytuł, pasek XP, monety i poziom.
   Oszczędza wysokość, którą fitBoard oddaje planszy (np. skala 2× przy 1920×1080). Zależy od szerokości okna, nie
   od szerokości #app, więc pomiar układu nie kręci się w kółko. */
@media (min-width: 720px) {
  .topbar {
    display: grid;
    grid-template-columns: auto minmax(120px, 1fr) auto;
    align-items: center;
    column-gap: 14px;
  }
  .topbar header { display: contents; }
  .topbar .brand { grid-column: 1; grid-row: 1; }
  .topbar .xp { grid-column: 2; grid-row: 1; margin-top: 0; }
  .topbar .hud { grid-column: 3; grid-row: 1; }
}

.xp-bar {
  height: 16px;
  border: 1px solid #1a0d04;
  border-radius: 8px;
  background: linear-gradient(180deg, #1c0f06, #2f1b0c);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, .6), 0 1px 0 rgba(255, 236, 190, .25);
  overflow: hidden;
}

#xpFill {
  position: relative;
  width: 0;
  height: 100%;
  background: linear-gradient(180deg, #d4f79a 0%, #86d24e 45%, #55a330 55%, #3f8424 100%);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18), 1px 0 0 rgba(0, 0, 0, .4);
  transition: width .35s ease-out;
}

#xpFill::after {
  content: '';
  position: absolute;
  left: 4px;
  right: 4px;
  top: 2px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .45);
}

#xpText {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .2px;
  color: #fff;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  text-shadow: 0 1px 0 #1a0d04, 1px 0 0 #1a0d04, -1px 0 0 #1a0d04, 0 -1px 0 #1a0d04;
}

/* =====================================================================
   Pora roku i pogoda — pigułki
   ===================================================================== */
/* jeden rząd zawsze (wysokość nie skacze przy zmianie pogody): pigułki pory roku i pogody kurczą się z wielokropkiem */
.sky {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
  margin: 0 0 9px;
  font-size: 12px;
}

.season, .weather, .clock, .sky-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  height: 26px;
  padding: 0 11px 0 3px;
  border: 1px solid rgba(255, 236, 190, .16);
  border-radius: 13px;
  background: rgba(10, 14, 7, .55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
  color: var(--muted);
  white-space: nowrap;
}

.weather { margin-left: auto; }
.season, .weather { flex: 0 1 auto; overflow: hidden; }
/* ikona pogody i pory roku nigdy nie jest ucięta: pigułka nie kurczy się poniżej ikony (3 + 20 + 3 px + ramka) */
.weather, .season { min-width: 28px; }
.season b { flex: none; }

/* zegar doby (dzień i noc): godzina i ikona słońca, wschodu, zachodu albo księżyca */
.clock {
  flex: none;
  gap: 4px;
  padding-right: 9px;
  font-variant-numeric: tabular-nums;
  transition: background-color .6s, border-color .6s;
}
.clock b { color: var(--text); font-weight: 700; }
.clock[data-phase="dawn"] { border-color: rgba(255, 184, 120, .45); background: rgba(70, 34, 30, .6); }
.clock[data-phase="dusk"] { border-color: rgba(240, 130, 70, .5); background: rgba(66, 26, 22, .62); }
.clock[data-phase="night"] { border-color: rgba(160, 176, 255, .4); background: rgba(14, 18, 44, .72); }
.clock[data-phase="night"] b { color: #dfe4ff; }

/* pigułki modułów w pasku nieba (np. trwające wydarzenie) — dodawaj elementy z klasą .sky-pill do #skyExtra */
/* pigułki modułów niosą to, co pilne (czas wydarzenia, roju), więc nie ustępują miejsca pogodzie: kurczą się dopiero
   ponad 60% paska, a ich napisy — z wielokropkiem; przy wąskim panelu pogoda zostaje samą ikoną (nazwa — w podpowiedzi) */
.sky-extra { display: flex; flex: 0 0 auto; gap: 6px; min-width: 0; max-width: 60%; overflow: hidden; }
.sky-extra:empty { display: none; }
.sky-pill { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; }
.sky-pill span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* pigułka roju (feat-bees): nazwa się kurczy, czas zawsze widoczny; w wąskim pasku sama ikona i czas */
.bees-pill .bees-name { flex: 0 1 auto; }
.bees-pill .bees-time { flex: none; overflow: visible; margin-left: -2px; font-variant-numeric: tabular-nums; }
@media (max-width: 420px) { .bees-pill .bees-name { display: none; } .bees-pill .bees-time { margin-left: 0; } }
@media (max-width: 420px) {
  .sky:has(.sky-extra:not(:empty)) .weather span { display: none; }
  .sky:has(.sky-extra:not(:empty)) .weather { flex: none; padding-right: 3px; }
  /* dwie pigułki modułów naraz (np. wydarzenie i rój): pora roku samą ikoną z dobą („3/5”, nazwa w podpowiedzi),
     pigułki ciaśniej — godzina, doba i czasy pigułek zostają w całości */
  .sky:has(.sky-extra > :nth-child(2)) #seasonName { display: none; }
  .sky:has(.sky-extra > :nth-child(2)) { gap: 4px; }
  .sky:has(.sky-extra > :nth-child(2)) :is(.season, .clock, .sky-pill) { gap: 4px; padding-right: 7px; }
  .sky:has(.sky-extra > :nth-child(2)) .sky-extra { gap: 4px; max-width: 64%; }
}

.sky img {
  flex: none;
  width: 16px;
  height: 16px;
  padding: 2px;
  box-sizing: content-box;
  border-radius: 50%;
  background: rgba(255, 236, 190, .12);
  image-rendering: pixelated;
}

.season b { color: var(--text); font-weight: 700; }
/* wąski panel: krótka doba pory roku („2/5”) — pigułka się nie kurczy, miejsce oddają pogoda i pigułki modułów */
.season.compact { flex-shrink: 0; }
.season span { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.weather span { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: #e6dabd; }
/* nazwa pogody się nie mieści (game.js: updateSkyHud, np. dwie pigułki modułów w wąskim pasku) — sama ikona */
.weather.icon-only span { display: none; }
.weather.icon-only { flex: none; padding-right: 3px; }

.weather.boost {
  border-color: rgba(159, 220, 255, .55);
  background: rgba(24, 70, 108, .55);
  color: var(--aqua);
}

.weather.boost span { color: #d4f0ff; font-weight: 600; }

/* =====================================================================
   Animacje przekazywane z JS
   ===================================================================== */
.bump { animation: bump .35s ease-out; }

@keyframes bump {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.shake-x { animation: shakeX .3s linear; }

@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.dom-float {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: -4px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 1px 0 #000, 1px 0 0 #000, -1px 0 0 #000, 0 -1px 0 #000;
  animation: rise .9s ease-out forwards;
}

.dom-float.plus { color: var(--gold-hi); }
.dom-float.minus { color: #ff9a88; }

@keyframes rise {
  from { opacity: 1; transform: translate(-50%, 0); }
  to   { opacity: 0; transform: translate(-50%, -24px); }
}

.fly { position: fixed; z-index: 50; pointer-events: none; image-rendering: pixelated; }

/* =====================================================================
   Plansza w grubej drewnianej ramie z nitami
   ===================================================================== */
.board-frame {
  position: relative;
  flex: none;
  align-self: center;  /* przy niskim panelu lewa część bywa szersza niż plansza — plansza na środku */
  padding: 6px;
  border: 2px solid var(--wood-dark);
  border-radius: 8px;
  background:
    var(--rivet) left 0 top 0 / 6px 6px no-repeat,
    var(--rivet) right 0 top 0 / 6px 6px no-repeat,
    var(--rivet) left 0 bottom 0 / 6px 6px no-repeat,
    var(--rivet) right 0 bottom 0 / 6px 6px no-repeat,
    linear-gradient(135deg, rgba(255, 236, 190, .14), transparent 40%, rgba(0, 0, 0, .18)),
    var(--plank);
  box-shadow: var(--bevel), 0 4px 0 var(--wood-dark), 0 9px 16px rgba(0, 0, 0, .45);
}

.board-wrap {
  position: relative;
  width: var(--board-w);
  height: var(--board-h);
  border-radius: 3px;
  overflow: hidden;
  background: var(--water);
  box-shadow: 0 0 0 2px var(--wood-dark);
}

/* delikatny cień wewnątrz ramy */
.board-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .4), inset 0 0 0 1px rgba(0, 0, 0, .25);
  pointer-events: none;
}

#board {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
}

#board.shake { animation: shake .14s linear; }

/* Strzałki przesuwania widoku (gdy wyspa jest większa niż widok — osobno w poziomie i w pionie): drewniane uchwyty
   na ramie, POZA planszą — nie zasłaniają pól. Uchwyt ma 8 px (tyle co rama: 2 px brzegu + 6 px wnętrza), leży na
   środku boku ramy (plansza może być prostokątna) i kończy się tuż przy krawędzi planszy. ::after wydłuża pole
   kliknięcia wzdłuż ramy (nigdy w stronę planszy). */
.pan-btn {
  --pan-at: -2px;
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--wood-dark);
  border-radius: 4px;
  background: linear-gradient(180deg, var(--wood-hi), var(--wood-mid));
  box-shadow: 0 1px 2px rgba(0, 0, 0, .5);
  color: var(--gold-hi);
  cursor: pointer;
  transition: background-color .12s, color .12s;
}
.pan-btn:hover, .pan-btn:focus-visible { background: linear-gradient(180deg, #c48a4c, var(--wood)); color: #fffbe6; }
.pan-btn:active { background: var(--gold-lo); }
.pan-btn::before { content: ''; width: 0; height: 0; border: 3px solid transparent; }
.pan-btn::after { content: ''; position: absolute; }
.pan-left, .pan-right { top: calc(50% - 20px); width: 8px; height: 40px; }
.pan-up, .pan-down { left: calc(50% - 20px); width: 40px; height: 8px; }
.pan-left { left: var(--pan-at); }
.pan-right { right: var(--pan-at); }
.pan-up { top: var(--pan-at); }
.pan-down { bottom: var(--pan-at); }
.pan-left::after, .pan-right::after { inset: -8px 0; }
.pan-up::after, .pan-down::after { inset: 0 -8px; }
.pan-left::before { border-right-color: currentColor; margin-left: -3px; }
.pan-right::before { border-left-color: currentColor; margin-right: -3px; }
.pan-up::before { border-bottom-color: currentColor; margin-top: -3px; }
.pan-down::before { border-top-color: currentColor; margin-bottom: -3px; }

@keyframes shake {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(2px, 2px); }
  50%  { transform: translate(-2px, 0); }
  75%  { transform: translate(0, -2px); }
  100% { transform: translate(0, 0); }
}

/* =====================================================================
   Linia statusu — stała wysokość na dwie linie (nic nie skacze),
   krótki tekst wyśrodkowany w pionie, dłuższy zawinięty i wyważony
   ===================================================================== */
#status {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-box-pack: center;   /* starszy Chrome: -webkit-box to flexbox */
  align-content: center;      /* nowszy Chrome: blok z line-clamp — wyśrodkowanie w pionie */
  -webkit-line-clamp: 2;
  height: 40px;
  margin: 12px 0 8px;
  padding: 3px 12px;
  border: 1px solid rgba(255, 236, 190, .12);
  border-radius: 12px;
  background: rgba(10, 14, 7, .5);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .35);
  color: #ecdfc0;
  font-size: 12.5px;
  line-height: 16px;
  text-align: center;
  white-space: normal;
  text-wrap: balance;
  overflow-wrap: break-word;
  overflow: hidden;
}

/* =====================================================================
   Pasek szybkiego wyboru — drewniana taca z pergaminowymi slotami
   ===================================================================== */
.belt {
  padding: 6px 6px 5px;
  border: 2px solid var(--wood-dark);
  border-radius: 10px;
  background: var(--plank-dark);
  box-shadow: var(--bevel), 0 3px 0 var(--wood-dark), 0 6px 12px rgba(0, 0, 0, .3);
}

.hotbar {
  display: grid;
  grid-template-columns: repeat(9, var(--slot));
  justify-content: center;
  gap: var(--slot-gap);
}

.slot {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--slot);
  height: var(--slot);
  padding: 0;
  border: 2px solid #5a3a1c;
  border-radius: 6px;
  background: linear-gradient(180deg, #f8e9c2, #e6cb92);
  box-shadow: inset 0 0 0 1px rgba(255, 250, 230, .55), inset 0 -3px 0 rgba(140, 95, 40, .22);
  color: var(--ink);
  cursor: pointer;
  transition: translate .08s ease-out;
}

.slot:hover { background: linear-gradient(180deg, #fdf3d6, #eed7a6); }
.slot:active { translate: 0 1px; }

.slot canvas {
  width: var(--icon);
  height: var(--icon);
  image-rendering: pixelated;
  pointer-events: none;
}

.slot.empty {
  background: linear-gradient(180deg, #d5b67c, #dcc08a);
  box-shadow: inset 0 2px 4px rgba(90, 58, 28, .38);
}

.slot.empty:hover { background: linear-gradient(180deg, #ddc08a, #e4cb98); }

.slot.zero canvas { opacity: .4; }

.slot.locked { background: linear-gradient(180deg, #ddd2bb, #c9bb9c); }
.slot.locked canvas { filter: grayscale(1) brightness(.8); opacity: .7; }

.slot .num {
  position: absolute;
  top: 1px;
  left: 3px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
  color: #553719;
  pointer-events: none;
}

/* numer na pustym (ciemniejszym) slocie — wciąż ≥ 4.5:1 */
.slot.empty .num { color: #4a2f14; }

.slot .count {
  position: absolute;
  right: 2px;
  bottom: 0;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.15;
  color: #fff;
  pointer-events: none;
  text-shadow: 0 1px 0 #1a0d04, 1px 0 0 #1a0d04, -1px 0 0 #1a0d04, 0 -1px 0 #1a0d04;
}

/* narzędzie z paskiem wytrzymałości — licznik nad paskiem */
.slot:has(.dura) .count { bottom: 5px; }

.slot .count.water { color: var(--aqua); text-shadow: 0 1px 0 #0b2a44, 1px 0 0 #0b2a44, -1px 0 0 #0b2a44, 0 -1px 0 #0b2a44; }

.slot .lock {
  position: absolute;
  right: 1px;
  top: 1px;
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
  pointer-events: none;
}

/* wybrany slot: złota obwódka i lekkie uniesienie */
.slot.selected {
  z-index: 1;
  translate: 0 -2px;
  border-color: var(--wood-dark);
  background: linear-gradient(180deg, #fff8dc, #f4dc9e);
  box-shadow:
    0 0 0 2px var(--gold), 0 0 0 4px var(--gold-lo), 0 5px 6px rgba(0, 0, 0, .35),
    inset 0 0 0 1px rgba(255, 255, 255, .7);
}

.slot.selected .num { color: #7a4f0c; }

/* zepsute narzędzie */
.slot.broken { border-color: #6e1f12; background: linear-gradient(180deg, #f3cdb9, #dea48a); }
.slot.broken canvas { filter: grayscale(1) brightness(.7); }

.slot.broken::after {
  content: '✕';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #e5483a;
  font-size: 22px;
  font-weight: 900;
  pointer-events: none;
  text-shadow: 0 1px 0 #2b0a04, 1px 0 0 #2b0a04, -1px 0 0 #2b0a04, 0 -1px 0 #2b0a04;
}

/* podniesiony w ekwipunku */
.slot.held {
  z-index: 2;
  translate: 0 -3px;
  border-color: #123a5c;
  background: linear-gradient(180deg, #eef8ff, #cfe8f7);
  box-shadow: 0 0 0 2px var(--aqua), 0 0 0 4px #1d4f7a, 0 6px 8px rgba(0, 0, 0, .35);
}

/* obwódka tuż przy krawędzi — mieści się w odstępie i nie zachodzi na sąsiednie sloty */
.slot:focus-visible { outline: 2px solid #fff; outline-offset: 0; }

.slot.unlocked { animation: unlock 1.3s ease-out; }

@keyframes unlock {
  0%   { transform: scale(1.18); filter: brightness(1.25); }
  40%  { transform: scale(1); filter: none; }
  100% { transform: scale(1); }
}

/* pasek wytrzymałości narzędzia */
.dura {
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 3px;
  height: 4px;
  border-radius: 2px;
  background: rgba(43, 24, 11, .7);
  box-shadow: 0 0 0 1px rgba(255, 250, 230, .45);
  overflow: hidden;
  pointer-events: none;
}

.dura i { display: block; height: 100%; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35); }

.dura.wide {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  display: inline-block;
  width: 64px;
  height: 7px;
  margin-right: 6px;
  vertical-align: 0;
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(90, 58, 28, .45);
}

/* napis „W ręce” na tacy (z przełącznikami trybu ulepszonej motyki) */
.hand {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  padding: 0 4px;
  color: #f6e4bb;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .5);
}

.hand-label { flex: none; color: rgba(255, 236, 190, .62); }
.hand b { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: #fff6dc; font-weight: 700; }
.hand-mode { display: inline-flex; flex: none; gap: 3px; }
.hand-mode[hidden] { display: none; }
.hand-btn {
  padding: 0 5px;
  min-width: 20px;
  height: 17px;
  border: 1px solid rgba(60, 36, 16, .8);
  border-radius: 4px;
  background: #7a4f28;
  color: #fff6dc;
  font: inherit;
  font-size: 11px;
  line-height: 15px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 230, 180, .25);
}
.hand-btn:hover { background: #8e5e30; }
.hand-btn:focus-visible { outline: 2px solid #ffd65a; outline-offset: 1px; }

/* =====================================================================
   Miejsca — drewniane szyldy z daszkiem i ikoną w kolumnie po prawej stronie planszy, od góry do dołu.
   Przyciski generuje game.js z listy PLACES; kolory daszka przychodzą w --aw1 / --aw2.
   Pełna kolumna: ikona, nazwa i klawisz. Wąska (#app.compact): ikona i klawisz (nazwa w title i aria-label).
   Szerokość kolumny wynika z treści — fitBoard() ją mierzy i resztę oddaje planszy.
   ===================================================================== */
.places {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.place-btn {
  --aw1: #5fa336;
  --aw2: #f3e3bf;
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 46px;
  padding: 11px 6px 0;  /* u góry daszek (13 px razem z brzegiem) — ikona na środku tego, co pod nim */
  border: 2px solid var(--wood-dark);
  border-radius: 8px;
  background: var(--plank);
  color: #fff4d8;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: .2px;
  white-space: nowrap;
  text-align: left;
  text-shadow: 0 1px 0 var(--wood-dark), 1px 0 0 rgba(43, 24, 11, .6), -1px 0 0 rgba(43, 24, 11, .6);
  cursor: pointer;
  box-shadow: var(--bevel), 0 3px 0 var(--wood-dark);
  transition: translate .08s ease-out;
}

/* daszek w paski — każde miejsce ma swój kolor */
.place-btn::before {
  content: '';
  position: absolute;
  left: -2px;
  right: -2px;
  top: -2px;
  height: 9px;
  border: 2px solid var(--wood-dark);
  border-radius: 8px 8px 3px 3px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .25), transparent 60%, rgba(0, 0, 0, .18)),
    repeating-linear-gradient(90deg, var(--aw1) 0 7px, var(--aw2) 7px 14px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .22);
}

/* nazwa miejsca zajmuje środek szyldu, klawisz przy prawej krawędzi */
.place-btn .pname {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.place-btn img {
  flex: none;
  width: 16px;
  height: 16px;
  padding: 4px;
  box-sizing: content-box;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #fff8e2, #e8cf98);
  box-shadow: 0 0 0 2px var(--wood-dark), inset 0 -2px 0 rgba(140, 95, 40, .25);
  image-rendering: pixelated;
}

.place-btn:hover { background: var(--grain), linear-gradient(180deg, #b07642, #8f5c31 55%, #774a26); }
.place-btn:active { translate: 0 2px; box-shadow: var(--bevel), 0 1px 0 var(--wood-dark); }
.place-btn.pulse { animation: pulse 1s ease-out; }

@keyframes pulse {
  0%, 100% { box-shadow: var(--bevel), 0 3px 0 var(--wood-dark), 0 0 0 0 rgba(255, 214, 90, 0); }
  30%      { box-shadow: var(--bevel), 0 3px 0 var(--wood-dark), 0 0 0 7px rgba(255, 214, 90, .6); }
}

/* mały klawisz skrótu */
.key {
  display: inline-block;
  flex: none;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 3px;
  background: rgba(43, 24, 11, .5);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .35);
  color: rgba(255, 244, 216, .9);
  font-size: 11px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  text-shadow: none;
  letter-spacing: 0;
}

/* licznik (np. rzeczy do sprzedania na Targu) — w prawym górnym rogu szyldu, na daszku: wystaje tylko w odstęp
   między szyldami (nie zasłania szyldu wyżej ani ikony i klawisza tego szyldu) */
.badge {
  position: absolute;
  z-index: 2;
  top: -6px;
  right: -4px;
  min-width: 19px;
  max-width: 34px;
  height: 19px;
  padding: 0 4px;
  border: 2px solid #fff3d6;
  border-radius: 10px;
  background: linear-gradient(180deg, #f0604a, #c22f1f);
  box-shadow: 0 0 0 1px var(--wood-dark), 0 2px 3px rgba(0, 0, 0, .4);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -.2px;
  line-height: 15px;
  text-align: center;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .45);
  white-space: nowrap;
}

/* =====================================================================
   Pod miejscami: ekwipunek, wiki i nowa gra — przy dolnej krawędzi kolumny (obok paska)
   ===================================================================== */
.side-tools {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 0;          /* szerokość kolumny wyznaczają szyldy miejsc — przyciski tutaj tylko ją wypełniają */
  min-width: 100%;
  margin-top: auto;
}

.small-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border: 2px solid var(--wood-dark);
  border-radius: 7px;
  background: linear-gradient(180deg, #5d3c1f, #452a12);
  box-shadow: inset 0 1px 0 rgba(255, 236, 190, .2), 0 2px 0 var(--wood-dark);
  color: #ecd9b0;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: translate .08s ease-out;
}

.small-btn:hover { color: #fff6dc; background: linear-gradient(180deg, #6e4826, #533316); }
.small-btn:active { translate: 0 1px; box-shadow: inset 0 1px 0 rgba(255, 236, 190, .2), 0 1px 0 var(--wood-dark); }

.side-tools .small-btn { width: 100%; padding: 0 8px 0 7px; }
.tool-btn .tname { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.tool-ico { display: grid; flex: none; place-items: center; width: 16px; height: 16px; }
.tool-ico img { width: 16px; height: 16px; image-rendering: pixelated; }

.reset { justify-content: center; color: #c9b48f; }

.reset.armed {
  border-color: #3a0d06;
  background: linear-gradient(180deg, #c94a35, #8f2818);
  color: #fff;
}

/* --- wąska kolumna (#app.compact, gdy brakuje miejsca na nazwy): ikona, a obok niej (przy dolnej krawędzi, bez
       nachodzenia na ikonę) klawisz; nazwa w title i aria-label --- */
#app.compact .stage { gap: 6px; }
#app.compact .place-btn { justify-content: center; gap: 2px; padding: 11px 3px 0 4px; }
#app.compact .place-btn .pname,
#app.compact .tool-btn .tname { display: none; }
#app.compact .place-btn .key,
#app.compact .tool-btn .key {
  position: relative;
  z-index: 1;
  align-self: flex-end;
  min-width: 13px;
  height: 14px;
  margin: 0 0 2px;
  padding: 0 2px;
  background: var(--wood-lo);
  box-shadow: 0 0 0 1px var(--wood-dark), inset 0 -1px 0 rgba(0, 0, 0, .35);
  color: #fff4d8;
  font-size: 11px;
  line-height: 14px;
}
#app.compact .tool-btn .key { align-self: center; margin: 0; }
#app.compact .side-tools .small-btn { justify-content: center; gap: 3px; padding: 0 3px; }
/* licznik w wąskiej kolumnie: mniejszy, na daszku szyldu — nie zasłania ikony ani sąsiedniego szyldu */
#app.compact .badge { top: -5px; right: -3px; min-width: 17px; height: 17px; padding: 0 3px; font-size: 11px; line-height: 13px; }
#app.compact .reset {
  height: 34px;
  padding: 0 2px;
  font-size: 11px;
  line-height: 12px;
  white-space: normal;
  text-align: center;
}

/* --- niski panel: ciaśniejsza kolumna (daszek, ikony, odstępy), żeby nic się nie przewijało --- */
@media (max-height: 659.98px) {
  .side { gap: 8px; }
  .places { gap: 5px; }
  .place-btn,
  #app.compact .place-btn { height: 38px; padding-top: 8px; }
  .place-btn::before { height: 6px; }
  .place-btn img { padding: 3px; }
  .side-tools { gap: 4px; }
  .small-btn { height: 27px; }
  #app.compact .reset { height: 30px; }
  .place-btn .badge, #app.compact .badge { top: -5px; min-width: 15px; height: 15px; padding: 0 3px; line-height: 11px; }
}

/* =====================================================================
   Okna: sklepy, ekwipunek, wiki
   ===================================================================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: radial-gradient(120% 90% at 50% 40%, rgba(12, 9, 4, .45), rgba(8, 6, 3, .75));
}

/* sklep i ekwipunek przyklejone do góry: zmiana wysokości (opis przedmiotu,
   pasek komunikatu) wydłuża okno w dół, a sloty i przyciski nie skaczą pod kursorem */
#shopModal,
#invModal {
  align-items: flex-start;
  padding-top: clamp(8px, 6vh, 64px);
}

/* szerokość okna: --sheet-w (520 px; na dużym ekranie więcej — niżej); wysokość: treść, najwyżej do dołu okna
   przeglądarki (na dużym ekranie 88% wysokości), dalej lista przewija się w środku */
.sheet {
  container: sheet / inline-size;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--sheet-w);
  max-height: 100%;
  padding: 0 6px 6px;
  border: 2px solid var(--wood-dark);
  border-radius: 12px;
  background: var(--plank);
  box-shadow: var(--bevel), 0 4px 0 var(--wood-dark), 0 16px 36px rgba(0, 0, 0, .6);
  overflow: hidden;
  animation: sheetIn .18s ease-out;
  --focus: #1f5fae;
}

/* okno (role="dialog", tabindex="-1") dostaje fokus z JS — bez ramki wokół całego okna */
.sheet:focus,
.sheet:focus-visible { outline: none; }

.sheet.wiki { height: 100%; }

/* duży ekran (strona www): okna szersze i wyższe — sklepy do ~1200 px (lista w dwóch kolumnach od ~880 px okna),
   wiki do ~1240 px z menu z boku, ekwipunek z większymi polami */
@media (min-width: 1000px) and (min-height: 600px) {
  :root {
    --sheet-w: min(92vw, clamp(520px, 52vw, 1200px));
    --wiki-w: min(94vw, clamp(860px, 72vw, 1240px));
  }
  .sheet { max-height: min(100%, 88vh); }
  #shopModal .sheet { min-height: min(100%, 50vh); }
  .sheet.wiki { max-height: min(100%, 90vh); }
}

/* pełny ekran (przycisk ⛶ w nagłówku albo klawisz F): okno na całe okno przeglądarki z małym marginesem;
   zapamiętane osobno dla każdego rodzaju okna (game.js: toggleFull) */
.modal.full,
#shopModal.full,
#invModal.full { align-items: stretch; justify-content: stretch; padding: 8px; }
.modal .sheet.full,
#invModal .sheet.full {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  min-height: 0;
}

@keyframes sheetIn {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

/* nagłówek-belka */
.sheet-head {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin: 0 -6px;
  padding: 7px 8px 7px 14px;
  /* lekko przyciemniona belka — jasny podtytuł ma na niej kontrast ≥ 4.5:1 */
  background: linear-gradient(180deg, rgba(43, 24, 11, .26), rgba(43, 24, 11, .2));
  box-shadow: inset 0 -1px 0 rgba(255, 236, 190, .14);
  --focus: var(--gold-hi);
}

.sheet-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.15;
  color: var(--gold-hi);
  white-space: nowrap;
  text-shadow:
    0 2px 0 var(--wood-dark), 1px 0 0 var(--wood-dark), -1px 0 0 var(--wood-dark),
    0 -1px 0 var(--wood-dark), 1px 2px 0 var(--wood-dark), -1px 2px 0 var(--wood-dark);
}

/* podtytuł: zawija się do dwóch linii zamiast ucinać w pół słowa */
.sheet-head .sub {
  flex: 1;
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  color: #fbeed2;
  font-size: 12px;
  line-height: 1.3;
  text-wrap: pretty;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .6);
}

.sheet.wiki .sheet-head h2 { flex: 1; }

.close {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-left: auto;
  padding: 0;
  border: 2px solid var(--wood-dark);
  border-radius: 8px;
  background: linear-gradient(180deg, #d65a42, #a33622);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), inset 0 -2px 0 rgba(0, 0, 0, .2), 0 2px 0 var(--wood-dark);
  color: #fff3e6;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .45);
  cursor: pointer;
}

.close:hover { background: linear-gradient(180deg, #e66a50, #b43f29); }
.close:active { translate: 0 1px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 1px 0 var(--wood-dark); }

/* „Pełny ekran” (⛶) obok zamykania: drewniany przycisk z czterema narożnikami (rysowanymi pikselami); gdy okno jest
   na pełnym ekranie — narożniki do środka („przywróć”) */
.sheet-full {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-left: auto;
  padding: 0;
  border: 2px solid var(--wood-dark);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--wood-hi), var(--wood-mid));
  box-shadow: inset 0 1px 0 rgba(255, 236, 190, .35), inset 0 -2px 0 rgba(0, 0, 0, .2), 0 2px 0 var(--wood-dark);
  color: var(--gold-hi);
  cursor: pointer;
}
.sheet-full::before {
  --c: linear-gradient(currentColor, currentColor);
  content: '';
  width: 14px;
  height: 14px;
  background:
    var(--c) left 0 top 0 / 5px 2px no-repeat, var(--c) left 0 top 0 / 2px 5px no-repeat,
    var(--c) right 0 top 0 / 5px 2px no-repeat, var(--c) right 0 top 0 / 2px 5px no-repeat,
    var(--c) left 0 bottom 0 / 5px 2px no-repeat, var(--c) left 0 bottom 0 / 2px 5px no-repeat,
    var(--c) right 0 bottom 0 / 5px 2px no-repeat, var(--c) right 0 bottom 0 / 2px 5px no-repeat;
  filter: drop-shadow(0 1px 0 rgba(43, 24, 11, .8));
}
.sheet-full[aria-pressed="true"]::before {
  background:
    var(--c) left 0 top 3px / 5px 2px no-repeat, var(--c) left 3px top 0 / 2px 5px no-repeat,
    var(--c) right 0 top 3px / 5px 2px no-repeat, var(--c) right 3px top 0 / 2px 5px no-repeat,
    var(--c) left 0 bottom 3px / 5px 2px no-repeat, var(--c) left 3px bottom 0 / 2px 5px no-repeat,
    var(--c) right 0 bottom 3px / 5px 2px no-repeat, var(--c) right 3px bottom 0 / 2px 5px no-repeat;
}
.sheet-full:hover { background: linear-gradient(180deg, #c48a4c, var(--wood)); color: #fffbe6; }
.sheet-full:active { translate: 0 1px; box-shadow: inset 0 1px 0 rgba(255, 236, 190, .35), 0 1px 0 var(--wood-dark); }
.sheet-full + .close { margin-left: 0; }

/* pergaminowe wnętrze */
.sheet-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 120px;
  padding: 10px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 2px solid var(--wood-dark);
  border-radius: 7px;
  background: var(--parchment);
  box-shadow: inset 0 2px 6px rgba(120, 80, 30, .35);
  color: var(--ink);
  scrollbar-color: #b58d56 transparent;
}

.sheet .muted { color: var(--ink-soft); }

/* pasek komunikatu w otwartym oknie (tekst wpisuje i czyści JS) */
.sheet-msg {
  flex: none;
  margin: 6px 0 0;
  padding: 6px 12px;
  border: 1px solid var(--wood-dark);
  border-radius: 8px;
  background: linear-gradient(180deg, #2a180b, #3a2412);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, .5), 0 1px 0 rgba(255, 236, 190, .25);
  color: var(--gold-hi);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  text-wrap: balance;
  overflow-wrap: break-word;
  text-shadow: 0 1px 0 #000;
  animation: msgIn .18s ease-out;
}

.sheet-msg:empty { display: none; }

/* błąd (np. za mało monet) — czerwony pasek */
.sheet-msg.bad {
  border-color: #2b0703;
  background: linear-gradient(180deg, #4e130a, #641b10);
  color: #ffc9bc;
}

.sheet-msg.bad::before {
  content: '!';
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 6px;
  border-radius: 50%;
  background: #e5483a;
  box-shadow: 0 0 0 1px #2b0703;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  line-height: 16px;
  text-align: center;
  vertical-align: 1px;
  text-shadow: none;
}

/* JS „podbija” pasek przy każdym komunikacie — tu łagodniej niż .bump (pasek ma całą szerokość okna) */
.sheet-msg.bump { animation: msgPop .3s ease-out; }

@keyframes msgIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

@keyframes msgPop {
  0%   { filter: brightness(1.6); }
  100% { filter: none; }
}

/* segment opisu (JS opakowuje w <span class="seg">) — nie łamie się w środku, póki mieści się w jednej linii opisu;
   dłuższy niż cała kolumna (wąskie okno) zawija się w sobie zamiast wchodzić pod przyciski (inline-block: cały
   segment przechodzi do nowej linii, a łamie się dopiero, gdy jest szerszy niż kolumna) */
.seg { display: inline-block; max-width: 100%; white-space: normal; }
.seg.wrap { display: inline; } /* długi opis (np. ulepszenie narzędzia u Kowala) zawija się jak zwykły tekst */

/* „mam/potrzeba” (rozbudowa wyspy): zielone, gdy wystarcza, czerwonawe, gdy brakuje */
.need { display: inline-flex; align-items: center; gap: 2px; margin-right: 4px; font-weight: 700; white-space: nowrap; }
.need.ok { color: #3f7a1c; }
.need.miss { color: #a3301e; }
.row.locked .need { opacity: .8; }

/* stopka-belka */
.sheet-foot {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  min-height: 46px;
  margin: 0 -6px -6px;
  padding: 7px 12px;
  color: rgba(255, 240, 210, .85);
  font-size: 12px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .45);
  --focus: var(--gold-hi);
}

.sheet-foot > span { flex: 1 1 140px; min-width: 0; }

.sheet-foot b {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 10px 2px 9px;
  border: 1px solid var(--wood-dark);
  border-radius: 12px;
  background: linear-gradient(180deg, #2a180b, #3a2412);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, .5), 0 1px 0 rgba(255, 236, 190, .25);
  color: var(--gold-hi);
  font-size: 13px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.sheet-foot img, .btn img, .meta img { width: 12px; height: 12px; image-rendering: pixelated; vertical-align: -1px; }

/* nagłówki sekcji */
.sec, .inv-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 2px 0;
  color: #7a4718;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .7px;
  text-transform: uppercase;
}

.sec:first-child, .inv-label:first-child { margin-top: 0; }

.sec::after, .inv-label::after {
  content: '';
  flex: 1;
  height: 2px;
  border-radius: 1px;
  background: linear-gradient(90deg, rgba(122, 71, 24, .45), transparent);
}

/* wiersz sklepu */
.row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 9px;
  padding: 6px 8px 6px 6px;
  border: 1px solid var(--parch-line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .75), 0 1px 0 rgba(120, 80, 30, .2);
}

.row canvas.ico {
  width: 32px;
  height: 32px;
  padding: 2px;
  box-sizing: content-box;
  border-radius: 6px;
  background: linear-gradient(180deg, #ecd6a6, #e0c48c);
  box-shadow: inset 0 0 0 1px rgba(120, 80, 30, .3), inset 0 2px 3px rgba(120, 80, 30, .2);
  image-rendering: pixelated;
}

.row .info { min-width: 0; }
.row .name { color: var(--ink); font-size: 13px; font-weight: 800; line-height: 1.25; }

.row .own {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 8px;
  background: rgba(120, 80, 30, .12);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  vertical-align: 1px;
}

.row .meta { margin-top: 1px; color: var(--ink-soft); font-size: 11.5px; line-height: 1.35; }

.row .acts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.row .note { color: #1f5f8a; font-size: 11px; font-weight: 700; }

.row .acts.note {
  padding: 3px 10px;
  border: 1px solid rgba(31, 95, 138, .35);
  border-radius: 12px;
  background: rgba(31, 95, 138, .1);
}

.row .note.ok { border-color: rgba(61, 122, 31, .4); background: rgba(95, 163, 54, .16); color: #2f6b17; }

.row.locked { border-color: #cbbb98; background: linear-gradient(180deg, #f1e9d8, #e6dbc2); }
.row.locked .name { color: #5e4f3c; }
.row.locked .meta { color: #645541; }
.row.locked canvas.ico { filter: grayscale(.85); opacity: .75; }

.row.broken { border-color: #b8402e; box-shadow: inset 0 0 0 1px rgba(184, 64, 46, .35), 0 1px 0 rgba(120, 80, 30, .2); }
.row.broken .own { background: rgba(201, 65, 47, .14); color: #a3301e; }

/* szerokie okno (duży ekran albo pełny ekran): wiersze miejsca w dwóch (trzech) kolumnach, wszystko inne (nagłówki
   sekcji, zakładki, bloki modułów, notatki) i wiersz z rozwiniętymi ustawieniami — na całą szerokość */
@container sheet (min-width: 880px) {
  #shopList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(410px, 1fr));
    align-content: start;
    column-gap: 8px;
  }
  /* plansza 2× — większe napisy i przyciski („Wszystkie · 37 758”): węższa kolumna ucinałaby ustawienia straganu
     (zostaw N + pory roku), więc kolumna ma co najmniej 520 px — okno 1000 px ma wtedy jedną kolumnę */
  body.big #shopList { grid-template-columns: repeat(auto-fill, minmax(520px, 1fr)); }
  #shopList > :not(.row),
  #shopList > .row:has(> .stall-ed),
  #shopList > :not(.row) + .row:is(:last-child, :has(+ :not(.row))),
  #shopList > .row:first-child:is(:last-child, :has(+ :not(.row))) { grid-column: 1 / -1; } /* samotny wiersz (np. stan kociołka) też */
}

/* przyciski w oknach */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 28px;
  padding: 0 10px;
  border: 2px solid var(--leaf-lo);
  border-radius: 7px;
  /* jasny tylko brzeg u góry; w pasie tekstu zieleń na tyle ciemna, że biały ma ≥ 4.5:1 */
  background: linear-gradient(180deg, #7dbd4b, #3f7f22 30%, #3a761f 70%, #2f6519);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), inset 0 -2px 0 rgba(0, 0, 0, .16), 0 2px 0 var(--leaf-lo);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  text-shadow: 0 1px 0 rgba(20, 50, 10, .65);
  cursor: pointer;
  transition: translate .06s ease-out;
}

.btn:hover { background: linear-gradient(180deg, #8fce5c, #438525 30%, #3d7b21 70%, #326b1b); }
.btn:active { translate: 0 2px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 0 0 var(--leaf-lo); }

.btn.gold {
  border-color: var(--gold-lo);
  background: linear-gradient(180deg, #ffe89c, #f2c443 55%, #dca02a);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), inset 0 -2px 0 rgba(0, 0, 0, .12), 0 2px 0 var(--gold-lo);
  color: #3a2410;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .45);
}

.btn.gold:hover { background: linear-gradient(180deg, #fff0b8, #f7cf5a 55%, #e3ab36); }
.btn.gold:active { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 0 0 var(--gold-lo); }

/* za mało monet — wciąż klikalny (pokaże, ile brakuje) */
.btn.poor,
.btn.poor:hover {
  border-color: #7d6f55;
  background: linear-gradient(180deg, #e2d7bf, #c4b697);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 2px 0 #7d6f55;
  color: #574832;
  text-shadow: none;
}

.btn.poor img { opacity: .6; }

.btn:disabled,
.btn:disabled:hover {
  opacity: .5;
  filter: grayscale(1);
  translate: none;
  cursor: not-allowed;
}

.lockinfo {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px 2px 4px;
  border: 1px solid rgba(138, 79, 15, .35);
  border-radius: 12px;
  background: rgba(138, 79, 15, .1);
  color: #8a4f0f;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.lockinfo img { width: 16px; height: 16px; image-rendering: pixelated; }

.empty-note {
  margin: 4px 0;
  padding: 34px 18px;
  border: 2px dashed rgba(120, 80, 30, .3);
  border-radius: 10px;
  color: var(--ink-faint);
  font-style: italic;
  text-align: center;
}

.empty-note.small { padding: 12px 14px; font-size: 12px; }

/* stare zakładki (zostawione dla zgodności) */
.tabs { display: flex; gap: 4px; }

.tab {
  padding: 3px 9px;
  border: 2px solid var(--wood-dark);
  border-radius: 7px;
  background: linear-gradient(180deg, #5d3c1f, #452a12);
  color: #ecd9b0;
  font-size: 12px;
  cursor: pointer;
}

.tab.active { background: linear-gradient(180deg, #ffe28f, #e0a93a); color: #3a2410; }

/* =====================================================================
   Ekwipunek
   ===================================================================== */
.inv-body { gap: 7px; }

.inv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--slot));
  justify-content: center;
  gap: var(--slot-gap);
  width: 100%;
  max-width: calc(9 * var(--slot) + 8 * var(--slot-gap) + 14px);
  margin: 0 auto;
  padding: 5px;
  border: 2px solid var(--wood-dark);
  border-radius: 9px;
  background: var(--plank-dark);
  box-shadow: inset 0 1px 0 rgba(255, 236, 190, .2), 0 2px 0 rgba(43, 24, 11, .35);
  --focus: #fff;
}

.inv-info {
  display: flex;
  flex: none;
  align-items: flex-start;
  gap: 10px;
  /* stała wysokość na typowy opis (nazwa, opis, dodatki) — okno nie zmienia rozmiaru przy najeżdżaniu */
  min-height: calc(4 * 1.4em + 28px); /* 4 linie + padding/ramka + wyższa linia nazwy i odstęp dodatków */
  margin-top: 4px;
  padding: 9px 10px;
  border: 1px solid var(--parch-line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .75), 0 1px 0 rgba(120, 80, 30, .2);
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.4;
}

.inv-info canvas {
  flex: none;
  width: 32px;
  height: 32px;
  padding: 3px;
  box-sizing: content-box;
  border-radius: 7px;
  background: linear-gradient(180deg, #ecd6a6, #e0c48c);
  box-shadow: inset 0 0 0 1px rgba(120, 80, 30, .3);
  image-rendering: pixelated;
}

.inv-info b { color: var(--ink); font-size: 13.5px; }

.inv-info .kind {
  display: inline-block;
  margin-left: 6px;
  padding: 0 7px;
  border: 1px solid #9cc0d8;
  border-radius: 9px;
  background: #dcebf5;
  color: #1f4f70;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
  line-height: 16px;
  text-transform: uppercase;
  vertical-align: 1px;
}

.inv-info .extra { margin-top: 4px; color: #8a4f0f; font-weight: 600; }

/* „Do czego służy” — zastosowania przedmiotu (rdzeń i moduły: hook itemUses) */
.inv-info .uses { margin-top: 5px; padding-top: 4px; border-top: 1px dashed var(--parch-line); }
.inv-info .uses-h { display: block; color: var(--ink); font-weight: 700; font-size: 11.5px; }
.inv-info .use { line-height: 1.35; }
.inv-info .use.more { color: var(--ink-soft); font-style: italic; }
:is(.inv-info, .wuses, #wikiBody) .use-kind {
  display: inline-block;
  min-width: 58px;
  padding: 0 5px;
  border-radius: 7px;
  background: #e9dcc0;
  color: #5a3a14;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1px;
  line-height: 15px;
  text-align: center;
  text-transform: uppercase;
}
:is(.inv-info, #wikiBody) .use-kind.k-recipe { background: #f6dcc0; color: #7a3a10; }
:is(.inv-info, #wikiBody) .use-kind.k-gift { background: #f6d0dc; color: #7a1f3c; }
:is(.inv-info, #wikiBody) .use-kind.k-upgrade { background: #dfe4ec; color: #2f3f56; }
:is(.inv-info, #wikiBody) .use-kind.k-feed { background: #e4efc8; color: #3f5a14; }
:is(.inv-info, #wikiBody) .use-kind.k-plant { background: #d8efc8; color: #2f5a14; }
:is(.inv-info, #wikiBody) .use-kind:is(.k-build, .k-craft) { background: #ead6b8; color: #5a3410; }
:is(.inv-info, #wikiBody) .use-kind.k-bait { background: #d8e8f2; color: #1f4f70; }
:is(.inv-info, #wikiBody) .use-kind.k-decor { background: #efe0f4; color: #5a2a70; }
:is(.inv-info, #wikiBody) .use-kind.k-fuel { background: #f4dcb8; color: #7a4210; }
:is(.inv-info, #wikiBody) .use-kind.k-tool { background: #dde8e0; color: #2a4a34; }

/* Wiki: „Do czego służy” w kartach, łańcuchy i rozwijane grupy przedmiotów (kategoria „Jak to się łączy”) */
.wuses { margin-top: 6px; padding-top: 4px; border-top: 1px dashed var(--parch-line); font-size: 12px; }
.wuses ul { margin: 2px 0 0; padding-left: 0; list-style: none; }
.wuses li { margin: 2px 0; line-height: 1.35; }
.wuses li.more { color: var(--ink-faint); font-style: italic; }
.wchains { display: grid; gap: 6px; margin: 8px 0; }
.wchain { padding: 7px 10px; border: 1px solid var(--parch-line); border-radius: 9px; background: var(--card); }
.wsteps { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 4px; margin-top: 4px; font-size: 12px; }
.wstep { display: inline-flex; align-items: center; gap: 3px; padding: 1px 6px; border-radius: 8px; background: rgba(236, 214, 166, .55); }
.warrow { color: var(--ink-faint); font-weight: 700; }
.wheart { color: #d8325a; font-weight: 700; }
.wdet { margin: 6px 0; border: 1px solid var(--parch-line); border-radius: 9px; background: var(--card); }
.wdet > summary { padding: 6px 10px; cursor: pointer; color: var(--ink); font-weight: 700; }
.wdet > summary:focus-visible { outline: 2px solid #c9a467; outline-offset: -2px; }
.wdet[open] > summary { border-bottom: 1px dashed var(--parch-line); }
.wdet .wtable-wrap { margin: 0; }

/* plecak: --inv-cols = kolumny plecaka (ulepszenia w Warsztacie), --inv-per = slotów w rzędzie siatki (JS zawija
   w wąskim oknie, np. 12 → 6 + 6); okno ekwipunku rośnie wszerz razem z liczbą kolumn */
#invModal { --slot: 40px; --slot-gap: 3px; --icon: 32px; }
#invModal .sheet { max-width: max(520px, calc(var(--inv-cols, 9) * (var(--slot) + var(--slot-gap)) + 74px)); }
/* duży ekran — większe pola ekwipunku: --slot/--slot-gap/--icon ustawia game.js (invSlotSize: ile wejdzie bez
   przewijania), a #invModal.inv-xl (72 px, ikony 64 px — jak pasek pod planszą 2×) ma większe numery i liczniki */

#invPack {
  --per: var(--inv-per, var(--inv-cols, 9));
  grid-template-columns: repeat(var(--per), var(--slot));
  max-width: calc(var(--per) * var(--slot) + (var(--per) - 1) * var(--slot-gap) + 14px);
}

#invPack.sorted { animation: invSorted .32s ease-out; }

@keyframes invSorted {
  0%   { box-shadow: inset 0 1px 0 rgba(255, 236, 190, .2), 0 0 0 2px rgba(255, 226, 143, .9); }
  100% { box-shadow: inset 0 1px 0 rgba(255, 236, 190, .2), 0 2px 0 rgba(43, 24, 11, .35); }
}

/* przetasowanie po sortowaniu: zmienione sloty „wskakują” kolejno (opóźnienie --d z JS) */
.slot.shuffle canvas { animation: invShuffle .34s ease-out both; animation-delay: var(--d, 0ms); }

@keyframes invShuffle {
  0%   { transform: translateY(-5px) scale(.6) rotate(-8deg); opacity: 0; }
  60%  { transform: translateY(1px) scale(1.08) rotate(3deg); opacity: 1; }
  100% { transform: none; opacity: 1; }
}

/* sortowanie: „Sortuj wg: [rodzaj | nazwa | ilość] ☐ też pasek [Sortuj R]” */
.inv-sort {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 8px;
  margin: 0 2px;
  color: var(--ink-soft);
  font-size: 11.5px;
}

.inv-sort-lbl { color: #7a4718; font-weight: 800; letter-spacing: .3px; }

.inv-modes {
  display: inline-flex;
  border: 2px solid var(--wood-dark);
  border-radius: 8px;
  box-shadow: 0 2px 0 rgba(43, 24, 11, .35);
  overflow: hidden;
  --focus: #1f5fae;
}

.inv-mode {
  min-height: 24px;
  padding: 0 9px;
  border: 0;
  border-left: 1px solid rgba(43, 24, 11, .45);
  background: linear-gradient(180deg, #f8ecd0, #e6cd99);
  color: #5a3a1c;
  font: 700 11.5px/1 "Segoe UI", system-ui, sans-serif;
  cursor: pointer;
}

.inv-mode:first-child { border-left: 0; }
.inv-mode:hover { background: linear-gradient(180deg, #fff5dc, #efd9a8); }
.inv-mode[aria-pressed="true"] {
  background: linear-gradient(180deg, #ffe28f, #e0a93a);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), inset 0 -2px 0 rgba(140, 90, 20, .25);
  color: #3a2410;
}
.inv-mode:focus-visible { outline: 2px solid var(--focus); outline-offset: -3px; }

.inv-sort-hot { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.inv-sort-hot input { width: 14px; height: 14px; margin: 0; color-scheme: light; accent-color: #3f7f22; cursor: pointer; }

.inv-sort-btn { gap: 6px; margin-left: auto; min-height: 26px; }
.inv-sort-btn kbd { min-width: 16px; padding: 0 4px; font-size: 11px; line-height: 13px; text-shadow: none; }

/* Warsztat → Plecak: „27 → 30 miejsc” */
.pack-grow { color: #2f5f96; font-weight: 800; }
/* Targ: blok modułów na górze listy towarów (hook marketHead, np. stragan) */
.market-head { margin: 0 0 6px; }

.muted { color: var(--muted); }

/* =====================================================================
   Wiki
   ===================================================================== */
/* wąskie okno: kategorie w dwóch rzędach przewijanych w bok (artykuł ma prawie całą wysokość okna);
   szerokie (≥ 720 px) — menu z boku, niżej */
.wiki-nav {
  display: grid;
  flex: none;
  grid-auto-flow: column;
  grid-template-rows: repeat(2, auto);
  grid-auto-columns: max-content;
  gap: 4px;
  padding: 0 0 7px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: #4e2f16 transparent;
  --focus: var(--gold-hi);
}

.wchip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 25px;
  padding: 0 9px 0 3px;
  border: 2px solid var(--wood-dark);
  border-radius: 13px;
  background: linear-gradient(180deg, #5d3c1f, #452a12);
  box-shadow: inset 0 1px 0 rgba(255, 236, 190, .18);
  color: #ecd9b0;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.wchip img { width: 16px; height: 16px; image-rendering: pixelated; }
.wchip:hover { background: linear-gradient(180deg, #6e4826, #533316); color: #fff6dc; }

.wchip.active,
.wchip.active:hover {
  border-color: #5a3a10;
  background: linear-gradient(180deg, #ffe89c, #f2c443 60%, #dca02a);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55);
  color: #3a2410;
}

.wiki-body {
  display: block;
  padding: 12px 14px 20px;
  color: #4a3520;
  line-height: 1.55;
  user-select: text;
}

.wiki-body .wtitle {
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid rgba(122, 71, 24, .3);
  color: #5a3110;
  font-size: 19px;
  font-weight: 800;
  line-height: 1.2;
}

.wiki-body h3 {
  margin: 18px 0 6px;
  color: #7a3f12;
  font-size: 14px;
  font-weight: 800;
}

.wiki-body p { margin: 6px 0; color: #4a3520; }
.wiki-body ul, .wiki-body ol { margin: 6px 0; padding-left: 20px; color: #4a3520; }
.wiki-body li { margin: 3px 0; }
.wiki-body li::marker { color: #a8722f; font-weight: 700; }
.wiki-body b { color: #2a1a0b; }
.wiki-body small { font-size: 11px; } /* nie mniej niż 11 px (domyślne „smaller” w wąskiej tabeli dawało ~9 px) */
.wiki-body a { color: #1f5f8a; }

/* Odnośnik do innej kategorii Wiki (wLink w wiki.js) — przycisk wyglądający jak link */
.wlink {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: #1f5f8a;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: rgba(31, 95, 138, .4);
  text-underline-offset: 2px;
  cursor: pointer;
}
.wlink:hover { color: #0f4468; text-decoration-color: currentColor; }
.wlink:focus-visible { outline: 2px solid #3f8fd6; outline-offset: 1px; border-radius: 3px; }
.wsee { white-space: nowrap; }

.pix16, .pix24, .pix32, .coin { image-rendering: pixelated; vertical-align: middle; }
.pix16 { width: 16px; height: 16px; }
.pix24 { width: 24px; height: 24px; }
.pix32 { width: 32px; height: 32px; }
.coin { width: 12px; height: 12px; margin-left: 2px; }

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  border: 1px solid #8a6a40;
  border-bottom-width: 3px;
  border-radius: 5px;
  background: linear-gradient(180deg, #fffaf0, #efe2c4);
  color: #3a2614;
  font: 700 11px/17px "Segoe UI", system-ui, sans-serif;
  text-align: center;
  white-space: nowrap;
}

.wtable {
  width: 100%;
  margin: 8px 0;
  border: 1px solid var(--parch-line);
  border-radius: 8px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  background: rgba(255, 250, 235, .55);
  font-size: 12px;
}

.wtable th {
  padding: 6px 7px;
  border-bottom: 2px solid var(--parch-line);
  background: linear-gradient(180deg, #ecd6a6, #e2c68e);
  color: #5a3110;
  font-weight: 800;
  line-height: 1.25;
  text-align: left;
  vertical-align: bottom;
}

.wtable td {
  padding: 5px 7px;
  border-bottom: 1px solid rgba(201, 164, 103, .45);
  color: #4a3520;
  vertical-align: middle;
}

.wtable tr:last-child td { border-bottom: 0; }
.wtable tr:nth-child(even) td { background: rgba(236, 214, 166, .25); }
.wtable td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.wtable tr.gap td { border-top: 2px dashed rgba(122, 71, 24, .35); }

/* Pudełko tabeli (renderWiki): tabela szersza niż okno przewija się w bok sama, bez przesuwania tekstu wokół */
.wtable-wrap {
  max-width: 100%;
  margin: 8px 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: #c9a467 transparent;
}
.wtable-wrap > .wtable { margin: 0; }

/* tabela, która nie mieści się w artykule (wiki.js: wikiFitTables) — wiersze jako karty: pierwsza komórka to tytuł,
   pozostałe płyną obok siebie z nazwą kolumny („Lato: 14”) */
.wtable.wstack, .wtable.wstack tbody, .wtable.wstack tr { display: block; }
.wtable.wstack tr.whead { display: none; }
.wtable.wstack tr { padding: 5px 8px 6px; border-bottom: 1px solid rgba(201, 164, 103, .45); }
.wtable.wstack tr:last-child { border-bottom: 0; }
.wtable.wstack tr:nth-child(odd) { background: rgba(236, 214, 166, .25); }
.wtable.wstack tr.gap { border-top: 2px dashed rgba(122, 71, 24, .35); }
.wtable.wstack tr:nth-child(even) td { background: none; }
.wtable.wstack td {
  display: inline-block;
  max-width: 100%;
  padding: 1px 12px 1px 0;
  border: 0;
  background: none;
  vertical-align: top;
}
.wtable.wstack td.num { white-space: normal; }
.wtable.wstack td:first-child { display: block; padding: 0 0 2px; color: var(--ink); }
.wtable.wstack td[data-label]::before { content: attr(data-label) ': '; color: #7a4718; font-weight: 700; }
.wtable.wstack td:empty { display: none; }

.wcard {
  margin: 8px 0;
  padding: 9px 11px;
  border: 1px solid var(--parch-line);
  border-radius: 9px;
  background: var(--card);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .75), 0 1px 0 rgba(120, 80, 30, .2);
}

.wcard-head { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }

.wcard-head .tag {
  margin-left: auto;
  padding: 0 8px;
  border: 1px solid #9cc0d8;
  border-radius: 10px;
  background: #dcebf5;
  color: #1f4f70;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  white-space: nowrap;
}

.wcard p { margin: 6px 0 2px; }

.stats, .seasons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 12px;
}

.sz {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px 1px 4px;
  border: 1px solid rgba(201, 164, 103, .7);
  border-radius: 10px;
  background: rgba(236, 214, 166, .55);
}

.sz.base { padding-left: 8px; }
.seasons { gap: 4px 6px; }

.stages { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

.stages figure {
  margin: 0;
  padding: 4px 4px 2px;
  border-radius: 6px;
  background: rgba(236, 214, 166, .45);
  text-align: center;
}

.stages figcaption { color: var(--ink-faint); font-size: 11px; }
.tree { width: 32px; height: 48px; image-rendering: pixelated; }

.steps li { margin: 5px 0; }

.tip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0;
  padding: 8px 11px;
  border: 1px solid #9cc0d8;
  border-left-width: 4px;
  border-radius: 8px;
  background: #e3f0f8;
  color: #20425c;
}

.tip b { color: #12324a; }
.tip img { margin-top: 2px; }

.ideas { display: grid; gap: 6px; margin-top: 8px; }

.idea {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 2px 8px;
  padding: 8px 11px;
  border: 1px solid var(--parch-line);
  border-radius: 9px;
  background: var(--card);
}

.idea > span:not(.chip-soon) { grid-column: 2; color: var(--ink-soft); font-size: 12px; }
.idea > .ties { color: var(--ink-faint); font-size: 11px; font-style: italic; }

.chip-soon {
  grid-row: span 3;
  align-self: start;
  padding: 2px 8px;
  border-radius: 10px;
  background: #6d4f93;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
}

/* =====================================================================
   Dopasowanie do panelu
   @container play — lewa część sceny (plansza + 16 px): pasek i status;
   @container app — cały układ (plansza + kolumna miejsc): belka u góry;
   #app.big — plansza w skali 2× i większej (klasę ustawia fitBoard, który mierzy układ w obu wariantach)
   ===================================================================== */

/* plansza < 384 px — mniejsze sloty, 9 w rzędzie */
@container play (max-width: 399.98px) {
  .belt { --slot: 38px; --slot-gap: 2px; }
}

@container play (max-width: 373.98px) {
  .belt { --slot: 36px; --slot-gap: 2px; }
}

/* bardzo wąska plansza — pasek w dwóch rzędach (5 + 4) */
@container play (max-width: 355.98px) {
  .belt { --slot: 40px; --slot-gap: 3px; }
  .hotbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    max-width: calc(5 * var(--slot) + 4 * var(--slot-gap));
    margin: 0 auto;
  }
  #status { padding: 3px 8px; font-size: 12px; }
}

/* wąska plansza (telefon) — status na trzy linie: długie opisy (kurnik, chata pracowników) mieszczą się z podpowiedzią */
@container play (max-width: 439.98px) {
  #status { height: 56px; -webkit-line-clamp: 3; }
}

@container app (max-width: 373.98px) {
  .brand-mark { display: none; }
}

@container app (max-width: 355.98px) {
  h1 { font-size: 16px; }
  .coins { padding-right: 9px; }
  .level { padding: 0 8px 0 6px; }
}

/* plansza 2× (i większa) — większe sloty, napisy i szyldy */
#app.big .belt { --slot: 72px; --slot-gap: 6px; --icon: 64px; padding: 8px 8px 7px; }
#app.big .slot, #invModal.inv-xl .slot { border-width: 3px; border-radius: 9px; }
#app.big .slot .num, #invModal.inv-xl .slot .num { top: 3px; left: 6px; font-size: 13px; }
#app.big .slot .count, #invModal.inv-xl .slot .count { right: 5px; bottom: 2px; font-size: 16px; }
#app.big .slot:has(.dura) .count, #invModal.inv-xl .slot:has(.dura) .count { bottom: 11px; }
#app.big .slot .lock, #invModal.inv-xl .slot .lock { width: 32px; height: 32px; right: 3px; top: 3px; }
#app.big .slot.broken::after, #invModal.inv-xl .slot.broken::after { font-size: 40px; }
#app.big .dura, #invModal.inv-xl .slot .dura { left: 9px; right: 9px; bottom: 6px; height: 6px; }
#app.big .hand { margin-top: 7px; font-size: 14px; }
#app.big h1 { font-size: 22px; }
#app.big .brand-mark { transform: scale(1.15); }
#app.big .coins, #app.big .level { height: 30px; border-radius: 15px; }
#app.big .coins b, #app.big .level b { font-size: 16px; }
#app.big .coins img { width: 20px; height: 20px; }
#app.big .xp-bar { height: 18px; border-radius: 9px; }
#app.big #xpText { font-size: 11.5px; }
#app.big .sky { font-size: 13px; }
#app.big #status { height: 44px; padding: 4px 16px; line-height: 17px; font-size: 13.5px; border-radius: 14px; }
#app.big .stage { gap: 14px; }
#app.big .side { gap: 16px; }
#app.big .places { gap: 12px; }
#app.big .place-btn { gap: 10px; height: 64px; padding: 13px 12px 0 9px; font-size: 15px; }
#app.big .place-btn::before { height: 11px; }
#app.big .place-btn img { width: 32px; height: 32px; }
#app.big .place-btn .key { min-width: 17px; height: 17px; font-size: 11px; line-height: 17px; }
#app.big .side-tools { gap: 8px; }
#app.big .small-btn { height: 40px; font-size: 13.5px; }
#app.big .side-tools .small-btn { padding: 0 10px 0 9px; gap: 8px; }
#app.big .tool-ico, #app.big .tool-ico img { width: 32px; height: 32px; }
#app.big.compact .place-btn { gap: 4px; padding: 13px 5px 0; }
#app.big.compact .side-tools .small-btn { padding: 0 4px; gap: 4px; }
#app.big.compact .reset { height: 42px; font-size: 11.5px; line-height: 13px; }
#app.big #status { margin: 9px 0 6px; }

/* okna przy planszy 2× (body.big — klasę ustawia fitBoard razem z #app.big): większe napisy, przyciski i pola
   ekwipunku, żeby okno nie wyglądało jak znaczek obok dużej planszy (ikony 32 px zostają ostre) */
body.big .sheet-head { min-height: 52px; }
body.big .sheet-head h2 { font-size: 20px; }
body.big .sheet-head .sub { font-size: 13.5px; }
body.big :is(.close, .sheet-full) { width: 34px; height: 34px; }
body.big .sheet-body { gap: 8px; }
body.big .row { gap: 5px 11px; padding: 8px 10px 8px 8px; }
body.big .row .name { font-size: 15px; }
body.big .row .meta { font-size: 13px; }
body.big .row .own { font-size: 12px; line-height: 18px; }
body.big .btn { min-height: 32px; padding: 0 12px; font-size: 13.5px; }
body.big .sec, body.big .inv-label { font-size: 12.5px; }
body.big .sheet-foot { font-size: 13.5px; }
body.big .sheet-foot b { font-size: 15px; }
body.big .sheet-msg { font-size: 14px; }
body.big .lockinfo { font-size: 13px; }
body.big .empty-note { font-size: 14px; }
body.big .inv-sort { font-size: 13px; }
body.big .inv-mode { min-height: 28px; font-size: 13px; }
body.big .inv-info { font-size: 13.5px; }
body.big .inv-info b { font-size: 15px; }
body.big .wchip { height: 30px; font-size: 13px; }
body.big .sheet.wiki { grid-template-columns: 250px minmax(0, 1fr); }
body.big .wiki-body { font-size: 15px; }
body.big .wiki-body .wtitle { font-size: 23px; }
body.big .wiki-body h3 { font-size: 16.5px; }
body.big .wtable { font-size: 13.5px; }
body.big .wsteps, body.big .wuses, body.big :is(.stats, .seasons) { font-size: 13.5px; }

/* okna: sloty ekwipunku dopasowane do szerokości okna */
@container sheet (max-width: 417.98px) {
  .inv-grid { --slot: 38px; --slot-gap: 2px; }
}

@container sheet (max-width: 391.98px) {
  .inv-grid { --slot: 36px; --slot-gap: 2px; }
}

@container sheet (max-width: 373.98px) {
  .inv-grid { padding: 3px; }
}

/* wąskie okno (9 slotów się nie mieści) — pasek jak główny: 5 + 4, plecak po 7 w rzędzie */
@container sheet (max-width: 369.98px) {
  #invHot {
    display: flex;
    flex-wrap: wrap;
    max-width: calc(5 * var(--slot) + 4 * var(--slot-gap) + 10px);
  }

  /* plecak zawija się sam (JS: --inv-per — np. 27 miejsc po 7, 12 kolumn po 6) */
  .inv-info { min-height: calc(6 * 1.4em + 28px); }
  .inv-sort-btn { margin-left: 0; }
}

/* bardzo wąskie okno — opis przedmiotu ma więcej linii, więc rezerwujemy na niego więcej miejsca */
@container sheet (max-width: 291.98px) {
  .inv-info { min-height: calc(7 * 1.4em + 28px); }
}

/* średnie okno — dwa przyciski jeden pod drugim, żeby opis miał miejsce; nagłówek okna w dwóch rzędach:
   tytuł z przyciskami, pod nimi podpowiedź na całą szerokość (do 3 linii) */
@container sheet (max-width: 459.98px) {
  .row .acts { flex-direction: column; flex-wrap: nowrap; align-items: stretch; }
  .row .acts .btn { min-height: 26px; }
  .sheet-head { flex-wrap: wrap; row-gap: 3px; }
  .sheet-head h2 { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .sheet-head .sub { order: 3; flex: 1 1 100%; -webkit-line-clamp: 3; }
}

/* wąskie okno — przyciski pod opisem (także sam przycisk podany jako „acts”, np. „Odbierz”, „Kup 90”,
   „← Mieszkańcy”: nigdy w kolumnie ikony), ciaśniejsze tabele i menu wiki */
@container sheet (max-width: 363.98px) {
  .wiki-body { padding: 10px 8px 18px; }
  .wtable { font-size: 11px; }
  .wtable th, .wtable td { padding: 4px 3px; }
  .wtable th:first-child, .wtable td:first-child { padding-left: 5px; }
  .wiki-nav { gap: 3px; }
  .wchip { height: 24px; padding: 0 7px 0 2px; font-size: 11px; }
  .row { grid-template-columns: 36px minmax(0, 1fr); }
  .row > :is(.acts, .lockinfo, .btn) { grid-column: 2; justify-self: start; }
  .row .acts { flex-direction: row; flex-wrap: wrap; justify-content: flex-start; }
}

@media (max-width: 360px) {
  .modal,
  .modal.full,
  #shopModal.full,
  #invModal.full { padding: 4px; } /* pełny ekran nie może być węższy od zwykłego okna */
}

/* szeroki panel — wiki z menu z boku */
@media (min-width: 720px) {
  .sheet.wiki {
    display: grid;
    grid-template-columns: 210px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    max-width: var(--wiki-w);
  }

  .sheet.wiki .sheet-head { grid-column: 1 / -1; }

  .sheet.wiki .wiki-nav {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    max-height: none;
    padding: 0 6px 0 0;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .sheet.wiki .wchip { flex: none; justify-content: flex-start; border-radius: 8px; }
  .sheet.wiki .wiki-body { padding: 14px 18px 22px; }
}

/* =====================================================================
   0.8: minimapa, przyciski miejsc w kolumnie narzędzi (nav: 'tools'), ukrywane przyciski (visible()),
   ciaśniejsza kolumna (#app.tight — gdy przyciski modułów nie mieszczą się bez przewijania)
   ===================================================================== */
.place-btn[hidden],
.side-tools .small-btn[hidden],
.minimap-box[hidden],
#minimap[hidden] { display: none; }

.minimap-box {
  display: flex;
  flex: none;
  justify-content: center;
}

#minimap {
  display: block;
  flex: none;
  box-sizing: content-box;
  border: 2px solid var(--wood-dark);
  border-radius: 4px;
  background: var(--water);
  box-shadow: 0 0 0 1px rgba(255, 236, 190, .18), 0 3px 0 var(--wood-dark), 0 5px 10px rgba(0, 0, 0, .35);
  image-rendering: pixelated;
  cursor: pointer;
  touch-action: none;
}

/* nakładka w prawym górnym rogu planszy (gdy minimapa nie mieści się w kolumnie) */
#minimap.overlay {
  position: absolute;
  z-index: 3;
  top: 5px;
  right: 5px;
  opacity: .94;
  box-shadow: 0 0 0 1px rgba(255, 236, 190, .25), 0 3px 8px rgba(0, 0, 0, .5);
}

#minimap.overlay:hover { opacity: 1; }
/* edycja pól pracowników: pasek narzędzi leży u góry planszy — nakładka minimapy schodzi wtedy do prawego dolnego rogu */
.board-frame:has(> .wk-editbar) #minimap.overlay { top: auto; bottom: 5px; }
.minimap-box.pulse #minimap { animation: mm-pulse .9s ease-out; }

@keyframes mm-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(255, 236, 190, .18), 0 3px 0 var(--wood-dark), 0 0 0 0 rgba(255, 214, 90, 0); }
  30%      { box-shadow: 0 0 0 1px rgba(255, 236, 190, .18), 0 3px 0 var(--wood-dark), 0 0 0 7px rgba(255, 214, 90, .6); }
}

/* przyciski miejsc z modułów pod Ekwipunkiem i Wiki — licznik W przycisku, na miejscu klawisza (klawisz jest też
   w podpowiedzi): mały przycisk nie ma daszka, więc licznik w rogu zasłaniałby sąsiedni przycisk albo klawisz */
.tool-btn { position: relative; }
.tool-btn .badge { position: static; flex: none; min-width: 19px; height: 18px; line-height: 14px; }
.tool-btn:has(> .badge:not([hidden])) > .key { display: none; }
#app.compact .tool-btn .badge { min-width: 17px; height: 17px; line-height: 13px; }
#mapBtn.on { color: #fff6dc; background: linear-gradient(180deg, #7a5230, #5d3c1f); box-shadow: inset 0 0 0 1px rgba(255, 228, 143, .55), 0 2px 0 var(--wood-dark); }

/* ciaśniejsza kolumna (fitSide dodaje #app.tight, gdy wszystkie przyciski nie mieszczą się bez przewijania strony) */
#app.tight .side { gap: 6px; }
#app.tight .places { gap: 4px; }
#app.tight .place-btn,
#app.tight.compact .place-btn { height: 36px; padding-top: 8px; }
#app.tight .place-btn::before { height: 6px; }
#app.tight .place-btn img { padding: 2px; }
#app.tight .side-tools { gap: 3px; }
#app.tight .small-btn { height: 26px; }
#app.big.tight .small-btn { height: 34px; } /* plansza 2× w niższym oknie: ikony 32 px nie nachodzą na sąsiednie przyciski */
#app.tight.compact .reset { height: 28px; }
/* ciasno: licznik niższy i wyżej na daszku (odstęp między szyldami ma tylko 4 px) */
#app.tight .place-btn .badge { top: -5px; min-width: 15px; height: 15px; padding: 0 3px; line-height: 11px; }

/* mniej ruchu, jeśli system tak prosi */
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
