/* Sylvie & The Solstice Pine — base: tokens, stage layers, Sylvie, speech bubble, loading, title, buttons. */

:root {
  --night: #0a1118;
  --gold: #fbbf24;
  --gold-d: #d97706;
  --ink: #3b2a1a;
  --ink-soft: #6b5337;
  --glass: rgba(8, 14, 20, 0.74);
  --line: rgba(251, 191, 36, 0.3);
  --font-display: "Cinzel", "Trajan Pro", Georgia, "Times New Roman", serif;
  --font-body: "Lora", Georgia, "Times New Roman", serif;
  --font-hand: "Caveat", "Segoe Script", "Bradley Hand", "Comic Sans MS", cursive;
  --hud-h: calc(56px + env(safe-area-inset-top, 0px));
  --sheet-h: 62vh;
  --sheet-h: 62dvh;
  --vvh: 100vh;
  --vvh: 100dvh;
  --kb: 0px;
  --ui: 1;
}
html[data-textsize="s"] { --ui: 0.94; }
html[data-textsize="l"] { --ui: 1.14; }

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

html, body {
  height: 100%;
  margin: 0;
  background: var(--night);
  color: #f6f1e4;
  font-family: var(--font-body);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body { position: fixed; inset: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
img { -webkit-user-drag: none; user-select: none; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

#game { position: fixed; inset: 0; overflow: hidden; overflow: clip; touch-action: manipulation; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---- the six tappable heirlooms (invisible buttons over the canvas) ------------------ */
#hits { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.hit {
  position: absolute; left: 0; top: 0; padding: 0; border: 0; background: transparent;
  border-radius: 20px; pointer-events: auto; -webkit-appearance: none; appearance: none;
}
.hit:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; box-shadow: 0 0 0 7px rgba(251, 191, 36, 0.25); }

/* ---- Sylvie -------------------------------------------------------------------------- */
.sylvie {
  position: absolute; left: 0; top: 0; z-index: 2; pointer-events: none; will-change: transform;
  transform-origin: 347px 386px;
  filter: drop-shadow(0 26px 30px rgba(0, 0, 0, 0.42));
  transition: opacity 0.5s;
}
.sylvie img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; visibility: hidden; pointer-events: none; }
.sylvie img.on { visibility: visible; }
.sylvie.is-hidden { opacity: 0; }
.sylvie-poke { position: absolute; left: 0; top: 0; z-index: 3; padding: 0; border: 0; border-radius: 50%; background: transparent; }

/* ---- speech bubble ------------------------------------------------------------------- */
.bubble {
  position: absolute; left: 0; top: 0; z-index: 4;
  max-width: min(300px, 78vw); padding: 12px 16px;
  border-radius: 18px; border: 2px solid #d9a441;
  background: #fff8e6; color: var(--ink);
  font: 500 calc(16px * var(--ui)) / 1.4 var(--font-body);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.bubble.is-visible { opacity: 1; pointer-events: auto; cursor: pointer; }
.bubble-text { margin: 0; }
.bubble-tail {
  position: absolute; bottom: -9px; width: 16px; height: 16px;
  background: #fff8e6; border-right: 2px solid #d9a441; border-bottom: 2px solid #d9a441;
  transform: translateX(-50%) rotate(45deg);
}
.bubble[data-pos="below"] .bubble-tail {
  top: -9px; bottom: auto; border: 0; border-left: 2px solid #d9a441; border-top: 2px solid #d9a441;
}

/* ---- loading ------------------------------------------------------------------------- */
.loading {
  position: absolute; inset: 0; z-index: 9; display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 30%, #17303f 0%, var(--night) 70%);
  transition: opacity 0.6s;
}
.loading.is-done { opacity: 0; pointer-events: none; }
.loading-inner { text-align: center; padding: 20px; }
.loading-title { margin: 0 0 18px; font: 700 22px var(--font-display); letter-spacing: 0.04em; color: var(--gold); }
.loading-track { width: min(240px, 60vw); height: 6px; margin: 0 auto; border-radius: 6px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.loading-track i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #d97706, #fbbf24); transition: width 0.2s; }
.loading-text { margin: 14px 0 0; font-size: 16px; color: #c9d6e2; }

/* ---- buttons ------------------------------------------------------------------------- */
.btn {
  appearance: none; -webkit-appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 20px;
  border: 2px solid transparent; border-radius: 14px;
  font: 700 calc(16px * var(--ui)) / 1.2 var(--font-display); letter-spacing: 0.03em; text-align: center;
  transition: transform 0.15s, filter 0.15s, box-shadow 0.2s, opacity 0.2s;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary {
  background: linear-gradient(180deg, #fcd34d, #f59e0b 55%, #d97706); color: #2a1604;
  box-shadow: 0 8px 22px rgba(217, 119, 6, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.07); }
.btn.ghost { background: rgba(255, 255, 255, 0.08); color: inherit; border-color: rgba(251, 191, 36, 0.45); }
.btn.danger { background: transparent; color: #f0a3a3; border-color: #a14a4a; }
.btn.big { min-height: 56px; font-size: 18px; }
.btn.small { min-height: 44px; padding: 8px 14px; font-size: 14px; }

.letter-input {
  width: 100%; border: 0; border-bottom: 2px solid rgba(150, 100, 40, 0.55); border-radius: 0;
  background: transparent; padding: 6px 2px; outline: none;
  font: 600 calc(24px * var(--ui)) / 1.2 var(--font-hand); color: #2f200f;
}
.letter-input::placeholder { color: rgba(90, 60, 25, 0.5); }
.letter-input:focus { border-bottom-color: #d98a1c; box-shadow: 0 2px 0 #d98a1c; }

/* ---- title screen -------------------------------------------------------------------- */
.title {
  position: absolute; inset: 0; z-index: 8; overflow: auto;
  display: flex; align-items: flex-end; justify-content: center;
  padding: calc(20px + env(safe-area-inset-top)) 20px calc(26px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(6, 11, 16, 0.94) 0%, rgba(6, 11, 16, 0.74) 40%, rgba(6, 11, 16, 0.1) 72%, transparent 100%);
  opacity: 0; transition: opacity 0.6s;
}
.title[hidden] { display: none; }
.title.is-shown { opacity: 1; }
.title-inner { width: min(520px, 100%); display: grid; gap: 10px; text-align: center; }
.title-kicker { margin: 0; font: 700 14px var(--font-display); letter-spacing: 0.2em; text-transform: uppercase; color: #f7d27a; }
.title-name { margin: 0; display: grid; font: 700 clamp(34px, 9vw, 56px) / 1.04 var(--font-display); color: #fff4d6; text-shadow: 0 3px 24px rgba(0, 0, 0, 0.7); }
.title-name .gold {
  background: linear-gradient(180deg, #fff0b0, #f5b53a 60%, #d97706);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.5));
}
.title-sub { margin: 0; font: 700 15px var(--font-display); letter-spacing: 0.14em; text-transform: uppercase; color: #9fc4dd; }
.title-tag { margin: 6px auto 2px; max-width: 44ch; font-size: 17px; line-height: 1.5; color: #e6edf4; }
.title-actions { display: grid; gap: 10px; margin-top: 8px; }
.title-name-field { display: grid; gap: 4px; text-align: left; font-size: 15px; color: #c9d6e2; }
.title .letter-input {
  border: 2px solid rgba(251, 191, 36, 0.45); border-radius: 14px; background: rgba(255, 255, 255, 0.08);
  padding: 12px 14px; font: 500 18px var(--font-body); color: #fff8e6;
}
.title .letter-input::placeholder { color: rgba(255, 244, 214, 0.5); }
.title .letter-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.3); }
.title-how { margin: 2px 0 0; font-size: 14px; color: #9db1c3; }
.title-credit { margin: 0; font: 700 14px var(--font-display); letter-spacing: 0.14em; color: #8199ad; }

body[data-orientation="landscape"] .title {
  align-items: center; justify-content: flex-start; padding-left: clamp(24px, 6vw, 96px);
  background: linear-gradient(to right, rgba(6, 11, 16, 0.92), rgba(6, 11, 16, 0.6) 46%, transparent 78%);
}
body[data-orientation="landscape"] .title-inner { width: min(480px, 46vw); text-align: left; }
body[data-orientation="landscape"] .title-tag { margin-left: 0; }
@media (max-height: 520px) and (orientation: landscape) {
  .title-tag, .title-how { display: none; }
  .title-name { font-size: clamp(28px, 6vw, 40px); }
}

/* ---- "follow Sylvie" pill after a tier is lit ------------------------------------------- */
.next-pill {
  position: absolute; z-index: 7; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom));
  width: min(420px, calc(100vw - 32px));
  transform: translate(-50%, 34px); opacity: 0; transition: transform 0.5s cubic-bezier(0.22, 0.9, 0.3, 1), opacity 0.5s;
}
.next-pill[hidden] { display: none; }
.next-pill.is-shown { transform: translate(-50%, 0); opacity: 1; }
.pill-inner {
  display: grid; gap: 6px; padding: 14px 16px; text-align: center;
  background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}
.pill-title { margin: 0; font: 700 calc(18px * var(--ui)) / 1.2 var(--font-display); color: var(--gold); }
.pill-sub { margin: 0 0 4px; font-size: 15px; color: #cdd9e4; }

/* ---- wish orb (flies from the card to the star) ----------------------------------------- */
.wish-orb {
  position: fixed; left: 0; top: 0; z-index: 20; width: 28px; height: 28px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, #fff, #ffe08a 45%, rgba(251, 191, 36, 0) 72%);
  box-shadow: 0 0 24px 8px rgba(255, 214, 120, 0.8);
}

@keyframes dotPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.7); } 60% { box-shadow: 0 0 0 9px rgba(251, 191, 36, 0); } }
@keyframes floatUp { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -26px); } }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after {
  animation-duration: 0.001s !important; animation-iteration-count: 1 !important;
  transition-duration: 0.001s !important; scroll-behavior: auto !important;
}
