:root {
  color-scheme: light;
  --ink: #111a33;
  --paper: #fff7df;
  --white: #fffdf6;
  --pink: #ff4f91;
  --pink-dark: #b92066;
  --lime: #c7f23e;
  --blue: #55d8ff;
  --orange: #ff9d3c;
  --muted: #716b72;
  --line: #111a33;
  --shadow: 5px 5px 0 var(--ink);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--ink); }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at -5% 10%, rgba(255,79,145,.28), transparent 34%),
    radial-gradient(circle at 105% 38%, rgba(85,216,255,.25), transparent 32%),
    linear-gradient(180deg, #fff7df 0, #fffdf6 55%, #f8efd2 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}
button, input { font: inherit; }
button { touch-action: manipulation; }
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .14;
  z-index: 20;
  background-image: repeating-linear-gradient(0deg, transparent 0 3px, rgba(17,26,51,.09) 3px 4px);
  mix-blend-mode: multiply;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 12;
  min-height: 72px;
  padding: max(12px, env(safe-area-inset-top)) 16px 10px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  color: white;
  background: rgba(17,26,51,.96);
  border-bottom: 3px solid var(--pink);
  backdrop-filter: blur(8px);
}
.topbar strong { display: block; font-size: 20px; letter-spacing: -.04em; }
.eyebrow { display: block; color: var(--lime); font: 800 9px/1.2 ui-monospace, monospace; letter-spacing: .1em; }
.status-cluster { display: grid; justify-items: end; gap: 3px; color: var(--blue); font: 800 10px/1.1 ui-monospace, monospace; }

#app { width: min(100%, 620px); margin: 0 auto; padding: 20px 14px 110px; outline: none; }
.scene { animation: scene-in .36s ease both; }
.scene-header { margin: 8px 2px 22px; }
.scene-kicker { margin: 0 0 7px; color: var(--pink-dark); font: 900 11px/1.2 ui-monospace, monospace; letter-spacing: .08em; }
.scene h1 { margin: 0; max-width: 12ch; font-size: clamp(38px, 12vw, 64px); line-height: .92; letter-spacing: -.075em; }
.scene-intro { margin: 14px 0 0; max-width: 48ch; font-size: 16px; line-height: 1.45; }

.system-banner {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 2px solid var(--ink);
  border-left: 9px solid var(--pink);
  border-radius: 12px;
  background: var(--lime);
  font: 800 12px/1.35 ui-monospace, monospace;
  box-shadow: 3px 3px 0 var(--ink);
}
.card-grid { display: grid; gap: 16px; }
.card {
  position: relative;
  padding: 17px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background: rgba(255,253,246,.96);
  box-shadow: var(--shadow);
}
.card.done::after {
  content: "ГОТОВО";
  position: absolute;
  top: 9px;
  right: -25px;
  width: 100px;
  padding: 3px 0;
  text-align: center;
  color: var(--ink);
  background: var(--lime);
  border: 1px solid var(--ink);
  transform: rotate(34deg);
  font: 900 8px/1 ui-monospace, monospace;
}
.card h2 { margin: 0 0 6px; padding-right: 28px; font-size: 21px; letter-spacing: -.035em; }
.card p { margin: 7px 0; line-height: 1.42; }
.muted { color: var(--muted); font-size: 13px; }
.result {
  min-height: 46px;
  margin-top: 12px;
  padding: 11px 12px;
  border: 1px dashed var(--ink);
  border-radius: 10px;
  background: var(--paper);
  font: 700 13px/1.4 ui-monospace, monospace;
}

.button {
  min-width: 48px;
  min-height: 48px;
  padding: 11px 15px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  color: var(--ink);
  background: white;
  font-weight: 850;
  line-height: 1.1;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
}
.button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.button.primary { background: var(--pink); color: white; }
.button.lime { background: var(--lime); }
.button.blue { background: var(--blue); }
.button.danger { background: #ef3340; color: white; }
.button.ghost { background: var(--white); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.button-row { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 12px; }
.button-row .button { flex: 1 1 130px; }
.chip-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 12px; }
.chip {
  min-height: 46px;
  padding: 9px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  color: var(--ink);
  background: white;
  font-size: 13px;
  font-weight: 750;
}
.chip[aria-pressed="true"], .chip.selected { background: var(--blue); box-shadow: inset 0 0 0 2px white; }
.choice-label { margin: 15px 0 -5px; color: var(--pink-dark); font: 900 10px/1 ui-monospace, monospace; letter-spacing: .12em; }
.chip-grid.compact { margin-top: 10px; }
.chip-grid.compact .chip { font-size: 12px; }

.shred-list { display: grid; gap: 8px; margin: 14px 0; }
.shred-task {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 10px 12px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: #fffdf7;
  color: var(--ink);
  text-align: left;
  transition: transform .22s, opacity .22s, background .22s;
}
.shred-task span { font-weight: 800; }
.shred-task b { flex: 0 0 auto; color: var(--pink-dark); font: 900 10px/1 ui-monospace, monospace; }
.shred-task.shredded { transform: translateX(9px) rotate(-1deg); opacity: .58; background: repeating-linear-gradient(-12deg, #fff 0 5px, #ffd4e3 5px 8px); text-decoration: line-through; }
.shred-task.shredded b { color: var(--ink); text-decoration: none; }

.reality-panel { display: grid; gap: 9px; margin: 14px 0; padding: 12px; border: 2px solid var(--ink); border-radius: 12px; background: var(--screen); }
.reality-toggle { display: grid; grid-template-columns: 48px 1fr; align-items: center; gap: 10px; min-height: 48px; padding: 7px 10px; border: 1px solid #7f8cb1; border-radius: 9px; background: #182344; color: white; text-align: left; font-weight: 800; }
.reality-toggle i { position: relative; width: 42px; height: 24px; border: 2px solid white; border-radius: 99px; background: #616c8c; }
.reality-toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: white; transition: transform .18s; }
.reality-toggle.on { border-color: var(--lime); color: var(--lime); }
.reality-toggle.on i { background: var(--pink); }
.reality-toggle.on i::after { transform: translateX(18px); }

.fact-grid { display: grid; gap: 8px; margin: 14px 0; }
.fact-file { display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 10px; min-height: 52px; padding: 9px 11px; border: 2px solid var(--ink); border-radius: 10px; background: #fffdf7; color: var(--ink); text-align: left; }
.fact-file b { color: var(--pink-dark); font: 900 12px/1 ui-monospace, monospace; }
.fact-file span { font-size: 12px; font-weight: 800; line-height: 1.25; }
.fact-file.open { background: linear-gradient(110deg, #fff7d9, #e9ffd3); box-shadow: inset 5px 0 0 var(--lime); }

.catch-zone { position: relative; height: 168px; margin: 14px 0; overflow: hidden; border: 2px dashed var(--ink); border-radius: 14px; background: radial-gradient(circle at 20% 25%, #fff 0 3px, transparent 4px), radial-gradient(circle at 75% 70%, #fff 0 2px, transparent 3px), linear-gradient(145deg, #131d3a, #263764); }
.catch-target { position: absolute; left: var(--catch-x); top: var(--catch-y); display: grid; place-items: center; width: 52px; height: 52px; border: 2px solid var(--ink); border-radius: 50%; background: var(--lime); color: var(--ink); font-size: 25px; box-shadow: 3px 3px 0 var(--pink); transform: translate(-50%, -50%); transition: left .16s, top .16s, transform .12s; }
.catch-target:active { transform: translate(-50%, -50%) scale(.86); }
.catch-target:disabled { left: 50%; top: 50%; opacity: 1; background: var(--blue); box-shadow: 3px 3px 0 var(--lime); }

.signal-slots { min-height: 62px; display: grid; place-items: center; margin: 13px 0 9px; border: 2px solid var(--ink); border-radius: 11px; background: var(--screen); color: var(--lime); font-size: 27px; letter-spacing: .16em; }
.signal-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.signal-buttons button { min-width: 48px; min-height: 54px; border: 2px solid var(--ink); border-radius: 10px; background: white; font-size: 23px; box-shadow: 2px 2px 0 var(--ink); }
.signal-buttons button:disabled { opacity: .34; box-shadow: none; }

.story-nav {
  position: fixed;
  z-index: 15;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: auto minmax(50px, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px max(12px, env(safe-area-inset-bottom));
  background: rgba(255,247,223,.96);
  border-top: 2px solid var(--ink);
  backdrop-filter: blur(8px);
}
.story-nav .button { min-height: 44px; padding: 9px 12px; font-size: 12px; box-shadow: 2px 2px 0 var(--ink); }
.progress-track { height: 12px; padding: 2px; border: 2px solid var(--ink); border-radius: 20px; background: white; }
.progress-track i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--pink), var(--blue), var(--lime)); transition: width .3s ease; }

.boot-screen { padding: 13px; border-radius: 12px; color: #dff7ff; background: var(--ink); font: 700 12px/1.6 ui-monospace, monospace; }
.boot-line { opacity: .75; }
.boot-progress { height: 16px; margin: 12px 0; border: 1px solid var(--blue); padding: 2px; }
.boot-progress i { display: block; width: 2%; height: 100%; background: var(--lime); transition: width .14s linear; }
.range-wrap { display: grid; grid-template-columns: 1fr 54px; align-items: center; gap: 12px; }
input[type="range"] { width: 100%; accent-color: var(--pink); }
.plan-output { display: grid; place-items: center; width: 54px; height: 54px; border: 2px solid var(--ink); border-radius: 50%; background: var(--lime); font: 900 19px/1 ui-monospace, monospace; }
.escape-zone { min-height: 112px; display: grid; place-items: center; border: 1px dashed var(--muted); border-radius: 12px; overflow: hidden; }
.escape-button { transition: transform .16s ease; }

.lie-question { font-weight: 800; font-size: 17px; }
.captcha-list { display: grid; gap: 8px; margin: 12px 0; }
.captcha-list label { display: flex; gap: 9px; align-items: flex-start; padding: 10px; border: 1px solid var(--ink); border-radius: 9px; background: white; font-size: 14px; }
.captcha-list input { width: 20px; height: 20px; accent-color: var(--pink); }
.coin { width: 84px; height: 84px; display: grid; place-items: center; margin: 10px auto; border: 3px solid var(--ink); border-radius: 50%; background: var(--orange); font-size: 34px; box-shadow: 5px 6px 0 rgba(17,26,51,.25); }
.coin.flipping { animation: flip .65s ease; }

.chaos-meter { height: 28px; padding: 4px; border: 2px solid var(--ink); border-radius: 99px; background: white; }
.chaos-meter i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--lime), var(--orange), var(--pink)); transition: width .35s; }
.tap-counter { font: 900 42px/1 ui-monospace, monospace; text-align: center; }
.party-lights { position: relative; display: grid; grid-template-columns: repeat(6, 1fr); gap: 11px 7px; margin: 16px 0; padding-top: 8px; border-top: 2px solid var(--ink); }
.party-light { position: relative; min-width: 44px; height: 48px; border: 0; background: transparent; }
.party-light::before { content: ""; position: absolute; left: 50%; top: -9px; width: 3px; height: 17px; background: var(--ink); transform: translateX(-50%); }
.party-light::after { content: ""; position: absolute; left: 50%; top: 8px; width: 24px; height: 28px; border: 2px solid var(--ink); border-radius: 50% 50% 58% 58%; background: var(--orange); box-shadow: 0 0 15px var(--orange); transform: translateX(-50%); transition: opacity .18s, filter .18s; }
.party-light:nth-child(3n + 2)::after { background: var(--pink); box-shadow: 0 0 15px var(--pink); }
.party-light:nth-child(3n)::after { background: var(--lime); box-shadow: 0 0 15px var(--lime); }
.party-light.out::after { opacity: .16; filter: grayscale(1); box-shadow: none; }
.fan-button { width: 100%; user-select: none; -webkit-user-select: none; }
.console { padding: 12px; border: 2px solid var(--blue); border-radius: 10px; color: #dff7ff; background: #081024; font: 700 12px/1.5 ui-monospace, monospace; }
.console-output { min-height: 94px; max-height: 180px; overflow: auto; white-space: pre-wrap; }
.console form { display: flex; align-items: center; gap: 5px; border-top: 1px solid #32426f; padding-top: 9px; }
.console input { width: 100%; min-height: 42px; border: 0; outline: 0; color: var(--lime); background: transparent; font: inherit; }

.repair-slots { min-height: 56px; padding: 8px; border: 2px dashed var(--ink); border-radius: 10px; background: var(--paper); }
.repair-slots span { display: inline-block; margin: 3px; padding: 7px; border-radius: 7px; background: var(--blue); font-weight: 800; }
.system-broken .card:nth-child(odd) { transform: rotate(-.7deg) translateX(-2px); }
.system-broken .card:nth-child(even) { transform: rotate(.9deg) translateX(3px); }
.system-broken .topbar { border-bottom-color: var(--lime); }
.system-broken .noise { opacity: .3; }

.ending-choice { display: grid; gap: 12px; }
.ending-choice .button { min-height: 66px; text-align: left; }
.final-card { padding: 20px; border: 3px solid var(--ink); border-radius: 22px; background: var(--white); box-shadow: 8px 8px 0 var(--ink); }
.final-card h2 {
  margin: 0;
  max-width: 100%;
  font-size: clamp(34px, 11vw, 58px);
  line-height: .92;
  letter-spacing: -.065em;
  overflow-wrap: anywhere;
}
.badge { display: inline-block; margin: 15px 0; padding: 7px 10px; border: 2px solid var(--ink); background: var(--lime); transform: rotate(-1.5deg); font: 900 11px/1.2 ui-monospace, monospace; }
.letter { margin: 24px -4px 8px; padding: 20px 17px; border-left: 5px solid var(--pink); background: var(--paper); font-size: 17px; line-height: 1.65; }
.secret-map { display: grid; gap: 7px; margin: 12px 0; }
.secret-map div { padding: 9px 10px; border: 1px dashed var(--ink); border-radius: 8px; font: 700 12px/1.3 ui-monospace, monospace; }

.toast-stack { position: fixed; z-index: 40; top: 80px; right: 10px; width: min(330px, calc(100% - 20px)); display: grid; gap: 8px; pointer-events: none; }
.toast { padding: 12px 14px; border: 2px solid var(--ink); border-radius: 12px; background: white; box-shadow: 4px 4px 0 var(--ink); animation: toast-in .25s ease both; }
.toast b, .toast span { display: block; }
.toast b { font-size: 12px; }
.toast span { margin-top: 3px; font-size: 13px; }
.fx-layer { position: fixed; inset: 0; z-index: 35; overflow: hidden; pointer-events: none; }
.confetti-piece { position: absolute; top: -20px; width: 10px; height: 17px; background: var(--pink); animation: fall 2.4s ease-in forwards; }

body.ending-chaos { --pink: #ff326e; --lime: #e6ff37; }
body.ending-kindness { --pink: #ec5799; --blue: #89e7ff; }
body.ending-suspicion { --pink: #974cff; --lime: #6dffba; }

@keyframes scene-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes flip { 50% { transform: rotateY(540deg) scale(1.2); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(18px); } }
@keyframes fall { to { transform: translate(var(--drift), 110vh) rotate(760deg); } }

@media (min-width: 700px) {
  #app { padding-top: 34px; }
  .card-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .story-nav { left: 50%; right: auto; width: min(620px, 100%); transform: translateX(-50%); border: 2px solid var(--ink); border-bottom: 0; border-radius: 16px 16px 0 0; }
}

@media (max-width: 370px) {
  .topbar strong { font-size: 17px; }
  #app { padding-inline: 10px; }
  .card { padding: 14px; }
  .button { padding-inline: 10px; }
  .party-lights { grid-template-columns: repeat(6, 1fr); gap-inline: 2px; }
}

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

