@import url('https://fonts.googleapis.com/css2?family=Zen+Maru+Gothic:wght@400;700&family=Outfit:wght@300;500;700&display=swap');

:root {
  --ink: #ede8df;
  --muted: #9a9590;
  --bg: #080b12;
  --accent: #f2a0b0;
  --accent2: #a0d4c0;
  --glass: rgba(28, 22, 35, 0.72);
  --glass-border: rgba(255, 255, 255, 0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { overflow: hidden; background: var(--bg); color: var(--ink); font-family: 'Outfit', 'DM Sans', sans-serif; cursor: default; }
[hidden] { display: none !important; }

/* ─── Scene Canvas ─── */
#scene { position: fixed; inset: 0; outline: none; touch-action: none; }
#scene canvas { width: 100%; height: 100%; display: block; }

/* ─── Atmosphere Overlay (scanlines + vignette) ─── */
.atmosphere {
  position: fixed; inset: 0; pointer-events: none; z-index: 2;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.03) 0px, rgba(0,0,0,0.03) 1px, transparent 1px, transparent 3px),
    radial-gradient(ellipse at center, rgba(12,18,30,0.02) 30%, rgba(3,5,12,0.78) 100%),
    linear-gradient(180deg, rgba(8,16,30,0.18), rgba(7,3,16,0.35));
}

.hud-torch { position: fixed; right: 18px; bottom: 18px; display: flex; align-items: center; gap: 8px; padding: 9px 13px; border: 1px solid rgba(255,180,90,.35); border-radius: 20px; background: rgba(12,10,16,.7); color: #d8c9b6; font-size: 11px; letter-spacing: 1px; box-shadow: 0 0 18px rgba(255,130,40,.12); }
.hud-torch b { color: #ffbd69; font-weight: 700; }
.hud-torch.off { border-color: rgba(160,160,180,.2); color: #777989; box-shadow: none; }
.hud-torch.off b { color: #777989; }
.hud-torch.off .torch-icon { filter: grayscale(1); opacity: .55; }
.torch-icon { font-size: 16px; filter: drop-shadow(0 0 5px #ff8a38); }
.hud-stalker { position: fixed; top: 74px; right: 28px; padding: 8px 12px; border: 1px solid rgba(173,55,70,.45); border-radius: 16px; background: rgba(22,6,13,.72); color: #bd6975; font-size: 10px; letter-spacing: 1.5px; opacity: .82; animation: hunterPulse 2.7s ease-in-out infinite; }
.hud-stalker.near { color: #ff8792; border-color: rgba(255,74,92,.75); box-shadow: 0 0 18px rgba(190,35,55,.35); }
@keyframes hunterPulse { 0%, 100% { opacity: .55; } 50% { opacity: .95; } }

/* ─── Crosshair ─── */
.crosshair {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 24px; height: 24px; z-index: 5; pointer-events: none;
}
.crosshair span {
  position: absolute; background: rgba(255,255,255,0.55); border-radius: 1px;
}
.crosshair span:nth-child(1) { top: 0; left: 50%; width: 2px; height: 7px; transform: translateX(-50%); }
.crosshair span:nth-child(2) { bottom: 0; left: 50%; width: 2px; height: 7px; transform: translateX(-50%); }
.crosshair span:nth-child(3) { left: 0; top: 50%; width: 7px; height: 2px; transform: translateY(-50%); }
.crosshair span:nth-child(4) { right: 0; top: 50%; width: 7px; height: 2px; transform: translateY(-50%); }
.crosshair.interact span { background: var(--accent); }

/* ─── Start Screen ─── */
.start-screen {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #05070cee 0%, #171123ee 46%, #08131bcc 100%);
  backdrop-filter: blur(30px);
  animation: fadeIn 0.6s ease-out;
}
.start-content { text-align: center; max-width: 480px; padding: 40px; }
.start-eyebrow {
  font-family: 'Zen Maru Gothic', serif; font-size: 18px; letter-spacing: 8px;
  color: var(--accent); margin-bottom: 12px; opacity: 0.8;
}
.start-title {
  font-family: 'Outfit', sans-serif; font-weight: 700;
  font-size: clamp(60px, 10vw, 100px); line-height: 0.95;
  letter-spacing: -3px; margin-bottom: 28px;
  background: linear-gradient(135deg, #f2e3d6 0%, #d56b78 50%, #657c9b 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.start-title em { font-style: italic; font-weight: 300; }
.start-desc { font-size: 14px; line-height: 1.8; color: var(--muted); margin-bottom: 40px; }
.start-btn {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 16px 36px; border: 1px solid var(--accent);
  background: rgba(242, 160, 176, 0.08); border-radius: 50px;
  font-family: 'Outfit', sans-serif; font-size: 15px; font-weight: 500;
  color: var(--accent); cursor: pointer;
  transition: all 0.3s ease;
  animation: pulse 2.5s ease-in-out infinite;
}
.start-btn:hover { background: rgba(242, 160, 176, 0.18); transform: scale(1.04); }
.start-btn-icon { font-size: 12px; }
.start-controls {
  margin-top: 45px; display: flex; flex-wrap: wrap; justify-content: center; gap: 16px 24px;
}
.control-item { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
kbd {
  display: inline-block; padding: 3px 8px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 5px; font-family: 'Outfit', monospace; font-size: 10px; color: var(--ink);
}

/* ─── HUD ─── */
.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 6;
  padding: 22px 28px; display: flex; justify-content: space-between; align-items: flex-start;
  pointer-events: none;
}
.hud-left {
  display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
}
.hud-petals {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; background: var(--glass);
  border: 1px solid var(--glass-border); border-radius: 30px;
  backdrop-filter: blur(12px);
}
.hud-petal-icon { font-size: 18px; filter: drop-shadow(0 0 6px rgba(242, 160, 176, 0.5)); }
.hud-petal-count {
  font-size: 20px; font-weight: 700; color: var(--accent);
  min-width: 20px; text-align: center;
  transition: transform 0.2s ease;
}
.hud-petal-count.pop { transform: scale(1.4); }
.hud-petal-total { font-size: 12px; color: var(--muted); }

/* ─── Quest Tracker (HUD) ─── */
.hud-quests {
  min-width: 250px; max-width: 320px;
  padding: 10px 16px; background: var(--glass);
  border: 1px solid var(--glass-border); border-radius: 16px;
  backdrop-filter: blur(14px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  animation: fadeIn 0.4s ease-out;
}
.quest-header {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--muted); margin-bottom: 5px;
}
.quest-icon { font-size: 12px; }
.quest-title { flex: 1; color: #d0c8be; }
.quest-count {
  font-size: 11px; background: rgba(242, 160, 176, 0.15);
  color: var(--accent); padding: 2px 8px; border-radius: 10px;
  font-weight: 700;
}
.quest-active {
  font-size: 12px; color: #ede8df; line-height: 1.4;
  font-weight: 500;
}
.quest-active kbd {
  font-size: 9px; padding: 2px 5px; margin: 0 2px;
}

.hud-compass {
  padding: 8px 16px; background: var(--glass);
  border: 1px solid var(--glass-border); border-radius: 20px;
  backdrop-filter: blur(12px); font-size: 13px; font-weight: 700;
  color: var(--accent2); letter-spacing: 2px;
}
.hud-time {
  padding: 8px 16px; background: var(--glass);
  border: 1px solid var(--glass-border); border-radius: 20px;
  backdrop-filter: blur(12px); font-size: 12px; color: var(--muted);
}

/* ─── Quest Toast Notification ─── */
.quest-toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  z-index: 25; pointer-events: none;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 24px; background: rgba(24, 18, 30, 0.9);
  border: 1px solid rgba(242, 160, 176, 0.35); border-radius: 40px;
  backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(242, 160, 176, 0.2), 0 2px 10px rgba(0,0,0,0.5);
  animation: toastSlide 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.quest-toast.hide {
  opacity: 0; transform: translate(-50%, -10px);
}
.toast-icon {
  font-size: 20px; filter: drop-shadow(0 0 8px rgba(242, 160, 176, 0.8));
  animation: float 2s ease-in-out infinite;
}
.toast-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--accent); font-weight: 700;
}
.toast-desc {
  font-size: 13px; color: #fff; font-weight: 500;
}

/* ─── Dialogue Box (Anime Visual Novel Style) ─── */
.dialogue-box {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%);
  z-index: 26; width: min(720px, 92vw);
  display: flex; gap: 20px; align-items: flex-start;
  padding: 22px 26px;
  background: rgba(22, 17, 28, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  backdrop-filter: blur(24px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  animation: dialogueAppear 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  user-select: none;
}
.dialogue-avatar {
  flex-shrink: 0; width: 64px; height: 64px;
  border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(242, 160, 176, 0.25), rgba(160, 212, 192, 0.25));
  border: 2px solid var(--accent);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.avatar-face {
  font-size: 32px;
}
.dialogue-body {
  flex: 1; display: flex; flex-direction: column; gap: 8px;
}
.dialogue-header {
  display: flex; align-items: center; gap: 10px;
}
.dialogue-speaker {
  font-family: 'Zen Maru Gothic', 'Outfit', sans-serif;
  font-size: 18px; font-weight: 700; color: #fff;
  letter-spacing: 0.5px;
}
.dialogue-tag {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  padding: 3px 8px; border-radius: 6px; font-weight: 700;
  background: rgba(255, 255, 255, 0.08); color: var(--muted);
}
.dialogue-text-wrap {
  min-height: 52px;
}
.dialogue-text {
  font-size: 15px; line-height: 1.6; color: #ede8df;
  font-weight: 400; letter-spacing: 0.2px;
}
.dialogue-prompt {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--muted); margin-top: 4px;
  opacity: 0.8;
}
.dialogue-prompt kbd {
  font-size: 10px; padding: 2px 6px;
}
.dialogue-arrow {
  color: var(--accent); font-size: 10px;
  animation: promptBounce 1.2s ease-in-out infinite;
}

/* ─── Interaction Prompt ─── */
.interact-prompt {
  position: fixed; bottom: 22%; left: 50%; transform: translateX(-50%);
  z-index: 7; display: flex; align-items: center; gap: 10px;
  padding: 12px 22px; background: var(--glass);
  border: 1px solid var(--glass-border); border-radius: 12px;
  backdrop-filter: blur(12px); font-size: 13px; color: var(--ink);
  animation: promptBounce 1.5s ease-in-out infinite;
}
.interact-prompt kbd { font-size: 12px; padding: 4px 10px; }

/* ─── Pause Screen ─── */
.pause-screen {
  position: fixed; inset: 0; z-index: 15;
  display: grid; place-items: center;
  background: rgba(16, 12, 22, 0.7);
  backdrop-filter: blur(16px);
  animation: fadeIn 0.25s ease-out;
}
.pause-content { text-align: center; max-width: 400px; }
.pause-content h2 {
  font-family: 'Outfit', sans-serif; font-size: 42px; font-weight: 300;
  letter-spacing: 6px; margin-bottom: 12px; color: var(--accent);
}
.pause-content > p { font-size: 13px; color: var(--muted); margin-bottom: 30px; }
.pause-controls { text-align: left; font-size: 12px; color: var(--muted); line-height: 2.2; }
.pause-controls kbd { margin-right: 4px; }

/* ─── Victory Screen ─── */
.victory-screen {
  position: fixed; inset: 0; z-index: 18;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at center, rgba(40, 20, 35, 0.85) 0%, rgba(16, 12, 22, 0.92) 100%);
  backdrop-filter: blur(20px);
  animation: fadeIn 1s ease-out;
}
.victory-content { text-align: center; max-width: 420px; }
.victory-kanji {
  font-family: 'Zen Maru Gothic', serif; font-size: 80px;
  color: var(--accent); opacity: 0.6; margin-bottom: 10px;
  animation: float 3s ease-in-out infinite;
}
.victory-content h2 {
  font-family: 'Outfit', sans-serif; font-size: 32px; font-weight: 500;
  margin-bottom: 14px;
  background: linear-gradient(135deg, #f8dce0, #a0d4c0);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.victory-sub { font-family: 'Zen Maru Gothic', serif; font-size: 15px; color: #c8b8a0; }
.victory-sub small { font-family: 'Outfit', sans-serif; font-size: 11px; color: var(--muted); }

/* ─── Death Screen ─── */
.death-screen {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at center, rgba(140, 15, 25, 0.94) 0%, rgba(10, 3, 6, 0.98) 100%);
  backdrop-filter: blur(20px);
  animation: deathFlash 0.5s ease-out;
}
.death-content {
  text-align: center; max-width: 440px; padding: 24px;
}
.death-kanji {
  font-family: 'Zen Maru Gothic', serif; font-size: 92px; font-weight: 700;
  color: #ff2a44; text-shadow: 0 0 35px rgba(255, 30, 60, 0.9), 0 0 70px rgba(180, 0, 30, 0.6);
  margin-bottom: 6px; line-height: 1;
  animation: pulseKanji 2.4s ease-in-out infinite;
}
.death-content h2 {
  font-family: 'Outfit', sans-serif; font-size: 36px; font-weight: 700;
  letter-spacing: 4px; margin-bottom: 12px;
  background: linear-gradient(135deg, #ffa0ac, #ff334b 60%, #991024);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  text-transform: uppercase;
}
.death-content p { font-size: 13.5px; color: #d6b8be; line-height: 1.75; margin-bottom: 16px; }
.death-sub { font-family: 'Zen Maru Gothic', serif; font-size: 15px; color: #e8a0a8; }
.death-sub small { font-family: 'Outfit', sans-serif; font-size: 11.5px; color: #a88890; }
.death-btn {
  margin-top: 18px;
  background: linear-gradient(135deg, #b81d33, #780e1e);
  box-shadow: 0 8px 28px rgba(184, 29, 51, 0.5);
  border: 1px solid rgba(255, 120, 140, 0.35);
  cursor: pointer;
}
.death-btn:hover {
  background: linear-gradient(135deg, #dc2842, #961227);
  box-shadow: 0 10px 35px rgba(220, 40, 66, 0.7);
  transform: translateY(-2px);
}
.atmosphere.blood-flash {
  box-shadow: inset 0 0 140px rgba(230, 15, 35, 0.9);
  background: radial-gradient(ellipse at center, rgba(160, 10, 20, 0.45) 0%, rgba(40, 0, 5, 0.8) 100%);
  transition: all 0.25s ease-out;
}

@keyframes deathFlash {
  0% { opacity: 0; background: rgba(255, 0, 40, 0.98); }
  25% { opacity: 1; background: rgba(200, 10, 30, 0.95); }
  100% { opacity: 1; background: radial-gradient(ellipse at center, rgba(140, 15, 25, 0.94) 0%, rgba(10, 3, 6, 0.98) 100%); }
}

@keyframes pulseKanji {
  0%, 100% { transform: scale(1); opacity: 0.95; }
  50% { transform: scale(1.08); opacity: 0.8; text-shadow: 0 0 55px rgba(255, 30, 60, 1); }
}


/* ─── Loading & Error ─── */
.loading {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 25; display: flex; align-items: center; gap: 14px;
  font-size: 13px; letter-spacing: 1px; color: var(--muted);
}
.loader {
  width: 20px; height: 20px; border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.error {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 30; width: min(440px, 90vw); padding: 30px;
  background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: 16px; backdrop-filter: blur(16px);
}
.error h2 { font-size: 20px; margin-bottom: 10px; color: var(--accent); }
.error p { font-size: 13px; color: var(--muted); line-height: 1.7; }
.text-button {
  margin-top: 16px; padding: 10px 0; border: none; background: none;
  font-size: 13px; color: var(--accent); cursor: pointer; font-family: inherit;
}

/* ─── Animations ─── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toastSlide {
  from { opacity: 0; transform: translate(-50%, -24px) scale(0.95); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
@keyframes dialogueAppear {
  from { opacity: 0; transform: translate(-50%, 20px) scale(0.97); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(242, 160, 176, 0.25); }
  50% { box-shadow: 0 0 0 14px rgba(242, 160, 176, 0); }
}
@keyframes promptBounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-6px); }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

/* ─── Responsive ─── */
@media (max-width: 700px) {
  .start-title { font-size: 52px; }
  .start-controls { gap: 10px 16px; }
  .hud { padding: 14px 16px; }
  .hud-petals { padding: 8px 14px; }
  .hud-petal-count { font-size: 18px; }
  .pause-content h2 { font-size: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}