.klv-world {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -3;
}
.klv-active {
  isolation: isolate;
}
.klv-active #ribbons,
.klv-active #hour-decor {
  visibility: hidden;
}
.klv-active .hero-character {
  isolation: isolate;
}
.klv-hero-gl,
.klv-hero-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
  display: block;
}
.klv-hero-gl[hidden] {
  display: none;
}
.klv-hero-overlay {
  z-index: 4;
}
.klv-rendered > img {
  opacity: 0 !important;
}
.klv-hero-gl {
  opacity: 0;
}
.klv-rendered .klv-hero-gl {
  opacity: 1;
}
.klv-hero-overlay {
  mix-blend-mode: screen;
}
.klv-vfx {
  border: 1px solid var(--hour-accent, #e7a6ce);
  border-radius: 8px;
  padding: 7px 10px;
  background: #23162ce8;
  color: #ffe7f5;
  white-space: nowrap;
  min-height: 36px;
}
.klv-panel {
  position: fixed;
  inset: auto;
  margin: 0;
  bottom: 90px;
  left: 12px;
  width: min(310px, calc(100vw - 24px));
  box-sizing: border-box;
  padding: 16px;
  background: #1a1125f5;
  color: #ffedf8;
  border: 1px solid var(--hour-accent, #e7a6ce);
  border-radius: 14px;
  box-shadow: 0 12px 40px #0009;
  z-index: 150;
  font: 14px system-ui;
}
.klv-panel label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
}
.klv-panel select {
  background: #302137;
  color: inherit;
  border: 1px solid #8e6389;
  border-radius: 6px;
  padding: 6px;
}
.klv-panel input {
  accent-color: #e7a6ce;
  max-width: 48%;
}
.klv-calibrator {
  position: absolute;
  inset: 0;
  z-index: 35;
  pointer-events: none;
  outline: 1px dashed #ffc0e4;
}
.klv-marker {
  position: absolute;
  translate: -50% -50%;
  pointer-events: auto;
  background: #170b24e8;
  color: #fff;
  border: 1px solid #ffbadd;
  border-radius: 8px;
  padding: 5px;
  font: 11px system-ui;
  cursor: grab;
  touch-action: none;
}
.klv-copy {
  position: absolute;
  left: 8px;
  top: 8px;
  pointer-events: auto;
  background: #311935;
  color: white;
  border: 1px solid #f7a9cf;
  border-radius: 7px;
  padding: 8px;
}
.klv-speech {
  position: fixed;
  max-width: 180px;
  padding: 10px 12px;
  border: 1px solid var(--hour-accent, #e7a6ce);
  border-radius: 12px;
  background: #1c1028ed;
  color: #ffe9f5;
  z-index: 30;
  pointer-events: none;
  font: 13px/1.35 system-ui;
  box-shadow: 0 0 16px #ab659a55;
}
.klv-spark {
  position: fixed;
  pointer-events: none;
  z-index: 29;
  color: var(--hour-accent, #e7a6ce);
  font: 20px Georgia;
  animation: klv-spark 0.85s ease-out both;
}
@keyframes klv-spark {
  to {
    translate: var(--dx) var(--dy);
    opacity: 0;
    scale: 0.35;
  }
}
.klv-side-hot {
  filter: drop-shadow(0 0 16px var(--hour-accent, #e7a6ce));
}
.klv-hero-target {
  box-shadow: 0 0 18px var(--hour-accent, #e7a6ce) !important;
}
.klv-active .krul-side-portraits img {
  pointer-events: auto;
  cursor: pointer;
}
.klv-active .krul-side-portraits {
  z-index: -1;
}
.klv-active .hero-character {
  pointer-events: none;
}
.klv-active .hero-copy {
  position: relative;
  z-index: 5;
}
.klv-active .hero-caption {
  z-index: 5;
}
.klv-active .hero-character > img {
  animation: none;
}
.klv-active.klv-locked .klv-speech,
.klv-active.klv-locked .klv-spark {
  visibility: hidden;
}
@media (max-width: 780px) {
  .klv-panel {
    bottom: 155px;
  }
  .music-dock .klv-vfx {
    grid-column: 1/-1;
    min-height: 30px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .klv-spark {
    animation: none;
    display: none;
  }
}
.klv-hero-overlay {
  z-index: 0;
  border-radius: inherit;
}
.klv-side-hot {
  filter: drop-shadow(0 0 16px var(--klv-accent, var(--hour-accent, #e7a6ce)));
}
.klv-panel[hidden] {
  display: none !important;
}
.klv-active .hero-character.klv-rendered {
  overflow: hidden;
}
.klv-active .hero-character:not(.klv-rendered) > img {
  opacity: 1 !important;
}
.klv-active .hero-actions {
  position: relative;
  z-index: 6;
}
.klv-active .hero-caption {
  position: absolute;
  z-index: 5;
}

/* Ink, moonlit stone and old brass. The hourly colour belongs to the light. */
body.klv-active {
  --brass: #c4a67a;
  --vellum: #f9f0e2;
  --stone: #131726;
  --klv-line: color-mix(in srgb, var(--klv-accent, #c1a6d9) 22%, #585347);
  background: #101523 url('/castle/sanguinem-night.webp') center / cover fixed;
}
body.klv-active::before {
  background: none;
}
.klv-world {
  z-index: -2;
}
.klv-active .topbar {
  background: linear-gradient(90deg, #0d111bef, #161826f2 70%, #131522ec);
  border-bottom: 1px solid #aa936854;
}
.klv-active .topbar .brand,
.klv-active .overline {
  color: #e0c599;
}
.klv-active .topbar .brand span {
  color: #e99cad;
}
body.klv-active .hero {
  isolation: isolate;
  overflow: hidden;
  min-height: clamp(386px, 33vw, 494px);
  margin-top: clamp(26px, 4vw, 66px);
  border: 1px solid var(--klv-line) !important;
  border-radius: 4px 26px 4px 26px;
  background: #101423;
  box-shadow: 0 16px 54px #04060cb0 !important;
  animation: none;
}
.klv-active .hero-scene {
  z-index: -3;
  background:
    linear-gradient(90deg, #090e1ac7, #10152370 54%, #160e1b 80%),
    url('/castle/sanguinem-night.webp') 30% 65% / cover;
}
.klv-active .hero .hero-character {
  inset: 0 0 0 auto;
  width: min(64%, 760px);
  z-index: -1;
  mask-image: linear-gradient(90deg, transparent, #000 21%, #000);
  border-radius: 0;
}
.klv-active .hero .hero-character img {
  object-position: 50% 48%;
  animation: none;
}
.klv-active .hero-rule {
  inset: 8px;
  z-index: 3;
  border-color: #dfc19b46;
  border-radius: 1px 18px 1px 18px;
}
.klv-active .hero-copy {
  width: fit-content;
  max-width: 62%;
  pointer-events: none;
}
.klv-active .hero-actions {
  width: fit-content;
  pointer-events: auto;
}
.klv-active .hero h1 {
  font-size: clamp(48px, 4.65vw, 84px);
  color: var(--vellum);
  letter-spacing: -0.05em;
  -webkit-text-stroke: 0;
  text-shadow: 0 2px 18px #090a14;
}
.klv-active .hero h1 em {
  color: #f3c5ad;
  font-style: italic;
  -webkit-text-stroke: 0;
}
.klv-active .hero-copy p {
  color: #e2dce0;
  max-width: 33ch;
}
.klv-active .overline {
  font-size: 11px;
  letter-spacing: 0.24em;
}
.klv-active .overline .rhombus {
  background: #d3b88a;
  box-shadow: none;
}
.klv-active .hero-actions .primary,
.klv-active #welcome-continue {
  color: #291a20;
  background: linear-gradient(115deg, #f3d9b4, #e2b993);
  border: 1px solid #eed9b7;
  border-radius: 4px;
}
.klv-active .hero-actions .ghost {
  color: #f7ded6;
  background: #141622d9;
  border: 1px solid #b49880;
  border-radius: 4px;
}
.klv-active .hero-caption {
  color: #f6dab7;
  letter-spacing: 0.32em;
  bottom: 20px;
  right: 24px;
}
.klv-hero-overlay {
  z-index: 1;
}
.klv-active .hero .corner {
  pointer-events: none;
  color: var(--brass);
  z-index: 3;
}
body.klv-active #krul-hourly-event {
  border-radius: 4px;
  border: 1px solid var(--klv-line) !important;
  border-inline-start: 3px solid var(--klv-accent) !important;
  background: linear-gradient(100deg, #181c2af7, #121522f5 64%, #20212af0);
}
.klv-active .krul-event-controls .btn {
  background: #151927;
  border-color: #77738380;
  border-radius: 4px;
}
body.klv-active #catalog .catalog-head {
  min-height: 65px;
  border: 0;
  border-block: 1px solid #bc9e726e;
  border-radius: 0;
  background: linear-gradient(90deg, #121625ed, #171b29d9, #141622ed);
  box-shadow: none;
  animation: none;
}
.klv-active #catalog .catalog-title-letters {
  color: var(--vellum);
  -webkit-text-stroke: 0;
  text-shadow: 0 2px 8px #111;
}
.klv-active #catalog .catalog-head::before,
.klv-active #catalog .catalog-head::after {
  background: var(--brass);
  border-color: #f1d8b8;
  box-shadow: none;
}
.klv-active #catalog .catalog-head .tabs {
  background: #111522;
  border-color: #57535a;
}
.klv-active #catalog .tabs button[aria-pressed='true'] {
  background: #393036;
  color: #f4daba;
  border-color: #97795c;
}
body.klv-active #catalog .card {
  background: linear-gradient(145deg, #222637f5, #131723fa 75%);
  border: 1px solid var(--klv-line) !important;
  border-radius: 3px 14px 3px 14px;
  box-shadow: 0 6px 24px #07091480 !important;
  animation: none;
}
.klv-active #catalog .card:hover,
.klv-active #catalog .card:focus-within {
  outline: 1px solid var(--klv-accent);
  outline-offset: -1px;
}
.klv-active .card .count-pill {
  background: #181b28ed;
  color: #e2cbaf;
  border-color: #ae967259;
}
.klv-active #reviews {
  border-color: #ab926965;
  background:
    linear-gradient(90deg, #141927f5, #161925dc),
    url('/castle/sanguinem-night.webp') center 66% / cover;
}
.klv-active .music-dock,
.klv-panel,
.klv-speech {
  background: #151926f5;
  color: #f8eddd;
  border-color: #a88b68;
}
.klv-panel {
  border-radius: 4px 16px 4px 16px;
}
.klv-panel strong {
  color: #f0d7b3;
  font: 22px var(--serif);
}
.klv-panel input {
  accent-color: #d6b188;
}
.klv-panel .klv-stats {
  color: #cdc2b6;
}
.klv-active .music-dock .klv-vfx {
  color: #efd6b8;
  background: #211e28;
  border-color: #a48a67;
  font: 600 12px var(--sans);
}
.klv-active #krul-welcome[open] {
  background:
    linear-gradient(0deg, #080c18c7, #1217243d 75%),
    url('/castle/sanguinem-night.webp') center/cover;
}
.klv-active .welcome-sub {
  color: #f0cfa8;
}
.klv-active .klv-side-hot {
  filter: drop-shadow(
    0 0 9px color-mix(in srgb, var(--klv-accent), transparent 40%)
  );
}
.klv-guardian-stage {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.klv-guardian-stage::before {
  content: '';
  position: absolute;
  top: 17%;
  bottom: 2%;
  width: 18vw;
  background: radial-gradient(
    ellipse at 50% 60%,
    var(--klv-accent),
    transparent 65%
  );
  opacity: var(--aura, 0);
  transition: opacity 0.28s;
  pointer-events: none;
}
.klv-guardian-stage:last-child::before {
  right: 0;
}
.klv-guardian-stage img {
  cursor: pointer;
}
.klv-locked .klv-guardian-stage::before {
  opacity: 0;
}
@media (min-width: 1280px) {
  .klv-active .krul-side-portraits img {
    height: min(72vh, 650px);
    max-width: 33vw;
    top: auto;
    bottom: 5%;
    mask-image: linear-gradient(#000 65%, transparent);
    animation: none;
  }
  .klv-active .krul-side-left {
    left: clamp(-100px, -5vw, -42px);
  }
  .klv-active .krul-side-right {
    right: clamp(-100px, -5vw, -42px);
  }
}
@media (max-width: 600px) {
  body.klv-active .hero {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 0;
    margin-top: 18px;
    border-radius: 4px 22px;
  }
  .klv-active .hero .hero-character {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    aspect-ratio: 1.55;
    flex: none;
    mask-image: linear-gradient(#000 77%, transparent);
  }
  .klv-active .hero .hero-character img {
    position: absolute;
    inset: 0;
    object-position: 50% 48%;
  }
  .klv-active .hero::after {
    display: none;
  }
  .klv-active .hero-copy {
    width: 100%;
    max-width: 100%;
    padding: 0 20px 24px;
    margin-top: -4px;
  }
  .klv-active .hero h1 {
    font-size: clamp(34px, 10.5vw, 58px);
    margin: 9px 0;
  }
  .klv-active .hero-actions {
    margin-top: 15px;
    flex-wrap: wrap;
  }
  .klv-active .hero-caption {
    top: 15px;
    bottom: auto;
    right: 16px;
  }
  .klv-active #catalog .catalog-head {
    padding: 9px 12px;
  }
  .klv-active .music-dock .klv-vfx {
    grid-column: auto;
    min-height: 32px;
  }
  .klv-active .music-dock #music-title {
    grid-column: 1 / -2;
    grid-row: 2;
    align-self: center;
  }
  .klv-panel {
    bottom: calc(102px + env(safe-area-inset-bottom));
    max-height: 60dvh;
    overflow: auto;
  }
}
.klv-active:not(.klv-locked)
  .krul-ornament:not(
    .dragging,
    .krul-dancing,
    .krul-magic,
    .krul-furious,
    .krul-return
  ) {
  translate: 0 var(--klv-beat, 0px);
  rotate: var(--klv-lean, 0deg);
}
.klv-locked .klv-guardian-stage {
  transform: none !important;
}
.klv-guardian-stage img:focus-visible {
  outline: 2px solid #e8c998;
  outline-offset: -4px;
}
@media (min-width: 1280px) {
  .klv-active .krul-side-portraits img {
    width: clamp(215px, 18.3vw, 350px);
    height: auto;
    bottom: 14%;
    mask-image: linear-gradient(#000 73%, transparent);
  }
  .klv-active .krul-side-left {
    left: -1.35vw;
  }
  .klv-active .krul-side-right {
    right: -1.35vw;
  }
}
.klv-active .hero-copy p .desk-break {
  display: none;
}
@media (min-width: 355px) and (max-width: 600px) {
  .klv-active .nav-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    column-gap: 5px;
    row-gap: 1px;
  }
  .klv-active .nav-inner .brand {
    font-size: clamp(16px, 4.7vw, 21px);
    letter-spacing: 0;
    gap: 3px;
  }
  .klv-active .nav-inner .brand svg {
    width: 24px;
  }
  .klv-active .nav-inner .cart-button,
  .klv-active .nav-inner > .btn {
    padding: 7px;
    font-size: 12px;
    margin: 0;
  }
  .klv-active .nav-inner nav {
    grid-row: 2;
    grid-column: 1/-1;
  }
}
.klv-active .hero h1 {
  text-shadow:
    0 2px 18px #090a14,
    0 0 18px rgb(235 196 161 / var(--klv-title-light, 0));
}


/* Lightweight character idle loops run independently of the WebGL quality tier.
   Keep the portrait's existing framing and the central hero unchanged. */
@media (prefers-reduced-motion: no-preference) {
  body.klv-active .krul-side-portraits img {
    animation: klv-guardian-idle 5.8s ease-in-out infinite;
    transform-origin: 50% 78%;
    will-change: transform;
  }
  body.klv-active .krul-side-portraits .krul-side-right {
    animation-duration: 6.7s;
    animation-delay: -2.6s;
  }
  body.klv-active .krul-side-portraits .krul-side-left {
    animation-delay: -0.8s;
  }
  @keyframes klv-guardian-idle {
    0%, 100% { transform: translate3d(0, 0, 0) rotate(-0.4deg) scale(1); }
    50% { transform: translate3d(0, -9px, 0) rotate(0.7deg) scale(1.022); }
  }
  body .krul-ornament:not(.dragging, .emote, .krul-dancing, .krul-magic, .krul-furious, .krul-vanished, .krul-return) {
    animation: klv-chibi-idle 3.2s ease-in-out infinite;
    transform-origin: 50% 90%;
  }
  body .krul-ornament.right-top { animation-delay: -0.8s; }
  body .krul-ornament.left-bottom { animation-delay: -1.6s; }
  body .krul-ornament.right-bottom { animation-delay: -2.4s; }
  @keyframes klv-chibi-idle {
    0%, 100% { transform: translate3d(0, 0, 0) rotate(-1.5deg); }
    50% { transform: translate3d(0, -8px, 0) rotate(1.5deg); }
  }
}
