*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --blood:   #8b0000;
  --blood2:  #c0392b;
  --text:    #e8dfd0;
  --dim:     rgba(232,223,208,0.45);
  --green:   #55ff55;
  --mono:    'Share Tech Mono', 'Courier New', monospace;
  --creep:   'Creepster', 'Impact', cursive;
}

body {
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  font-family: var(--mono);
  color: var(--text);
  user-select: none;
  cursor: crosshair;
}

/* ── Sky ────────────────────────────────────────────────────── */
#sky {
  position: fixed;
  inset: 0;
  background: linear-gradient(
    to bottom,
    #02020a 0%,
    #07051a 20%,
    #110820 38%,
    #200c1a 55%,
    #2e1008 72%,
    #3d1604 85%,
    #4a1e04 100%
  );
  z-index: 0;
}

/* ── Moon ───────────────────────────────────────────────────── */
#moon {
  position: fixed;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 36%, #fffce8 0%, #e8ddb8 55%, #b8a86e 100%);
  top: 9%;
  right: 14%;
  z-index: 1;
  box-shadow: 0 0 35px rgba(230,215,155,0.28);
}
#moon-halo {
  position: fixed;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(200,180,100,0.06) 40%, transparent 70%);
  top: calc(9% - 29px);
  right: calc(14% - 29px);
  z-index: 1;
}

/* ── Fog ────────────────────────────────────────────────────── */
#fog-layer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 30%;
  background: linear-gradient(to top,
    rgba(8,5,18,0.85) 0%,
    rgba(14,8,24,0.45) 50%,
    transparent 100%
  );
  z-index: 2;
  pointer-events: none;
  animation: fogDrift 14s ease-in-out infinite alternate;
}
@keyframes fogDrift {
  from { transform: scaleX(1.02) translateX(-1%); opacity: 0.8; }
  to   { transform: scaleX(0.98) translateX(1%);  opacity: 1;   }
}

/* ── Graveyard SVG ──────────────────────────────────────────── */
#graveyard {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 42%;
  z-index: 3;
  pointer-events: none;
}

/* ── Flash ──────────────────────────────────────────────────── */
#flash {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center,
    rgba(160,0,0,0.55),
    rgba(80,0,0,0.15) 60%,
    transparent
  );
  opacity: 0;
  pointer-events: none;
  z-index: 95;
  transition: opacity 0.12s ease-out;
}

/* ── Crosshair ──────────────────────────────────────────────── */
#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  z-index: 10;
  pointer-events: none;
}
#crosshair::before,
#crosshair::after {
  content: '';
  position: absolute;
  background: rgba(255,220,180,0.3);
  border-radius: 1px;
}
#crosshair::before { width: 1px; height: 100%; left: 11.5px; top: 0; }
#crosshair::after  { width: 100%; height: 1px; top: 11.5px;  left: 0; }

/* ── HUD ────────────────────────────────────────────────────── */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 80;
  background: linear-gradient(to bottom, rgba(0,0,0,0.55), transparent);
  pointer-events: none;
  font-size: 12px;
  letter-spacing: 0.2em;
}

#lives { font-size: 17px; letter-spacing: 3px; }

#hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
#wave-label { font-size: 9px; letter-spacing: 0.45em; color: var(--dim); }
#wave-val   { font-family: var(--creep); font-size: 22px; color: #cc6030; line-height: 1; }
#diff-hud   { font-size: 8px; letter-spacing: 0.4em; color: rgba(200,80,80,0.55); margin-top: 1px; }

#hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
#score-wrap { color: var(--dim); text-shadow: 0 0 10px rgba(180,80,30,0.5); }
#score-val  { color: var(--text); }

/* HUD lang toggle */
.lang-btn {
  padding: 3px 9px;
  background: transparent;
  border: 1px solid rgba(180,60,60,0.4);
  color: rgba(232,223,208,0.6);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.3em;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1.6;
}
.lang-btn:hover {
  border-color: rgba(220,80,80,0.9);
  color: var(--text);
  box-shadow: 0 0 12px rgba(160,30,30,0.2);
}

/* ── Zombies ────────────────────────────────────────────────── */
#zombies {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

.zombie {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform-origin: bottom center;
  pointer-events: none;
  will-change: transform, left, top;
}

/* Word label */
.z-label {
  background: rgba(0,0,0,0.78);
  border: 1px solid rgba(130,0,0,0.5);
  border-radius: 3px;
  padding: 4px 12px 3px;
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 0.14em;
  white-space: nowrap;
  margin-bottom: 5px;
  text-shadow: none;
  transition: border-color 0.2s;
}
.z-label.targeted {
  border-color: rgba(200,200,50,0.7);
  box-shadow: 0 0 10px rgba(200,200,50,0.15);
}
.z-typed { color: var(--green); text-shadow: 0 0 8px var(--green); }
.z-rest  { color: var(--text); }

/* JP mode label */
.z-label-jp {
  text-align: center;
  padding: 4px 11px 3px;
}
.z-jp {
  font-family: 'Noto Sans JP', 'Hiragino Kaku Gothic Pro', 'Yu Gothic', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #e8dfd0;
  line-height: 1.15;
  letter-spacing: 0.04em;
  margin-bottom: 3px;
}
.z-romaji {
  font-size: 14px;
  letter-spacing: 0.1em;
  color: rgba(232,223,208,0.6);
  line-height: 1.2;
}
.z-label-jp .z-typed { color: var(--green); text-shadow: 0 0 6px var(--green); }
.z-label-jp .z-rest  { color: rgba(232,223,208,0.55); }

/* Error flash on label */
.z-label.z-error { animation: labelError 0.3s ease; }
@keyframes labelError {
  0%, 100% { background: rgba(0,0,0,0.78); }
  50%      { background: rgba(140,0,0,0.6); }
}

/* Figure walk animation */
.z-figure {
  animation: zombieWalk 0.6s ease-in-out infinite alternate;
  transform-origin: bottom center;
}
.zombie-fast .z-figure { animation-duration: 0.28s; }
.zombie-tank .z-figure { animation-duration: 0.9s;  }

@keyframes zombieWalk {
  from { transform: rotate(-3.5deg) translateY(0); }
  to   { transform: rotate( 3.5deg) translateY(-6px); }
}

/* SVG sizes */
.z-svg      { display: block; filter: drop-shadow(0 5px 10px rgba(0,0,0,0.9)); }
.zombie-normal .z-svg { width: 58px;  height: 107px; }
.zombie-fast   .z-svg { width: 50px;  height: 92px;  }
.zombie-tank   .z-svg { width: 76px;  height: 140px; filter: drop-shadow(0 6px 14px rgba(0,0,0,0.95)); }

/* Glow per type */
.zombie-fast .z-svg {
  filter: drop-shadow(0 0 5px rgba(80,80,200,0.45)) drop-shadow(0 5px 10px rgba(0,0,0,0.9));
}
.zombie-tank .z-svg {
  filter: drop-shadow(0 0 8px rgba(200,90,20,0.4)) drop-shadow(0 6px 14px rgba(0,0,0,0.95));
}

/* ── Blood particles ────────────────────────────────────────── */
.blood-drop {
  position: fixed;
  border-radius: 50%;
  background: var(--blood2);
  pointer-events: none;
  z-index: 55;
  animation: bloodFly 0.65s ease-out forwards;
}
@keyframes bloodFly {
  0%   { transform: translate(0,0) scale(1);    opacity: 1; }
  100% { transform: translate(var(--tx),var(--ty)) scale(0.2); opacity: 0; }
}

/* ── Shake ──────────────────────────────────────────────────── */
.shake { animation: screenShake 0.4s ease; }
@keyframes screenShake {
  0%,100% { transform: translate(0,0);       }
  15%     { transform: translate(-9px,5px);  }
  30%     { transform: translate(9px,-5px);  }
  45%     { transform: translate(-6px,6px);  }
  60%     { transform: translate(6px,-4px);  }
  75%     { transform: translate(-4px,3px);  }
}

/* ── Screens ────────────────────────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  position: fixed;
  inset: 0;
  background: rgba(0,0,5,0.9);
  backdrop-filter: blur(8px);
  z-index: 100;
  text-align: center;
  padding: 24px;
}
.screen.active { display: flex; }

.s-eyebrow {
  font-size: 9px;
  letter-spacing: 0.55em;
  color: rgba(180,50,50,0.8);
}

.s-title {
  font-family: var(--creep);
  font-size: clamp(72px, 13vw, 120px);
  letter-spacing: 0.05em;
  line-height: 0.88;
  color: #e0d0c0;
  text-shadow:
    0 0 60px rgba(180,30,30,0.6),
    0 0 20px rgba(200,40,40,0.35);
}

.s-rules {
  list-style: none;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: rgba(232,223,208,0.38);
  line-height: 2.1;
}

/* Language selector (start / game-over screens) */
.lang-select {
  display: flex;
  gap: 6px;
}
.lang-opt {
  padding: 7px 22px;
  background: transparent;
  border: 1px solid rgba(180,60,60,0.3);
  color: rgba(232,223,208,0.4);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.3em;
  cursor: pointer;
  transition: all 0.2s;
}
.lang-opt.active {
  background: rgba(130,20,20,0.25);
  border-color: rgba(200,70,70,0.85);
  color: var(--text);
  box-shadow: 0 0 16px rgba(160,30,30,0.15);
}
.lang-opt:hover:not(.active) {
  border-color: rgba(200,70,70,0.55);
  color: rgba(232,223,208,0.75);
}

/* Difficulty selector */
.diff-select {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: center;
}
.diff-opt {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid rgba(140,140,140,0.2);
  color: rgba(232,223,208,0.35);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.25em;
  cursor: pointer;
  transition: all 0.2s;
}
.diff-opt:hover:not(.active) {
  border-color: rgba(200,200,200,0.4);
  color: rgba(232,223,208,0.65);
}
/* Active colors per difficulty */
.diff-opt.active[data-diff="beginner"] { border-color: #44aa44; color: #88dd88; background: rgba(40,120,40,0.12); }
.diff-opt.active[data-diff="easy"]     { border-color: #88bb33; color: #aad855; background: rgba(80,130,30,0.12); }
.diff-opt.active[data-diff="normal"]   { border-color: #cc8800; color: #ffb833; background: rgba(140,90,0,0.12);  }
.diff-opt.active[data-diff="hard"]     { border-color: #cc4400; color: #ff7033; background: rgba(140,40,0,0.12);  }
.diff-opt.active[data-diff="veryhard"] { border-color: #bb0000; color: #ff3333; background: rgba(130,0,0,0.15);
  box-shadow: 0 0 14px rgba(180,0,0,0.15); }

.s-score {
  font-family: var(--creep);
  font-size: clamp(32px, 6vw, 54px);
  letter-spacing: 0.2em;
  color: #e0d0c0;
}
.s-wave-result { font-size: 11px; letter-spacing: 0.3em; color: var(--dim); }

button {
  padding: 12px 52px;
  background: transparent;
  border: 1px solid rgba(160,40,40,0.45);
  color: rgba(232,223,208,0.82);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.4em;
  cursor: pointer;
  transition: all 0.24s;
  margin-top: 6px;
}
button:hover {
  background: rgba(140,30,30,0.12);
  border-color: rgba(200,50,50,0.8);
  box-shadow: 0 0 28px rgba(160,30,30,0.2);
}

.go-buttons {
  display: flex;
  gap: 10px;
}
#topBtn {
  border-color: rgba(140,140,140,0.3);
  color: rgba(232,223,208,0.5);
}
#topBtn:hover {
  background: rgba(80,80,80,0.1);
  border-color: rgba(200,200,200,0.5);
  color: rgba(232,223,208,0.85);
  box-shadow: none;
}
