@font-face {
  font-family: "Verse";
  src: local("Palatino Linotype"), local("Palatino"), local("Book Antiqua"), local("Georgia");
  font-display: swap;
}

:root {
  --bg: #0e1018;
  --ink: #e8e0d0;
  --muted: #a09888;
  --flame: #e85020;
  --vorpal: #70e0c8;
  --panel: rgba(10, 12, 20, 0.82);
  --gold: #d4b878;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #d8d0c0;
    --ink: #1a1814;
    --muted: #5a5040;
    --panel: rgba(248, 244, 236, 0.9);
    --gold: #8a6830;
  }
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Verse, Palatino, Georgia, serif;
}

#c {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

#fps {
  position: fixed;
  top: 12px;
  right: 12px;
  background: var(--panel);
  border: 1px solid rgba(212, 184, 120, 0.35);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: system-ui, sans-serif;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  z-index: 10;
}

#verse {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(560px, 90vw);
  text-align: center;
  z-index: 10;
  pointer-events: none;
}

#verse-text {
  background: var(--panel);
  border: 1px solid rgba(212, 184, 120, 0.3);
  border-radius: 10px;
  padding: 14px 20px;
  font-size: clamp(14px, 2.2vw, 18px);
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-line;
  opacity: 0;
  transition: opacity 0.6s ease;
}

#verse-text.show { opacity: 1; }

#hud-bottom {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

#prompt {
  font-size: 14px;
  color: var(--gold);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  min-height: 1.2em;
}

#sword-meter {
  width: 160px;
  height: 8px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(112, 224, 200, 0.4);
  border-radius: 4px;
  overflow: hidden;
}

#sword-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #308878, var(--vorpal));
  transition: width 0.08s linear;
}

#title-screen,
#end-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(20, 24, 40, 0.75), rgba(8, 10, 16, 0.92));
  z-index: 30;
  text-align: center;
  padding: 24px;
}

#title-screen.hidden,
#end-screen.hidden { display: none; }

#title-screen h1,
#end-screen h1 {
  font-size: clamp(36px, 8vw, 64px);
  font-weight: 400;
  letter-spacing: 0.08em;
  color: var(--gold);
  margin-bottom: 8px;
}

.tag {
  font-style: italic;
  color: var(--muted);
  margin-bottom: 28px;
}

#title-screen button,
#end-screen button {
  font-family: Verse, Palatino, Georgia, serif;
  font-size: 18px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 12px 28px;
  cursor: pointer;
  margin-bottom: 16px;
}

#title-screen button:hover,
#title-screen button:focus-visible,
#end-screen button:hover,
#end-screen button:focus-visible {
  background: rgba(212, 184, 120, 0.15);
  outline: none;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  font-family: system-ui, sans-serif;
}

#end-verse {
  max-width: 480px;
  margin: 0 auto 24px;
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-line;
  color: var(--ink);
}

@media (prefers-reduced-motion: reduce) {
  #verse-text { transition: none; }
}
