:root {
  --red: #b3121b;
  --red-dark: #7d0b12;
  --yellow: #ffcc00;
  --ink: #1b1b1f;
  --paper: #fff8ee;
  --muted: #5d5d66;
  --stage-bg: #15161a;
  --radius: 18px;
  --touch: 56px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- górny pasek ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--red);
  color: #fff;
}
.brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; flex-wrap: wrap; }
.brand-num {
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: .02em;
  background: #fff;
  color: var(--red);
  padding: 2px 10px;
  border-radius: 10px;
}
.brand-name { font-weight: 600; font-size: 1.05rem; opacity: .95; }

/* ---------- przyciski ---------- */
.btn {
  min-height: var(--touch);
  padding: 0 22px;
  border-radius: 999px;
  border: 0;
  font: inherit;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  touch-action: manipulation;
  transition: transform .12s ease, background .2s ease, box-shadow .2s ease;
}
.btn:active { transform: scale(.96); }
.btn:focus-visible { outline: 4px solid var(--yellow); outline-offset: 2px; }
.btn-primary { background: var(--yellow); color: var(--ink); box-shadow: 0 4px 0 #b58f00; }
.btn-primary:hover { background: #ffd83d; }
.btn-red { background: var(--red); color: #fff; box-shadow: 0 4px 0 var(--red-dark); }
.btn-light { background: #fff; color: var(--ink); box-shadow: 0 3px 0 #d6cfc3; }
.btn-ghost { background: rgba(255,255,255,.15); color: #fff; min-height: 48px; white-space: nowrap; }
.btn-ghost:hover { background: rgba(255,255,255,.25); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-round { width: var(--touch); padding: 0; font-size: 1.6rem; }

/* ---------- scena ze zdjęciem ---------- */
.app { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.stage-wrap {
  position: relative;
  flex: 1;
  min-height: 52vh;
  background: var(--stage-bg);
  overflow: hidden;
}
.stage { position: absolute; inset: 0; touch-action: pan-y; }
.layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity .6s ease;
}
.layer.is-visible { opacity: 1; }
.layer svg { position: relative; width: 100%; height: 100%; display: block; user-select: none; -webkit-user-select: none; }
.layer .bg {
  position: absolute;
  inset: -40px;
  width: calc(100% + 80px);
  height: calc(100% + 80px);
  object-fit: cover;
  filter: blur(22px) brightness(.45) saturate(1.2);
  pointer-events: none;
}

.open-fade { transition: opacity .8s ease; }

.rail-shadow { stroke: rgba(0,0,0,.55); stroke-linecap: round; }
.rail { stroke: #d9dde3; stroke-linecap: round; }

/* skrytki na widoku szczegółowym */
.compartment { cursor: pointer; }
.compartment .c-area {
  fill: rgba(255, 204, 0, .06);
  stroke: var(--yellow);
  stroke-dasharray: 14 10;
  animation: dash 1.6s linear infinite;
}
.compartment:hover .c-area, .compartment:focus-visible .c-area { fill: rgba(255,204,0,.2); }
.compartment:focus { outline: none; }
.c-badge-bg { fill: var(--yellow); stroke: var(--ink); }
.c-badge-txt { fill: var(--ink); font-weight: 800; font-family: var(--font); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
@keyframes dash { to { stroke-dashoffset: -48; } }

.zoomed .compartment { pointer-events: none; }
.zoomed .compartment .c-area { stroke-opacity: .0; fill: transparent; }
.zoomed .c-badge { display: none; }

/* sprzęt */
.item { cursor: pointer; }
.item:focus { outline: none; }
.item .i-area { fill: rgba(255,255,255,0); stroke: rgba(255,255,255,0); transition: fill .2s, stroke .2s; }
/* pole z kilku kształtów: wypełnienie bez obrysu, obrys bez wypełnienia (tylko dookoła) */
.u-fill { stroke: none !important; }
.u-line { fill: none !important; pointer-events: none; }
.item:hover .i-area, .item:focus-visible .i-area, .item.is-active .i-area { fill: rgba(255,204,0,.25); stroke: var(--yellow); }
.i-marker { pointer-events: none; }
.i-dot { fill: var(--yellow); stroke: var(--ink); }
.item.unknown .i-dot { fill: #e6e6ea; }
.i-pulse { fill: none; stroke: var(--yellow); opacity: .8; animation: pulse 1.8s ease-out infinite; transform-box: fill-box; transform-origin: center; }
.item.unknown .i-pulse { stroke: #e6e6ea; }
.i-txt { fill: var(--ink); font-weight: 900; font-family: var(--font); text-anchor: middle; dominant-baseline: central; }
@keyframes pulse { 0% { transform: scale(1); opacity: .85; } 100% { transform: scale(2.1); opacity: 0; } }
.hide-items .item { display: none; }

/* podpowiedź i przyciski na scenie */
.stage-hint {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  background: rgba(0,0,0,.7);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 1.05rem;
  font-weight: 600;
  max-width: calc(100% - 24px);
  text-align: center;
  pointer-events: none;
}
.stage-actions {
  position: absolute;
  left: 0; right: 0; bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 0 12px;
  pointer-events: none;
}
.stage-actions .btn { pointer-events: auto; box-shadow: 0 4px 14px rgba(0,0,0,.45); }
.stage-actions .btn.pop { animation: pop .35s ease both; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- dolny pasek ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 12px;
  background: #fff;
  border-top: 4px solid var(--yellow);
}
.angles { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.angle-btn {
  min-height: var(--touch);
  min-width: 96px;
  padding: 6px 12px;
  border: 3px solid #e4dccf;
  background: #fff;
  border-radius: 14px;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  touch-action: manipulation;
}
.angle-btn img { width: 84px; height: 54px; object-fit: cover; border-radius: 8px; display: block; }
.angle-btn[aria-pressed="true"] { border-color: var(--red); background: #ffefe9; }
.angle-btn:focus-visible { outline: 4px solid var(--yellow); outline-offset: 2px; }
.toolbar-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
.view-title { font-weight: 800; font-size: 1.25rem; margin: 0 6px; }

/* ---------- karta (bottom sheet) ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; }
.sheet {
  position: fixed;
  z-index: 21;
  left: 0; right: 0; bottom: 0;
  max-height: 78dvh;
  overflow: auto;
  background: #fff;
  border-radius: 24px 24px 0 0;
  padding: 22px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0,0,0,.3);
  animation: sheet-in .28s ease both;
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 900px) {
  .sheet {
    left: auto; right: 24px; bottom: 24px; top: auto;
    width: 420px;
    border-radius: 24px;
    max-height: calc(100dvh - 120px);
  }
}
.sheet-close {
  position: absolute; top: 10px; right: 10px;
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 0;
  background: #f1ede6;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}
.sheet-close:focus-visible { outline: 4px solid var(--yellow); }
.sheet h2 { margin: 4px 56px 8px 0; font-size: 1.7rem; line-height: 1.15; }
.sheet p { font-size: 1.15rem; line-height: 1.5; margin: 10px 0; }
.sheet .where { color: var(--muted); font-size: 1rem; margin-top: 0; }
.badge {
  display: inline-block;
  font-size: .85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fff1c2;
  color: #6b5000;
  border: 2px dashed #d9a900;
}
.fact {
  background: #fff6d6;
  border-left: 6px solid var(--yellow);
  border-radius: 12px;
  padding: 12px 14px;
}
.fact strong { display: block; margin-bottom: 4px; }
.unknown-box { background: #f1f1f4; border-left-color: #9a9aa5; }
.sheet ul { padding-left: 1.2em; font-size: 1.1rem; line-height: 1.5; }

.footer {
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  font-size: .85rem;
  color: var(--muted);
  text-align: center;
  background: var(--paper);
}

/* ---------- quiz ---------- */
.topnav { display: flex; gap: 8px; }
.btn-quiz { background: var(--yellow); color: var(--ink); }
.btn-quiz:hover { background: #ffd83d; }

.quiz-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(10, 10, 14, .55);
  z-index: 5;
  overflow: auto;
}
.quiz-panel {
  background: #fff;
  border-radius: 24px;
  padding: 20px;
  width: min(560px, 100%);
  max-height: 100%;
  overflow: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
  animation: pop .3s ease both;
}
.quiz-panel h2 { margin: 0 0 4px; font-size: 1.8rem; text-align: center; }
.q-sub { text-align: center; color: var(--muted); margin: 4px 0 12px; font-size: 1.05rem; }
.q-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.q-modes { grid-template-columns: repeat(2, 1fr); }
.q-choice {
  min-height: var(--touch);
  border: 3px solid #e4dccf;
  background: #fff;
  border-radius: 16px;
  padding: 10px 8px;
  font: inherit;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-align: center;
  touch-action: manipulation;
}
.q-choice b { font-size: 1.15rem; }
.q-choice span { font-size: .88rem; color: var(--muted); }
.q-choice em { font-style: normal; font-size: .85rem; font-weight: 700; color: var(--red); }
.q-choice[aria-checked="true"] { border-color: var(--red); background: #ffefe9; }
.q-choice:focus-visible { outline: 4px solid var(--yellow); outline-offset: 2px; }
.q-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.q-big { font-size: 4rem; font-weight: 900; text-align: center; margin: 4px 0 0; color: var(--red); line-height: 1; }
.q-stars { text-align: center; font-size: 2rem; margin: 4px 0; }

.quiz-q {
  position: absolute; left: 50%; top: 12px;
  transform: translateX(-50%);
  z-index: 4;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 800;
  font-size: 1.4rem;
  padding: 10px 22px;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
  text-align: center;
  max-width: calc(100% - 24px);
}
.quiz-q.ok { background: #2fbf5b; color: #fff; }
.quiz-q.bad { background: #fff; color: var(--red); }

.quiz-svg { cursor: crosshair; }
.q-shape { fill: none; }
.q-target { stroke: var(--yellow); fill: rgba(255,204,0,.12); stroke-dasharray: 12 8; animation: dash 1.6s linear infinite; }
.q-ok { stroke: #2fbf5b; fill: rgba(47,191,91,.25); }
.q-show { stroke: #2fbf5b; fill: rgba(47,191,91,.2); stroke-dasharray: 10 6; animation: dash 1.2s linear infinite; }
.q-mark.ok { fill: #2fbf5b; stroke: #fff; }
.q-mark.bad { fill: var(--red); stroke: #fff; }

.toolbar:has(.q-status) { flex-direction: column; align-items: stretch; }
.q-status {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  font-weight: 800; font-size: 1.1rem; flex-wrap: wrap;
}
.q-status .q-quit { min-height: 44px; padding: 0 14px; font-size: .95rem; }
.q-timer {
  --left: 100%;
  min-width: 96px; text-align: center;
  padding: 6px 12px; border-radius: 999px;
  background: linear-gradient(90deg, #ffe48a var(--left), #f1ede6 var(--left));
}
.q-timer.low { background: linear-gradient(90deg, #ffb3b3 var(--left), #f1ede6 var(--left)); color: var(--red); }
.q-answers { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; width: min(640px, 100%); margin: 0 auto; }
.q-answer { width: 100%; border-radius: 16px; white-space: normal; line-height: 1.2; padding: 8px 12px; min-height: 64px; }
.q-answer.ok { background: #2fbf5b; color: #fff; box-shadow: 0 3px 0 #1d8a3e; opacity: 1; }
.q-answer.bad { background: var(--red); color: #fff; opacity: 1; }
.q-answer[disabled] { pointer-events: none; }
.q-answer[disabled]:not(.ok):not(.bad) { opacity: .5; }
.q-tip { margin: 2px 0; text-align: center; font-size: 1.15rem; font-weight: 700; }

@media (max-width: 600px) {
  .topbar { padding: 8px 12px; }
  .brand { gap: 2px 10px; }
  .brand-num { font-size: 1.25rem; }
  .brand-name { font-size: .85rem; line-height: 1.2; }
  .btn-ghost { padding: 0 14px; font-size: 1rem; }
  .angles { flex-wrap: nowrap; width: 100%; gap: 6px; }
  .angle-btn { flex: 1 1 0; min-width: 0; padding: 4px 3px; font-size: .8rem; border-width: 2px; }
  .angle-btn img { width: 100%; height: 40px; }
  .angle-btn span { white-space: nowrap; }
  .view-title { display: none; }
  .toolbar-row { flex-wrap: nowrap; gap: 6px; }
  .toolbar-row .btn { padding: 0 14px; font-size: .95rem; white-space: nowrap; }
  .stage-hint { font-size: .95rem; padding: 8px 14px; }
  .q-group { grid-template-columns: 1fr; }
  .q-choice { flex-direction: row; flex-wrap: wrap; justify-content: center; column-gap: 8px; padding: 8px; }
  .quiz-panel { padding: 16px 12px; }
  .quiz-panel h2 { font-size: 1.5rem; }
  .quiz-q { font-size: 1.1rem; padding: 8px 16px; }
  .q-answer { font-size: 1rem; min-height: 58px; }
  .q-status { gap: 10px; font-size: 1rem; }
  .stage-wrap { min-height: 46vh; }
  .btn { font-size: 1.05rem; padding: 0 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .layer, .open-fade { transition-duration: .01s; }
  .i-pulse, .compartment .c-area { animation: none; }
}

/* ---------- intro ---------- */
.intro {
  position: fixed; inset: 0; z-index: 50;
  background: #000;
  overflow: hidden;
}
.intro-scene { position: absolute; opacity: 0; }
.intro-bg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.intro-door { position: absolute; display: block; }
.intro-truck-clip { position: absolute; inset: 0; }
.intro-truck { position: absolute; }
.intro-truck img { display: block; width: 100%; height: auto; }
.intro-flash {
  position: absolute;
  width: 9%; height: 9%;
  border-radius: 50%;
  background: radial-gradient(circle, #9fd4ff 0%, #1e6bff 40%, rgba(30,107,255,0) 72%);
  mix-blend-mode: screen;
  opacity: 0;
  pointer-events: none;
}
.intro-flash.f1 { left: 9%; top: -1%; }
.intro-flash.f2 { left: 21%; top: -2.5%; }
.intro-title {
  position: absolute; left: 50%; top: max(16px, env(safe-area-inset-top));
  transform: translateX(-50%);
  opacity: 0;
  background: rgba(179, 18, 27, .92);
  color: #fff;
  border-radius: 20px;
  padding: 12px 22px;
  text-align: center;
  box-shadow: 0 6px 24px rgba(0,0,0,.45);
  width: max-content;
  max-width: calc(100% - 32px);
}
.intro-title b { display: block; font-size: 1.5rem; }
.intro-title span { display: block; font-size: 1.05rem; opacity: .95; margin-top: 2px; }
.intro-skip { position: absolute; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); min-height: 48px; }
@media (max-width: 600px) {
  .intro-title b { font-size: 1.15rem; }
  .intro-title span { font-size: .95rem; }
}

/* ---------- wybór wozu ---------- */
.mode-picker .app, .mode-picker .topnav { display: none; }
.picker { flex: 1; padding: 24px 16px 32px; max-width: 1100px; width: 100%; margin: 0 auto; }
.picker-title { margin: 0 0 6px; font-size: 2rem; }
.picker-lead { margin: 0 0 20px; color: var(--muted); font-size: 1.1rem; }
.picker-list { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.pick {
  display: flex; flex-direction: column; border-radius: var(--radius); overflow: hidden;
  background: #fff; color: inherit; text-decoration: none;
  box-shadow: 0 2px 10px rgba(0,0,0,.12); transition: transform .15s, box-shadow .15s;
}
a.pick:hover, a.pick:focus-visible { transform: translateY(-3px); box-shadow: 0 8px 22px rgba(0,0,0,.18); }
a.pick:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.pick-img { aspect-ratio: 3 / 2; background: var(--stage-bg); }
.pick-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pick-body { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px 16px; }
.pick-num { font-size: 1.5rem; color: var(--red); }
.pick-name { font-weight: 600; }
.pick-cta {
  margin-top: 10px; align-self: flex-start; min-height: 48px; padding: 0 20px; border-radius: 999px;
  display: inline-flex; align-items: center; font-weight: 700; background: var(--red); color: #fff;
}
.pick-note { font-size: .95rem; color: var(--muted); }
.picker-sub { margin: 36px 0 4px; font-size: 1.5rem; }
.pick-soon .pick-img img { filter: grayscale(.6) brightness(.8); }
.pick-soon .pick-cta { background: #e6e1d8; color: var(--muted); }
@media (max-width: 600px) {
  .picker-title { font-size: 1.6rem; }
  .btn-wozy { padding: 0 14px; }
}
@media (max-width: 480px) {
  body:not(.mode-picker) .brand-name { display: none; }
  .topnav { gap: 6px; }
  .topnav .btn { padding: 0 12px; }
}
