:root {
  --paper: #fbf7ea;
  --forest: #cfe8bd;
  --forest-dark: #a9d690;
  --meadow: #f7e08f;
  --water: #a6d8f2;
  --water-edge: #3b8fc4;
  --contour: #b06a2b;
  --course: #c2187a;
  --course-dark: #8e0f58;
  --ink: #23262b;
  --muted: #5d6470;
  --card: #ffffff;
  --line: #e4dccb;
  --good: #2f9e44;
  --good-bg: #e6f6e9;
  --bad: #d9480f;
  --bad-bg: #fff0e6;
  --grass: #6dbb3c;
  --grass-dark: #4a8a25;
  --radius: 14px;
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  background-image: radial-gradient(#e9e1cc 1px, transparent 1px);
  background-size: 22px 22px;
  min-height: 100vh;
}
h1, h2, .brand span, .season-title, .map-title { font-family: 'Baloo 2', 'Nunito', sans-serif; }
button { font: inherit; color: inherit; }

/* --- Pasek górny --- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--course); color: #fff;
  box-shadow: 0 3px 0 var(--course-dark);
}
.brand { display: flex; align-items: center; gap: 8px; background: none; border: 0; color: #fff; cursor: pointer; padding: 0; }
.brand svg { width: 32px; height: 32px; }
.brand span { font-size: 1.6rem; font-weight: 800; letter-spacing: .5px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.star-count { font-weight: 800; font-size: 1.1rem; color: #ffe066; margin-right: 4px; }
.icon-btn {
  background: rgba(255,255,255,.16); border: 2px solid rgba(255,255,255,.35); color: #fff;
  border-radius: 10px; padding: 6px 10px; cursor: pointer; font-weight: 700;
}
.icon-btn:hover { background: rgba(255,255,255,.28); }

main { max-width: 980px; margin: 0 auto; padding: 18px 16px 60px; }

/* --- Przyciski (blokowe, trochę jak w Minecrafcie) --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 3px solid var(--ink); background: var(--card); border-radius: 10px;
  padding: 10px 18px; font-weight: 800; font-size: 1.05rem; cursor: pointer;
  box-shadow: 0 4px 0 var(--ink); transition: transform .05s, box-shadow .05s;
  min-height: 48px; text-align: center;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--grass); color: #fff; border-color: var(--grass-dark); box-shadow: 0 4px 0 var(--grass-dark); }
.btn-primary:active:not(:disabled) { box-shadow: 0 1px 0 var(--grass-dark); }
.btn-ghost { background: transparent; border: 2px solid var(--line); box-shadow: none; min-height: 40px; padding: 6px 12px; font-size: .95rem; }
.btn-big { font-size: 1.3rem; padding: 14px 28px; }

.row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.center { text-align: center; justify-content: center; }
.lead { font-size: 1.15rem; }
.hint { color: var(--muted); font-size: .95rem; }

/* --- Strona główna --- */
.hero { text-align: center; padding: 24px 8px 8px; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); margin: 0 0 6px; color: var(--course-dark); }
.section-title { margin: 28px 0 10px; }
.season-list { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.season-card {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left;
  background: var(--card); border: 3px solid var(--ink); border-radius: var(--radius);
  padding: 16px; cursor: pointer; box-shadow: 0 5px 0 var(--ink);
}
.season-card .btn { margin-top: 8px; }
.season-subject { font-size: .85rem; font-weight: 800; color: var(--course); text-transform: uppercase; letter-spacing: .6px; }
.season-title { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.season-progress { color: var(--muted); }

/* --- Mapa --- */
.map-head, .play-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.map-title { margin: 0; font-size: clamp(1.4rem, 4vw, 2rem); line-height: 1.1; }
.map-wrap { background: var(--card); border: 3px solid var(--ink); border-radius: var(--radius); overflow: hidden; box-shadow: 0 5px 0 var(--ink); }
.map { display: block; width: 100%; height: auto; }
.course line { stroke: var(--course); stroke-width: 5; opacity: .85; }
.start { fill: none; stroke: var(--course); stroke-width: 6; }
.cp-label { fill: var(--course); font: 800 22px 'Nunito', sans-serif; }
.cp .ring { fill: rgba(251,247,234,.85); stroke: var(--course); stroke-width: 6; }
.cp .hit { fill: transparent; }
.cp-num { fill: var(--course); font: 800 30px 'Baloo 2', sans-serif; }
.cp-emoji { font-size: 32px; }
.cp.open { cursor: pointer; }
.cp.open:hover .ring, .cp.open:focus .ring { stroke-width: 9; }
.cp:focus { outline: none; }
.cp.locked { opacity: .45; }
.cp.done .ring { fill: #fff; }
.cp.next .ring { animation: pulse 1.3s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { 50% { transform: scale(1.15); stroke-width: 9; } }

.cp-list { display: grid; gap: 10px; margin-top: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.cp-card {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 10px;
  background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px;
  cursor: pointer; text-align: left;
}
.cp-card:hover:not(:disabled) { border-color: var(--course); }
.cp-card.locked { opacity: .55; cursor: default; }
.cp-badge {
  width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--course); color: var(--course);
  display: grid; place-items: center; font-weight: 800;
}
.cp-badge.final { outline: 3px solid var(--course); outline-offset: 2px; }
.cp-title { font-weight: 800; }
.cp-stars { color: #e8a400; font-weight: 800; white-space: nowrap; }
.cp-animal { font-size: 1.5rem; }

/* --- Ściągawka --- */
.rule-card {
  background: #fffbe6; border: 3px dashed var(--contour); border-radius: var(--radius);
  padding: 14px 20px; max-width: 760px; margin: 12px auto;
}
.rule-card h2 { margin: 4px 0 8px; color: var(--contour); }
.rule-card li { margin: 8px 0; font-size: 1.08rem; line-height: 1.45; }

/* --- Zadania --- */
.play-head { justify-content: space-between; }
.play-title { font-weight: 800; font-size: 1.15rem; }
.counter { color: var(--muted); font-weight: 700; }
.bar { height: 14px; background: #ece4cf; border-radius: 99px; overflow: hidden; border: 2px solid var(--ink); }
.bar-fill { height: 100%; width: 0; background: var(--grass); transition: width .4s; }
.task-box {
  margin-top: 16px; background: var(--card); border: 3px solid var(--ink); border-radius: var(--radius);
  padding: 20px; box-shadow: 0 5px 0 var(--ink); min-height: 300px;
}
.q { font-size: clamp(1.25rem, 3.4vw, 1.6rem); margin: 4px 0 14px; line-height: 1.25; }
.context { background: #f3efe2; border-left: 5px solid var(--contour); padding: 10px 14px; border-radius: 6px; font-size: 1.1rem; font-style: italic; }
.retry-tag { display: inline-block; background: #fff3bf; border: 2px solid #f0c419; border-radius: 99px; padding: 2px 12px; font-weight: 800; margin-bottom: 8px; }
.answers { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.answers.letters { grid-template-columns: repeat(2, minmax(100px, 160px)); justify-content: center; }
.answer { font-size: 1.15rem; padding: 14px; }
.letter { font-size: 2.2rem; font-family: 'Baloo 2', sans-serif; min-height: 80px; }
.answer.right, .slot.right { background: var(--good-bg); border-color: var(--good); box-shadow: 0 4px 0 var(--good); color: #1d6b2c; }
.answer.wrong, .slot.wrong { background: var(--bad-bg); border-color: var(--bad); box-shadow: 0 4px 0 var(--bad); color: #a33a0c; }
.answer:disabled { opacity: 1; }
.answers .answer:disabled:not(.right):not(.wrong) { opacity: .5; }
.big-word { font-family: 'Baloo 2', sans-serif; font-size: clamp(2.6rem, 9vw, 4rem); font-weight: 800; text-align: center; letter-spacing: 1px; margin: 4px 0 18px; }
.hole { display: inline-block; min-width: .75em; line-height: 1; border-bottom: 5px solid var(--course); color: var(--course); }
.hole.right { color: var(--good); border-color: var(--good); }
.hole.wrong { color: var(--bad); border-color: var(--bad); }
.reasons { margin-top: 6px; }
.reasons .answer { font-size: 1rem; text-align: left; justify-content: flex-start; }

.slots { list-style: none; counter-reset: s; padding: 0; margin: 0 0 14px; display: grid; gap: 8px; }
.slot {
  counter-increment: s; display: flex; align-items: center; gap: 10px; min-height: 48px;
  border: 3px solid var(--ink); border-radius: 10px; padding: 8px 12px; font-weight: 800; font-size: 1.1rem; cursor: pointer; background: #fff;
}
.slot::before { content: counter(s) "."; color: var(--course); width: 1.6em; }
.slot.empty { border-style: dashed; border-color: var(--line); color: var(--muted); cursor: default; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 3px solid var(--water-edge); background: #eaf6fd; border-radius: 99px; padding: 10px 16px;
  font-weight: 800; font-size: 1.05rem; cursor: pointer; box-shadow: 0 3px 0 var(--water-edge);
}
.chip:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--water-edge); }

.built { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin: 6px 0 16px; }
.cell {
  width: 52px; height: 60px; display: grid; place-items: center; border: 3px solid var(--ink); border-radius: 8px;
  font: 800 2rem 'Baloo 2', sans-serif; background: #fff;
}
.cell.empty { border-style: dashed; border-color: var(--line); }
.built.right .cell { background: var(--good-bg); border-color: var(--good); }
.built.wrong .cell { background: var(--bad-bg); border-color: var(--bad); }
.tiles { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.tile {
  width: 56px; height: 56px; border: 3px solid #7a4a1d; border-radius: 6px; cursor: pointer;
  background: #c98d4e; color: #fff; font: 800 1.8rem 'Baloo 2', sans-serif;
  box-shadow: inset 0 -5px 0 rgba(0,0,0,.2), 0 3px 0 #7a4a1d; text-shadow: 0 2px 0 rgba(0,0,0,.25);
}
.tile:disabled { opacity: .25; }
.tool { min-height: 44px; }

.feedback { margin-top: 18px; border-radius: 12px; padding: 14px 16px; border: 3px solid; display: grid; gap: 8px; animation: pop .25s ease-out; }
.feedback.ok { background: var(--good-bg); border-color: var(--good); }
.feedback.bad { background: var(--bad-bg); border-color: var(--bad); }
.fb-head { font-weight: 800; font-size: 1.3rem; }
.feedback.ok .fb-head { color: #1d6b2c; }
.feedback.bad .fb-head { color: #a33a0c; }
.fb-explain { font-size: 1.1rem; line-height: 1.45; }
.feedback .btn { justify-self: end; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }

/* --- Okno ściągawki --- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal[hidden] { display: none; }
.modal-inner { background: var(--paper); border-radius: var(--radius); padding: 12px; max-width: 800px; max-height: 90vh; overflow: auto; text-align: center; }

/* --- Wynik i azyl --- */
.result { text-align: center; padding: 20px 0; }
.result h1 { margin: 0; color: var(--course-dark); }
.burst { font-size: 4rem; animation: pop .5s ease-out; }
.big-stars { font-size: 3.4rem; color: #f2b100; letter-spacing: 6px; text-shadow: 0 3px 0 #b07f00; }
.new-animal {
  display: inline-flex; align-items: center; gap: 16px; background: #fff; border: 3px solid var(--grass-dark);
  border-radius: var(--radius); padding: 12px 20px; margin: 10px 0; text-align: left; animation: pop .6s ease-out;
}
.animal-emoji { font-size: 3.4rem; line-height: 1; }
.azyl { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-top: 14px; }
.pen {
  background: linear-gradient(#bfe3a6 0 70%, #8cc46a 70%); border: 4px solid #7a4a1d; border-radius: 10px;
  padding: 16px 10px; text-align: center; box-shadow: 0 4px 0 #7a4a1d;
}
.pen.empty { background: #e9e4d5; border-color: #b9ae94; box-shadow: 0 4px 0 #b9ae94; }
.pen-name { font-weight: 800; margin-top: 6px; }
.pen-src { font-size: .85rem; color: var(--muted); }
.error { background: var(--bad-bg); border: 3px solid var(--bad); padding: 16px; border-radius: 12px; }

@media (max-width: 560px) {
  .hide-sm { display: none; }
  .brand span { font-size: 1.3rem; }
  .task-box { padding: 14px; }
  .cell { width: 40px; height: 50px; font-size: 1.6rem; }
  .tile { width: 48px; height: 48px; }
  .answers { grid-template-columns: 1fr; }
  .answers.letters { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
