:root {
  --bg: #0b0d12;
  --bg-2: #12151d;
  --panel: #171b26;
  --line: #262c3b;
  --text: #e8ecf4;
  --muted: #8a93a8;
  --accent: #39ff88;
  --danger: #ff4d6d;
  --warn: #ffc94d;
  --safe: #4dd2ff;
  --pixel: "Press Start 2P", ui-monospace, monospace;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(57, 255, 136, 0.07), transparent 60%),
    var(--bg);
}

a { color: var(--accent); }

button { font: inherit; color: inherit; }

.hidden { display: none !important; }

/* Header */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 10px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.brand { display: flex; align-items: center; gap: 14px; }
.lock { font-size: 34px; filter: drop-shadow(0 0 12px rgba(57, 255, 136, 0.5)); }

h1 {
  font-family: var(--pixel);
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
  letter-spacing: 1px;
  color: var(--muted);
}
h1 span { color: var(--text); font-size: 16px; text-shadow: 3px 3px 0 #000, 0 0 18px rgba(57, 255, 136, 0.35); }

.top-actions { display: flex; gap: 8px; }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 8px;
  background: var(--panel);
  border: 2px solid var(--line);
  cursor: pointer;
  font-family: var(--pixel);
  font-size: 14px;
  display: grid; place-items: center;
}
.icon-btn:hover { border-color: var(--accent); }

/* Algorithm chips */
.algos {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 20px 12px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  scrollbar-width: thin;
}

.chip {
  flex: 0 0 auto;
  border: 2px solid var(--line);
  background: var(--bg-2);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  display: inline-flex; align-items: center; gap: 8px;
  transition: transform 0.08s ease, border-color 0.15s ease;
}
.chip:hover { transform: translateY(-1px); border-color: #3a4256; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip.active { border-color: var(--text); background: var(--panel); }
.chip.done { opacity: 0.6; text-decoration: line-through; }

/* Stage */
.stage-wrap {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
  flex: 1;
}

.stage {
  position: relative;
  border: 2px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px) 0 0 / 24px 24px,
    #090b10;
  height: min(58vh, 560px);
  min-height: 320px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.stage.shake { animation: shake 0.25s linear; }

canvas { display: block; width: 100%; height: 100%; cursor: none; }

.hud {
  position: absolute; inset: 12px 14px auto 14px;
  display: flex; justify-content: space-between; align-items: flex-start;
  pointer-events: none;
  font-family: var(--pixel);
  font-size: 10px;
}
.hud-left { display: flex; align-items: center; gap: 10px; }
.hud-right { text-align: right; line-height: 2; }
.hud-label { color: var(--muted); }
.bar { width: 140px; height: 10px; background: #1d2230; border: 2px solid #000; }
.bar-fill { height: 100%; width: 100%; background: var(--accent); transition: width 0.12s linear, background 0.3s; }

.hint {
  position: absolute; left: 0; right: 0; bottom: 12px;
  text-align: center;
  font-family: var(--pixel);
  font-size: 9px;
  color: var(--muted);
  pointer-events: none;
  opacity: 0.8;
  transition: opacity 0.4s;
}

.toast-zone {
  position: absolute; left: 50%; bottom: 38px;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none;
  width: min(92%, 640px);
}
.toast {
  background: rgba(10, 12, 18, 0.92);
  border: 2px solid var(--line);
  border-left: 4px solid var(--warn);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
  animation: toastIn 0.18s ease-out;
  text-align: center;
}
.toast.bad { border-left-color: var(--danger); }
.toast.good { border-left-color: var(--accent); }

/* Verdict */
.verdict {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  padding: 24px;
  background: rgba(5, 6, 9, 0.72);
  backdrop-filter: blur(2px);
  text-align: center;
  animation: fadeIn 0.3s ease-out;
}
.stamp {
  font-family: var(--pixel);
  font-size: clamp(26px, 6vw, 54px);
  color: var(--danger);
  border: 6px solid currentColor;
  padding: 12px 22px;
  transform: rotate(-6deg);
  text-shadow: 4px 4px 0 #000;
  box-shadow: 4px 4px 0 #000;
  animation: stamp 0.35s cubic-bezier(.2,1.6,.4,1);
}
.stamp.safe { color: var(--safe); }
.verdict-title { font-family: var(--pixel); font-size: 12px; line-height: 1.7; margin-top: 8px; }
.verdict-body { max-width: 560px; margin: 0; color: #c9d0dd; line-height: 1.55; font-size: 14px; }
.verdict-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.btn {
  font-family: var(--pixel);
  font-size: 10px;
  padding: 12px 14px;
  border: 2px solid var(--text);
  background: var(--panel);
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  box-shadow: 3px 3px 0 #000;
}
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }
.btn.primary { background: var(--accent); color: #04130a; border-color: var(--accent); }
.btn.ghost { border-color: var(--line); }

/* Weapons */
.weapons {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 12px 0;
}
.weapon {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 10px 8px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  position: relative;
  transition: transform 0.08s ease, border-color 0.15s;
}
.weapon:hover { transform: translateY(-2px); }
.weapon.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(57,255,136,0.2), 0 6px 22px rgba(57,255,136,0.12); }
.weapon .emoji { font-size: 28px; line-height: 1; }
.weapon .name { font-family: var(--pixel); font-size: 8px; line-height: 1.5; text-align: center; }
.weapon .key {
  position: absolute; top: 6px; left: 8px;
  font-family: var(--pixel); font-size: 8px; color: var(--muted);
}
.weapon .eff {
  font-size: 10px; color: var(--muted);
}
.eff.hi { color: var(--danger); }
.eff.mid { color: var(--warn); }
.eff.lo { color: var(--muted); }

/* Dossier */
.dossier {
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 20px;
}
.dossier-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.kicker { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.dossier h2 { font-family: var(--pixel); font-size: 18px; margin: 8px 0 0; }
.status {
  font-family: var(--pixel); font-size: 9px;
  padding: 8px 10px; border-radius: 6px; border: 2px solid currentColor;
  line-height: 1.4;
}
.status.broken { color: var(--danger); }
.status.weak { color: var(--warn); }
.status.safe { color: var(--safe); }
.status.dead { color: #b07cff; }
.dossier-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
  margin-top: 14px;
}
.k { font-size: 10px; color: var(--muted); letter-spacing: 1px; margin-bottom: 4px; }
.v { font-size: 14px; line-height: 1.45; }
.threat { margin: 14px 0 0; color: #c9d0dd; line-height: 1.6; font-size: 14px; }

/* About */
.about {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,0.7);
  display: grid; place-items: center;
  padding: 16px;
}
.about-card {
  position: relative;
  max-width: 640px; width: 100%;
  max-height: 88vh; overflow: auto;
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 22px 24px;
  line-height: 1.6;
  font-size: 14px;
}
.about-card h2 { font-family: var(--pixel); font-size: 14px; margin-top: 0; }
.about-card h3 { font-family: var(--pixel); font-size: 10px; color: var(--accent); margin-top: 22px; }
.about-card ul { padding-left: 18px; }
.about-card li { margin-bottom: 6px; }
.about-card .fine { color: var(--muted); font-size: 12px; }
.close { position: absolute; top: 12px; right: 12px; }

/* Footer */
.foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  max-width: 1200px; width: 100%; margin: 0 auto;
  padding: 8px 20px 24px;
  color: var(--muted); font-size: 12px;
}

/* Animations */
@keyframes shake {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-4px, 2px); }
  40% { transform: translate(4px, -2px); }
  60% { transform: translate(-3px, -1px); }
  80% { transform: translate(2px, 2px); }
  100% { transform: translate(0, 0); }
}
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes stamp { from { transform: rotate(-6deg) scale(2.2); opacity: 0; } to { transform: rotate(-6deg) scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .stage.shake, .stamp, .toast { animation: none; }
}

/* Mobile */
@media (max-width: 760px) {
  .top, .algos, .stage-wrap, .foot { padding-left: 16px; padding-right: 16px; }
  h1 { font-size: 10px; }
  h1 span { font-size: 12px; }
  .lock { font-size: 26px; }
  .stage { height: 46vh; min-height: 280px; }
  .weapons { grid-template-columns: repeat(3, 1fr); }
  .dossier-grid { grid-template-columns: 1fr; }
  .bar { width: 90px; }
  .hint { font-size: 7px; }
  .weapon .eff { display: none; }
}
