/* ============================================================================
   Cozy Room — cute pastel UI
   ----------------------------------------------------------------------------
   Fonts: "Quicksand" by The Quicksand Project Authors (Andrew Paglinawan),
   SIL Open Font License 1.1 — vendored as woff2 in ./fonts/.
   ========================================================================== */

@font-face {
  font-family: 'Quicksand';
  src: url('./fonts/quicksand-latin-500.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Quicksand';
  src: url('./fonts/quicksand-latin-600.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Quicksand';
  src: url('./fonts/quicksand-latin-700.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --ink: #3b3157;
  --ink-soft: #726890;
  --ink-faint: rgba(59, 49, 87, 0.48);
  --paper: #fffaf2;
  --cream: #fff4e6;
  --lav: #cfc0ee;
  --lav-deep: #a58fd6;
  --pink: #f7aec6;
  --pink-deep: #ef8fae;
  --coral: #fb9d7d;
  --peach: #ffc9a8;
  --butter: #ffd991;
  --mint: #a9e3cb;
  --sky: #cfe6f8;

  --glass: linear-gradient(158deg, rgba(255, 252, 246, 0.93) 0%, rgba(250, 243, 255, 0.84) 58%, rgba(244, 236, 255, 0.80) 100%);
  --glass-strong: linear-gradient(160deg, #fffbf3 0%, #fbf3ff 62%, #f6eeff 100%);
  --stroke: rgba(255, 255, 255, 0.78);
  --stroke-soft: rgba(165, 143, 214, 0.22);
  --shadow: 0 14px 34px -12px rgba(52, 38, 86, 0.42), 0 3px 10px -4px rgba(52, 38, 86, 0.22);
  --shadow-soft: 0 8px 22px -14px rgba(52, 38, 86, 0.5);
  --inner: inset 0 1px 0 rgba(255, 255, 255, 0.9), inset 0 -1px 0 rgba(165, 143, 214, 0.12);
  --radius: 20px;
  --radius-sm: 13px;
  --font: 'Quicksand', ui-rounded, 'SF Pro Rounded', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #14111f; color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#app { display: block; width: 100vw; height: 100vh; outline: none; }

/* ------------------------------------------------------------------ boot */
#boot {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(120% 90% at 50% 8%, #4a3f6b 0%, #241d33 62%, #14111f 100%);
  z-index: 60; transition: opacity 0.7s ease, visibility 0.7s ease;
  font-family: var(--font);
}
#boot.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-card { text-align: center; color: #f7f0ff; }
.boot-cat { font-size: 42px; opacity: 0.92; animation: bob 2.6s ease-in-out infinite; }
.boot-title { font-size: 32px; font-weight: 700; letter-spacing: 0.05em; margin-top: 12px; }
.boot-sub { margin-top: 9px; font-size: 13px; opacity: 0.55; letter-spacing: 0.09em; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

/* -------------------------------------------------------------------- ui */
#ui {
  position: fixed; inset: 0; z-index: 20;
  pointer-events: none; user-select: none;
  font-size: clamp(13.5px, 1.25vmin + 7.2px, 26px);
  line-height: 1.35;
  letter-spacing: 0.005em;
  color: var(--ink);
}
#ui button { font: inherit; cursor: pointer; -webkit-appearance: none; appearance: none; }
#ui .glass {
  background: var(--glass);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow), var(--inner);
  -webkit-backdrop-filter: blur(16px) saturate(1.25);
  backdrop-filter: blur(16px) saturate(1.25);
  border-radius: var(--radius);
}
#ui .hidden { display: none !important; }

/* translucent little keycap */
.kbd {
  display: inline-grid; place-items: center;
  min-width: 1.55em; height: 1.55em; padding: 0 0.36em;
  border-radius: 0.46em;
  font-size: 0.78em; font-weight: 700; letter-spacing: 0.03em;
  color: var(--ink);
  background: linear-gradient(180deg, #fffdf8, #f3ebfa);
  border: 1px solid rgba(165, 143, 214, 0.30);
  box-shadow: 0 1.5px 0 rgba(132, 108, 178, 0.28), inset 0 1px 0 #fff;
  white-space: nowrap;
}

/* --------------------------------------------------------------- the HUD */
.hud { position: absolute; inset: 0; opacity: 1; transition: opacity 0.28s ease; z-index: 1; }
body.nohud .hud { display: none !important; }
#ui.celebrating .hud { opacity: 0; pointer-events: none; }
#ui.photo .hud { opacity: 0; pointer-events: none; }

.hud-corner { position: absolute; display: flex; gap: 0.6em; align-items: flex-start; }
.hud-tl { top: clamp(14px, 2.1vh, 26px); left: clamp(14px, 1.8vw, 30px); }
.hud-tr { top: clamp(14px, 2.1vh, 26px); right: clamp(14px, 1.8vw, 30px); flex-direction: column; align-items: flex-end; }

.room-tag { padding: 0.62em 1em 0.68em; min-width: 9.4em; }
.room-title {
  font-size: 1.06em; font-weight: 700; letter-spacing: 0.045em;
  display: flex; align-items: center; gap: 0.4em;
}
.room-title .tiny-star { width: 0.85em; height: 0.85em; flex: none; color: #f2b64f; opacity: 0.95; }
.mood-chip {
  margin-top: 0.42em; display: inline-flex; align-items: center; gap: 0.42em;
  font-size: 0.76em; font-weight: 600; color: var(--ink-soft);
  padding: 0.12em 0.55em 0.16em 0.45em; border-radius: 999px;
  background: linear-gradient(120deg, rgba(255, 233, 205, 0.75), rgba(236, 224, 255, 0.7));
  border: 1px solid rgba(255, 255, 255, 0.7);
  transition: background 0.6s ease, color 0.4s ease;
}
.mood-dot {
  width: 0.5em; height: 0.5em; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #fff6d9, #ffb787 62%, #f18e6e);
  box-shadow: 0 0 0.5em rgba(255, 180, 130, 0.9);
  transition: background 0.6s ease, box-shadow 0.6s ease;
}
.mood-chip[data-mood='day'] .mood-dot { background: radial-gradient(circle at 34% 30%, #ffffff, #cfe8ff 60%, #9fc9ef); box-shadow: 0 0 0.5em rgba(160, 205, 245, 0.9); }
.mood-chip[data-mood='dusk'] .mood-dot { background: radial-gradient(circle at 34% 30%, #ffe3f3, #d3a7e8 60%, #a67cc9); box-shadow: 0 0 0.5em rgba(196, 148, 232, 0.9); }
.mood-chip[data-mood='night'] .mood-dot { background: radial-gradient(circle at 34% 30%, #e8f0ff, #8fa6e8 60%, #63709e); box-shadow: 0 0 0.5em rgba(140, 165, 240, 0.8); }

/* progress card */
.progress-card { padding: 0.58em 0.9em 0.62em; display: grid; gap: 0.3em; justify-items: end; }
.pips { display: flex; gap: 0.32em; }
.pip { width: 1.15em; height: 1.15em; position: relative; }
.pip svg { width: 100%; height: 100%; display: block; overflow: visible; }
.pip .star-base { fill: rgba(196, 178, 226, 0.44); stroke: rgba(101, 77, 145, 0.58); stroke-width: 1.15; }
.pip .star-fill {
  fill: url(#starGrad); opacity: 0; transform-origin: 50% 55%;
  transform: scale(0.4); transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.2, 1.7, 0.4, 1);
}
.pip.on .star-fill { opacity: 1; transform: scale(1); }
.pip.on { filter: drop-shadow(0 0 0.32em rgba(255, 200, 105, 0.75)); }
.pip.pop { animation: pipPop 0.5s cubic-bezier(0.2, 1.7, 0.4, 1); }
@keyframes pipPop { 0% { transform: scale(1); } 38% { transform: scale(1.45) rotate(-8deg); } 100% { transform: scale(1); } }
.progress-label { font-size: 0.78em; font-weight: 600; color: var(--ink-soft); letter-spacing: 0.03em; }
.progress-label b { font-size: 1.26em; font-weight: 700; color: var(--ink); }

/* crosshair */
.crosshair {
  position: absolute; left: 50%; top: 50%; width: 22px; height: 22px;
  transform: translate(-50%, -50%); display: grid; place-items: center;
  transition: opacity 0.25s ease, transform 0.18s ease;
  opacity: 0.72;
}
.crosshair::before {
  content: ''; width: 5.5px; height: 5.5px; border-radius: 50%;
  background: rgba(255, 253, 246, 0.98);
  box-shadow: 0 0 0 1.5px rgba(52, 38, 84, 0.5), 0 0 0 5px rgba(255, 250, 236, 0.10), 0 0 12px rgba(255, 240, 215, 0.7);
}
.crosshair::after {
  content: ''; position: absolute; inset: 2px; border-radius: 50%;
  border: 1px solid rgba(255, 250, 240, 0.32);
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.crosshair.hot::after { border-color: rgba(255, 226, 168, 0.75); transform: scale(1.18); }
.crosshair.hot::before { background: #fff3cf; box-shadow: 0 0 0 1.5px rgba(58, 44, 92, 0.3), 0 0 14px rgba(255, 216, 138, 0.9); }

/* interaction prompt */
.prompt {
  position: absolute; left: 50%; bottom: clamp(48px, 7.4vh, 84px);
  transform: translate(-50%, 14px) scale(0.96); opacity: 0;
  display: flex; align-items: center; gap: 0.62em;
  padding: 0.52em 1em 0.56em 0.7em; border-radius: 999px;
  transition: opacity 0.18s ease, transform 0.24s cubic-bezier(0.2, 1.3, 0.4, 1);
  max-width: min(74vw, 44em);
}
.prompt.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.prompt .kbd { background: linear-gradient(180deg, #fff6e7, #ffe9c8); border-color: rgba(226, 178, 112, 0.42); }
.prompt-label {
  font-size: 0.9em; font-weight: 600; letter-spacing: 0.012em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* toasts */
.toast-stack {
  position: absolute; left: 50%; bottom: clamp(104px, 16vh, 160px);
  transform: translateX(-50%);
  display: flex; flex-direction: column-reverse; align-items: center; gap: 0.45em;
  width: min(80vw, 34em); pointer-events: none;
}
.toast {
  font-size: 0.85em; font-weight: 600; color: var(--ink);
  padding: 0.5em 0.95em 0.54em;
  border-radius: 999px;
  background: linear-gradient(150deg, rgba(255, 250, 241, 0.96), rgba(250, 240, 255, 0.94));
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow-soft);
  display: flex; align-items: center; gap: 0.5em;
  opacity: 0; transform: translateY(8px) scale(0.97);
  transition: opacity 0.3s ease, transform 0.36s cubic-bezier(0.2, 1.3, 0.4, 1);
  text-align: center;
}
.toast::before {
  content: ''; width: 0.52em; height: 0.52em; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, #fff5d6, #ffc184 65%, #f79f86);
  box-shadow: 0 0 0.5em rgba(255, 190, 140, 0.85);
}
.toast.show { opacity: 1; transform: translateY(0) scale(1); }
.toast.out { opacity: 0; transform: translateY(-8px) scale(0.97); }

/* controls hint card */
.hint-card {
  position: absolute; left: clamp(14px, 1.8vw, 30px); bottom: clamp(14px, 2.1vh, 26px);
  padding: 0.66em 0.9em 0.7em; display: grid; gap: 0.36em;
  font-size: 0.76em; color: var(--ink-soft);
  transition: opacity 0.9s ease, transform 0.9s ease;
  max-width: 20em;
}
.hint-card .hint-row { display: flex; align-items: center; gap: 0.6em; }
.hint-card .hint-row span { white-space: nowrap; }
.hint-card .hint-keys { display: flex; gap: 0.22em; flex: none; }
.hint-card.fade { opacity: 0; transform: translateY(8px); }
.hint-title {
  font-size: 0.86em; font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--ink-faint); margin-bottom: 0.1em;
}

/* sound toggle */
.sound-toggle {
  position: absolute; right: clamp(14px, 1.8vw, 30px); bottom: clamp(14px, 2.1vh, 26px);
  width: 2.7em; height: 2.7em; border-radius: 50%;
  display: grid; place-items: center; pointer-events: auto;
  background: var(--glass); border: 1px solid var(--stroke);
  box-shadow: var(--shadow-soft), var(--inner);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  color: var(--ink-soft); transition: transform 0.18s ease, color 0.18s ease, background 0.3s ease;
}
.sound-toggle:hover { transform: translateY(-2px) scale(1.04); color: var(--ink); }
.sound-toggle:active { transform: scale(0.96); }
.sound-toggle svg { width: 1.3em; height: 1.3em; }
.sound-toggle .slash { opacity: 0; transition: opacity 0.2s ease; }
.sound-toggle.muted .slash { opacity: 1; }
.sound-toggle.muted { color: var(--pink-deep); }

/* lock hint (pointer lock fallback) */
.lock-hint {
  position: absolute; left: 50%; bottom: clamp(48px, 7.4vh, 84px);
  transform: translate(-50%, 10px); opacity: 0;
  padding: 0.5em 1em 0.54em; border-radius: 999px;
  font-size: 0.82em; font-weight: 600; color: var(--ink-soft);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.lock-hint.show { opacity: 1; transform: translate(-50%, 0); }

/* --------------------------------------------------------- photo mode */
.photo-chip {
  position: absolute; left: 50%; z-index: 5; top: clamp(16px, 3.2vh, 34px); transform: translate(-50%, -8px);
  opacity: 0; transition: opacity 0.3s ease, transform 0.3s ease;
  padding: 0.46em 1.05em 0.5em; border-radius: 999px;
  font-size: 0.8em; font-weight: 600; letter-spacing: 0.06em; color: var(--ink-soft);
  display: flex; align-items: center; gap: 0.55em;
}
.photo-chip.show { opacity: 1; transform: translate(-50%, 0); }
.photo-chip .lens { width: 0.72em; height: 0.72em; border-radius: 50%; border: 2px solid currentColor; opacity: 0.65; }
.photo-frame { position: absolute; inset: clamp(10px, 2.2vh, 26px); z-index: 4; opacity: 0; transition: opacity 0.35s ease; }
.photo-frame.show { opacity: 0.85; }
.photo-frame i {
  position: absolute; width: 1.5em; height: 1.5em;
  border: 1.5px solid rgba(255, 250, 240, 0.65); border-radius: 3px;
}
.photo-frame i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 10px; }
.photo-frame i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 10px; }
.photo-frame i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 10px; }
.photo-frame i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 10px; }

/* ----------------------------------------------------------- overlays */
.veil {
  position: absolute; inset: 0; pointer-events: auto; z-index: 10;
  display: grid; place-items: center;
  opacity: 0; visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}
.veil.show { opacity: 1; visibility: visible; }
.veil::before {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(120% 92% at 50% 10%, rgba(58, 43, 92, 0.58), rgba(24, 17, 40, 0.80) 74%),
    radial-gradient(84% 62% at 50% 104%, rgba(255, 178, 135, 0.18), transparent 72%);
  -webkit-backdrop-filter: blur(12px) saturate(1.06) brightness(0.92);
  backdrop-filter: blur(12px) saturate(1.06) brightness(0.92);
}
.veil > .card-wrap { position: relative; z-index: 1; width: min(92vw, 31em); }

/* generic card */
.card {
  position: relative;
  background: var(--glass-strong);
  border: 1px solid var(--stroke);
  border-radius: clamp(20px, 2.2vw, 30px);
  box-shadow: 0 34px 70px -30px rgba(31, 22, 52, 0.72), 0 2px 0 rgba(255, 255, 255, 0.6) inset, var(--inner);
  padding: clamp(24px, 3.6vh, 40px) clamp(22px, 2.6vw, 42px);
  transform: translateY(16px) scale(0.98);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.2, 1.25, 0.4, 1), opacity 0.4s ease;
}
.veil.show .card { transform: none; opacity: 1; }
.card h1, .card h2 { margin: 0; letter-spacing: 0.01em; }

/* intro */
.intro .card-wrap { width: min(92vw, 33em); }
.intro-card { text-align: center; }
.intro-badge {
  width: clamp(84px, 11vh, 116px); height: clamp(84px, 11vh, 116px);
  margin: -74px auto 10px; display: block;
  filter: drop-shadow(0 12px 22px rgba(74, 50, 110, 0.34));
  animation: badgeFloat 6s ease-in-out infinite;
}
@keyframes badgeFloat { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-6px) rotate(1.5deg); } }
.intro-eyebrow {
  font-size: 0.72em; font-weight: 700; letter-spacing: 0.24em; text-transform: uppercase;
  color: rgba(74, 58, 110, 0.62);
}
.intro-title {
  font-size: clamp(2.15rem, 4.6vw, 3.15rem); font-weight: 700; line-height: 1.02;
  margin-top: 0.1em !important;
  background: linear-gradient(178deg, #3d2d60 10%, #5a3f7f 56%, #7d538f 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.intro-sub {
  margin: 0.55em auto 0; max-width: 26em;
  font-size: 0.95em; font-weight: 500; color: #5f5279; line-height: 1.55;
}
.intro-sub b { color: var(--ink); font-weight: 700; }

.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 0.55em;
  padding: 0.78em 1.6em 0.82em; border-radius: 999px;
  font-size: 1em; font-weight: 700; letter-spacing: 0.015em;
  color: #fffaf4;
  background: linear-gradient(155deg, #ffab80 0%, #f6879b 46%, #dd7cb2 100%);
  box-shadow: 0 14px 28px -10px rgba(206, 91, 130, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.5);
  transition: transform 0.18s cubic-bezier(0.2, 1.4, 0.4, 1), box-shadow 0.22s ease, filter 0.2s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 16px 30px -10px rgba(214, 108, 140, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.6); filter: saturate(1.06); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.9); outline-offset: 3px; }
.btn .spark { width: 1.1em; height: 1.1em; opacity: 0.95; }
.btn-ghost {
  background: linear-gradient(160deg, rgba(255, 253, 248, 0.95), rgba(244, 236, 255, 0.9));
  color: var(--ink); border: 1px solid var(--stroke);
  box-shadow: var(--shadow-soft), var(--inner);
}
.btn-ghost:hover { box-shadow: 0 10px 22px -12px rgba(52, 38, 86, 0.55), var(--inner); }

.intro-start { margin-top: clamp(16px, 2.5vh, 26px); font-size: 1.02em; padding-left: 1.35em; padding-right: 1.55em; }
.intro-start .arrow { transition: transform 0.25s ease; }
.intro-start:hover .arrow { transform: translateX(3px); }

.keygrid {
  margin-top: clamp(16px, 2.6vh, 28px);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.42em 0.55em;
  padding-top: clamp(14px, 2.2vh, 22px);
  border-top: 1px solid rgba(165, 143, 214, 0.22);
  text-align: left;
}
.keygrid .krow { display: flex; align-items: center; gap: 0.44em; font-size: 0.76em; font-weight: 600; color: #5c4e78; }
.keygrid .krow .kbd { transform: scale(0.94); }
.intro-foot { margin-top: clamp(14px, 2vh, 20px); font-size: 0.72em; color: rgba(74, 58, 110, 0.55); letter-spacing: 0.04em; }

/* pause */
.pause .card-wrap { width: min(92vw, 27em); }
.pause-card { text-align: center; position: relative; }
.pause-sound {
  position: absolute; top: 0.9em; right: 0.9em; bottom: auto; left: auto;
  width: 2.35em; height: 2.35em;
}
.pause-sound svg { width: 1.15em; height: 1.15em; }
.pause-title { font-size: clamp(1.6rem, 3.2vw, 2.05rem); font-weight: 700; color: #40305f; }
.pause-sub { margin-top: 0.4em; font-size: 0.88em; color: #63557f; }
.pause-actions { margin-top: 1.15em; display: grid; gap: 0.55em; justify-items: stretch; }
.pause-actions .btn { width: 100%; }
.mood-row { display: flex; gap: 0.4em; justify-content: center; flex-wrap: wrap; margin-top: 1.05em; }
.mood-btn {
  pointer-events: auto; font-size: 0.76em; font-weight: 600; color: #5c4e78;
  padding: 0.5em 0.78em 0.54em; border-radius: 999px;
  background: rgba(255, 255, 255, 0.5); border: 1px solid var(--stroke-soft);
  transition: transform 0.16s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.mood-btn:hover { transform: translateY(-1px); background: rgba(255, 255, 255, 0.8); color: var(--ink); }
.mood-btn.active {
  color: #fffaf4;
  background: linear-gradient(150deg, #b9a4e6, #9b84cf);
  border-color: rgba(255, 255, 255, 0.55);
  box-shadow: 0 8px 18px -10px rgba(120, 92, 180, 0.9);
}
.pause-hints { margin-top: 1.1em; display: flex; flex-wrap: wrap; gap: 0.4em 0.8em; justify-content: center; font-size: 0.72em; color: rgba(74, 58, 110, 0.6); }
.pause-hints .hint-mini { display: inline-flex; align-items: center; gap: 0.34em; }
.pause-foot { margin-top: 1em; font-size: 0.7em; color: rgba(74, 58, 110, 0.55); }

/* completion */
.complete .card-wrap { width: min(92vw, 31em); }
.complete-card { text-align: center; padding-top: clamp(30px, 4.6vh, 46px); }
.ribbon {
  width: clamp(92px, 13vh, 128px); height: clamp(92px, 13vh, 128px);
  margin: -88px auto -6px; display: block;
  animation: ribbonIn 0.75s cubic-bezier(0.2, 1.5, 0.35, 1) both, badgeFloat 5.5s 0.8s ease-in-out infinite;
  filter: drop-shadow(0 14px 24px rgba(74, 50, 110, 0.38));
}
@keyframes ribbonIn { from { transform: scale(0.5) rotate(-24deg); opacity: 0; } to { transform: none; opacity: 1; } }
.complete-title {
  font-size: clamp(1.8rem, 3.8vw, 2.5rem); font-weight: 700; line-height: 1.1;
  color: #4a346f; letter-spacing: 0.005em;
}
.complete-sub { margin-top: 0.6em; font-size: 0.92em; color: #63557f; line-height: 1.5; }
.complete-stars { display: flex; justify-content: center; gap: 0.42em; margin: 1em 0 0.2em; }
.complete-stars .pip { width: 1.5em; height: 1.5em; }
.complete-stars .pip .star-fill { animation: starShine 2.6s ease-in-out infinite; }
.complete-stars .pip:nth-child(2) .star-fill { animation-delay: 0.12s; }
.complete-stars .pip:nth-child(3) .star-fill { animation-delay: 0.24s; }
.complete-stars .pip:nth-child(4) .star-fill { animation-delay: 0.36s; }
.complete-stars .pip:nth-child(5) .star-fill { animation-delay: 0.48s; }
@keyframes starShine { 0%, 100% { filter: drop-shadow(0 0 1px rgba(255, 205, 120, 0.4)); } 50% { filter: drop-shadow(0 0 6px rgba(255, 205, 120, 0.95)); } }
.complete-actions { margin-top: 1.25em; display: flex; gap: 0.55em; justify-content: center; flex-wrap: wrap; }

.confetti { position: absolute; inset: -10% -2%; overflow: hidden; pointer-events: none; z-index: 0; }
.confetti span {
  position: absolute; top: -8%; display: block; opacity: 0;
  animation: confettiFall var(--dur, 3.6s) linear var(--delay, 0s) infinite;
  will-change: transform, opacity;
}
@keyframes confettiFall {
  0% { transform: translate3d(0, -10vh, 0) rotate(0deg); opacity: 0; }
  8% { opacity: 0.9; }
  85% { opacity: 0.75; }
  100% { transform: translate3d(var(--drift, 0px), 112vh, 0) rotate(var(--spin, 360deg)); opacity: 0; }
}

/* -------------------------------------------------- responsive / a11y */
@media (max-width: 760px) {
  #ui { font-size: clamp(12.5px, 3.1vw, 16px); }
  .keygrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .keygrid .krow { font-size: 0.74em; }
  .hint-card { display: none; }
  .hud-tr .progress-card { padding: 0.5em 0.7em 0.54em; }
  .room-tag { min-width: 0; }
  .prompt { bottom: 70px; }
  .toast-stack { bottom: 124px; width: 88vw; }
}
@media (max-height: 520px) {
  .keygrid { margin-top: 0.7em; padding-top: 0.7em; }
  .intro-badge { width: 64px; height: 64px; margin-top: -58px; }
  .card { padding-top: 18px; padding-bottom: 18px; }
  .hint-card { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.08s !important; }
  .confetti { display: none; }
}

/* no-hud QA mode hides every piece of chrome */
body.nohud #ui { display: none !important; }
