:root {
  --bg: #09090c;
  --panel: rgba(18, 18, 24, .92);
  --text: #f8f8f2;
  --muted: #9898a8;
  --red: #ff2a3d;
  --yellow: #ffd84a;
  --green: #43ff9b;
  --cyan: #58d9ff;
  --purple: #bd7cff;
  --shadow: 0 24px 80px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; overflow-x: hidden; }
body { min-height: 100vh; }
button { font: inherit; }

#noise {
  position: fixed; inset: 0; pointer-events: none; opacity: .14; z-index: 9998;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

#flash { position: fixed; inset: 0; pointer-events: none; z-index: 9997; opacity: 0; background: white; }
#fx-layer { position: fixed; inset: 0; z-index: 3000; pointer-events: none; overflow: hidden; }

.topbar {
  position: relative; z-index: 100; display: flex; justify-content: space-between; align-items: center;
  padding: 18px 24px; border-bottom: 1px solid rgba(255,255,255,.08); backdrop-filter: blur(16px);
  background: rgba(7,7,10,.66);
}
.logo { border: 0; background: transparent; color: white; font-weight: 1000; letter-spacing: -.05em; font-size: clamp(18px, 3vw, 30px); cursor: pointer; padding: 0; }
.blink { color: var(--red); animation: blink .8s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.hud { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.hud-card, .tiny-btn {
  min-width: 76px; border: 1px solid rgba(255,255,255,.10); background: rgba(255,255,255,.045); color: white;
  border-radius: 10px; padding: 8px 10px;
}
.hud-card span { display: block; color: var(--muted); font-size: 9px; letter-spacing: .15em; }
.hud-card b { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; }
.tiny-btn { cursor: pointer; font-size: 10px; font-weight: 900; letter-spacing: .08em; }
.tiny-btn:hover { border-color: rgba(255,255,255,.3); transform: translateY(-1px); }

.stage {
  min-height: calc(100vh - 128px); position: relative; display: grid; place-items: center; padding: 86px 20px 70px;
  background:
    radial-gradient(circle at 50% 45%, rgba(255,42,61,.12), transparent 25%),
    radial-gradient(circle at 12% 22%, rgba(88,217,255,.05), transparent 24%),
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: auto, auto, 32px 32px, 32px 32px;
}

.ticker { position: absolute; top: 18px; left: 0; right: 0; overflow: hidden; white-space: nowrap; color: var(--yellow); font: 800 11px ui-monospace, monospace; letter-spacing: .1em; }
.ticker span { display: inline-block; padding-left: 100%; animation: ticker 17s linear infinite; }
@keyframes ticker { to { transform: translateX(-100%); } }

.hero { width: min(760px, 95vw); text-align: center; position: relative; z-index: 4; }
.eyebrow { font: 900 11px ui-monospace, monospace; color: var(--red); letter-spacing: .22em; margin: 0 0 16px; }
h1 { font-size: clamp(44px, 9vw, 104px); line-height: .86; letter-spacing: -.075em; margin: 0; font-weight: 1000; text-transform: uppercase; }
h1 span { color: transparent; -webkit-text-stroke: 2px var(--text); }
#subtitle { color: var(--muted); font-size: clamp(14px, 2vw, 18px); margin: 20px auto 26px; max-width: 530px; }

.button-zone { width: 300px; height: 300px; position: relative; margin: 14px auto 18px; display: grid; place-items: center; }
.warning-ring { position: absolute; width: 250px; height: 250px; border-radius: 50%; border: 1px dashed rgba(255,42,61,.3); animation: spin 18s linear infinite; pointer-events: none; }
.warning-ring::after { content: "NO WARRANTY • BAD IDEA • NO WARRANTY • BAD IDEA •"; position: absolute; inset: -30px; color: rgba(255,255,255,.25); font: 700 8px monospace; letter-spacing: .3em; }
@keyframes spin { to { transform: rotate(360deg); } }
.chaos-button {
  width: 174px; height: 174px; border-radius: 50%; border: 9px solid #4e0711; position: relative; z-index: 3;
  background: radial-gradient(circle at 40% 30%, #ff6b76, #f5142a 45%, #a70818 78%); color: white;
  box-shadow: 0 16px 0 #5d0711, 0 30px 55px rgba(255,25,45,.25), inset 0 4px 5px rgba(255,255,255,.3);
  cursor: pointer; font-weight: 1000; font-size: 17px; letter-spacing: -.03em; text-shadow: 0 2px 2px #73000c;
  transition: transform .08s ease, box-shadow .08s ease, left .15s ease, top .15s ease;
  touch-action: manipulation;
}
.chaos-button:hover { transform: translateY(-2px) scale(1.02); }
.chaos-button:active { transform: translateY(11px) scale(.98); box-shadow: 0 5px 0 #5d0711, 0 15px 25px rgba(255,25,45,.2); }
.button-glare { position: absolute; width: 56%; height: 32%; border-radius: 50%; left: 21%; top: 11%; background: linear-gradient(rgba(255,255,255,.45), transparent); filter: blur(1px); }

.sanity-wrap { max-width: 430px; margin: 0 auto; }
.sanity-label { display: flex; justify-content: space-between; font: 800 10px ui-monospace, monospace; color: var(--muted); margin-bottom: 7px; }
.sanity-track { height: 8px; background: rgba(255,255,255,.07); overflow: hidden; border-radius: 999px; }
.sanity-bar { height: 100%; width: 100%; background: linear-gradient(90deg, var(--green), var(--yellow), var(--red)); transform-origin: left; transition: width .25s ease; }
.hint { color: #5f5f6d; font: 11px ui-monospace, monospace; margin-top: 18px; }

.floating-note { position: absolute; color: rgba(255,255,255,.18); font: 700 11px ui-monospace, monospace; transform: rotate(-8deg); }
.note-a { left: 5vw; top: 30%; }
.note-b { right: 4vw; top: 60%; transform: rotate(7deg); }
.note-c { left: 14vw; bottom: 13%; transform: rotate(3deg); }

.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 92vw); background: var(--panel); backdrop-filter: blur(22px); border-left: 1px solid rgba(255,255,255,.1); z-index: 5000; padding: 24px; transform: translateX(105%); transition: transform .25s ease; box-shadow: var(--shadow); overflow: auto; }
.panel.open { transform: translateX(0); }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; }
.panel h2 { margin: -8px 0 20px; font-size: 34px; letter-spacing: -.05em; }
.close-btn { border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.05); color: white; width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 22px; }
.achievement-list { display: grid; gap: 10px; }
.achievement { border: 1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.035); padding: 13px; border-radius: 14px; display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: center; }
.achievement.locked { opacity: .35; filter: grayscale(1); }
.achievement-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: rgba(255,255,255,.08); font-size: 23px; }
.achievement strong { display: block; font-size: 13px; }
.achievement small { color: var(--muted); }
.danger-small { width: 100%; margin-top: 20px; border: 1px solid rgba(255,42,61,.45); color: #ff7180; background: rgba(255,42,61,.08); border-radius: 10px; padding: 12px; cursor: pointer; font-weight: 900; }

.modal { position: fixed; inset: 0; z-index: 6000; display: grid; place-items: center; background: rgba(0,0,0,.68); backdrop-filter: blur(8px); padding: 20px; }
.modal.hidden { display: none; }
.modal-card { width: min(620px, 94vw); max-height: 85vh; overflow: auto; background: #121218; border: 1px solid rgba(255,255,255,.12); border-radius: 18px; box-shadow: var(--shadow); padding: 28px; position: relative; }
.modal-x { position: absolute; top: 12px; right: 12px; }
.modal h2 { font-size: clamp(26px, 6vw, 48px); line-height: .95; letter-spacing: -.05em; margin: 0 0 12px; }
.modal p { color: #b0b0bc; line-height: 1.6; }
.modal .action-btn { border: 0; background: white; color: #0b0b0e; font-weight: 1000; padding: 12px 18px; border-radius: 10px; cursor: pointer; }
.modal input { width: 100%; padding: 13px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,.15); background: #09090d; color: white; font-size: 17px; outline: none; }

footer { min-height: 56px; padding: 18px 22px; display: flex; gap: 9px; align-items: center; justify-content: center; color: #565663; font: 10px ui-monospace, monospace; border-top: 1px solid rgba(255,255,255,.06); }
.link-btn { border: 0; color: #818190; background: transparent; text-decoration: underline; cursor: pointer; font: inherit; }

.chaos-img { position: fixed; z-index: 3500; pointer-events: none; user-select: none; object-fit: contain; filter: drop-shadow(0 16px 24px rgba(0,0,0,.35)); }
.fall { animation: fall var(--dur, 3s) linear forwards; }
@keyframes fall { from { transform: translateY(-40vh) rotate(var(--r1)); } to { transform: translateY(145vh) rotate(var(--r2)); } }
.fly { animation: fly var(--dur, 4s) cubic-bezier(.25,.6,.2,1) forwards; }
@keyframes fly { from { transform: translate(-30vw, 15vh) rotate(-12deg); } to { transform: translate(145vw, -40vh) rotate(18deg); } }
.pop { animation: pop .9s cubic-bezier(.1,.9,.1,1) forwards; }
@keyframes pop { 0% { transform: scale(0) rotate(-18deg); opacity: 0; } 55% { transform: scale(1.15) rotate(4deg); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }

.toast { background: rgba(17,17,22,.94); border: 1px solid rgba(255,255,255,.12); box-shadow: 0 14px 45px rgba(0,0,0,.38); color: white; padding: 11px 14px; border-radius: 12px; font-size: 12px; animation: toastIn .3s ease; }
#toast-stack { position: fixed; top: 88px; right: 18px; z-index: 8000; display: grid; gap: 8px; width: min(330px, calc(100vw - 36px)); }
@keyframes toastIn { from { opacity: 0; transform: translateX(18px); } }

.shake { animation: shake .42s linear; }
@keyframes shake { 0%,100%{transform:translate(0)} 15%{transform:translate(-8px,4px)} 30%{transform:translate(7px,-5px)} 45%{transform:translate(-5px,-3px)} 60%{transform:translate(8px,3px)} 75%{transform:translate(-3px,5px)} }
.invert { filter: invert(1) hue-rotate(180deg); }
.rotate-world { animation: worldRotate 2.4s ease-in-out; }
@keyframes worldRotate { 35%,65% { transform: rotate(180deg) scale(.82); } }
.disco { animation: disco 2s linear; }
@keyframes disco { 0%{filter:hue-rotate(0deg)} 100%{filter:hue-rotate(720deg)} }
.pixel { image-rendering: pixelated; font-family: ui-monospace, monospace !important; }

.fake-error { font-family: ui-monospace, monospace; text-align: left; }
.fake-error .error-title { color: #ff6574; font-weight: 900; }
.fake-error pre { white-space: pre-wrap; color: #8f8f9c; background: #08080b; padding: 14px; border-radius: 10px; border: 1px solid #262630; }

.target { position: fixed; z-index: 7000; width: 74px; height: 74px; border-radius: 50%; border: 6px solid white; background: var(--red); color: white; font-size: 26px; font-weight: 1000; cursor: crosshair; box-shadow: 0 0 0 8px rgba(255,42,61,.2); }
.clone-button { position: fixed; z-index: 7000; padding: 16px 20px; border: 2px solid #550813; background: #e41f34; color: white; border-radius: 999px; font-weight: 1000; cursor: pointer; box-shadow: 0 7px 0 #660916; }
.clone-button.fake { filter: saturate(.6); }

.boss-bar { margin: 18px 0 8px; background: #08080b; border: 1px solid #292932; height: 18px; border-radius: 999px; overflow: hidden; }
.boss-bar > div { height: 100%; width: 100%; background: var(--red); transition: width .12s linear; }

.credits-grid { display: grid; gap: 10px; }
.credit { background: #0b0b10; border: 1px solid #24242d; border-radius: 12px; padding: 12px; }
.credit b { display: block; margin-bottom: 4px; }
.credit a { color: var(--cyan); }

@media (max-width: 720px) {
  .topbar { align-items: flex-start; gap: 12px; flex-direction: column; }
  .hud { justify-content: flex-start; }
  .stage { min-height: calc(100vh - 180px); padding-top: 70px; }
  .button-zone { width: 260px; height: 260px; }
  .chaos-button { width: 150px; height: 150px; }
  .warning-ring { width: 215px; height: 215px; }
  .floating-note { display: none; }
}
