/* ============ Absurdoro – wygląd ============ */

:root {
  --paper: #fffaf0;
  --bg: #f4ead7;
  --ink: #2a1d17;
  --ink-2: #5b4a3f;
  --muted: #8a7768;
  --tomato: #e5432f;
  --tomato-d: #b52a19;
  --leaf: #3c8d3a;
  --mustard: #e7b33a;
  --sky: #3a7bd5;
  --shadow: 5px 5px 0 var(--ink);
  --r: 14px;
  --font: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --type: "Special Elite", "Courier New", monospace;
  --mono: "Space Mono", ui-monospace, Consolas, monospace;
  --emoji: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, rgba(229, 67, 47, .08), transparent 40%),
    radial-gradient(circle at 88% 70%, rgba(60, 141, 58, .08), transparent 45%),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(42, 29, 23, .035) 31px 32px),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
b { font-weight: 800; }
small { font-size: .8em; }
[hidden] { display: none !important; }

/* ---------- Przyciski ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  padding: .55em 1em;
  border: 2px solid var(--ink); border-radius: 10px;
  background: var(--paper); color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  font-weight: 600; cursor: pointer;
  transition: transform .08s, box-shadow .08s, background .15s;
  white-space: nowrap;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.btn.primary { background: var(--tomato); color: #fff; }
.btn.primary:hover { background: #f05540; }
.btn.danger { background: #fde4df; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; }
.btn.ghost:hover { border-color: var(--ink); box-shadow: 3px 3px 0 var(--ink); background: var(--paper); }
.btn.big { padding: .8em 1.4em; font-size: 1.08rem; font-weight: 800; }
.btn.tiny { padding: .25em .6em; font-size: .82rem; box-shadow: 2px 2px 0 var(--ink); border-radius: 8px; }
.btn.icon { width: 2.6em; padding: .55em 0; }
.btn.on { background: var(--mustard); }

/* ---------- Pasek górny ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 14px clamp(16px, 3vw, 36px);
  max-width: 1280px; margin: 0 auto;
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.logo-tomato {
  width: 40px; height: 36px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ff8a6b, var(--tomato) 45%, var(--tomato-d));
  border: 2.5px solid var(--ink); position: relative;
  animation: wobble 4s ease-in-out infinite;
}
.logo-tomato::before {
  content: ""; position: absolute; left: 50%; top: -9px; width: 20px; height: 12px; transform: translateX(-50%);
  background: var(--leaf); border: 2px solid var(--ink); border-radius: 50% 50% 40% 40%;
  clip-path: polygon(0 60%, 20% 0, 40% 50%, 50% 0, 60% 50%, 80% 0, 100% 60%, 50% 100%);
}
.logo-tomato::after {
  content: ""; position: absolute; left: 9px; top: 13px; width: 5px; height: 5px; border-radius: 50%;
  background: var(--ink); box-shadow: 13px 0 0 var(--ink);
}
.logo-text { font-size: 1.9rem; font-weight: 800; letter-spacing: -.03em; }
.logo-text span { color: var(--tomato); }
.logo-sub {
  font-family: var(--type); font-size: .85rem; color: var(--ink-2);
  border-left: 2px solid var(--ink); padding-left: 14px; line-height: 1.2; max-width: 230px;
}
.top-nav { margin-left: auto; display: flex; gap: 6px; }
body[data-screen="scr-run"] .topbar { display: none; }

@keyframes wobble { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg) scale(1.04); } }

/* ---------- Ekrany ---------- */
.screen { display: none; }
.screen.active { display: block; animation: screen-in .35s ease-out; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } }

.paper {
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

/* ---------- Ekran główny ---------- */
.home-grid {
  display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 28px;
  max-width: 1280px; margin: 0 auto; padding: 8px clamp(16px, 3vw, 36px) 48px;
  align-items: start;
}
.form-a38 { padding: 0 0 22px; overflow: hidden; }
.form-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--ink); color: var(--paper); padding: 12px 22px;
  font-family: var(--type);
}
.form-head b { font-family: var(--font); font-size: 1.25rem; letter-spacing: .04em; margin-right: 10px; }
.form-head span { opacity: .8; }
.form-no { font-size: .85rem; opacity: .7; white-space: nowrap; }
.field { padding: 14px 22px 0; }
.field > label { display: block; font-weight: 800; margin-bottom: 8px; }
.field > label i { font-style: normal; font-family: var(--type); color: var(--tomato); margin-right: 4px; }
#f-name {
  width: 100%; font-size: 1.35rem; font-weight: 600;
  padding: 10px 4px; border: none; border-bottom: 3px dashed var(--ink);
  background: transparent; outline: none;
}
#f-name:focus { border-bottom-style: solid; border-bottom-color: var(--tomato); }
#f-name::placeholder { color: #b9a99a; font-weight: 400; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

.analyzer {
  margin: 16px 22px 0; border-radius: 12px; overflow: hidden;
  background: #142019; color: #9cf0a8; font-family: var(--mono); font-size: .86rem;
  border: 2px solid var(--ink);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, .5);
}
.an-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #0c1510; color: #d6ffd9; font-weight: 700; }
.an-head small { color: #6aa874; font-weight: 400; }
.an-led { width: 9px; height: 9px; border-radius: 50%; background: #3df07a; box-shadow: 0 0 8px #3df07a; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.an-out { padding: 8px 12px 2px; min-height: 52px; }
.an-out p { margin: 0 0 6px; animation: type-in .3s ease-out both; }
.an-out p:nth-child(2) { animation-delay: .12s; }
.an-out p:nth-child(3) { animation-delay: .24s; }
.an-out p:nth-child(4) { animation-delay: .36s; }
@keyframes type-in { from { opacity: 0; clip-path: inset(0 100% 0 0); } to { opacity: 1; clip-path: inset(0 0 0 0); } }
.an-busy span { animation: blink 1s infinite; }
.an-busy span:nth-child(2) { animation-delay: .2s; }
.an-busy span:nth-child(3) { animation-delay: .4s; }
.an-metrics { padding: 0 12px 10px; display: grid; gap: 4px; }
.met { display: grid; grid-template-columns: 170px 1fr auto; gap: 10px; align-items: center; }
.met span { color: #6aa874; }
.met i { height: 8px; background: #22382a; border-radius: 4px; overflow: hidden; }
.met i em { display: block; height: 100%; background: #3df07a; transition: width .6s; }
.met i.warn em { background: #f0c53d; }
.met b { color: #e6ffe9; font-weight: 700; white-space: nowrap; }
.met b small { color: #6aa874; font-weight: 400; }
.met b.wide { grid-column: 2 / 4; white-space: normal; }

.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.preset {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 6px 12px; border: 2px solid var(--ink); border-radius: 10px; background: #fff;
  cursor: pointer; text-align: left; line-height: 1.15; transition: background .15s, transform .1s;
}
.preset b { font-size: .92rem; }
.preset small { color: var(--muted); }
.preset:hover { transform: translateY(-2px); }
.preset.on { background: var(--mustard); }
.dur-row { display: flex; align-items: center; gap: 16px; }
.dur-row output { min-width: 110px; font-size: 1.1rem; }
.dur-row output b { font-size: 2rem; }

input[type="range"] {
  -webkit-appearance: none; appearance: none; flex: 1; width: 100%; height: 12px;
  background: repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 10%), #fff;
  border: 2px solid var(--ink); border-radius: 8px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 30px; height: 30px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ff8a6b, var(--tomato) 55%, var(--tomato-d));
  border: 2.5px solid var(--ink); cursor: grab;
}
input[type="range"]::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%; background: var(--tomato); border: 2.5px solid var(--ink); cursor: grab;
}
input[type="range"]:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }

.convert {
  margin: 16px 22px 0; padding: 12px 16px; border: 2px dashed var(--ink); border-radius: 12px;
  background: repeating-linear-gradient(-45deg, rgba(231, 179, 58, .08) 0 10px, transparent 10px 20px);
}
.cv-head { display: flex; justify-content: space-between; align-items: center; font-weight: 800; margin-bottom: 6px; }
#cv-list { margin: 0; padding-left: 20px; display: grid; gap: 3px; }
#cv-list li { animation: type-in .4s both; }
#cv-list li::marker { content: "≈ "; color: var(--tomato); font-weight: 800; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; }
select {
  width: 100%; padding: 9px 10px; border: 2px solid var(--ink); border-radius: 10px; background: #fff; cursor: pointer;
}
.level-desc { margin-top: 8px; color: var(--ink-2); font-style: italic; min-height: 1.4em; }
#f-level { display: block; }

.form-actions { display: flex; flex-wrap: wrap; gap: 12px; padding: 22px 22px 0; }
.form-legal { margin: 14px 22px 0; font-size: .75rem; color: var(--muted); font-family: var(--type); line-height: 1.4; }

.side { display: grid; gap: 22px; }
.card { padding: 16px 20px; }
.card h3 { margin: 0 0 10px; font-size: 1.15rem; }
.empty { color: var(--muted); font-style: italic; margin: 6px 0; }
.hint { color: var(--muted); font-size: .85rem; margin: 10px 0 0; }
.queue { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.queue li {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 10px; border: 2px solid var(--ink); border-radius: 10px; background: #fff;
}
.queue li div { min-width: 0; }
.queue li b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue li small { color: var(--muted); }
.q-btns { display: flex; gap: 4px; flex-shrink: 0; }
.mode-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: .92rem; }
.mode-list li { display: flex; gap: 8px; align-items: center; }
.mode-list span { font-family: var(--emoji); font-size: 1.15rem; }
.tot-big { display: flex; align-items: baseline; gap: 10px; }
.tot-big b { font-size: 2.6rem; color: var(--tomato); line-height: 1; }
.tot-list { margin: 8px 0 0; padding-left: 18px; color: var(--ink-2); display: grid; gap: 2px; }

/* ---------- Nakładki i okna ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(42, 29, 23, .55); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 16px;
  animation: fade-in .2s;
}
@keyframes fade-in { from { opacity: 0; } }
.process, .dialog {
  width: min(620px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  padding: 22px 26px; position: relative; animation: pop-in .3s cubic-bezier(.2, 1.4, .4, 1);
}
.dialog.wide { width: min(820px, 100%); }
@keyframes pop-in { from { transform: scale(.85); opacity: 0; } }
.process h2, .dialog h2 { margin: 0 0 12px; }
.dialog h3 { margin: 18px 0 8px; }
.dialog p { line-height: 1.5; }
.small { font-size: .88rem; color: var(--ink-2); }
.dialog-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; justify-content: flex-end; }
.steps { list-style: none; margin: 0; padding: 0; font-family: var(--type); display: grid; gap: 6px; }
.step { display: flex; justify-content: space-between; gap: 14px; animation: type-in .25s both; }
.step .st-r { color: var(--muted); text-align: right; }
.step.ok .st-t::before { content: "✓ "; color: var(--leaf); font-weight: 800; }
.step:not(.ok) .st-t::before { content: "⏳ "; }
.step.ok .st-r { color: var(--leaf); }
.skip { margin-top: 14px; }

.cert { font-size: .95rem; position: relative; }
.cert-head { font-family: var(--type); font-size: 1.05rem; border-bottom: 2px solid var(--ink); padding-bottom: 6px; margin-bottom: 8px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.cert-head small { color: var(--muted); }
.cert-big { font-size: 2.6rem; font-weight: 800; color: var(--tomato); line-height: 1; }
.cert-eq { font-family: var(--type); margin: 4px 0 12px; color: var(--ink-2); }
.cert table { width: 100%; border-collapse: collapse; }
.cert th { text-align: left; font-weight: 600; color: var(--ink-2); padding: 4px 10px 4px 0; width: 38%; vertical-align: top; }
.cert td { padding: 4px 0; border-bottom: 1px dotted #c9b9a6; }
.cert td small { color: var(--muted); }
.cert-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.stamp {
  display: inline-block; font-family: var(--type); font-weight: 800; letter-spacing: .08em;
  color: var(--tomato); border: 4px double var(--tomato); border-radius: 8px; padding: 4px 14px;
  transform: rotate(-12deg); opacity: .85; mix-blend-mode: multiply; pointer-events: none;
}
.stamp.big { position: absolute; right: 10px; top: 70px; font-size: 1.5rem; animation: stamp-in .45s cubic-bezier(.2, 1.6, .4, 1) .1s both; }
.stamp.huge { font-size: clamp(1.3rem, 3.4vw, 2.4rem); opacity: 0; }
.stamp.huge.slam { animation: stamp-in .5s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes stamp-in { 0% { transform: rotate(-12deg) scale(3.5); opacity: 0; } 60% { opacity: .9; } 100% { transform: rotate(-12deg) scale(1); opacity: .85; } }

/* ---------- Zadanie w toku ---------- */
#scr-run.active {
  display: grid; grid-template-rows: auto 8px minmax(0, 1fr) auto;
  height: 100vh; height: 100dvh;
}
.run-top {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 10px clamp(12px, 2.5vw, 28px); background: var(--ink); color: var(--paper);
}
.run-task { min-width: 0; }
.run-task small { display: block; font-family: var(--type); opacity: .7; font-size: .78rem; }
.run-task b { display: block; font-size: clamp(1.05rem, 2.4vw, 1.5rem); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-real { text-align: right; flex-shrink: 0; }
.run-real small { display: block; font-family: var(--type); opacity: .6; font-size: .72rem; }
.run-real b { font-family: var(--mono); font-size: 1.35rem; }
.run-progress { background: #3d2e25; position: relative; }
.run-progress span { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, var(--mustard), var(--tomato)); transition: width .3s linear; }
.stage { position: relative; overflow: hidden; background: var(--paper); }
.mode-host { position: absolute; inset: 0; }
.mode-host.enter { animation: mode-in .5s cubic-bezier(.2, 1.2, .4, 1); }
@keyframes mode-in { from { opacity: 0; transform: scale(.94) rotate(-1deg); } }
.mode-canvas { position: absolute; inset: 0; display: block; }
.mode-caption {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  max-width: calc(100% - 24px); padding: 7px 16px; border-radius: 999px;
  background: rgba(42, 29, 23, .86); color: #fff; font-size: .9rem; text-align: center;
  pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mode-caption b { color: var(--mustard); }

.run-bottom {
  display: grid; grid-template-columns: minmax(0, 1fr) 200px auto; align-items: center; gap: 16px;
  padding: 10px clamp(12px, 2.5vw, 28px); border-top: 2.5px solid var(--ink); background: var(--bg);
}
.mode-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mode-icon { font-family: var(--emoji); font-size: 2rem; }
.mode-info > div { min-width: 0; }
.mode-info b { display: block; font-size: 1.08rem; }
.mode-info small { display: block; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode-rot { font-size: .8rem; color: var(--ink-2); }
.rot-bar { height: 6px; border: 1.5px solid var(--ink); border-radius: 4px; margin-top: 4px; overflow: hidden; background: #fff; }
.rot-bar span { display: block; height: 100%; width: 0; background: var(--tomato); }
.run-ctrl { display: flex; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.ctrl-group { display: flex; gap: 6px; }
.paused-veil {
  position: fixed; inset: 0; z-index: 20; pointer-events: none;
  display: grid; place-items: center;
  background: repeating-linear-gradient(45deg, rgba(42, 29, 23, .08) 0 20px, transparent 20px 40px);
}
.paused-veil div {
  background: var(--ink); color: var(--paper); padding: 16px 26px; border-radius: 14px; text-align: center;
  box-shadow: 6px 6px 0 var(--tomato); transform: rotate(-3deg);
}
.paused-veil b { display: block; font-size: 2.4rem; letter-spacing: .1em; }
body.is-paused .stage { filter: grayscale(.85) brightness(.95); }

.mode-menu {
  position: fixed; inset: 0; z-index: 30; background: rgba(42, 29, 23, .6); backdrop-filter: blur(3px);
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); align-content: center; gap: 12px;
  padding: 40px max(16px, calc(50vw - 520px));
}
.mode-menu h3 { grid-column: 1 / -1; color: #fff; margin: 0 0 4px; font-size: 1.5rem; }
.mm-item {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; text-align: left;
  padding: 12px; border: 2.5px solid var(--ink); border-radius: 12px; background: var(--paper); cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink); transition: transform .1s;
}
.mm-item:hover { transform: translate(-2px, -2px) rotate(-.5deg); }
.mm-item span { grid-row: span 2; font-family: var(--emoji); font-size: 2rem; }
.mm-item small { color: var(--ink-2); line-height: 1.3; }
.mm-item.on { background: var(--mustard); }

/* ---------- Końcowe 10 sekund ---------- */
.final10 {
  position: fixed; inset: 0; z-index: 40; pointer-events: none;
  display: grid; place-content: center; text-align: center;
  background: radial-gradient(circle, rgba(229, 67, 47, .25), rgba(42, 29, 23, .78));
}
.f10-num {
  font-size: clamp(4rem, 17vw, 13rem); font-weight: 800; color: #fff; line-height: 1;
  text-shadow: 6px 6px 0 var(--tomato), 12px 12px 0 var(--ink);
  font-family: var(--font), var(--emoji); word-break: break-all; padding: 0 16px;
}
.f10-num.pop { animation: f10 .9s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes f10 { 0% { transform: scale(2.6) rotate(-8deg); opacity: 0; } 30% { opacity: 1; } 100% { transform: scale(1) rotate(0); } }
.f10-sub { color: var(--mustard); font-size: clamp(1.1rem, 3vw, 1.8rem); font-weight: 800; margin-top: 18px; font-family: var(--type); }
body.quake .stage, body.quake .final10 { animation: quake .45s; }
@keyframes quake { 10%, 50%, 90% { transform: translate(-6px, 3px) rotate(-.5deg); } 30%, 70% { transform: translate(6px, -3px) rotate(.5deg); } }
body.glitch .stage { animation: glitch 1.1s steps(2); }
@keyframes glitch {
  0% { filter: hue-rotate(0); transform: none; }
  20% { filter: hue-rotate(90deg) saturate(3); transform: skewX(4deg); }
  40% { filter: invert(1); transform: translateX(-10px); }
  60% { filter: hue-rotate(-120deg); transform: skewY(-2deg) scale(1.02); }
  80% { filter: none; transform: translateX(6px); }
  100% { filter: none; transform: none; }
}

/* ---------- Komunikaty ---------- */
.toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 60;
  display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px));
}
body[data-screen="scr-run"] .toasts { bottom: 96px; }
.toast {
  background: var(--paper); border: 2.5px solid var(--ink); border-radius: 12px; box-shadow: 4px 4px 0 var(--ink);
  padding: 10px 14px; cursor: pointer;
  transform: translateX(120%) rotate(4deg); transition: transform .45s cubic-bezier(.2, 1.4, .4, 1), opacity .3s;
}
.toast.in { transform: none; }
.toast.out { opacity: 0; transform: translateY(10px); }
.toast b { font-family: var(--type); color: var(--tomato); letter-spacing: .05em; font-size: .85rem; }
.toast p { margin: 4px 0 0; line-height: 1.4; font-size: .95rem; }
.toast.bad { background: #fde4df; }
.toast.control { background: #fff3c4; cursor: default; animation: control-pulse 1s infinite; }
@keyframes control-pulse { 50% { box-shadow: 4px 4px 0 var(--tomato); } }
.toast-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

#confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 70; }

/* ============ Sposoby odliczania ============ */

/* Przelicznik */
.m-units {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px 24px 60px;
  background:
    radial-gradient(circle at 50% 45%, #fff 0, transparent 60%),
    repeating-conic-gradient(from 0deg at 50% 45%, rgba(231, 179, 58, .12) 0 10deg, transparent 10deg 20deg),
    var(--paper);
}
.mu-label { font-family: var(--type); font-size: clamp(1rem, 2.2vw, 1.4rem); color: var(--ink-2); }
.mu-flip { perspective: 600px; }
.mu-flip.flip-in { animation: flip-in .6s cubic-bezier(.2, 1.3, .4, 1); }
@keyframes flip-in { from { transform: rotateX(90deg); opacity: 0; } }
.mu-value {
  font-size: clamp(2.6rem, 11vw, 8.5rem); font-weight: 800; line-height: 1.05; letter-spacing: -.03em;
  color: var(--tomato); text-shadow: 4px 4px 0 var(--ink); font-variant-numeric: tabular-nums;
  word-break: break-all; max-width: 92vw;
}
.mu-value.long { font-size: clamp(1.8rem, 6vw, 4.6rem); text-shadow: 3px 3px 0 var(--ink); }
.mu-value.huge { font-size: clamp(1.1rem, 3.2vw, 2.6rem); text-shadow: 2px 2px 0 var(--ink); }
.mu-unit { font-size: clamp(1.4rem, 4vw, 3rem); font-weight: 800; margin-top: 6px; }
.mu-note { max-width: 640px; margin-top: 18px; color: var(--ink-2); font-size: clamp(.95rem, 1.8vw, 1.15rem); line-height: 1.45; min-height: 3em; }
.mu-next { width: 180px; height: 5px; border-radius: 3px; background: rgba(42, 29, 23, .12); margin-top: 18px; overflow: hidden; }
.mu-next span { display: block; height: 100%; background: var(--ink); }
.mu-also { position: absolute; bottom: 16px; font-family: var(--type); color: var(--muted); font-size: .9rem; }

/* Tablica odjazdów */
.m-board {
  position: absolute; inset: 0; background: #14161c; color: #f3d34a; padding: clamp(12px, 3vw, 32px);
  display: flex; flex-direction: column; gap: 10px; font-family: var(--mono); overflow: hidden;
}
.mb-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid #333; padding-bottom: 10px; }
.mb-title { font-size: clamp(1.4rem, 3.5vw, 2.4rem); font-weight: 700; color: #fff; font-family: var(--font); }
.mb-title small { display: block; font-size: .9rem; color: #9aa0ad; font-weight: 400; }
.mb-clock { font-size: clamp(1.2rem, 3vw, 2rem); color: #fff; }
.mb-cols, .mb-row { display: grid; grid-template-columns: 5fr 16fr 14fr 2.4fr 18fr; gap: 1.4%; align-items: center; }
.mb-cols { color: #9aa0ad; font-size: .78rem; letter-spacing: .1em; }
.mb-rows { display: grid; gap: 8px; }
.mb-row { padding: 6px 0; border-bottom: 1px solid #23262e; }
.mb-row.main { background: rgba(243, 211, 74, .07); outline: 1px solid rgba(243, 211, 74, .3); border-radius: 6px; padding: 8px 6px; }
.flap-row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; }
.flap {
  display: grid; place-items: center; aspect-ratio: 3 / 4.2; background: linear-gradient(#262a33 49%, #111 50%, #1d2028 51%);
  border-radius: 3px; font-size: clamp(.55rem, 1.25vw, 1.1rem); font-weight: 700; color: #f3d34a; line-height: 1; overflow: hidden;
}
.mb-row.main .flap { color: #fff; }
.c-note .flap { color: #7fe39a; }
.flap.flip { animation: flap .09s ease-in; }
@keyframes flap { from { transform: scaleY(.2); filter: brightness(1.8); } }
.mb-marquee { margin-top: auto; background: #f3d34a; color: #14161c; border-radius: 6px; overflow: hidden; white-space: nowrap; padding: 8px 0; font-family: var(--font); font-weight: 800; }
.mb-marquee-in { display: inline-block; padding-left: 100%; animation: marquee 30s linear infinite; }
@keyframes marquee { to { transform: translateX(-100%); } }

/* Kopiowanie */
.m-copy { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: #3a6ea5 linear-gradient(135deg, #3a6ea5, #1f4f82); }
.mc-win {
  width: min(560px, 100%); background: #f0f0f0; border: 1px solid #555; box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
  font-family: "Segoe UI", Tahoma, sans-serif; color: #111; font-size: .92rem;
}
.mc-bar { display: flex; align-items: center; gap: 4px; background: linear-gradient(#fff, #e3e3e3); padding: 6px 8px; border-bottom: 1px solid #aaa; }
.mc-bar span { flex: 1; }
.mc-bar i { font-style: normal; width: 28px; text-align: center; color: #333; }
.mc-bar i.x:hover { background: #e81123; color: #fff; }
.mc-body { padding: 16px 20px 18px; }
.mc-anim { display: flex; align-items: center; justify-content: space-between; height: 64px; margin-bottom: 10px; position: relative; }
.mc-folder { font-family: var(--emoji); font-size: 2.4rem; text-align: center; line-height: 1; }
.mc-folder small { display: block; font-family: "Segoe UI", sans-serif; font-size: .7rem; color: #444; }
.mc-fly { position: absolute; left: 60px; right: 60px; top: 10px; height: 40px; }
.mc-fly span { position: absolute; font-family: var(--emoji); font-size: 1.4rem; animation: fly 2.2s linear infinite; }
.mc-fly span:nth-child(2) { animation-delay: .73s; }
.mc-fly span:nth-child(3) { animation-delay: 1.46s; }
@keyframes fly { 0% { left: 0; top: 20px; opacity: 0; } 15% { opacity: 1; } 50% { top: -6px; } 85% { opacity: 1; } 100% { left: calc(100% - 20px); top: 20px; opacity: 0; } }
body.is-paused .mc-fly span { animation-play-state: paused; }
.mc-file { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-from { color: #444; margin: 2px 0 10px; }
.mc-pct { font-size: 1.25rem; margin-bottom: 6px; }
.mc-graph { display: block; width: 100%; height: 70px; background: #fff; }
.mc-prog { height: 18px; border: 1px solid #999; background: #e6e6e6; margin-top: 8px; }
.mc-prog span { display: block; height: 100%; width: 0; background: linear-gradient(#5fd35f, #2fa82f); transition: width .4s linear; }
.mc-info { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin: 12px 0 0; }
.mc-info dt { color: #555; }
.mc-info dd { margin: 0; font-weight: 600; }
.mc-honest { margin-top: 12px; font-size: .78rem; color: #888; font-style: italic; }
.mc-btns { display: flex; justify-content: flex-end; margin-top: 10px; }
.mc-cancel { padding: 4px 22px; border: 1px solid #999; background: #e8e8e8; cursor: pointer; font-family: inherit; }
.mc-cancel:hover { background: #e5f1fb; border-color: #0078d7; }
.mc-msg { min-height: 1.3em; color: #c00; text-align: right; font-size: .82rem; margin-top: 4px; }

/* Zaświadczenie */
.m-doc { position: absolute; inset: 0; overflow: auto; padding: 18px; background: #6d5a49 repeating-linear-gradient(90deg, rgba(0, 0, 0, .06) 0 3px, transparent 3px 60px); }
.md-paper {
  max-width: 760px; margin: 0 auto; background: #fbf7ea; padding: clamp(16px, 3vw, 34px); font-family: var(--type);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35); transform: rotate(-.4deg); position: relative;
}
.md-head { display: flex; justify-content: space-between; gap: 12px; font-size: .82rem; line-height: 1.35; }
.md-head small { color: #6b5d50; }
.md-nr { text-align: right; }
.md-paper h2 { text-align: center; letter-spacing: .25em; margin: 18px 0 10px; font-size: clamp(1.2rem, 2.6vw, 1.7rem); }
.md-paper h2 small { display: block; letter-spacing: .05em; font-size: .6em; font-weight: 400; }
.md-lead { font-size: .95rem; }
.md-table { width: 100%; border-collapse: collapse; font-size: clamp(.82rem, 1.5vw, .98rem); }
.md-table th { text-align: left; font-weight: 400; color: #6b5d50; padding: 6px 12px 6px 0; width: 30%; vertical-align: top; border-bottom: 1px dotted #b8a993; }
.md-table td { padding: 6px 0; border-bottom: 1px dotted #b8a993; word-break: break-word; font-weight: 700; }
.md-table td.mono { font-family: var(--mono); letter-spacing: .04em; }
.tally { font-family: var(--mono); letter-spacing: 1px; }
.tally span { display: inline-block; margin-right: 10px; }
.tally .t5 { position: relative; }
.tally .t5::after { content: ""; position: absolute; left: -3px; right: -3px; top: 50%; height: 2px; background: currentColor; transform: rotate(-24deg); }
.md-foot { font-size: .78rem; color: #6b5d50; margin-top: 14px; }
.md-sign { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 12px; }
.md-stamp {
  width: 110px; height: 110px; border-radius: 50%; border: 4px double #2e4fb8; color: #2e4fb8; display: grid; place-content: center; text-align: center;
  font-size: .62rem; transform: rotate(-14deg); opacity: .8; mix-blend-mode: multiply;
}
.md-stamp b { font-size: 1.5rem; }
.md-stamp.thump { animation: stamp-in .45s cubic-bezier(.2, 1.6, .4, 1); }
.md-sig { text-align: center; }
.md-sig i { display: block; font-family: "Brush Script MT", "Segoe Script", cursive; font-size: 1.6rem; color: #1d3c9b; border-bottom: 1px solid #555; padding: 0 20px; }
.md-sig small { color: #6b5d50; }

/* Świat */
.m-world { position: absolute; inset: 0; overflow: auto; padding: clamp(16px, 3vw, 36px) clamp(16px, 4vw, 48px) 24px; background: linear-gradient(160deg, #0f2440, #1b3f5e 60%, #23557a); color: #eaf4ff; }
.mw-head { font-size: clamp(1.1rem, 2.4vw, 1.6rem); font-weight: 600; margin-bottom: 14px; }
.mw-head b { color: var(--mustard); font-family: var(--mono); }
.mw-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.mw-list li {
  display: flex; gap: 14px; align-items: center; padding: 10px 16px; border-radius: 12px;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .12); font-size: clamp(.95rem, 1.9vw, 1.25rem);
}
.mw-list li.swap { animation: flip-in .6s cubic-bezier(.2, 1.3, .4, 1); }
.mw-list b { color: #ffd76a; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.mw-ic { font-family: var(--emoji); font-size: 1.6rem; width: 1.6em; text-align: center; flex-shrink: 0; }
.mw-foot { margin-top: 16px; color: #b9d3ec; font-size: .98rem; }
.mw-foot b { color: #fff; }

/* Giełda */
.m-stock { position: absolute; inset: 0; display: flex; flex-direction: column; background: #0d1117; color: #e6edf3; padding: clamp(12px, 2.5vw, 26px); gap: 10px; }
.ms-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.ms-name { font-size: clamp(1.4rem, 3.2vw, 2.2rem); font-weight: 800; }
.ms-sub { color: #8b949e; font-size: .85rem; }
.ms-price { text-align: right; font-family: var(--mono); }
.ms-price b { display: block; font-size: clamp(1.6rem, 4vw, 2.8rem); }
.ms-price span { font-weight: 700; }
.up { color: #3ddc84; }
.dn { color: #ff5a5a; }
.ms-chart { flex: 1; min-height: 0; width: 100%; display: block; border: 1px solid #21262d; border-radius: 8px; }
.ms-news { display: flex; gap: 10px; align-items: center; font-size: clamp(.9rem, 1.8vw, 1.1rem); }
.ms-news b { background: #ff5a5a; color: #fff; padding: 2px 8px; border-radius: 4px; font-size: .8rem; }
.ms-news span.in { animation: type-in .5s both; }
.ms-ticker { overflow: hidden; white-space: nowrap; border-top: 1px solid #21262d; border-bottom: 1px solid #21262d; padding: 6px 0; font-family: var(--mono); font-size: .9rem; }
.ms-ticker-in { display: inline-block; padding-left: 100%; animation: marquee 40s linear infinite; }
.ms-ticker-in span { margin-right: 32px; }
.ms-close { color: #8b949e; font-size: .9rem; text-align: center; }
.ms-close b { color: #fff; font-family: var(--mono); }

/* ============ Raport końcowy ============ */
#scr-final { padding: 0 clamp(16px, 3vw, 36px) 60px; }
.final-wrap { max-width: 1100px; margin: 0 auto; }
.final-hero {
  position: relative; text-align: center; padding: 34px 20px 28px; margin-top: 8px;
  background: var(--tomato); color: #fff; border: 2.5px solid var(--ink); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden;
}
.final-hero::before {
  content: ""; position: absolute; inset: -50%;
  background: repeating-conic-gradient(rgba(255, 255, 255, .08) 0 12deg, transparent 12deg 24deg);
  animation: spin 40s linear infinite;
}
.final-hero > * { position: relative; }
.final-hero.quit { background: #6b6f80; }
@keyframes spin { to { transform: rotate(360deg); } }
.fh-kicker { font-family: var(--type); opacity: .9; font-size: .85rem; }
.final-hero h1 { font-size: clamp(2.6rem, 9vw, 6rem); line-height: .92; margin: 12px 0; letter-spacing: -.03em; text-shadow: 5px 5px 0 var(--ink); }
.fh-task { font-size: clamp(1.1rem, 2.5vw, 1.5rem); font-weight: 600; margin: 0 0 14px; }
.final-hero .stamp { color: #fff; border-color: #fff; mix-blend-mode: normal; background: rgba(42, 29, 23, .2); }
.fh-away { font-style: italic; opacity: .9; }
.final-shock { font-size: clamp(1.05rem, 2.2vw, 1.35rem); text-align: center; font-weight: 600; max-width: 820px; margin: 22px auto 6px; line-height: 1.45; }
.sec-h { font-size: clamp(1.3rem, 3vw, 1.9rem); margin: 34px 0 14px; letter-spacing: -.02em; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.fact {
  background: var(--paper); border: 2.5px solid var(--ink); border-radius: 14px; box-shadow: 4px 4px 0 var(--ink);
  padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start;
  animation: card-in .5s cubic-bezier(.2, 1.4, .4, 1) both; animation-delay: calc(var(--i) * .09s + .3s);
}
@keyframes card-in { from { opacity: 0; transform: translateY(20px) rotate(-2deg); } }
.fact-ic { font-family: var(--emoji); font-size: 1.9rem; line-height: 1; }
.fact p { margin: 0; line-height: 1.4; }
.fact p::first-letter { text-transform: uppercase; }
.fact b { color: var(--tomato); font-size: 1.25em; font-variant-numeric: tabular-nums; }
.tiny-note { font-size: .78rem; color: var(--muted); margin: 8px 0 0; }
.compare { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; }
.compare li { display: flex; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1.5px dashed rgba(42, 29, 23, .25); }
.compare span { font-family: var(--emoji); font-size: 1.5rem; }
.compare p { margin: 0; }
.compare b { color: var(--tomato-d); }
.awards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.award {
  text-align: center; padding: 16px 14px; background: linear-gradient(#fff7dd, var(--paper)); border: 2.5px solid var(--ink); border-radius: 14px;
  box-shadow: 4px 4px 0 var(--ink); animation: card-in .5s cubic-bezier(.2, 1.4, .4, 1) both; animation-delay: calc(var(--i) * .12s + .8s);
}
.medal {
  width: 74px; height: 74px; margin: 0 auto 10px; border-radius: 50%; display: grid; place-items: center; font-family: var(--emoji); font-size: 2.2rem;
  background: radial-gradient(circle at 35% 30%, #fff3b0, var(--mustard) 60%, #a87a12); border: 3px solid var(--ink);
  box-shadow: 0 0 0 5px #fff, 0 0 0 7px var(--ink);
}
.award b { display: block; line-height: 1.2; }
.award small { display: block; color: var(--ink-2); margin-top: 4px; }
.jury { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.judge {
  display: flex; gap: 14px; align-items: center; padding: 10px 14px; background: var(--paper);
  border: 2px solid var(--ink); border-radius: 12px; animation: card-in .5s both; animation-delay: calc(var(--i) * .1s + 1.2s);
}
.judge .score {
  flex-shrink: 0; width: 64px; height: 50px; display: grid; place-items: center; border-radius: 8px; background: var(--ink); color: #fff;
  font-family: var(--mono); font-size: 1.35rem; font-weight: 700;
}
.judge b { display: block; }
.judge small { color: var(--ink-2); }
.judge.avg { background: var(--mustard); }
.judge.avg .score { background: var(--tomato); }
.final-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 40px; }
.break-end .final-hero { background: var(--leaf); }
.break-end .compare { margin-top: 24px; }

/* ---------- Ustawienia i archiwum ---------- */
.set-grid, .set-modes { display: grid; gap: 8px; }
.set-modes { grid-template-columns: 1fr 1fr; }
.chk { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.chk input { width: 20px; height: 20px; accent-color: var(--tomato); }
.chk small { color: var(--muted); }
.arch-wrap { max-height: 50vh; overflow: auto; border: 2px solid var(--ink); border-radius: 10px; }
.arch { width: 100%; border-collapse: collapse; font-size: .9rem; }
.arch th { position: sticky; top: 0; background: var(--ink); color: #fff; text-align: left; padding: 6px 10px; }
.arch td { padding: 6px 10px; border-bottom: 1px dotted #c9b9a6; vertical-align: top; }
.arch td small { display: block; color: var(--muted); }
.arch tr.quit td { color: var(--muted); }

/* ---------- Poziom absurdu na ekranie głównym ---------- */
body[data-screen="scr-home"][data-level="5"] .logo-tomato { animation-duration: .8s; }
body[data-screen="scr-home"][data-level="5"] .form-a38 { animation: drift 6s ease-in-out infinite; }
@keyframes drift { 50% { transform: rotate(-.4deg) translateY(-2px); } }

/* ---------- Telefon i wąskie ekrany ---------- */
@media (max-width: 980px) {
  .home-grid { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr 1fr; }
  .run-bottom { grid-template-columns: 1fr; gap: 8px; }
  .mode-rot { display: none; }
  .run-ctrl { justify-content: flex-start; }
}
@media (max-width: 640px) {
  .logo-sub { display: none; }
  .top-nav .btn { padding: .45em .55em; font-size: 1.2rem; }
  .top-nav .btn span { display: none; }
  .logo-text { font-size: 1.6rem; }
  .presets { display: grid; grid-template-columns: 1fr 1fr; }
  .field, .analyzer, .convert { margin-left: 0; margin-right: 0; }
  .field { padding: 14px 16px 0; }
  .analyzer, .convert { margin: 16px 16px 0; }
  .form-actions { padding: 22px 16px 0; }
  .form-legal { margin: 14px 16px 0; }
  .an-head small { display: none; }
  .row2 { grid-template-columns: 1fr; }
  .met { grid-template-columns: 1fr auto; }
  .met i { display: none; }
  .met b.wide { grid-column: 2; }
  .form-head { flex-direction: column; align-items: flex-start; }
  .facts, .compare, .set-modes { grid-template-columns: 1fr; }
  .mode-list { grid-template-columns: 1fr; }
  .mode-info small { display: none; }
  .ctrl-group { flex-wrap: wrap; }
  .run-ctrl .btn { font-size: .85rem; padding: .45em .7em; }
  .mode-caption { white-space: normal; border-radius: 12px; font-size: .8rem; }
  .stamp.big { top: 64px; right: 4px; font-size: 1.1rem; }
  body[data-screen="scr-run"] .toasts { bottom: auto; top: 72px; }
  .mb-cols { display: none; }
}

/* ---------- Druk dyplomu ---------- */
@media print {
  body { background: #fff; }
  .topbar, .toasts, #confetti, .final-actions, .overlay { display: none !important; }
  .screen { display: none !important; }
  #scr-final { display: block !important; padding: 0; }
  .final-hero { box-shadow: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .final-hero::before { display: none; }
  .fact, .award, .judge { box-shadow: none; animation: none; break-inside: avoid; }
  .stamp.huge { opacity: .85; }
}

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