:root {
  --bg: #0a0000;
  --red: #c41e3a;
  --dark-red: #5c0a14;
  --gold: #ffd700;
  --text: #f0e6e6;
  --glitch: #ff0033;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  cursor: default;
}

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.hidden { display: none !important; }

/* ===== MENU ===== */
#menu {
  background: radial-gradient(ellipse at center, #1a0508 0%, #050000 70%);
}

.menu-box {
  max-width: 480px;
  width: 92%;
  padding: 2rem;
  background: rgba(20, 0, 5, 0.85);
  border: 1px solid var(--dark-red);
  box-shadow: 0 0 40px rgba(196, 30, 58, 0.3);
  text-align: center;
}

h1.glitch {
  font-size: 3.2rem;
  letter-spacing: 0.15em;
  color: var(--red);
  position: relative;
  text-shadow: 2px 0 #0ff, -2px 0 #f0f;
  animation: glitch 2.5s infinite;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  overflow: hidden;
}
.glitch::before {
  color: #0ff;
  animation: glitch-1 1.2s infinite linear alternate-reverse;
  clip-path: polygon(0 0, 100% 0, 100% 35%, 0 35%);
}
.glitch::after {
  color: #f0f;
  animation: glitch-2 1.5s infinite linear alternate-reverse;
  clip-path: polygon(0 65%, 100% 65%, 100% 100%, 0 100%);
}

@keyframes glitch {
  0%, 90%, 100% { transform: none; }
  92% { transform: translate(2px, -1px); }
  94% { transform: translate(-2px, 1px); }
  96% { transform: translate(1px, 2px); }
}

@keyframes glitch-1 {
  0% { transform: translate(0); }
  20% { transform: translate(-3px, 1px); }
  40% { transform: translate(3px, -1px); }
  60% { transform: translate(-1px, -2px); }
  80% { transform: translate(2px, 2px); }
  100% { transform: translate(0); }
}
@keyframes glitch-2 {
  0% { transform: translate(0); }
  25% { transform: translate(3px, 0); }
  50% { transform: translate(-3px, 1px); }
  75% { transform: translate(1px, -1px); }
  100% { transform: translate(0); }
}

.subtitle {
  color: #888;
  margin: 0.3rem 0 1.2rem;
  letter-spacing: 0.3em;
  font-size: 0.85rem;
}

.desc {
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1.5rem;
  color: #ccc;
}

.config {
  display: grid;
  gap: 0.6rem;
  text-align: left;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}
.config label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.config input[type="number"] {
  width: 80px;
  background: #1a0005;
  border: 1px solid var(--dark-red);
  color: var(--gold);
  padding: 0.3rem 0.5rem;
  text-align: right;
}
.config input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--red);
}

.btn {
  display: inline-block;
  padding: 0.7rem 1.6rem;
  margin: 0.3rem;
  background: transparent;
  border: 1px solid var(--red);
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.05em;
}
.btn:hover {
  background: var(--red);
  color: #fff;
  box-shadow: 0 0 15px rgba(196, 30, 58, 0.6);
}
.btn.primary {
  background: var(--red);
  color: #fff;
  font-weight: 600;
}
.btn.primary:hover {
  background: #e02545;
}
.btn.small {
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
}

.credits {
  margin-top: 1.5rem;
  font-size: 0.7rem;
  color: #555;
  line-height: 1.4;
}

/* ===== GAME ===== */
#game {
  background:
    radial-gradient(ellipse at 50% 30%, #1a0508 0%, #050000 55%),
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(80,0,10,0.04) 2px, rgba(80,0,10,0.04) 4px);
  cursor: crosshair;
}

#wait-hint {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 15;
  pointer-events: none;
  max-width: 90vw;
}
#wait-hint h2 {
  color: #c41e3a;
  font-size: 1.6rem;
  letter-spacing: 0.12em;
  margin-bottom: 0.8rem;
  text-shadow: 0 0 20px rgba(196,30,58,0.5);
}
#wait-hint p {
  color: #888;
  font-size: 0.95rem;
  line-height: 1.5;
}
#wait-hint .pulse {
  display: inline-block;
  margin-top: 1.2rem;
  color: #666;
  font-size: 0.8rem;
  animation: wait-pulse 1.5s ease-in-out infinite;
}
@keyframes wait-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}
#wait-hint.hidden { display: none !important; }

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 0.8rem 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0,0,0,0.7);
  z-index: 50;
  font-size: 0.9rem;
  border-bottom: 1px solid #300;
}

#status { color: #aaa; }
#gold-display { color: var(--gold); font-weight: bold; font-size: 1.1rem; }

/* Coins */
#coins-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

.coin {
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ffe566, #c9a000 60%, #8a7000);
  border: 2px solid #ffec8b;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.7), inset 0 0 8px rgba(255,255,200,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: bold;
  color: #3a2a00;
  cursor: grab;
  pointer-events: auto;
  z-index: 25;
  transition: transform 0.1s;
  touch-action: none;
}
.coin:active { cursor: grabbing; transform: scale(1.1); }
.coin.gold1 { --v: 10; }
.coin.gold2 { --v: 50; width: 52px; height: 52px; }
.coin.gold3 { --v: 100; width: 56px; height: 56px; box-shadow: 0 0 16px rgba(255,215,0,0.9); }
.coin.gold4 { --v: 150; width: 58px; height: 58px; }
.coin.gold5 { --v: 200; width: 60px; height: 60px; }
.coin.gold6 { /* honeypot */
  width: 64px; height: 64px;
  background: radial-gradient(circle at 30% 30%, #fff0a0, #ffaa00 50%, #cc7700);
  box-shadow: 0 0 25px rgba(255, 180, 0, 1);
  animation: pulse-gold 1.2s infinite;
}
.coin.crucifix {
  width: 56px; height: 56px;
  border-radius: 8px;
  background: linear-gradient(135deg, #ddd, #888);
  border: 2px solid #fff;
  color: #111;
  font-size: 1.6rem;
  box-shadow: 0 0 20px rgba(255,255,255,0.6);
}

@keyframes pulse-gold {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* Ransom Overlay */
#ransom-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}

#ransom-overlay.active {
  pointer-events: auto;
}

.face {
  position: absolute;
  width: 180px;
  height: 180px;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 110;
}
.face.show { opacity: 1; animation: face-appear 0.3s ease; }

.pixel-face {
  width: 100%;
  height: 100%;
  background: #111;
  image-rendering: pixelated;
  position: relative;
  border: 3px solid #333;
  box-shadow: 0 0 30px #000, 0 0 60px rgba(100,0,0,0.5);
  filter: contrast(1.4) brightness(0.9);
}
.pixel-face::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0,0,0,0.3) 3px, rgba(0,0,0,0.3) 6px),
    repeating-linear-gradient(90deg, transparent, transparent 3px, rgba(0,0,0,0.2) 3px, rgba(0,0,0,0.2) 6px);
  pointer-events: none;
}

.eye {
  position: absolute;
  width: 28px;
  height: 28px;
  background: #000;
  border: 2px solid #222;
  top: 42px;
}
.eye.left { left: 38px; }
.eye.right { right: 38px; }
.eye::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  background: #400;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
}

.mouth {
  position: absolute;
  bottom: 38px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 12px;
  background: #000;
  border: 2px solid #222;
  clip-path: polygon(0 0, 100% 0, 90% 100%, 10% 100%);
}

@keyframes face-appear {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; filter: blur(8px); }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; filter: blur(0); }
}

.stop-sign {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 220px;
  height: 220px;
  background: #c00;
  clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
  border: 8px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 120;
  box-shadow: 0 0 40px #f00, 0 0 80px rgba(255,0,0,0.5);
  transition: transform 0.12s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.stop-sign.show { transform: translate(-50%, -50%) scale(1); }
.sign-inner {
  font-size: 2.4rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.1em;
  text-shadow: 0 0 10px #000;
}

/* Ransom Window (payment UI) */
.ransom-window {
  position: absolute;
  left: 50%;
  top: 55%;
  transform: translate(-50%, -50%);
  width: min(420px, 92vw);
  background: #120005;
  border: 2px solid var(--red);
  box-shadow: 0 0 50px rgba(200, 0, 40, 0.6);
  z-index: 130;
  pointer-events: auto;
  font-family: Consolas, "Courier New", monospace;
}
.rw-header {
  background: var(--red);
  color: #fff;
  padding: 0.6rem 1rem;
  display: flex;
  justify-content: space-between;
  font-weight: bold;
  font-size: 0.85rem;
}
.timer {
  background: #000;
  padding: 0.15rem 0.5rem;
  color: #0f0;
  font-variant-numeric: tabular-nums;
}
.rw-body {
  padding: 1.2rem;
  text-align: center;
}
.rw-body p { margin-bottom: 0.8rem; font-size: 0.9rem; }
.drop-zone {
  min-height: 110px;
  border: 2px dashed var(--gold);
  background: rgba(255, 215, 0, 0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin: 1rem 0;
  transition: background 0.2s, border-color 0.2s;
  font-size: 0.95rem;
  color: var(--gold);
}
.drop-zone.drag-over {
  background: rgba(255, 215, 0, 0.2);
  border-color: #fff;
  box-shadow: inset 0 0 20px rgba(255, 215, 0, 0.3);
}
#paid {
  font-size: 1.3rem;
  font-weight: bold;
  color: #fff;
}
.hint { font-size: 0.75rem; color: #888; }
.rw-footer { padding: 0 1rem 1rem; }
.progress {
  height: 8px;
  background: #300;
  border-radius: 4px;
  overflow: hidden;
}
#progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), #ffaa00);
  transition: width 0.25s;
}

#vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(80, 0, 10, 0.7) 100%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
  z-index: 105;
}
#vignette.on { opacity: 1; }

#static {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.15'/%3E%3C/svg%3E");
  opacity: 0;
  pointer-events: none;
  z-index: 106;
  mix-blend-mode: overlay;
}
#static.on { opacity: 0.4; animation: static-flicker 0.1s infinite; }

@keyframes static-flicker {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.5; }
}

/* Crash & Success */
#crash, #success {
  background: #000;
  z-index: 200;
  flex-direction: column;
}
.crash-content, .success-content {
  text-align: center;
  padding: 2rem;
}
#crash h1 { color: var(--red); font-size: 2.5rem; margin-bottom: 1rem; }
#success h1 { color: #0f0; font-size: 2.2rem; margin-bottom: 1rem; }
.small { font-size: 0.85rem; color: #666; margin-top: 0.5rem; }

/* Infected cursor */
body.infected {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Ccircle cx='16' cy='16' r='14' fill='%23c00' stroke='%23fff' stroke-width='2'/%3E%3Ctext x='16' y='21' text-anchor='middle' fill='%23fff' font-size='14' font-weight='bold'%3E!%3C/text%3E%3C/svg%3E") 16 16, crosshair !important;
}

/* Mobile tweaks */
@media (max-width: 600px) {
  h1.glitch { font-size: 2.2rem; }
  .face { width: 140px; height: 140px; }
  .stop-sign { width: 160px; height: 160px; }
  .sign-inner { font-size: 1.6rem; }
  .coin { width: 42px; height: 42px; font-size: 0.6rem; }
}
