:root {
  --bg: #0d0a0b;
  --panel: #1b1416;
  --panel-2: #261b1e;
  --wood: #5a3a22;
  --gold: #f2c14e;
  --gold-dim: #a8832d;
  --red: #e5484d;
  --green: #46c46a;
  --ink: #f4ead8;
  --muted: #a4968a;
  --line: #3d2c2f;
  --px: "Press Start 2P", monospace;
  --vt: "VT323", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: var(--vt); font-size: 22px; line-height: 1.25; min-height: 100vh; }
[hidden] { display: none !important; }

/* CRT effect */
.crt { position: relative; max-width: 980px; margin: 0 auto; padding: 12px 16px 40px; min-height: 100vh; }
.crt::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 50;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,.18) 2px 3px);
}
.crt::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 51;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 60%, rgba(0,0,0,.55) 100%);
}

/* HUD */
.hud {
  display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center;
  background: var(--panel); border: 3px solid var(--gold-dim); padding: 8px 12px; margin-bottom: 10px;
  box-shadow: 0 4px 0 #000;
}
.logo { font-family: var(--px); font-size: 12px; color: var(--gold); margin-right: auto; }
.stat { display: flex; flex-direction: column; line-height: 1; }
.stat span { font-family: var(--px); font-size: 7px; color: var(--muted); margin-bottom: 4px; }
.stat b { font-family: var(--px); font-size: 10px; color: var(--ink); font-weight: normal; }
#hudScore { color: var(--gold); }
.icon-btn { font-family: var(--px); background: var(--panel-2); color: var(--gold); border: 2px solid var(--gold-dim); width: 34px; height: 30px; cursor: pointer; }
.icon-btn.off { color: var(--muted); text-decoration: line-through; }

/* Buttons */
.btn {
  font-family: var(--px); font-size: 11px; cursor: pointer; padding: 12px 16px; border: 3px solid #000;
  background: var(--panel-2); color: var(--ink); box-shadow: 0 4px 0 #000; position: relative; top: 0;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { top: 3px; box-shadow: 0 1px 0 #000; }
.btn.primary { background: var(--gold); color: #2a1a05; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); box-shadow: none; }
.btn.small { font-size: 8px; padding: 6px 8px; }
.btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

/* Start */
.title-card { text-align: center; padding: 26px 8px; }
.title-emblem { font-size: 56px; color: var(--gold); text-shadow: 4px 4px 0 #000; animation: bob 1.6s steps(2) infinite; }
h1 { font-family: var(--px); font-size: clamp(26px, 7vw, 52px); color: var(--gold); margin: 8px 0; text-shadow: 4px 4px 0 #6b1d1d, 8px 8px 0 #000; letter-spacing: 2px; }
.subtitle { font-family: var(--px); font-size: 11px; color: var(--ink); margin: 0 0 14px; }
.blink { font-family: var(--px); font-size: 9px; color: var(--red); animation: blink 1s steps(1) infinite; }
.start-form { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 22px auto; max-width: 360px; }
.start-form label { font-family: var(--px); font-size: 9px; color: var(--muted); }
.start-form input {
  width: 100%; font-family: var(--px); font-size: 13px; text-align: center; padding: 12px; color: var(--gold);
  background: #000; border: 3px solid var(--gold-dim); outline: none;
}
.start-form input:focus { border-color: var(--gold); }
.continue { display: flex; gap: 12px; justify-content: center; align-items: center; margin: 22px 0; flex-wrap: wrap; }
.howto, .leaderboard { text-align: left; max-width: 620px; margin: 22px auto 0; background: var(--panel); border: 3px solid var(--line); padding: 14px 18px; }
.howto h3, .leaderboard h3 { font-family: var(--px); font-size: 10px; color: var(--gold); margin: 0 0 10px; }
.howto p { margin: 6px 0; }
.howto b { color: var(--gold); font-weight: normal; }
.keys { color: var(--muted); font-size: 18px; }
.leaderboard ol { margin: 0; padding-left: 28px; }
.leaderboard li { padding: 2px 0; }
.leaderboard li .lb-score { color: var(--gold); float: right; }
.leaderboard li .lb-rank { color: var(--muted); font-size: 18px; }
.muted { color: var(--muted); list-style: none; margin-left: -28px; }

/* Court */
.case-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.case-tag { font-family: var(--px); font-size: 8px; background: #6b1d1d; color: var(--ink); padding: 6px 8px; border: 2px solid #000; }
.case-title { font-family: var(--px); font-size: 11px; color: var(--gold); line-height: 1.5; }
.stage { position: relative; border: 4px solid #000; box-shadow: 0 0 0 3px var(--gold-dim), 0 6px 0 3px #000; background: #000; }
#court { display: block; width: 100%; height: auto; image-rendering: pixelated; image-rendering: crisp-edges; }
.banner {
  position: absolute; left: 50%; top: 3.2%; transform: translateX(-50%); white-space: nowrap;
  font-family: var(--px); font-size: clamp(5px, 1.25vw, 11px); color: var(--gold); text-shadow: 1px 1px 0 #000; letter-spacing: 1px;
}
.plate {
  position: absolute; left: 53.125%; width: 22.5%; top: 89.4%; height: 6.7%; display: grid; place-items: center; overflow: hidden;
  font-family: var(--px); font-size: clamp(4px, 1.05vw, 10px); color: #2a1a05; white-space: nowrap;
}
.stamp {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%) rotate(-12deg);
  font-family: var(--px); font-size: clamp(14px, 4vw, 34px); padding: 10px 16px; border: 5px solid currentColor;
  background: rgba(0,0,0,.55); animation: stamp .35s cubic-bezier(.2,1.6,.4,1) both;
}
.stamp.ok { color: var(--green); }
.stamp.bad { color: var(--red); }

.dialog {
  position: relative; margin-top: 16px; background: #0a0809; border: 4px solid var(--ink); padding: 22px 16px 12px;
  min-height: 150px; box-shadow: inset 0 0 0 3px #000, 0 5px 0 #000; cursor: pointer; user-select: none;
}
.nameplate {
  position: absolute; top: -16px; left: 14px; font-family: var(--px); font-size: 10px; color: #2a1a05;
  background: var(--gold); padding: 6px 10px; border: 3px solid #000;
}
.nameplate.savci { background: var(--red); color: #fff; }
.nameplate.mudafi, .nameplate.vekil { background: var(--green); color: #04210d; }
.nameplate.kursu { background: #6aa6ff; color: #04152e; }
.nameplate.raportor { background: #c9b8ff; color: #1a0f3a; }
.dialog-text { margin: 0; font-size: 25px; min-height: 92px; white-space: pre-wrap; }
.dialog-ctrl { display: flex; justify-content: space-between; align-items: center; }
.ctrl-left { display: flex; gap: 8px; }
#autoBtn.on { color: #2a1a05; background: var(--gold); border-color: #000; }
.next-ind { font-family: var(--px); font-size: 12px; color: var(--gold); animation: blink .8s steps(1) infinite; }
.next-ind.hide { visibility: hidden; }

.decision { margin-top: 16px; }
.decision-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.decision h2 { font-family: var(--px); font-size: 12px; color: var(--gold); margin: 0; animation: blink 1.2s steps(1) 3; }
.options { display: grid; gap: 10px; }
.opt {
  display: grid; grid-template-columns: 44px 1fr; align-items: stretch; text-align: left; cursor: pointer;
  background: var(--panel); color: var(--ink); border: 3px solid var(--line); padding: 0; font-family: var(--vt); font-size: 22px;
  box-shadow: 0 4px 0 #000; position: relative; top: 0;
}
.opt .letter { display: grid; place-items: center; font-family: var(--px); font-size: 14px; background: var(--panel-2); color: var(--gold); border-right: 3px solid var(--line); }
.opt .txt { padding: 10px 12px; }
.opt:hover:not(:disabled), .opt:focus-visible { border-color: var(--gold); outline: none; }
.opt:hover:not(:disabled) .letter { background: var(--gold); color: #2a1a05; }
.opt:active:not(:disabled) { top: 3px; box-shadow: 0 1px 0 #000; }
.opt:disabled { cursor: default; opacity: .55; }
.opt.right { border-color: var(--green); opacity: 1; }
.opt.right .letter { background: var(--green); color: #04210d; }
.opt.wrong { border-color: var(--red); opacity: 1; }
.opt.wrong .letter { background: var(--red); color: #fff; }

.casefile { position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 30; display: grid; place-items: center; padding: 16px; }
.casefile-inner {
  position: relative; width: min(760px, 100%); max-height: 86vh; overflow: auto; background: #efe3c6; color: #2a1d10;
  border: 4px solid #000; padding: 18px 22px; box-shadow: 8px 8px 0 #000;
  background-image: repeating-linear-gradient(#efe3c6 0 27px, #d9c9a6 27px 28px);
}
.casefile h3 { font-family: var(--px); font-size: 12px; margin: 0 0 12px; color: #6b1d1d; }
.casefile h4 { font-family: var(--px); font-size: 9px; margin: 14px 0 4px; color: #6b1d1d; }
.casefile ul { margin: 0; padding-left: 22px; }
.casefile dl { display: grid; grid-template-columns: auto 1fr; gap: 0 12px; margin: 0; }
.casefile dt { font-weight: bold; }
.casefile dd { margin: 0; }
.close { position: absolute; right: 10px; top: 10px; font-family: var(--px); background: #6b1d1d; color: #fff; border: 2px solid #000; cursor: pointer; padding: 4px 7px; }

.verdict { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.78); display: grid; place-items: center; padding: 16px; animation: fade .25s both; }
.verdict-card {
  width: min(720px, 100%); max-height: 90vh; overflow: auto; background: var(--panel); border: 4px solid var(--gold);
  box-shadow: 8px 8px 0 #000; padding: 20px 22px; text-align: center;
}
.verdict-card h4 { font-family: var(--px); font-size: 9px; color: var(--muted); margin: 16px 0 6px; text-align: left; }
.verdict-big { font-family: var(--px); font-size: clamp(18px, 5vw, 30px); margin-bottom: 8px; }
.verdict-big.ok { color: var(--green); text-shadow: 3px 3px 0 #0b3d1a; }
.verdict-big.bad { color: var(--red); text-shadow: 3px 3px 0 #4a0b0d; }
.verdict-points { font-family: var(--px); font-size: 14px; color: var(--gold); }
.promo { font-family: var(--px); font-size: 10px; color: #2a1a05; background: var(--gold); display: inline-block; padding: 8px 10px; margin-top: 10px; animation: blink .5s steps(1) 6; }
.verdict-answer { text-align: left; margin: 0; padding: 10px 12px; border-left: 4px solid var(--green); background: #0f1a12; }
.verdict-reason { text-align: left; margin: 0; }
.source { display: block; margin: 16px 0; color: var(--gold); font-size: 20px; }
.endstats { font-size: 26px; margin: 18px auto; max-width: 520px; background: var(--panel); border: 3px solid var(--line); padding: 16px; text-align: left; }
.endstats b { color: var(--gold); font-weight: normal; }
#screenEnd .btn { margin: 8px; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 60; font-family: var(--px); font-size: 10px; background: var(--red); color: #fff; padding: 10px 14px; border: 3px solid #000; }

@keyframes blink { 50% { opacity: 0; } }
@keyframes bob { 50% { transform: translateY(-4px); } }
@keyframes stamp { from { transform: translate(-50%, -50%) rotate(-12deg) scale(3); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.shake { animation: shake .3s steps(3) 1; }
@keyframes shake { 33% { transform: translate(-4px, 2px); } 66% { transform: translate(4px, -2px); } }

@media (max-width: 600px) {
  body { font-size: 20px; }
  .dialog-text { font-size: 22px; min-height: 110px; }
  .stat span { font-size: 6px; }
  .stat b { font-size: 8px; }
  .logo { width: 100%; }
  .opt { grid-template-columns: 36px 1fr; font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
}
