:root {
  --bg: #06070b; --ink: #e8ecff; --dim: #7a82a6; --line: #1f2540;
  --h: #ff4d3d; --r: #3df0d0; --acc: #9b8cff;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --disp: 'Unbounded', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--mono); overflow: hidden; touch-action: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

.scan { pointer-events: none; position: fixed; inset: 0; z-index: 50;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 3px); mix-blend-mode: overlay; }
#vignette { pointer-events: none; position: fixed; inset: 0; z-index: 5; transition: box-shadow .3s; }
#vignette.seen { animation: seen 0.8s infinite; }
#vignette.see { box-shadow: inset 0 0 140px rgba(155,140,255,.45); }
@keyframes seen { 0%,100% { box-shadow: inset 0 0 90px rgba(255,40,40,.35);} 50% { box-shadow: inset 0 0 170px rgba(255,40,40,.7);} }

.screen { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(6,7,11,.82); backdrop-filter: blur(4px); padding: 16px; overflow: auto; }
.card { width: min(560px, 100%); border: 1px solid var(--line); background: linear-gradient(180deg, #0c0f1a, #080a12); padding: 28px; border-radius: 4px; box-shadow: 0 0 0 1px #000, 0 30px 80px rgba(0,0,0,.6); }
.card.wide { width: min(860px, 100%); }
h1, h2 { font-family: var(--disp); margin: 0 0 8px; letter-spacing: .02em; }
h1 { font-size: clamp(34px, 8vw, 58px); font-weight: 900; }
h2 { font-size: clamp(22px, 4vw, 34px); }
.tag { color: var(--acc); margin: 0 0 18px; }
.rules { padding-left: 20px; line-height: 1.6; color: #c3c8e4; margin: 0 0 22px; }
.c-h { color: var(--h); } .c-r { color: var(--r); }
.small { color: var(--dim); font-size: 12px; }

.btn { font: 700 14px var(--mono); color: var(--ink); background: #141a2e; border: 1px solid #2b3459; padding: 11px 16px; border-radius: 3px; cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { border-color: var(--acc); }
.btn.primary { background: var(--ink); color: #05060a; border-color: var(--ink); width: 100%; font-family: var(--disp); font-size: 15px; padding: 14px; }
.btn.primary:hover { background: #fff; box-shadow: 0 0 24px rgba(155,140,255,.5); }
.btn.ghost { background: transparent; border-style: dashed; width: 100%; margin: 6px 0 12px; }
.btn:disabled { opacity: .45; cursor: default; }
.join { display: flex; gap: 8px; margin: 12px 0; }
input { font: 700 15px var(--mono); background: #05060a; color: var(--ink); border: 1px solid #2b3459; padding: 10px 12px; border-radius: 3px; flex: 1; min-width: 0; text-transform: uppercase; }
.opts { border: 1px solid var(--line); padding: 12px 14px; margin: 0 0 12px; display: grid; gap: 10px; }
.opt { display: grid; gap: 6px; font-size: 13px; color: #c3c8e4; cursor: pointer; }
.opt b { color: var(--acc); }
.opt input[type=range] { padding: 0; accent-color: var(--acc); }
.opt.check { grid-template-columns: auto 1fr; align-items: center; gap: 10px; }
.opt.check input { flex: none; width: 18px; height: 18px; padding: 0; accent-color: var(--acc); }
.code { font: 900 54px var(--disp); letter-spacing: .15em; color: var(--acc); margin-bottom: 8px; }
.linkRow { display: flex; gap: 8px; } .linkRow input { text-transform: none; font-size: 12px; }
.pulse { animation: pulse 1.4s infinite; color: var(--dim); } @keyframes pulse { 50% { opacity: .35; } }

.glitch { position: relative; }
.glitch::before, .glitch::after { content: attr(data-text); position: absolute; inset: 0; mix-blend-mode: screen; }
.glitch::before { color: var(--h); transform: translate(-3px, 0); animation: g1 3s infinite steps(1); opacity: .8; }
.glitch::after { color: var(--r); transform: translate(3px, 0); animation: g2 2.3s infinite steps(1); opacity: .8; }
@keyframes g1 { 0%,92% { clip-path: inset(0 0 0 0); transform: translate(-3px,0);} 93% { clip-path: inset(20% 0 50% 0); transform: translate(-10px,0);} 96% { clip-path: inset(60% 0 10% 0); transform: translate(6px,0);} }
@keyframes g2 { 0%,88% { clip-path: inset(0 0 0 0); transform: translate(3px,0);} 90% { clip-path: inset(40% 0 30% 0); transform: translate(12px,0);} 95% { clip-path: inset(5% 0 80% 0); transform: translate(-6px,0);} }

#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#hud .top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 10px 16px; gap: 12px; }
#roleLbl { font: 700 13px var(--disp); letter-spacing: .05em; }
#timer { font: 900 30px var(--disp); font-variant-numeric: tabular-nums; }
#timer.low { color: var(--h); }
.energy { justify-self: end; display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--dim); }
.energy .bar { width: 140px; height: 8px; background: #121628; border: 1px solid #2b3459; }
.energy .bar i { display: block; height: 100%; width: 50%; background: linear-gradient(90deg, var(--acc), #d8d2ff); box-shadow: 0 0 10px var(--acc); transition: width .1s; }
.energy b { color: var(--ink); width: 26px; text-align: right; }
#goal { text-align: center; color: var(--dim); font-size: 12px; margin-top: -4px; }
.abils { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; pointer-events: auto; }
.ab { position: relative; overflow: hidden; width: 168px; text-align: left; font-family: var(--mono); color: var(--ink); background: rgba(12,15,26,.9); border: 1px solid #2b3459; padding: 8px 10px 8px 38px; border-radius: 3px; cursor: pointer; }
.ab kbd { position: absolute; left: 9px; top: 9px; font: 700 13px var(--mono); border: 1px solid #3a4470; padding: 1px 6px; border-radius: 2px; }
.ab b { display: block; font-size: 13px; } .ab small { color: var(--dim); font-size: 10px; }
.ab i { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--acc); box-shadow: 0 0 8px var(--acc); }
.ab.off { opacity: .4; } .ab.on { border-color: var(--acc); box-shadow: 0 0 16px rgba(155,140,255,.35); }
@media (max-width: 620px) { .ab { width: 31vw; padding-left: 10px; } .ab kbd { display: none; } .ab small { display: none; } .energy .bar { width: 70px; } #timer { font-size: 22px; } }

#banner { position: fixed; inset: 0; z-index: 15; display: grid; place-items: center; text-align: center; pointer-events: none; font: 900 clamp(30px, 7vw, 72px) var(--disp); text-shadow: 0 0 30px currentColor; }
#banner small { display: block; font: 400 15px var(--mono); color: var(--dim); text-shadow: none; margin-top: 10px; }
#alert { position: fixed; top: 84px; left: 50%; transform: translateX(-50%); z-index: 15; font: 700 13px var(--disp); letter-spacing: .15em; padding: 6px 14px; pointer-events: none; }
#alert.seen { color: #fff; background: rgba(255,40,40,.75); animation: pulse .6s infinite; }
#alert.info { color: #05060a; background: var(--acc); }

#replay { width: 100%; aspect-ratio: 23/15; display: block; margin: 12px 0 8px; background: #05060a; border: 1px solid var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 11px; color: var(--dim); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.dot.h { background: var(--h); } .dot.r { background: var(--r); }
.ring.h { border: 2px dashed var(--h); } .ring.r { border: 2px dashed var(--r); }
.ctrl { display: flex; align-items: center; gap: 10px; margin: 10px 0 0; }
.ctrl input { flex: 1; padding: 0; accent-color: var(--acc); }
#rpTime { font-variant-numeric: tabular-nums; width: 44px; }
#final { border: 1px solid var(--line); padding: 14px; margin-bottom: 12px; line-height: 1.7; }
#final .win { font: 900 22px var(--disp); }

/* 8-біт режим: піксельний шрифт, без заокруглень і світіння */
body.pixel { --disp: 'Press Start 2P', monospace; }
body.pixel .card, body.pixel .btn, body.pixel .ab, body.pixel input { border-radius: 0; }
body.pixel .card { box-shadow: 0 0 0 4px #000, 0 0 0 6px #2038ec; }
body.pixel #timer { font-size: 22px; }
body.pixel #roleLbl, body.pixel #alert { font-size: 10px; line-height: 1.6; }
body.pixel .ab b { font: 9px var(--disp); margin-bottom: 4px; }
body.pixel .energy .bar i, body.pixel .ab i { box-shadow: none; }
body.pixel #banner { text-shadow: 4px 4px 0 #000; font-size: clamp(18px, 4.5vw, 44px); line-height: 1.4; }
body.pixel .code { font-size: 34px; }
