/* ==========================================================
   The Well — Keepers of the Well
   Builds on css/style.css (variables, fonts, .btn).
   ========================================================== */

body.cabal {
  min-height: 100vh; min-height: 100svh;
  background: #050302;
  color: var(--cream);
  overflow-x: clip;
}
body.cabal ::selection { background: rgba(245,185,66,.35); color: var(--cream); }

.embers { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.veil {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background:
    radial-gradient(ellipse 70% 55% at 50% 42%, rgba(60,32,10,.32) 0%, transparent 70%),
    radial-gradient(ellipse 120% 100% at 50% 50%, transparent 55%, rgba(0,0,0,.75) 100%);
}

/* ---------- top bar ---------- */
.cbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) clamp(14px, 3vw, 32px) 14px;
}
.cbar__home { display: block; width: 34px; height: 34px; color: var(--gold-3); opacity: .7; transition: opacity .6s, color .6s; }
.cbar__home:hover, .cbar__home:focus-visible { opacity: 1; color: var(--gold); }
.cbar__home svg { width: 100%; height: 100%; }
.cbar__right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cbar__seats, .cbar__wallet {
  padding: .4em .85em; border-radius: 999px; white-space: nowrap;
  border: 1px solid rgba(245,185,66,.25); background: rgba(10,6,3,.7);
  color: var(--sand); font: 500 .74rem var(--body); letter-spacing: .08em;
}
.cbar__wallet { cursor: pointer; transition: border-color .3s, color .3s; }
.cbar__wallet:hover { border-color: var(--gold); color: var(--gold-2); }
@media (max-width: 480px) { .cbar__seats { font-size: .66rem; padding: .35em .7em; } }

/* ---------- rite layout ---------- */
.well {
  position: relative; z-index: 2;
  min-height: 100vh; min-height: 100svh;
  display: grid; place-items: center;
  padding: 92px clamp(18px, 6vw, 60px) 64px;
}
.rite {
  width: 100%; max-width: 640px; margin: 0 auto; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 1.15rem;
  animation: rise 1.4s var(--ease) both;
}
.rite[hidden] { display: none; }
.rite--wide { max-width: 1020px; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }

.whisper-label {
  margin: 0; color: var(--gold); font: 500 .74rem var(--body);
  letter-spacing: .42em; text-transform: uppercase; opacity: .85;
}
.rite__title {
  margin: 0; outline: none;
  font: 500 clamp(1.9rem, 5.2vw, 3.3rem) / 1.08 var(--body);
  letter-spacing: -.01em; color: var(--cream);
  text-shadow: 0 0 28px rgba(245,185,66,.18);
}
.rite__title--riddle { font-size: clamp(1.35rem, 3.6vw, 2.1rem); line-height: 1.3; font-weight: 400; max-width: 30ch; }
.rite__text { margin: 0; max-width: 46ch; color: var(--muted); font-size: 1.04rem; }
.rite__fine { margin: 0; max-width: 44ch; color: var(--muted); opacity: .65; font-size: .8rem; }
.rite__row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.rite .btn { margin-top: .4rem; }
.link-quiet {
  background: none; border: 0; padding: .3em; cursor: pointer;
  color: var(--muted); font: 500 .85rem var(--body); letter-spacing: .06em;
  text-decoration: underline; text-decoration-color: rgba(245,185,66,.35); text-underline-offset: 4px;
  transition: color .3s;
}
.link-quiet:hover, .link-quiet:focus-visible { color: var(--gold-2); }
.btn[disabled] { opacity: .45; cursor: not-allowed; filter: grayscale(.4); }

/* ---------- sigil ---------- */
.sigil { width: clamp(96px, 22vw, 132px); height: clamp(96px, 22vw, 132px); color: var(--gold); filter: drop-shadow(0 0 18px rgba(245,185,66,.25)); }
.sigil--dim { opacity: .35; filter: none; }
.sigil--locked { color: var(--gold-3); opacity: .55; filter: grayscale(.5); }
.sigil--breathe { animation: breathe 6s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { opacity: .7; filter: drop-shadow(0 0 10px rgba(245,185,66,.15)); transform: scale(1); }
  50% { opacity: 1; filter: drop-shadow(0 0 30px rgba(245,185,66,.45)); transform: scale(1.03); }
}
.ring { position: relative; display: grid; place-items: center; }
.ring::before {
  content: ""; position: absolute; inset: -14px; border-radius: 50%;
  border: 1px solid transparent; border-top-color: var(--gold); border-right-color: rgba(245,185,66,.3);
  animation: spin 2.4s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- locked ledger ---------- */
.ledger { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; width: min(440px, 100%); border: 1px solid rgba(245,185,66,.2); border-radius: 16px; overflow: hidden; background: rgba(245,185,66,.2); }
.ledger div { padding: 1rem; background: #0b0705; display: grid; gap: .2rem; }
.ledger span { font-size: .7rem; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.ledger b { font: 400 1.35rem var(--display); color: var(--gold-2); overflow-wrap: anywhere; }

/* ---------- trials hub ---------- */
.trials { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; width: 100%; margin-top: .6rem; }
@media (max-width: 760px) { .trials { grid-template-columns: 1fr; } }
.trial {
  position: relative; overflow: hidden; text-align: left;
  display: flex; flex-direction: column; align-items: flex-start; gap: .55rem;
  padding: 1.6rem 1.5rem 1.5rem; border-radius: 20px;
  background: linear-gradient(180deg, rgba(26,16,8,.92), rgba(8,5,3,.95));
  border: 1px solid rgba(245,185,66,.22);
  transition: border-color .6s, box-shadow .6s;
}
.trial:hover { border-color: rgba(245,185,66,.5); }
.trial__num { position: absolute; right: 16px; top: -10px; font: 400 6.5rem/1 var(--display); color: rgba(245,185,66,.07); pointer-events: none; }
.trial h2 { margin: 0; font: 500 1.35rem var(--body); color: var(--cream); letter-spacing: .01em; }
.trial p { margin: 0; color: var(--muted); font-size: .96rem; }
.trial__meta { color: var(--sand) !important; font-size: .85rem !important; letter-spacing: .03em; }
.trial .btn { margin-top: .5rem; }
.trial__seal {
  align-self: flex-start; padding: .25em .8em; border-radius: 999px;
  border: 1px solid var(--gold); color: var(--gold-2);
  font: 700 .7rem var(--body); letter-spacing: .25em; text-transform: uppercase;
}
.trial.is-passed { border-color: rgba(245,185,66,.6); box-shadow: 0 0 40px rgba(245,185,66,.12), inset 0 0 0 1px rgba(245,185,66,.15); }

/* ---------- game ---------- */
.rite--game { max-width: 1100px; }
.game { width: 100%; display: grid; gap: 10px; }
.game__hud { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 4px; }
.game__score { display: flex; align-items: baseline; gap: .5rem; }
.game__score small { font-size: .7rem; letter-spacing: .25em; text-transform: uppercase; color: var(--muted); }
.game__score b { font: 400 1.6rem var(--display); color: var(--gold-2); min-width: 3ch; text-align: left; }
.game__score i { font-style: normal; color: var(--muted); font-size: .9rem; }
.game__lives { display: flex; gap: 6px; }
.game__lives i {
  width: 14px; height: 18px; display: block;
  background: radial-gradient(circle at 50% 70%, #ffd978, #ff7a1a 45%, #a3260b 80%);
  -webkit-mask: var(--drop) center / 100% 100% no-repeat; mask: var(--drop) center / 100% 100% no-repeat;
  transform: rotate(180deg); filter: drop-shadow(0 0 6px rgba(255,140,40,.6));
}
.game__lives i.is-spent { background: #2a1c10; filter: none; }
.game__frame {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  border-radius: 18px; overflow: hidden;
  border: 1px solid rgba(245,185,66,.3);
  box-shadow: 0 30px 80px rgba(0,0,0,.7), 0 0 0 1px rgba(0,0,0,.6);
  background: #050302;
}
.game__canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.game__panel {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .7rem;
  padding: 1rem 1.4rem; text-align: center;
  background: radial-gradient(ellipse at center, rgba(5,3,2,.7), rgba(5,3,2,.92));
  animation: rise .7s var(--ease) both;
}
.game__panel[hidden] { display: none; }
.game__panel h2 { margin: 0; font: 500 clamp(1.3rem, 3.4vw, 2.2rem) var(--body); color: var(--cream); }
.game__panel p { margin: 0; max-width: 40ch; color: var(--muted); font-size: clamp(.85rem, 2vw, 1rem); }
.game__keys { display: flex; gap: 14px; color: var(--muted); font-size: .75rem; letter-spacing: .1em; opacity: .7; }
.game__pad { display: none; }
@media (pointer: coarse) {
  .game__keys { display: none; }
  .game__pad { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 10px; user-select: none; -webkit-user-select: none; }
  .game__pad button {
    height: 64px; border-radius: 16px; touch-action: none;
    background: rgba(26,16,8,.95); border: 1px solid rgba(245,185,66,.35);
    color: var(--gold-2); font: 500 1.2rem var(--body);
    -webkit-tap-highlight-color: transparent;
  }
  .game__pad button:active { background: rgba(245,185,66,.18); }
  .game__pad .game__jump { font: 400 1.25rem var(--display); letter-spacing: .04em; background: linear-gradient(180deg, var(--gold-2), var(--gold-3)); color: var(--oil); border: 0; }
}
@media (pointer: coarse) and (orientation: portrait) {
  .rite--game .game__frame { aspect-ratio: 4 / 3; }
}

/* ---------- riddles ---------- */
.timer { position: relative; width: 66px; height: 66px; display: grid; place-items: center; }
.timer svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.timer circle { fill: none; stroke: rgba(245,185,66,.15); stroke-width: 2; }
.timer .timer__run { stroke: var(--gold); stroke-linecap: round; transition: stroke-dashoffset .2s linear, stroke .3s; }
.timer span { font: 400 1.4rem var(--display); color: var(--gold-2); }
body.is-urgent .timer .timer__run { stroke: #ff7a1a; }
body.is-urgent .timer span { color: #ffb36b; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.choices { display: grid; gap: 10px; width: min(480px, 100%); }
.choice {
  padding: 1rem 1.2rem; border-radius: 14px; text-align: left; cursor: pointer;
  background: rgba(14,9,5,.9); border: 1px solid rgba(245,185,66,.22);
  color: var(--cream); font: 500 1rem var(--body);
  transition: border-color .3s, background .3s, transform .3s var(--ease);
}
.choice:hover:not(:disabled) { border-color: var(--gold); transform: translateX(4px); }
.choice:disabled { cursor: default; opacity: .55; }
.choice.is-picked { opacity: 1; border-color: var(--gold); }
.choice.is-right { background: rgba(245,185,66,.16); border-color: var(--gold-2); }
.choice.is-wrong { background: rgba(120,24,10,.35); border-color: #a3260b; }
.answer { display: flex; gap: 10px; width: min(480px, 100%); }
.answer[hidden] { display: none; }
.answer input {
  flex: 1; min-width: 0; padding: .9rem 1.1rem; border-radius: 14px;
  background: rgba(14,9,5,.95); border: 1px solid rgba(245,185,66,.3); color: var(--cream);
  font: 500 1rem var(--body); outline: none;
}
.answer input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245,185,66,.15); }
.answer .btn { margin: 0; }

/* ---------- reveal ---------- */
.rite--reveal { max-width: 720px; gap: 0; }
.skyline { position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0; visibility: hidden; transition: opacity 2s ease, visibility 0s 2s; }
body[data-rite="reveal"] .skyline { opacity: 1; visibility: visible; transition: opacity 2s ease; }
.skyline svg { width: 100%; height: 100%; display: block; }
.skyline .draw { stroke-dasharray: 1600; stroke-dashoffset: 1600; }
.skyline .window, .skyline .sea { opacity: 0; }
.skyline .reflection { opacity: .22; }
.skyline .star { animation: twinkle 5s ease-in-out infinite; }
.skyline.is-playing .draw { animation: draw 4.5s cubic-bezier(.6,.1,.2,1) forwards; }
.skyline.is-playing .window { animation: lightUp 1.2s ease forwards; }
.skyline.is-playing .sea { animation: lightUp 3s 1.5s ease forwards; }
.skyline.is-playing .sweep { animation: sweep 11s 4s linear infinite; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes lightUp { to { opacity: 1; } }
@keyframes twinkle { 50% { opacity: .2; } }
@keyframes sweep { from { transform: translateX(0) skewX(-18deg); } to { transform: translateX(2400px) skewX(-18deg); } }
.revelation { display: flex; flex-direction: column; align-items: center; gap: 1.1rem; text-align: center; padding-bottom: 6vh; }
[data-r-line] { opacity: 0; }
.rite--reveal.is-playing [data-r-line] { animation: rise 1.8s var(--ease) forwards; }
.rite--reveal.is-playing [data-r-line="1"] { animation-delay: .8s; }
.rite--reveal.is-playing [data-r-line="2"] { animation-delay: 2.2s; }
.rite--reveal.is-playing [data-r-line="3"] { animation-delay: 3.8s; }
.rite--reveal.is-playing [data-r-line="4"] { animation-delay: 5.2s; }
.revelation__line { margin: 0; color: var(--muted); letter-spacing: .35em; text-transform: uppercase; font-size: .78rem; }
.revelation__title {
  margin: 0; outline: none;
  font: 400 clamp(2.4rem, 7.5vw, 4.8rem) / 1 var(--display); letter-spacing: .01em;
  background: linear-gradient(180deg, #fff1c4 0%, var(--gold-2) 35%, var(--gold) 70%, #c98a1c 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 24px rgba(245,185,66,.35));
}
.keeper {
  position: relative; width: min(420px, 100%);
  padding: 1.6rem 1.4rem 1.4rem; border-radius: 22px;
  background: linear-gradient(180deg, rgba(20,12,6,.92), rgba(5,3,2,.96));
  border: 1px solid rgba(245,185,66,.45);
  box-shadow: 0 0 60px rgba(245,185,66,.12), inset 0 0 0 1px rgba(245,185,66,.1);
  display: grid; justify-items: center; gap: .35rem;
}
.keeper__sigil { width: 46px; height: 46px; color: var(--gold); }
.keeper__no { margin: .2rem 0 0; color: var(--muted); letter-spacing: .3em; text-transform: uppercase; font-size: .75rem; }
.keeper__no b { display: block; margin-top: .1rem; font: 400 3.2rem/1 var(--display); letter-spacing: .02em; color: var(--gold-2); }
.keeper__name { margin: .2rem 0; color: var(--cream); font: 500 1.05rem var(--body); letter-spacing: .32em; text-transform: uppercase; }
.keeper__seats { margin: .4rem 0 0; color: var(--muted); font-size: .8rem; letter-spacing: .08em; }
.tier {
  display: inline-block; padding: .35em 1em; border-radius: 999px;
  font: 700 .72rem var(--body); letter-spacing: .28em; text-transform: uppercase;
  border: 1px solid rgba(245,185,66,.45); color: var(--sand); background: rgba(245,185,66,.06);
}
.tier[data-tier="roughneck"] { color: #e0a878; border-color: #8a5a32; background: rgba(138,90,50,.15); }
.tier[data-tier="driller"] { color: #f2e2b8; border-color: #c9b07a; background: rgba(201,176,122,.12); }
.tier[data-tier="oil-baron"] {
  color: var(--oil); border-color: transparent;
  background: linear-gradient(110deg, var(--gold-3), var(--gold-2) 40%, #fff1c4 50%, var(--gold-2) 60%, var(--gold-3));
  background-size: 250% 100%; animation: shine 4s linear infinite;
}
@keyframes shine { to { background-position: -250% 0; } }
.mark { display: grid; justify-items: center; gap: .7rem; width: 100%; }
.mark.is-given > .btn, .mark.is-given > .rite__fine { display: none; }
.mark__box {
  width: min(460px, 100%); display: grid; gap: .6rem; justify-items: center;
  padding: 1.1rem; border-radius: 18px; border: 1px dashed rgba(245,185,66,.45); background: rgba(5,3,2,.85);
  animation: rise .9s var(--ease) both;
}
.mark__box[hidden] { display: none; }
.mark__box label { font-size: .7rem; letter-spacing: .3em; text-transform: uppercase; color: var(--gold); }
.mark__row { display: flex; gap: 8px; width: 100%; }
.mark__row input {
  flex: 1; min-width: 0; padding: .7rem .9rem; border-radius: 12px;
  background: #0b0705; border: 1px solid rgba(245,185,66,.3); color: var(--gold-2);
  font: 500 .85rem ui-monospace, SFMono-Regular, Menlo, monospace;
}
.mark__row .btn { margin: 0; }
.mark__clock { margin: 0; font: 400 1.1rem var(--display); color: var(--gold-2); letter-spacing: .04em; }

/* ---------- omen (in-lore notices) ---------- */
.omen {
  position: fixed; left: 50%; bottom: max(26px, env(safe-area-inset-bottom)); z-index: 30;
  translate: -50% 16px; max-width: min(92vw, 520px);
  padding: .85em 1.4em; border-radius: 14px; text-align: center;
  background: rgba(8,5,3,.95); border: 1px solid rgba(245,185,66,.4); color: var(--sand);
  font: 500 .92rem var(--body); letter-spacing: .02em;
  box-shadow: 0 16px 40px rgba(0,0,0,.6);
  opacity: 0; pointer-events: none; transition: opacity .5s, translate .5s var(--ease);
}
.omen.is-on { opacity: 1; translate: -50% 0; }

/* ---------- focus ---------- */
body.cabal :focus-visible { outline: 2px solid rgba(245,185,66,.7); outline-offset: 3px; }
body.cabal .rite__title:focus, body.cabal .revelation__title:focus { outline: none; }

/* ---------- reduced motion: everything still, everything visible ---------- */
@media (prefers-reduced-motion: reduce) {
  .rite, .game__panel, .mark__box { animation: none !important; }
  [data-r-line] { opacity: 1 !important; animation: none !important; }
  .skyline .draw { stroke-dashoffset: 0 !important; animation: none !important; }
  .skyline .window, .skyline .sea { opacity: 1 !important; animation: none !important; }
  .skyline .sweep, .skyline .star { animation: none !important; }
}
