/* ==========================================================================
   Mahabharat360 · Mystery Rooms — story guide (m360-guide.js)
   Loaded only by games that have a guide. Uses the tokens from m360.css.
   Phones: the guide is a dock along the bottom. Wide screens (960px+): a card
   floating at the bottom of the scene column, so the lock column stays clear.
   No visible scrollbars anywhere in the guide.
   ========================================================================== */

/* The guide shows and hides parts with the hidden attribute (team form, Onward button, title badge);
   make it win over display rules such as .btn's inline-flex. */
[hidden] { display: none !important; }

body.g-on .room { padding-bottom: calc(40px + var(--safe-b) + var(--g-dock-h, 0px)); }

/* ---------- dock ---------- */
.g-dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 46;
  padding: 12px max(12px, env(safe-area-inset-right, 0px)) calc(14px + var(--safe-b)) max(12px, env(safe-area-inset-left, 0px));
  background: linear-gradient(180deg, rgba(30, 24, 54, 0.97), rgba(11, 9, 18, 0.99));
  border-top: 1px solid rgba(246, 207, 131, 0.3); border-radius: 22px 22px 0 0;
  box-shadow: 0 -18px 44px rgba(0, 0, 0, 0.6);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s ease;
}
.g-dock::before { content: ""; position: absolute; left: 16%; right: 16%; top: -1px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, transparent, var(--gold-2), var(--accent), transparent); }
.g-dock.min { transform: translateY(110%); opacity: 0; pointer-events: none; }
.g-dock.rise { animation: g-rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes g-rise { from { transform: translateY(100%); opacity: 0; } }
.g-row { display: grid; grid-template-columns: 60px minmax(0, 1fr) 34px; gap: 10px; align-items: start; max-width: 720px; margin: 0 auto; }
.g-av { width: 60px; height: 60px; padding: 0; border: 0; background: transparent; border-radius: 50%; }
.g-bubble { min-width: 0; cursor: pointer; }
.g-who { font-size: 10.5px; font-weight: 700; letter-spacing: 0.17em; text-transform: uppercase; color: var(--gold); }
.g-said { font-size: 15.5px; line-height: 1.45; color: var(--text); min-height: 44px; margin-top: 2px; }
.g-said p { margin: 0; }
.g-said p + p { margin-top: 5px; }
.g-min { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--text-dim); display: grid; place-items: center; padding: 0; }
.g-chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px auto 0; max-width: 720px; }
.g-chips:empty { display: none; }
.g-chip {
  min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent); color: #bff0ea; font-size: 14px; font-weight: 600; line-height: 1.2;
  animation: g-chip 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.g-chip.gold { border-color: rgba(246, 207, 131, 0.7); background: rgba(227, 168, 74, 0.16); color: var(--gold-2); }
.g-chip.more { border-style: dashed; border-color: var(--line-2); background: transparent; color: var(--text-dim); }
.g-chip:nth-child(2) { animation-delay: 0.05s; } .g-chip:nth-child(3) { animation-delay: 0.1s; } .g-chip:nth-child(4) { animation-delay: 0.15s; } .g-chip:nth-child(5) { animation-delay: 0.2s; }
@keyframes g-chip { from { opacity: 0; transform: translateY(6px); } }
.g-caret { display: inline-block; width: 2px; height: 1em; background: var(--gold-2); margin-left: 2px; vertical-align: -2px; animation: g-blink 0.9s steps(2) infinite; }
@keyframes g-blink { 50% { opacity: 0; } }
.g-next { display: flex; margin: 8px 0 0 auto; padding: 4px 2px; border: 0; background: none; color: var(--gold-2); font-size: 13px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; animation: g-nudge 1.4s ease-in-out infinite; }
@keyframes g-nudge { 0%, 100% { transform: translateX(0); opacity: 0.75; } 50% { transform: translateX(4px); opacity: 1; } }

/* tucked away: a small wheel in the corner, with a speech pop-up beside it */
.g-fab {
  position: fixed; right: max(12px, env(safe-area-inset-right, 0px)); bottom: calc(14px + var(--safe-b)); z-index: 46;
  width: 64px; height: 64px; border-radius: 50%; padding: 3px;
  background: radial-gradient(circle, rgba(30, 24, 54, 0.96), rgba(11, 9, 18, 0.98)); border: 1px solid rgba(246, 207, 131, 0.38);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.6), 0 0 24px color-mix(in srgb, var(--accent) 30%, transparent);
}
.g-fab-av { display: block; width: 100%; height: 100%; }
.g-dot { position: absolute; top: 3px; right: 3px; width: 13px; height: 13px; border-radius: 50%; background: #ffb347; box-shadow: 0 0 10px #ffb347; border: 2px solid var(--bg); }
.g-peek {
  position: fixed; right: calc(max(12px, env(safe-area-inset-right, 0px)) + 74px); bottom: calc(22px + var(--safe-b)); z-index: 47;
  max-width: min(320px, calc(100% - 110px)); padding: 10px 13px; border-radius: 16px 16px 4px 16px; text-align: left;
  background: rgba(30, 24, 54, 0.97); border: 1px solid rgba(246, 207, 131, 0.32); color: var(--text); font-size: 14.5px; line-height: 1.4;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}
.g-peek.in { animation: g-chip 0.3s ease both; }
/* while typing on a phone the keyboard owns the bottom of the screen: wheel and pop-up sit under the timer */
body.g-typing .g-fab { top: calc(66px + var(--safe-t)); bottom: auto; width: 50px; height: 50px; }
body.g-typing .g-peek { top: calc(70px + var(--safe-t)); bottom: auto; right: calc(max(12px, env(safe-area-inset-right, 0px)) + 60px); border-radius: 16px 4px 16px 16px; }

/* spotlight: dims the page except the target; taps pass straight through */
.g-spot { position: fixed; z-index: 45; pointer-events: none; border-radius: 16px; box-shadow: 0 0 0 200vmax rgba(4, 3, 10, 0.72); transition: left 0.15s, top 0.15s; }
.g-spot.ring { border-radius: 50%; }
.g-spot::after { content: ""; position: absolute; inset: -4px; border-radius: inherit; border: 2px solid var(--gold-2); box-shadow: 0 0 22px rgba(246, 207, 131, 0.7), inset 0 0 18px rgba(246, 207, 131, 0.35); animation: g-spot 1.3s ease-in-out infinite; }
@keyframes g-spot { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.08); opacity: 0.65; } }

/* ---------- chamber title card ---------- */
.g-title { position: fixed; inset: 0; z-index: 70; overflow: hidden; background: #000; display: flex; flex-direction: column; justify-content: flex-end; padding: 0 max(24px, env(safe-area-inset-right, 0px)) calc(24vh + var(--safe-b)) max(24px, env(safe-area-inset-left, 0px)); cursor: pointer; outline: none; }
.g-title-bg { position: absolute; inset: -4%; background: center / cover no-repeat; transform: scale(1.16); filter: brightness(0.6) saturate(0.9); }
.g-title.go .g-title-bg { animation: g-kb 4.6s ease-out forwards; }
@keyframes g-kb { from { transform: scale(1.18) translateX(3%); } to { transform: scale(1.04) translateX(-2%); } }
.g-title-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, 0.35) 0%, rgba(0, 0, 0, 0.05) 28%, rgba(7, 6, 12, 0.9) 66%, #07060c 100%); }
.g-title-num { position: absolute; right: 4%; bottom: 26%; font-family: var(--font-display); font-weight: 700; font-size: clamp(180px, 42vw, 360px); line-height: 1; color: var(--gold-2); opacity: 0; }
.g-title.go .g-title-num { animation: g-num 1.6s ease-out 0.2s forwards; }
@keyframes g-num { from { opacity: 0; transform: translateY(20px); } to { opacity: 0.13; transform: none; } }
.g-title-in { position: relative; display: grid; gap: 6px; width: 100%; max-width: 720px; margin: 0 auto; }
.g-title-in h2 { font-size: clamp(36px, 10vw, 64px); color: #fbf3e4; text-shadow: 0 2px 30px rgba(0, 0, 0, 0.8); }
.g-title-sk { font-family: var(--font-display); font-size: clamp(17px, 4.4vw, 22px); color: #9fe9df; margin: 0; }
.g-title-rule { height: 2px; width: 0; background: linear-gradient(90deg, var(--gold-2), var(--accent), transparent); border-radius: 2px; margin-top: 8px; }
.g-title-tap { font-size: 12.5px; color: var(--text-faint); margin: 14px 0 0; letter-spacing: 0.06em; }
.g-title.go .g-title-in > * { animation: g-up 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.g-title.go .g-title-in > :nth-child(2) { animation-delay: 0.25s; }
.g-title.go .g-title-in > :nth-child(3) { animation-delay: 0.5s; }
.g-title.go .g-title-in > :last-child { animation-delay: 1.6s; }
.g-title.go .g-title-in > .g-title-rule { animation: g-rule 1.4s ease-out 0.7s forwards; }
@keyframes g-rule { to { width: 70%; } }
@keyframes g-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.g-title.out { opacity: 0; transition: opacity 0.45s ease; }

/* ---------- opening ---------- */
.g-open { position: relative; min-height: 100vh; min-height: 100dvh; overflow: hidden; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: calc(64px + var(--safe-t)) 18px calc(24px + var(--safe-b)); isolation: isolate; }
.g-o-bg { position: absolute; inset: 0; z-index: -2; background: center / cover no-repeat; opacity: 0; filter: saturate(0.85) brightness(0.85); transition: opacity 1.4s ease; }
.g-open.show-bg .g-o-bg { opacity: 0.6; transition: opacity 0.12s; }
.g-open.dim-bg .g-o-bg { opacity: 0.14; transition: opacity 1.8s ease; }
.g-o-vig { position: absolute; inset: 0; z-index: -1; background: radial-gradient(ellipse at 50% 45%, transparent 25%, #000 88%); }
.g-open.beat .g-o-vig { background: radial-gradient(ellipse at 50% 45%, rgba(229, 87, 61, 0.22) 0%, transparent 45%, #000 88%); }
.g-o-flash { position: absolute; inset: 0; z-index: 3; background: #e3eaff; opacity: 0; pointer-events: none; }
.g-open.flash .g-o-flash { animation: g-lightning 0.62s steps(1) forwards; }
@keyframes g-lightning { 0% { opacity: 0.85; } 20% { opacity: 0.08; } 40% { opacity: 0.6; } 60%, 100% { opacity: 0; } }
.g-o-top { position: absolute; top: 0; left: 0; right: 0; z-index: 4; display: flex; justify-content: space-between; align-items: center; padding: calc(10px + var(--safe-t)) 16px 0; }
.g-o-skip { min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid rgba(243, 233, 214, 0.25); background: rgba(0, 0, 0, 0.4); color: var(--text-dim); font-size: 13.5px; font-weight: 600; }
.g-o-prophecy { position: absolute; left: 26px; right: 26px; top: 40%; z-index: 2; max-width: 560px; margin: 0 auto; font-family: var(--font-display); font-size: clamp(24px, 6.4vw, 34px); line-height: 1.3; color: #f8efdf; text-shadow: 0 2px 24px #000; opacity: 0; transform: translateY(10px); transition: opacity 1s ease, transform 1.2s ease; text-wrap: balance; pointer-events: none; }
.g-o-prophecy small { display: block; margin-top: 12px; font-family: var(--font-body); font-size: 12px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold); }
.g-open.prophecy-on .g-o-prophecy { opacity: 1; transform: none; }
.g-o-stack { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; max-width: 420px; }
.g-o-av { width: min(58vw, 230px); aspect-ratio: 1; opacity: 0; transform: scale(0.35); filter: brightness(2.4) blur(6px); transition: opacity 1.1s ease, transform 1.4s cubic-bezier(0.2, 0.9, 0.2, 1), filter 1.2s ease; }
.g-open.wheel-on .g-o-av { opacity: 1; transform: none; filter: none; }
.g-open.wheel-out .g-o-av { opacity: 0; transform: scale(0.04); filter: brightness(3) blur(3px); transition: transform 0.85s cubic-bezier(0.6, 0, 0.8, 0.4), opacity 0.85s ease, filter 0.85s ease; }
.g-o-name { opacity: 0; transition: opacity 1s ease; font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: 0.28em; text-transform: uppercase; color: var(--gold-2); margin-top: 6px; }
.g-o-name small { display: block; font-family: var(--font-body); font-size: 13px; font-weight: 500; letter-spacing: 0.08em; text-transform: none; color: #9fe9df; }
.g-open.name-on .g-o-name { opacity: 1; }
.g-open.wheel-out .g-o-name, .g-open.wheel-out .g-o-bubble { opacity: 0; transition: opacity 0.4s; }
.g-o-bubble { width: 100%; margin-top: 12px; text-align: left; }
.g-o-said { min-height: 78px; padding: 12px 15px; border-radius: 16px; background: rgba(27, 22, 48, 0.8); border: 1px solid rgba(246, 207, 131, 0.26); box-shadow: 0 0 30px color-mix(in srgb, var(--accent) 14%, transparent); font-size: 16.5px; line-height: 1.5; color: var(--text); cursor: pointer; }
.g-o-said p { margin: 0; }
.g-o-said p + p { margin-top: 6px; }
.g-o-chips { justify-content: flex-start; }
.g-o-form { display: grid; gap: 10px; margin-top: 12px; }
.g-o-form label { font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-faint); }
.g-dice span { display: inline-grid; place-items: center; }

/* ---------- "chamber opened" popup ---------- */
.overlay.center .modal { max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
.overlay.center .modal::-webkit-scrollbar { display: none; }
.g-success { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 12px; align-items: start; text-align: left; margin: 14px 0 12px; padding: 12px 14px; border-radius: 16px; background: color-mix(in srgb, var(--accent) 9%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); cursor: pointer; }
.g-s-av { width: 84px; height: 84px; }
.g-s-body { min-width: 0; }
.g-success .g-said { font-size: 15px; min-height: 0; }
.g-cliff { font-family: var(--font-display); font-size: 17px; line-height: 1.4; color: var(--gold-2); margin-top: 8px; }
.g-cliff:empty { display: none; }
.g-cliff p { margin: 0; color: var(--gold-2); }

/* ---------- ending ---------- */
.g-ending { margin: 6px auto 22px; max-width: 560px; padding: 20px 18px; border-radius: 20px; text-align: center; background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--accent) 16%, var(--bg-2)), var(--bg-2) 70%); border: 1px solid rgba(246, 207, 131, 0.3); cursor: pointer; }
.g-e-av { width: 150px; height: 150px; margin: 0 auto 8px; }
.g-ending .g-said { font-size: 17px; line-height: 1.55; margin-top: 8px; }
.g-ending .g-said p + p { margin-top: 8px; }
.g-cite { font-family: var(--font-display); color: var(--gold-2); font-size: 16px; margin: 14px 0 0; }
.g-rank { display: grid; gap: 2px; margin-top: 16px; padding: 14px; border-radius: 14px; background: rgba(227, 168, 74, 0.1); border: 1px solid rgba(227, 168, 74, 0.4); }
.g-rank .kicker { margin: 0; }
.g-rank b { font-family: var(--font-display); font-size: 28px; color: var(--gold-2); line-height: 1.15; }
.g-rank span:last-child { color: var(--text-dim); font-size: 15px; }

/* ---------- wide screens: the guide floats over the bottom of the scene column ---------- */
@media (min-width: 960px) {
  .g-dock {
    left: max(16px, calc((100vw - 1180px) / 2 + 16px)); right: auto; bottom: 16px;
    width: min(560px, calc((min(100vw, 1180px) - 58px) * 0.574));
    padding: 14px 14px 14px; border: 1px solid rgba(246, 207, 131, 0.3); border-radius: 22px;
  }
  .g-dock::before { left: 10%; right: 10%; }
  .g-row, .g-chips { max-width: none; }
  .g-fab { left: max(16px, calc((100vw - 1180px) / 2 + 16px)); right: auto; bottom: 16px; }
  .g-peek { left: calc(max(16px, calc((100vw - 1180px) / 2 + 16px)) + 74px); right: auto; bottom: 24px; border-radius: 16px 16px 16px 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .g-dock, .g-dock.rise, .g-chip, .g-peek.in, .g-spot::after, .g-next, .g-caret, .g-title *, .g-title-bg, .g-open * { animation: none !important; transition: none !important; }
  .g-title-num { opacity: 0.13; }
  .g-title-rule { width: 70%; }
}
