:root {
  --ink: #3a2c3c;
  --ink-soft: #6c5566;
  --cream: #fbf3e8;
  --amber: #ffc86b;
  --teal: #4f8279;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --sans: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #d9afc9;
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

#app {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(120% 90% at 68% 18%, rgba(255, 226, 197, 0.95) 0%, rgba(255, 214, 196, 0.5) 34%, rgba(255, 210, 200, 0) 62%),
    radial-gradient(90% 70% at 20% 80%, rgba(146, 118, 168, 0.5) 0%, rgba(146, 118, 168, 0) 70%),
    linear-gradient(180deg, #b9a0d2 0%, #d3a9c8 34%, #edbfbd 70%, #f7cdb0 100%);
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: default;
}

#wayfinding { position: absolute; inset: 0; pointer-events: none; }
#wayfinding[hidden], #wayfinding [hidden] { display: none !important; }
.goal-marker {
  position: absolute; transform: translate(-50%, -50%); min-width: 60px; min-height: 60px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 0; border-radius: 28px; padding: 4px 10px; cursor: pointer; pointer-events: auto;
  color: #79502c; background: rgba(255, 247, 225, .88); box-shadow: 0 0 20px #ffc86b66;
  transition: background .2s, color .2s; white-space: nowrap;
}
.goal-marker.unreachable { color: #78697d; background: rgba(251, 243, 232, .8); box-shadow: none; }
.goal-marker:hover { background: #fff6e0; }
.goal-icon { font-size: 29px; line-height: 30px; }
.goal-label { font: 10px var(--sans); letter-spacing: .035em; }
.tutorial {
  position: absolute; left: clamp(18px, 4vw, 64px); top: 180px; width: min(290px, 34vw);
  padding: 16px 18px; border: 1px solid #9c7c7d33; border-radius: 18px;
  background: rgba(251, 243, 232, .88); backdrop-filter: blur(9px); pointer-events: auto;
}
.tutorial .eyebrow { font-size: 9px; letter-spacing: .17em; }
#tutorialText { font: 15px/1.5 var(--serif); margin: 10px 0; }
.tutorial-turns { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tutorial-turns button { min-width: 52px; min-height: 44px; padding: 4px; font-size: 22px; border: 1px solid #9c7c7d55; border-radius: 12px; background: #fff7ed; cursor: pointer; }
.tutorial-turns button:disabled { opacity: .45; }
#tutorialStep { font-size: 9px; letter-spacing: .06em; text-align: center; color: var(--ink-soft); }
.click-feedback { position: absolute; width: 32px; height: 32px; margin: -16px; border: 2px solid #9b8393; border-radius: 50%; animation: clickRing .7s ease-out forwards; }
.click-feedback.accepted { border-color: #ca8d3d; }
.click-feedback.blocked { border-style: dashed; background: #9b839326; }
@keyframes clickRing { from { opacity: 1; transform: scale(.65); } to { opacity: 0; transform: scale(1.8); } }
@media (max-width: 700px) {
  .tutorial { left: 14px; top: auto; bottom: 68px; width: min(300px, calc(100vw - 28px)); padding: 10px 14px; }
  #tutorialText { font-size: 13px; margin: 7px 0; }
  #hintBar { display: none; }
  .goal-label { font-size: 9px; }
}

#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(115% 95% at 50% 45%, rgba(58, 44, 60, 0) 55%, rgba(58, 44, 60, 0.18) 100%);
}

.hidden { display: none !important; }

.eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

#hud {
  position: absolute;
  top: clamp(22px, 4.4vh, 54px);
  left: clamp(22px, 4vw, 64px);
  pointer-events: none;
  transition: opacity 700ms ease;
}

.hud-title {
  margin: 10px 0 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(26px, 3.4vw, 44px);
  letter-spacing: 0.01em;
  color: var(--ink);
  opacity: 0.92;
}

#hintBar {
  position: absolute;
  left: clamp(22px, 4vw, 64px);
  bottom: clamp(64px, 8vh, 96px);
  max-width: 30ch;
  font-family: var(--serif);
  font-size: clamp(15px, 1.5vw, 19px);
  line-height: 1.5;
  color: var(--ink);
  opacity: 0.78;
  pointer-events: none;
  transition: opacity 600ms ease;
}

#controls {
  position: absolute;
  right: clamp(22px, 4vw, 64px);
  bottom: clamp(26px, 4vh, 46px);
  display: flex;
  gap: 18px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  pointer-events: none;
  opacity: 0.8;
}

kbd {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.08em;
  border: 1px solid rgba(58, 44, 60, 0.35);
  border-radius: 4px;
  padding: 1px 5px;
  margin-right: 3px;
  background: rgba(251, 243, 232, 0.45);
}

#progress {
  position: absolute;
  left: 50%;
  bottom: clamp(14px, 2.4vh, 26px);
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  pointer-events: none;
}

.pip {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid rgba(58, 44, 60, 0.4);
  background: transparent;
}

.pip.done { background: rgba(58, 44, 60, 0.55); border-color: transparent; }
.pip.active { background: var(--amber); border-color: transparent; box-shadow: 0 0 10px rgba(255, 200, 107, 0.9); }

#muteBtn {
  position: absolute;
  top: clamp(18px, 3.5vh, 44px);
  right: clamp(18px, 3vw, 52px);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(58, 44, 60, 0.25);
  background: rgba(251, 243, 232, 0.35);
  color: var(--ink);
  font-size: 15px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 200ms ease, transform 200ms ease;
}

#muteBtn:hover { background: rgba(251, 243, 232, 0.6); transform: scale(1.05); }
#muteBtn.muted { opacity: 0.45; }

#hintBtn {
  position: absolute;
  top: clamp(18px, 3.5vh, 44px);
  right: calc(clamp(18px, 3vw, 52px) + 50px);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px 0 12px;
  border-radius: 19px;
  border: 1px solid rgba(58, 44, 60, 0.25);
  background: rgba(251, 243, 232, 0.35);
  color: var(--ink);
  font-size: 15px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 200ms ease, transform 200ms ease, opacity 300ms ease;
}

#hintBtn:hover { background: rgba(251, 243, 232, 0.65); transform: translateY(-1px); }
#hintBtn.empty { opacity: 0.5; }
#hintBtn.pulse { animation: hintPulse 1.6s ease-in-out infinite; }

@keyframes hintPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 200, 107, 0); }
  50% { box-shadow: 0 0 0 5px rgba(255, 200, 107, 0.32); }
}

.hint-glyph { color: #d99a3f; font-size: 14px; }
#hintCount { font-size: 11px; letter-spacing: 0.12em; opacity: 0.75; }

.hint-inner, .ad-inner { max-width: 46ch; }

.hint-status {
  font-family: var(--serif);
  font-size: clamp(15px, 1.6vw, 19px);
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0 auto 6px;
}

.hint-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 26px;
}

.hint-code { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.hint-code input {
  font-family: var(--sans);
  font-size: 14px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 10px 16px;
  width: 16ch;
  border-radius: 999px;
  border: 1px solid rgba(58, 44, 60, 0.28);
  background: rgba(251, 243, 232, 0.55);
  color: var(--ink);
  outline: none;
}

.hint-code input:focus { border-color: var(--teal); background: rgba(251, 243, 232, 0.85); }
.hint-code input.bad { border-color: #c2554f; animation: codeShake 320ms ease; }

@keyframes codeShake {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-5px); }
  60% { transform: translateX(5px); }
}

.hint-note {
  margin: 26px auto 0;
  font-size: 11px;
  line-height: 1.7;
  letter-spacing: 0.06em;
  color: rgba(58, 44, 60, 0.5);
  max-width: 40ch;
}

.version-tag {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(58, 44, 60, 0.45);
}

.title-version { margin-top: 14px; }

.hud-version {
  position: absolute;
  top: 0;
  right: -8px;
  transform: translateX(100%);
  pointer-events: none;
}

.supporter-pack {
  width: min(100%, 36rem);
  padding: 14px 18px 12px;
  border-radius: 16px;
  background: rgba(251, 243, 232, 0.45);
  border: 1px solid rgba(58, 44, 60, 0.12);
}

.supporter-pack-title {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(58, 44, 60, 0.55);
}

.kofi-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kofi-links a {
  color: var(--teal);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-decoration: none;
  border-bottom: 1px solid rgba(79, 130, 121, 0.35);
}

.kofi-links a:hover { border-bottom-color: var(--teal); }

.kofi-note {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.hint-privacy {
  margin: 18px auto 0;
  font-size: 11px;
  letter-spacing: 0.08em;
}

.hint-privacy a {
  color: rgba(58, 44, 60, 0.55);
  text-decoration: none;
  border-bottom: 1px solid rgba(58, 44, 60, 0.2);
}

.hint-privacy a:hover { color: var(--ink-soft); }

.ad-bar {
  margin: 26px auto 18px;
  width: min(360px, 70vw);
  height: 4px;
  border-radius: 2px;
  background: rgba(58, 44, 60, 0.15);
  overflow: hidden;
}

#adProgress {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--amber);
  transition: width 200ms linear;
}

#toast {
  position: absolute;
  left: 50%;
  bottom: 12%;
  transform: translate(-50%, 8px);
  font-family: var(--serif);
  font-size: clamp(15px, 1.6vw, 20px);
  color: var(--ink);
  background: rgba(251, 243, 232, 0.72);
  border: 1px solid rgba(58, 44, 60, 0.12);
  padding: 10px 20px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 380ms ease, transform 380ms ease;
  white-space: nowrap;
}

#toast.show { opacity: 1; transform: translate(-50%, 0); }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6vh 8vw;
  text-align: center;
  background: radial-gradient(120% 100% at 50% 40%, rgba(247, 227, 214, 0.86), rgba(222, 186, 205, 0.9));
  backdrop-filter: blur(3px);
  transition: opacity 500ms ease;
  z-index: 5;
}

#titleScreen {
  justify-content: flex-start;
  text-align: left;
  background:
    radial-gradient(90% 80% at 24% 40%, rgba(255, 235, 215, 0.9) 0%, rgba(240, 205, 200, 0.55) 45%, rgba(220, 185, 205, 0.25) 100%),
    linear-gradient(100deg, rgba(238, 206, 208, 0.92) 0%, rgba(214, 178, 203, 0.4) 52%, rgba(190, 160, 200, 0) 100%);
  backdrop-filter: blur(1px);
  align-items: center;
}

.title-block { max-width: 34ch; padding-left: clamp(0px, 4vw, 40px); }

.game-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(40px, 6.4vw, 82px);
  line-height: 0.94;
  margin: 12px 0 16px;
  letter-spacing: -0.01em;
  color: #3a2c3c;
  text-shadow: 0 2px 30px rgba(255, 233, 214, 0.6);
}

.tagline {
  font-family: var(--serif);
  font-size: clamp(15px, 1.6vw, 20px);
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 0 0 26px;
}

/* One column of pills: eight chapters stack neatly beside the title without wrapping. */
.chapter-buttons {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 20px;
}

.chapter-buttons button {
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.03em;
  padding: 5px 13px;
  border-radius: 999px;
  border: 1px solid rgba(58, 44, 60, 0.28);
  background: rgba(251, 243, 232, 0.4);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: all 200ms ease;
}

.chapter-buttons button.available:hover { background: rgba(251, 243, 232, 0.85); transform: translateY(-1px); }
.chapter-buttons button.locked { opacity: 0.38; cursor: not-allowed; }
.chapter-buttons button.current { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }

button.primary {
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0.08em;
  padding: 12px 30px;
  border-radius: 999px;
  border: 1px solid rgba(58, 44, 60, 0.55);
  background: #3a2c3c;
  color: #fbf3e8;
  cursor: pointer;
  transition: transform 220ms ease, box-shadow 220ms ease, background 220ms ease;
  box-shadow: 0 10px 30px rgba(58, 44, 60, 0.22);
}

button.primary:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(58, 44, 60, 0.3); }
button.primary:active { transform: translateY(0); }

button.ghost {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.06em;
  padding: 11px 22px;
  border-radius: 999px;
  border: 1px solid rgba(58, 44, 60, 0.28);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background 200ms ease;
}

button.ghost:hover { background: rgba(251, 243, 232, 0.6); }

.footnote {
  margin: 30px 0 0;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(58, 44, 60, 0.45);
}

.card {
  background: radial-gradient(120% 100% at 50% 40%, rgba(249, 232, 219, 0.92), rgba(226, 192, 208, 0.88));
  opacity: 1;
  pointer-events: none;
}

.card.fade-out, .screen.fade-out { opacity: 0; }

.card-inner h2, .complete-inner h2, .pause-inner h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(34px, 4.6vw, 58px);
  margin: 14px 0 14px;
  color: var(--ink);
  max-width: 18ch;
  margin-inline: auto;
  text-wrap: balance;
}

#cardSubtitle, #completeBody {
  font-family: var(--serif);
  font-size: clamp(16px, 1.7vw, 21px);
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 34ch;
  margin: 0 auto;
}

.card-hint {
  margin: 32px auto 0;
  font-size: 11px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: rgba(58, 44, 60, 0.55);
}

.complete-inner, .pause-inner { max-width: 42ch; }
.complete-inner .row, .pause-inner .row {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 34px;
  flex-wrap: wrap;
}

.pause-row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(58, 44, 60, 0.12);
  font-family: var(--serif);
  font-size: 15px;
  color: var(--ink-soft);
  text-align: left;
}

.pause-row span { color: var(--ink); }

#fader {
  position: absolute;
  inset: 0;
  background: #e7cfd8;
  opacity: 0;
  pointer-events: none;
  transition: opacity 420ms ease;
  z-index: 8;
}

#fader.on { opacity: 1; }

@media (max-width: 960px) {
  #controls { display: none; }
}

@media (max-width: 720px) {
  #hintBar { font-size: 14px; max-width: 22ch; }
  #titleScreen { justify-content: center; text-align: center; align-items: flex-end; padding-bottom: 8vh; }
  .title-block { padding-left: 0; }
  .chapter-buttons { align-items: center; flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .game-title { font-size: clamp(40px, 12vw, 64px); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 1ms !important; }
}
