:root {
  --ink: #f6ead2;
  --ink-dim: rgba(246, 234, 210, 0.62);
  --gold: #e3b765;
  --ember: #d9763a;
  --glass: rgba(24, 18, 12, 0.42);
  --line: rgba(227, 183, 101, 0.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1a140e;
  color: var(--ink);
  font-family: "Shippori Mincho", "Hiragino Mincho ProN", serif;
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  cursor: grab;
}
#scene:active { cursor: grabbing; }

/* ---------- loader ---------- */
#loader {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 40%, #3a2716 0%, #140e09 70%);
  transition: opacity 1.6s ease, visibility 1.6s;
}
#loader.done { opacity: 0; visibility: hidden; }
.ld-inner { text-align: center; }
.ld-title {
  font-size: 44px;
  letter-spacing: 0.35em;
  margin-right: -0.35em;
  color: var(--ink);
  text-shadow: 0 0 30px rgba(227, 150, 60, 0.35);
}
.ld-sub { margin-top: 10px; font-size: 13px; color: var(--ink-dim); letter-spacing: 0.15em; }
.ld-bar {
  width: 220px; height: 1px; margin: 26px auto 0;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.ld-bar i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--ember), var(--gold));
  transition: width 0.3s ease;
}
.ld-leaf {
  width: 26px; height: 26px; margin: 0 auto 22px;
  background: var(--ember);
  border-radius: 0 60% 0 60%;
  transform: rotate(45deg);
  animation: sway 2.4s ease-in-out infinite;
  box-shadow: 0 0 24px rgba(217, 118, 58, 0.55);
}
@keyframes sway {
  0%, 100% { transform: rotate(30deg) translateX(-6px); }
  50% { transform: rotate(70deg) translateX(6px); }
}

/* ---------- UI ---------- */
#ui { transition: opacity 0.6s ease; }
#ui.hidden { opacity: 0; pointer-events: none; }

#title {
  position: fixed;
  top: 28px; left: 36px;
  pointer-events: none;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
}
#title h1 {
  margin: 0;
  font-weight: 600;
  font-size: 34px;
  letter-spacing: 0.3em;
}
#title p {
  margin: 4px 0 0;
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-size: 17px;
  letter-spacing: 0.12em;
  color: var(--ink-dim);
}

#panel {
  position: fixed;
  right: 28px; bottom: 28px;
  width: 330px;
  padding: 18px 20px 16px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 14px;
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.row {
  display: grid;
  grid-template-columns: 34px 1fr 64px;
  align-items: center;
  gap: 10px;
  margin: 4px 0;
}
.lbl { font-size: 14px; letter-spacing: 0.1em; color: var(--ink-dim); }
.val {
  text-align: right;
  font-family: "Cormorant Garamond", serif;
  font-size: 18px;
  color: var(--gold);
}
#windLabel { font-family: "Shippori Mincho", serif; font-size: 13px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(90deg, rgba(227,183,101,0.15), rgba(227,183,101,0.6));
  border-radius: 2px;
}
input[type="range"]::-moz-range-track {
  height: 2px;
  background: linear-gradient(90deg, rgba(227,183,101,0.15), rgba(227,183,101,0.6));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px; margin-top: -6px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(227, 183, 101, 0.18), 0 0 14px rgba(227, 150, 60, 0.6);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border: none;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
}

.chips {
  display: flex;
  gap: 6px;
  margin: 2px 0 10px 44px;
}
.chips button, .btns button {
  font-family: inherit;
  color: var(--ink);
  background: rgba(255, 240, 210, 0.05);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s, color 0.25s;
}
.chips button { font-size: 12px; padding: 3px 10px; }
.row.seg { grid-template-columns: 34px 1fr; margin: 6px 0; }
.chips.inline { margin: 0; flex-wrap: wrap; gap: 5px; }
.chips.inline button { min-width: 34px; }
.chips button.on {
  background: linear-gradient(135deg, rgba(217,118,58,0.55), rgba(227,183,101,0.4));
  border-color: rgba(227, 183, 101, 0.7);
}
.chips button:hover, .btns button:hover { background: rgba(227, 183, 101, 0.16); }

.btns {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(227, 183, 101, 0.14);
}
.btns button { font-size: 13px; padding: 6px 13px; letter-spacing: 0.08em; }
.btns button.on {
  background: linear-gradient(135deg, rgba(217,118,58,0.55), rgba(227,183,101,0.4));
  border-color: rgba(227, 183, 101, 0.7);
}

#hint {
  position: fixed;
  left: 36px; bottom: 30px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  transition: opacity 2s ease;
}
#hint.fade { opacity: 0; }
kbd {
  font-family: "Cormorant Garamond", serif;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 5px;
}

#credit {
  position: fixed;
  top: 32px; right: 30px;
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-size: 14px;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

/* ---------- walking ---------- */
#fade {
  position: fixed; inset: 0; z-index: 15;
  background: #0b0806;
  opacity: 0; pointer-events: none;
  transition: opacity 0.5s ease;
}
#fade.on { opacity: 1; }
#walkHud { display: none; }
body.walking #walkHud { display: block; }
body.walking #hint, body.walking #title p { display: none; }
#crosshair {
  position: fixed; left: 50%; top: 50%;
  width: 4px; height: 4px; margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: rgba(255, 240, 210, 0.7);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
#prompt {
  position: fixed; left: 50%; top: 58%;
  transform: translateX(-50%);
  padding: 6px 16px;
  font-size: 14px; letter-spacing: 0.12em;
  color: var(--ink);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  opacity: 0; transition: opacity 0.4s;
  pointer-events: none;
}
#prompt.on { opacity: 1; }
#prompt.action { pointer-events: auto; cursor: pointer; }
#walkTip {
  position: fixed; left: 50%; top: 22px;
  transform: translateX(-50%);
  font-size: 12px; letter-spacing: 0.08em;
  color: var(--ink-dim);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  transition: opacity 1s;
  white-space: nowrap;
}
#walkTip.dim { opacity: 0.35; }
#btnExitWalk {
  position: fixed; left: 36px; bottom: 28px;
  font-family: inherit; font-size: 13px; letter-spacing: 0.1em;
  padding: 8px 16px;
  color: var(--ink);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
#joy {
  display: none;
  position: fixed; left: 28px; bottom: 90px;
  width: 130px; height: 130px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(24, 18, 12, 0.3);
  touch-action: none;
}
#joy i {
  position: absolute; left: 50%; top: 50%;
  width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: rgba(227, 183, 101, 0.55);
  box-shadow: 0 0 16px rgba(227, 150, 60, 0.4);
}
@media (pointer: coarse) {
  #joy { display: block; }
  #walkTip { white-space: normal; width: 80%; text-align: center; top: 68px; }
  body.walking #panel { display: none; }
}
#placeToast {
  position: fixed; left: 50%; top: 34%;
  transform: translate(-50%, -50%);
  text-align: center;
  opacity: 0; transition: opacity 1.2s ease;
  pointer-events: none; z-index: 16;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.8);
}
#placeToast.on { opacity: 1; }
#placeToast { white-space: nowrap; }
#placeToast b { display: block; font-size: clamp(22px, 7vw, 30px); font-weight: 600; letter-spacing: 0.4em; margin-right: -0.4em; }
#placeToast span { display: block; margin-top: 6px; font-family: "Cormorant Garamond", serif; font-style: italic; font-size: 16px; letter-spacing: 0.15em; color: var(--ink-dim); }
.btns button.walk { border-color: rgba(227, 183, 101, 0.55); }
body.walking #scene { cursor: crosshair; }

@media (max-width: 640px) {
  #btnExitWalk { left: auto; right: 16px; bottom: 24px; }
  #credit { top: auto; bottom: 8px; right: 16px; font-size: 11px; }
  #title { top: 18px; left: 16px; }
  #title h1 { font-size: 24px; }
  #title p { font-size: 14px; }
  #panel { left: 16px; right: 16px; bottom: 16px; width: auto; padding: 10px 14px 10px; }
  .chips { margin: 0 0 6px; flex-wrap: wrap; }
  .row.seg { margin: 3px 0; }
  .chips.inline button { padding: 2px 8px; }
  .btns { margin-top: 8px; padding-top: 8px; gap: 5px; }
  .btns button { font-size: 12px; padding: 5px 10px; }
  #hint { display: none; }
}
