/* =========================================================================
   Koro's Dojo — Explorable pixel-art room
   ========================================================================= */

.dojo-scene {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: var(--color-bg-deep);
  overflow: hidden;
  transition: opacity 0.5s ease;
}

/* --- Room layout: CSS grid for object placement --- */

.dojo-room {
  position: relative;
  width: 100%;
  height: calc(100dvh - 100px);
  max-width: 900px;
  margin: 0 auto;
  background-image: url("/assets/environments/dojo.webp");
  background-size: cover;
  background-position: center;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  grid-template-areas:
    "window    bookshelf  bookshelf  telescope"
    "candle    koro-area  koro-area  filing"
    "backpack  scroll-rack terminal   orb";
  padding: 16px;
  gap: 8px;
  overflow: hidden;
}

/* --- Lantern glow — radial gradient driven by JS custom property --- */

.dojo-lantern-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(
    circle var(--lantern-radius, 120px) at var(--koro-x, 50%) var(--koro-y, 45%),
    transparent 0%,
    rgba(0, 0, 0, 0.65) 100%
  );
  transition: --lantern-radius 1.2s ease;
  mix-blend-mode: multiply;
}

/* --- Koro center --- */

.dojo-koro {
  grid-area: koro-area;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 3;
}

.dojo-koro .koro-sprite {
  position: absolute;
  width: 96px;
  height: 96px;
  object-fit: contain;
  image-rendering: pixelated;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.dojo-koro .koro-sprite.koro-active {
  opacity: 1;
  animation: dojoKoroBreath 2.5s ease-in-out infinite;
}

@keyframes dojoKoroBreath {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

/* --- Dojo objects --- */

.dojo-object {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  transition: transform 0.2s ease, filter 0.4s ease;
}

.dojo-object-img {
  width: 100%;
  max-width: 80px;
  height: auto;
  object-fit: contain;
  filter: brightness(0.5) saturate(0.6);
  transition: filter 0.4s ease, transform 0.2s ease;
}

.dojo-object:hover .dojo-object-img,
.dojo-object:focus-visible .dojo-object-img {
  filter: brightness(0.85) saturate(0.9);
  transform: scale(1.06);
}

.dojo-object.dojo-obj-lit .dojo-object-img { filter: brightness(1) saturate(1); }
.dojo-object.dojo-obj-lit:hover .dojo-object-img { filter: brightness(1.1) saturate(1.1); transform: scale(1.08); }
.dojo-object.dojo-obj-found .dojo-object-img { filter: brightness(0.9) saturate(0.8); }

.dojo-object.dojo-obj-found::after {
  content: "";
  position: absolute;
  top: 4px; right: 4px;
  width: 12px; height: 12px;
  background: var(--color-moss);
  border-radius: 50%;
  border: 2px solid var(--color-bg-deep);
  z-index: 4;
}

.dojo-object.dojo-obj-hidden { opacity: 0; pointer-events: none; }
.dojo-object.dojo-obj-locked { cursor: default; }
.dojo-object.dojo-obj-locked .dojo-object-img { filter: brightness(0.25) saturate(0.2); }

.dojo-object-glow {
  position: absolute;
  inset: -4px;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.dojo-object:hover .dojo-object-glow,
.dojo-object:focus-visible .dojo-object-glow {
  opacity: 1;
  background: radial-gradient(ellipse, rgba(255, 209, 102, 0.12) 0%, transparent 70%);
}

.dojo-object.dojo-obj-hint { animation: hintPulse 1.5s ease-in-out infinite; }

@keyframes hintPulse {
  0%, 100% { filter: brightness(0.5); }
  50% { filter: brightness(0.75); }
}

/* Grid area assignments */
.dojo-obj-window      { grid-area: window; align-self: start; }
.dojo-obj-bookshelf   { grid-area: bookshelf; align-self: start; justify-self: center; }
.dojo-obj-telescope   { grid-area: telescope; align-self: start; justify-self: end; }
.dojo-obj-candle      { grid-area: candle; align-self: center; }
.dojo-obj-filing      { grid-area: filing; align-self: center; justify-self: end; }
.dojo-obj-backpack    { grid-area: backpack; align-self: end; }
.dojo-obj-scroll-rack { grid-area: scroll-rack; align-self: end; justify-self: center; }
.dojo-obj-terminal    { grid-area: terminal; align-self: end; }
.dojo-obj-orb         { grid-area: orb; align-self: end; justify-self: end; }
.dojo-obj-plant       { grid-area: scroll-rack; align-self: center; justify-self: start; }
.dojo-obj-tea         { grid-area: orb; align-self: center; justify-self: center; }

/* --- Progress bar --- */

.dojo-progress {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: calc(var(--z-ui) + 1);
  background: rgba(15, 14, 23, 0.92);
  backdrop-filter: blur(8px);
  padding: 10px 20px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  justify-content: center;
}

.dojo-progress-label {
  font-family: var(--font-display);
  font-size: 8px;
  letter-spacing: 2px;
  color: var(--color-gold);
  text-transform: uppercase;
}

.dojo-progress-track {
  position: relative;
  width: clamp(180px, 40vw, 360px);
  height: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  overflow: visible;
}

.dojo-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--color-gold);
  border-radius: 1px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 12px rgba(255, 209, 102, 0.5);
  animation: progressGlow 2s ease-in-out infinite;
}

@keyframes progressGlow {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 209, 102, 0.3); }
  50% { box-shadow: 0 0 16px rgba(255, 209, 102, 0.6); }
}

.dojo-milestone {
  position: absolute;
  top: -8px;
  width: 8px;
  height: 8px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  transform: translateX(-50%);
  transition: background 0.5s ease, box-shadow 0.5s ease;
}

.dojo-ms-4  { left: calc(4 / 13 * 100%); }
.dojo-ms-7  { left: calc(7 / 13 * 100%); }
.dojo-ms-9  { left: calc(9 / 13 * 100%); }
.dojo-ms-11 { left: calc(11 / 13 * 100%); }
.dojo-ms-13 { left: 100%; }

.dojo-milestone.ms-reached {
  background: var(--color-gold);
  box-shadow: 0 0 8px rgba(255, 209, 102, 0.6);
}

.dojo-progress-count {
  font-family: var(--font-display);
  font-size: 9px;
  color: var(--color-pixel-cream);
  opacity: 0.7;
}

.dojo-tier-text {
  width: 100%;
  text-align: center;
  font-family: var(--font-display);
  font-size: 8px;
  color: var(--color-pixel-cream);
  opacity: 0.6;
  letter-spacing: 1px;
  margin: 0;
}

/* --- Scroll reveal modal --- */

.dojo-scroll-modal {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-overlay) + 10);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.dojo-scroll-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 14, 23, 0.85);
  backdrop-filter: blur(4px);
}

.dojo-scroll-content {
  position: relative;
  z-index: 1;
  max-width: 480px;
  width: 100%;
  background: linear-gradient(180deg, #1a1408 0%, var(--color-bg-deep) 100%);
  border: 2px solid rgba(255, 209, 102, 0.3);
  border-radius: 12px;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  max-height: 85vh;
  overflow-y: auto;
  animation: scrollReveal 0.5s cubic-bezier(0.2, 0, 0.2, 1);
}

@keyframes scrollReveal {
  from { opacity: 0; transform: scale(0.9) translateY(16px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.dojo-scroll-art {
  filter: drop-shadow(0 0 16px rgba(255, 209, 102, 0.3));
}

.dojo-scroll-tier {
  font-family: var(--font-display);
  font-size: 8px;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 2px;
  border: 1px solid;
}

.dojo-scroll-tier[data-tier="foundation"] { color: var(--color-moss); border-color: var(--color-moss); }
.dojo-scroll-tier[data-tier="power"]      { color: var(--color-pixel-warm); border-color: var(--color-pixel-warm); }
.dojo-scroll-tier[data-tier="data"]       { color: var(--color-teal); border-color: var(--color-teal); }
.dojo-scroll-tier[data-tier="advanced"]   { color: var(--color-sakura); border-color: var(--color-sakura); }

.dojo-scroll-title { font-family: var(--font-display); font-size: clamp(12px, 2vw, 16px); color: var(--color-gold); margin: 0; letter-spacing: 1px; }
.dojo-scroll-feature { font-family: var(--font-body); font-size: 13px; color: var(--color-teal); margin: 0; }

.dojo-scroll-koro-line {
  font-family: var(--font-body);
  font-size: clamp(14px, 1.6vw, 16px);
  color: var(--color-pixel-cream);
  line-height: 1.6;
  opacity: 0.9;
  font-style: italic;
}

.dojo-scroll-personal {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--color-gold);
  line-height: 1.5;
  padding: 12px 16px;
  background: rgba(255, 209, 102, 0.06);
  border: 1px solid rgba(255, 209, 102, 0.15);
  border-radius: 6px;
  width: 100%;
}

.dojo-scroll-prompt-block { width: 100%; text-align: left; }
.dojo-scroll-prompt-label { font-family: var(--font-display); font-size: 8px; letter-spacing: 1.5px; color: var(--color-teal); text-transform: uppercase; margin: 0 0 8px; }

.dojo-scroll-prompt {
  display: block;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--color-pixel-cream);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 12px 14px;
  line-height: 1.5;
  word-break: break-word;
}

.dojo-scroll-close {
  padding: 12px 32px;
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--color-bg-deep);
  background: var(--color-teal);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  min-height: 44px;
  margin-top: 8px;
  transition: background 0.15s ease;
}

.dojo-scroll-close:hover { background: var(--color-gold); }

/* --- Dojo Master overlay (cinematic celebration) --- */

.dojo-master-overlay {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-overlay) + 20);
  background:
    radial-gradient(ellipse at center, rgba(48, 32, 12, 0.65) 0%, rgba(15, 14, 23, 0.96) 70%),
    rgba(15, 14, 23, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 9vh 16px;
  animation: masterOverlayIn 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.dojo-master-scroll {
  position: relative;
  width: 100%;
  max-width: 720px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
}
.dojo-master-overlay.dojo-master-dismissing {
  animation: masterOverlayOut 0.32s ease forwards;
}

@keyframes masterOverlayIn {
  from { opacity: 0; backdrop-filter: blur(0); }
  to   { opacity: 1; backdrop-filter: blur(2px); }
}
@keyframes masterOverlayOut {
  to { opacity: 0; }
}

/* Expanding gold radial — cinematic "moment of arrival" */
.dojo-master-radial {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255, 209, 102, 0.55) 0%,
    rgba(255, 209, 102, 0.18) 40%,
    transparent 70%);
  transform: translate(-50%, -50%) scale(0);
  pointer-events: none;
  animation: masterRadialExpand 2.4s ease-out forwards;
}
@keyframes masterRadialExpand {
  0%   { transform: translate(-50%, -50%) scale(0);   opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(8);   opacity: 0; }
}

/* Confetti shower — pieces fall + drift via per-piece custom props */
.dojo-master-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.confetti-piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 14px;
  border-radius: 1px;
  opacity: 0;
  animation: confettiFall var(--confetti-dur, 3.2s) cubic-bezier(0.4, 0.05, 0.5, 1) var(--confetti-delay, 0s) forwards;
}
.confetti-gold   { background: var(--color-gold); }
.confetti-teal   { background: var(--color-teal); }
.confetti-sakura { background: var(--color-sakura); }
.confetti-moss   { background: var(--color-moss); }
.confetti-cream  { background: var(--color-pixel-cream); }
@keyframes confettiFall {
  0%   { transform: translate(0, -20px) rotate(0deg);                                           opacity: 0; }
  10%  { opacity: 1; }
  100% { transform: translate(var(--confetti-drift, 0), 110vh) rotate(var(--confetti-rot, 360deg)); opacity: 1; }
}

/* Content stack with staggered reveal */
.dojo-master-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 0;
  max-width: 600px;
  z-index: 2;
}

/* Koro: bigger, brighter, with a pulsating gold aura behind him.
   padding-top gives clearance for masterKoroBounce's -18px peak so
   the top of Koro's head can't be clipped by the parent overflow. */
.dojo-master-koro-wrap {
  position: relative;
  width: 140px;
  height: 140px;
  padding-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: masterKoroIn 0.9s cubic-bezier(0.2, 0.9, 0.2, 1.2) 0.2s backwards;
}
@keyframes masterKoroIn {
  from { transform: scale(0.4); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.dojo-master-aura {
  position: absolute;
  inset: -40px;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255, 209, 102, 0.5) 0%,
    rgba(255, 209, 102, 0.18) 45%,
    transparent 75%);
  animation: masterAuraPulse 2.4s ease-in-out infinite;
  filter: blur(6px);
}
@keyframes masterAuraPulse {
  0%, 100% { transform: scale(1);   opacity: 0.6; }
  50%      { transform: scale(1.18); opacity: 1;   }
}
.dojo-master-koro {
  position: relative;
  z-index: 1;
  width: 110px;
  height: 110px;
  image-rendering: pixelated;
  animation: masterKoroBounce 1.4s ease-in-out infinite;
  filter: drop-shadow(0 6px 16px rgba(255, 209, 102, 0.55));
}
@keyframes masterKoroBounce {
  0%, 100% { transform: translateY(0)    rotate(-2deg); }
  50%      { transform: translateY(-12px) rotate(2deg);  }
}

/* Title slams in with a scale+blur impact, then settles. The
   .dojo-master-content screen-shake (defined below) is timed to fire
   on the impact frame so the whole composition jolts on the beat. */
.dojo-master-title {
  font-family: var(--font-display);
  font-size: clamp(22px, 4vw, 38px);
  color: var(--color-gold);
  margin: 0;
  letter-spacing: 1.2px;
  text-shadow:
    0 0 20px rgba(255, 209, 102, 0.7),
    0 4px 24px rgba(255, 209, 102, 0.4),
    0 0 60px rgba(255, 209, 102, 0.3);
  animation: masterTitleSlam 1.1s cubic-bezier(0.2, 0.8, 0.2, 1) 0.6s backwards;
}
@keyframes masterTitleSlam {
  0%   { transform: scale(2.4); filter: blur(6px); opacity: 0; }
  55%  { transform: scale(0.92); filter: blur(0);  opacity: 1; }
  72%  { transform: scale(1.04); filter: blur(0);  opacity: 1; }
  100% { transform: scale(1);    filter: blur(0);  opacity: 1; }
}
.dojo-master-subtitle,
.dojo-master-flavor {
  font-family: var(--font-body);
  margin: 0;
  color: var(--color-pixel-cream);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
}
.dojo-master-subtitle {
  font-size: clamp(13px, 1.7vw, 16px);
  opacity: 0.95;
}
.dojo-master-flavor {
  font-size: clamp(11px, 1.4vw, 13px);
  opacity: 0.75;
  font-style: italic;
}
.dojo-master-stagger-2 { animation: masterTextIn 0.7s ease-out 1.0s backwards; }
.dojo-master-stagger-3 { animation: masterTextIn 0.7s ease-out 1.4s backwards; }
.dojo-master-stagger-4 { animation: masterTextIn 0.7s ease-out 1.8s backwards; }
@keyframes masterTextIn {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

/* "Navigate away" controls (Enter button, Back-to-wheel link) appear
   ~5 seconds after the master ceremony opens, giving the player a
   window to engage with the email / Koro Weekly / offers pills
   before the exit doors appear. Implemented via a class-swap (JS adds
   .is-revealed after the timer fires) rather than a CSS animation
   delay — the animation-fill-mode approach turned out to be flaky
   across the cache-and-display-toggle path the master overlay takes. */
.dojo-master-late-action {
  opacity: 0;
  transition: opacity 0.6s ease-in;
  pointer-events: none;
}
.dojo-master-late-action.is-revealed {
  opacity: 1;
  pointer-events: auto;
}

/* Two CTAs side-by-side (stack on narrow viewports) */
.dojo-master-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin-top: 8px;
}
.dojo-master-zo-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--color-teal);
  border: 2px solid var(--color-teal);
  text-decoration: none;
}
.dojo-master-zo-cta:hover,
.dojo-master-zo-cta:focus-visible {
  background: var(--color-teal);
  color: var(--color-bg-deep);
  outline: none;
}

.dojo-master-enter-room {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 28px;
  min-height: 44px;
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 1.5px;
  color: var(--color-bg-deep);
  background: var(--color-gold);
  border: none;
  cursor: pointer;
  box-shadow:
    0 0 0 3px var(--color-pixel-cream),
    0 0 0 6px var(--color-bg-deep),
    0 0 20px rgba(255, 209, 102, 0.4),
    0 4px 0 0 rgba(0, 0, 0, 0.35);
  transition: transform 120ms ease, background 120ms ease, box-shadow 200ms ease;
}
.dojo-master-enter-room:hover,
.dojo-master-enter-room:focus-visible {
  background: var(--color-pixel-warm);
  transform: translateY(-2px);
  box-shadow:
    0 0 0 3px var(--color-pixel-cream),
    0 0 0 6px var(--color-bg-deep),
    0 0 32px rgba(255, 209, 102, 0.55),
    0 6px 0 0 rgba(0, 0, 0, 0.35);
  outline: none;
}
.dojo-master-enter-room:active {
  transform: translateY(1px);
}

/* Discovery breadcrumb — quiet hint that there's a hidden room
   (the ETL Workshop, demoted to a `zozen` cheat-code Easter egg per
   the 2026-04-26 jury verdict). Italic, gold, half-opacity so casual
   players miss it; specific enough that "word → cheat input → zozen"
   is figure-out-able for curious players. */
.dojo-master-breadcrumb {
  margin: 10px 0 0;
  font-family: var(--font-body);
  font-size: 11px;
  font-style: italic;
  letter-spacing: 0.5px;
  color: var(--color-gold);
  opacity: 0.5;
  text-align: center;
}

/* Discrete action pills — three small buttons sit below the cinematic
   block so capture options stay accessible without crowding the
   ceremony. Clicking a pill expands a slim inline pane below the row.
   Only one pane open at a time. */
.dojo-master-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 14px 0 0;
}
.dojo-master-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(15, 14, 23, 0.55);
  border: 1px solid rgba(255, 209, 102, 0.45);
  color: var(--color-pixel-cream);
  padding: 6px 12px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 0.4px;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease,
    color 160ms ease, transform 120ms ease;
}
.dojo-master-pill:hover,
.dojo-master-pill:focus-visible {
  background: rgba(255, 209, 102, 0.18);
  border-color: var(--color-gold);
  outline: none;
  transform: translateY(-1px);
}
.dojo-master-pill.is-active {
  background: var(--color-gold);
  border-color: var(--color-gold);
  color: var(--color-bg-deep);
}

.dojo-master-pane {
  width: 100%;
  max-width: 380px;
  margin: 8px auto 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  animation: dmPaneIn 220ms ease;
}
@keyframes dmPaneIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.dojo-master-pane-form {
  display: flex;
  gap: 5px;
}
.dojo-master-pane-form-stack {
  flex-direction: column;
}
.dojo-master-pane-input {
  flex: 1;
  min-width: 0;
  background: rgba(15, 14, 23, 0.7);
  border: 1px solid rgba(254, 246, 228, 0.25);
  color: var(--color-pixel-cream);
  padding: 7px 10px;
  font-family: var(--font-body);
  font-size: 12px;
  border-radius: 4px;
}
.dojo-master-pane-input:focus {
  outline: none;
  border-color: var(--color-gold);
}
.dojo-master-pane-input::placeholder { color: rgba(254, 246, 228, 0.45); }
.dojo-master-pane-cta {
  background: var(--color-gold);
  color: var(--color-bg-deep);
  border: 0;
  padding: 7px 14px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 160ms ease;
}
.dojo-master-pane-cta:hover { background: var(--color-pixel-warm); }
.dojo-master-pane-status {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--color-teal);
  min-height: 14px;
  text-align: center;
}

/* Offers screen — opens from the "See offers" card. Mirrors the quiz
   reveal-offers layout but lives inside the master overlay so it can
   stack above the celebration without coordinating with #reveal-scene. */
.dojo-master-offers {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-overlay) + 30);
  background: rgba(15, 14, 23, 0.97);
  overflow-y: auto;
  padding: 10vh 16px;
  animation: masterOverlayIn 0.4s ease;
}
.dojo-master-offers-close {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(254, 246, 228, 0.3);
  background: rgba(15, 14, 23, 0.85);
  color: var(--color-cream);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
  transition: transform 160ms ease, background 160ms ease;
}
.dojo-master-offers-close:hover {
  background: rgba(15, 14, 23, 0.95);
  transform: scale(1.06);
}
.dojo-master-offers-stack {
  max-width: 980px;
  margin: 0 auto;
  text-align: center;
}
.dojo-master-offers-heading {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: clamp(20px, 3vw, 28px);
  color: var(--color-gold);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.dojo-master-offers-sub {
  margin: 0 0 32px;
  color: var(--color-cream);
  opacity: 0.75;
  font-size: 14px;
}

@media (max-width: 600px) {
  .dojo-master-overlay { padding: 7vh 12px; }
  .dojo-master-offers { padding: 8vh 12px; }
  .dojo-master-koro-wrap { width: 110px; height: 110px; padding-top: 14px; }
  .dojo-master-koro { width: 88px; height: 88px; }
  .dojo-master-pills { gap: 6px; }
  .dojo-master-pill { padding: 5px 10px; font-size: 10.5px; }
}

/* Phone landscape: compress the Dojo Master ceremony overlay AND the
   offers screen that opens from it ("Dive deeper with Koro") so they
   fit a 393-tall viewport without scroll. The 140px Koro wrap, 22-38px
   title, 9vh padding, and 5vh letterbox bars combined eat all of a
   short landscape viewport. Shrinking everything proportionally keeps
   the cinematic hierarchy (title still dominates, Koro still glows)
   just at a smaller scale. Desktop is unaffected (gate doesn't match). */
@media (orientation: landscape) and (max-height: 500px) {
  .dojo-master-overlay {
    padding: 6px 12px;
  }
  .dojo-master-offers {
    padding: 8px 12px;
  }
  .dojo-master-letterbox {
    height: 2vh;
  }
  .dojo-master-koro-wrap {
    width: 72px;
    height: 72px;
    padding-top: 8px;
  }
  .dojo-master-koro {
    width: 56px;
    height: 56px;
  }
  .dojo-master-aura {
    inset: -16px;
  }
  .dojo-master-content {
    gap: 3px;
    max-width: 100%;
  }
  .dojo-master-title {
    font-size: 16px;
    letter-spacing: 1px;
  }
  .dojo-master-subtitle {
    font-size: 11px;
  }
  .dojo-master-flavor {
    font-size: 10px;
    line-height: 1.3;
  }
  .dojo-master-pills {
    gap: 5px;
    margin: 4px 0 0;
  }
  .dojo-master-pill {
    padding: 3px 8px;
    font-size: 9px;
  }
  .dojo-master-pane {
    margin-top: 3px;
  }
  .dojo-master-breadcrumb {
    display: none;
  }
  .dojo-master-actions {
    gap: 6px;
    margin-top: 3px;
  }
  .dojo-master-actions .reveal-dojo-cta {
    padding: 7px 18px;
    min-height: 30px;
    font-size: 10px;
  }
  /* Offers screen ("Dive deeper") inside the master ceremony */
  .dojo-master-offers-close {
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    font-size: 18px;
  }
  .dojo-master-offers-heading {
    font-size: 13px;
    letter-spacing: 1.2px;
    margin-bottom: 3px;
  }
  .dojo-master-offers-sub {
    font-size: 10px;
    margin-bottom: 8px;
  }
  .dojo-master-offers .offers-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .dojo-master-offers .offer-card {
    padding: 10px 12px;
    gap: 4px;
  }
  .dojo-master-offers .offer-name {
    font-size: 12px;
  }
  .dojo-master-offers .offer-price {
    font-size: 32px;
  }
  .dojo-master-offers .offer-desc {
    font-size: 10px;
  }
  .dojo-master-offers .offer-cta {
    padding: 6px 14px;
    min-height: 32px;
    font-size: 10px;
  }
}

/* --- Cinematic celebration layer (added 2026-04-26 amplification pass) --- */

/* Letterbox bars top + bottom — pure cinema framing. Slide in on
   open, slide out on dismiss via the .dojo-master-dismissing class
   (already toggled by dismissMasterOverlay). */
.dojo-master-letterbox {
  position: absolute;
  left: 0;
  right: 0;
  height: 5vh;
  background: #000;
  z-index: calc(var(--z-overlay) + 21);
  pointer-events: none;
}
.dojo-master-letterbox-top    { top: 0;    transform: translateY(-100%); animation: masterLetterboxInTop    0.65s cubic-bezier(0.2, 0.8, 0.2, 1) 0.1s forwards; }
.dojo-master-letterbox-bottom { bottom: 0; transform: translateY( 100%); animation: masterLetterboxInBottom 0.65s cubic-bezier(0.2, 0.8, 0.2, 1) 0.1s forwards; }
@keyframes masterLetterboxInTop    { to { transform: translateY(0); } }
@keyframes masterLetterboxInBottom { to { transform: translateY(0); } }
.dojo-master-overlay.dojo-master-dismissing .dojo-master-letterbox-top    { animation: masterLetterboxOutTop    0.32s ease forwards; }
.dojo-master-overlay.dojo-master-dismissing .dojo-master-letterbox-bottom { animation: masterLetterboxOutBottom 0.32s ease forwards; }
@keyframes masterLetterboxOutTop    { to { transform: translateY(-100%); } }
@keyframes masterLetterboxOutBottom { to { transform: translateY( 100%); } }

/* Vignette — soft radial darkening on edges, focuses center. */
.dojo-master-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: calc(var(--z-overlay) + 22);
  background: radial-gradient(
    ellipse at center,
    transparent 0%,
    transparent 35%,
    rgba(15, 14, 23, 0.55) 75%,
    rgba(15, 14, 23, 0.85) 100%
  );
  animation: masterVignetteIn 1.4s ease forwards;
}
@keyframes masterVignetteIn { from { opacity: 0; } to { opacity: 1; } }

/* God rays from Koro — conic gradient slow-rotates behind the
   sprite, screen-blended over the existing aura. */
.dojo-master-godrays {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(900px, 110vw);
  height: min(900px, 110vw);
  margin-left: calc(min(900px, 110vw) / -2);
  margin-top: calc(min(900px, 110vw) / -2);
  background: repeating-conic-gradient(
    from 0deg at 50% 50%,
    transparent 0deg 7deg,
    rgba(255, 209, 102, 0.22) 7deg 9deg,
    transparent 9deg 14deg
  );
  border-radius: 50%;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0;
  animation:
    masterGodraysIn 1.4s ease forwards,
    masterGodraysSpin 28s linear infinite;
  z-index: -1;
}
@keyframes masterGodraysIn   { to { opacity: 0.85; } }
@keyframes masterGodraysSpin { to { transform: rotate(360deg); } }

/* Continuous sparkle stream rising from Koro (positions/timings set
   inline by buildSparkleStream so each dot is unique). */
.dojo-master-sparkles {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(440px, 60vw);
  height: 70vh;
  margin-left: calc(min(440px, 60vw) / -2);
  pointer-events: none;
  z-index: calc(var(--z-overlay) + 23);
}
.dojo-master-spark {
  position: absolute;
  bottom: 16%;
  display: block;
  border-radius: 50%;
  background: radial-gradient(circle at center, #fff5c2 0%, var(--color-gold) 55%, transparent 75%);
  filter: drop-shadow(0 0 6px rgba(255, 209, 102, 0.85));
  opacity: 0;
  animation:
    masterSparkRise var(--spark-dur, 2.6s) ease-out var(--spark-delay, 0s) infinite;
}
@keyframes masterSparkRise {
  0%   { transform: translateY(0)    scale(0.6); opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: translateY(-220px) scale(1.2); opacity: 0; }
}

/* Subtle screen shake on the content stack timed to land on the
   title slam (~0.6s + ~0.7s into masterTitleSlam = ~1.3s after
   overlay open). Lasts ~280ms then settles. */
.dojo-master-content {
  animation: masterContentShake 0.28s ease-out 1.18s backwards;
}
@keyframes masterContentShake {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-4px, 2px); }
  40%  { transform: translate(3px, -3px); }
  60%  { transform: translate(-2px, 3px); }
  80%  { transform: translate(2px, -1px); }
  100% { transform: translate(0, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .dojo-master-overlay,
  .dojo-master-radial,
  .confetti-piece,
  .dojo-master-koro-wrap,
  .dojo-master-aura,
  .dojo-master-koro,
  .dojo-master-title,
  .dojo-master-stagger-2,
  .dojo-master-stagger-3,
  .dojo-master-stagger-4,
  .dojo-master-late-action,
  .dojo-master-letterbox,
  .dojo-master-letterbox-top,
  .dojo-master-letterbox-bottom,
  .dojo-master-vignette,
  .dojo-master-godrays,
  .dojo-master-spark,
  .dojo-master-content {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }
  .dojo-master-radial,
  .dojo-master-letterbox,
  .dojo-master-godrays,
  .dojo-master-sparkles,
  .confetti-piece { display: none; }
  /* Late-action elements have explicit opacity:0 on the base rule;
     under reduced-motion they appear instantly without the fade. */
  .dojo-master-late-action {
    opacity: 1 !important;
    transition: none !important;
    pointer-events: auto !important;
  }
}

/* --- Room floods gold on Dojo Master --- */

.dojo-room.dojo-mastered {
  animation: roomFloodGold 2s ease forwards;
}

@keyframes roomFloodGold {
  0% { filter: brightness(1); }
  50% { filter: brightness(1.3) saturate(1.2); }
  100% { filter: brightness(1.15) saturate(1.1); }
}

.dojo-room.dojo-mastered .dojo-lantern-glow {
  opacity: 0;
}

.dojo-room.dojo-mastered .dojo-object-img {
  filter: brightness(1.1) saturate(1.1) !important;
}

/* --- Mobile --- */

@media (max-width: 600px) {
  .dojo-room {
    height: calc(100dvh - 90px);
    padding: 10px;
    gap: 4px;
  }

  .dojo-koro .koro-sprite {
    width: 64px;
    height: 64px;
  }

  .dojo-object-img {
    max-width: 56px;
  }

  .dojo-progress {
    padding: 8px 12px 10px;
    gap: 6px 10px;
  }

  .dojo-scroll-content {
    padding: 24px 16px;
    max-height: 80vh;
  }

  .dojo-scroll-art {
    width: 56px;
    height: 56px;
  }
}

/* Ensure touch targets are 44px minimum */
@media (pointer: coarse) {
  .dojo-object {
    min-width: 44px;
    min-height: 44px;
  }

  .dojo-scroll-close {
    min-width: 200px;
  }
}

@media (max-width: 400px) {
  .dojo-room {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(4, 1fr);
    grid-template-areas:
      "window    bookshelf  telescope"
      "candle    koro-area  filing"
      "scroll-rack koro-area terminal"
      "backpack  orb        orb";
  }

  .dojo-object-img {
    max-width: 48px;
  }

  .dojo-obj-plant,
  .dojo-obj-tea {
    display: none;
  }
}
