:root {
  --bg-deep: #06101f;
  --bg-panel: rgba(5, 17, 40, 0.72);
  --bg-panel-soft: rgba(11, 31, 66, 0.64);
  --line-blue: rgba(122, 224, 255, 0.34);
  --line-gold: rgba(255, 220, 148, 0.58);
  --text-main: #f4f8ff;
  --text-muted: rgba(233, 243, 255, 0.78);
  --text-faint: rgba(233, 243, 255, 0.58);
  --gold: #f6dc9d;
  --gold-strong: #ffebaf;
  --blue: #79d8ff;
  --blue-strong: #2e95ff;
  --success: #a3ffd1;
  --danger: #ff8ca7;
  --ink: #563013;
  --ink-soft: rgba(84, 48, 22, 0.92);
  --paper-title: #603212;
  --paper-muted: #9d6a41;
  --shadow-xl: 0 30px 90px rgba(0, 10, 28, 0.56);
  --shadow-soft: 0 16px 50px rgba(0, 10, 28, 0.38);
  --radius-xl: 34px;
  --radius-lg: 24px;
  --radius-md: 16px;
  --font-ui: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-hand: "Segoe Print", "Bradley Hand ITC", "Comic Sans MS", "Trebuchet MS", cursive;
}

* { box-sizing: border-box; }
html {
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-behavior: smooth;
}
body {
  min-height: 100%;
  margin: 0;
  font-family: var(--font-ui);
  color: var(--text-main);
  background: var(--bg-deep);
  overflow-x: hidden;
  overflow-y: auto;
}
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }

.app-shell {
  min-height: 100svh;
  position: relative;
  isolation: isolate;
  overflow: visible;
}

.screen {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(16px, 2vw, 32px);
  overflow: visible;
}

.sky-bg::before,
.sky-bg::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.sky-bg::before {
  z-index: -2;
  background: linear-gradient(180deg, rgba(6, 17, 42, .08), rgba(4, 10, 27, .68));
}

.sky-bg::after {
  z-index: -1;
  background-image:
    radial-gradient(circle at 17% 23%, rgba(255,255,255,.95) 0 1px, transparent 1.7px),
    radial-gradient(circle at 72% 18%, rgba(255,255,255,.72) 0 1px, transparent 1.6px),
    radial-gradient(circle at 83% 71%, rgba(110, 222, 255, .9) 0 1.2px, transparent 1.8px),
    radial-gradient(circle at 42% 74%, rgba(255, 232, 168, .7) 0 1.1px, transparent 1.8px);
  background-size: 720px 620px, 680px 540px, 580px 520px, 520px 420px;
  opacity: .38;
  animation: driftStars 18s linear infinite;
}

.bg-layer,
.story-desk {
  position: fixed;
  inset: 0;
  background-size: cover;
  background-position: center;
  pointer-events: none;
  transform: translateZ(0);
}
.bg-layer.celestial-city { background-image: url("../assets/bg-hub.webp"); }
.bg-layer.sky-pillars { background-image: url("../assets/bg-sky-columns.webp"); }
.bg-layer.hub-ornate { background-image: url("../assets/bg-lore-hall.webp"); }
.bg-layer.reward-gate { background-image: url("../assets/bg-portal.webp"); }
.story-desk { background-image: url("../assets/bg-wood-desk.jpg"); }
.story-desk::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 38%, rgba(255,241,212,.14), transparent 32%),
    linear-gradient(180deg, rgba(31,12,5,.14), rgba(20,8,4,.36));
}

.frame-card {
  position: relative;
  width: min(100%, 960px);
  border: 1px solid rgba(122, 224, 255, .18);
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.018)),
    linear-gradient(135deg, rgba(12, 48, 96, .72), rgba(5, 18, 45, .82));
  filter: drop-shadow(var(--shadow-xl));
  overflow: hidden;
}

.frame-surface {
  position: absolute;
  inset: 0;
  background-position: center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  pointer-events: none;
  opacity: .78;
  mix-blend-mode: normal;
}
.frame-night .frame-surface { background-image: url("../assets/ui-frame-dark.webp"); }
.frame-wave .frame-surface { background-image: url("../assets/ui-frame-blue.webp"); }

.frame-content {
  position: relative;
  z-index: 1;
  padding: clamp(54px, 6vw, 78px) clamp(44px, 5vw, 72px);
}

.centered-copy {
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 14px;
}
.center-card { width: min(980px, 96vw); }

.title-xl,
.title-lg {
  margin: 0;
  color: var(--gold-strong);
  text-shadow: 0 0 26px rgba(255, 229, 166, 0.28);
}
.title-xl {
  font-size: clamp(34px, 7vw, 82px);
  line-height: .94;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.title-lg {
  font-size: clamp(28px, 4vw, 56px);
  line-height: 1.02;
}
.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: clamp(15px, 1.5vw, 19px);
  line-height: 1.6;
}
.subtitle.narrow { max-width: 620px; }

.eyebrow {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255, 227, 161, .1);
  border: 1px solid rgba(255, 227, 161, .28);
  color: var(--gold-strong);
  font-size: 12px;
  line-height: 1;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.icon { width: 20px; height: 20px; }
.icon-large { width: 88px; height: 88px; }

.boot-emblem {
  width: 132px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle, rgba(122,224,255,.34), rgba(33,88,169,.14) 58%, transparent 74%);
  animation: pulse 2.8s ease-in-out infinite;
}

.loader-orb {
  width: 118px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--gold-strong);
  font-size: 24px;
  font-weight: 700;
  border: 1px solid rgba(122,224,255,.38);
  background: radial-gradient(circle, rgba(112,230,255,.20), rgba(19,54,119,.1));
  box-shadow: inset 0 0 40px rgba(105, 221, 255, .1), 0 0 34px rgba(87, 193, 255, .16);
}
.progress-bar {
  width: min(420px, 82vw);
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.1);
}
.progress-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(255, 223, 145, .92), rgba(112, 230, 255, .9));
  box-shadow: 0 0 18px rgba(112, 230, 255, .32);
  transition: width .25s ease;
}
.loader-message { margin: 0; color: var(--text-faint); min-height: 24px; }

.portal-card { width: min(920px, 96vw); }
.portal-form {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
}
.input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  border-radius: 999px;
  padding: 0 18px;
  background: rgba(6, 18, 44, .62);
  border: 1px solid rgba(122, 224, 255, .24);
  box-shadow: inset 0 0 24px rgba(72, 180, 255, .08);
}
.input-wrap input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  color: var(--text-main);
  outline: none;
  font-size: 18px;
  letter-spacing: .05em;
}
.validation-note {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.btn-row.center { justify-content: center; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  padding: 12px 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--text-main);
  position: relative;
  overflow: hidden;
  text-decoration: none;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.99); }
.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 0 34%, rgba(255,255,255,.24) 42%, transparent 54%);
  transform: translateX(-120%);
  transition: transform .7s ease;
}
.btn:hover::after { transform: translateX(120%); }
.btn-primary {
  background: linear-gradient(180deg, rgba(255,240,196,.34), rgba(255,202,96,.15)), linear-gradient(135deg, #2d95ff, #174eaa 56%, #0a255d);
  border-color: rgba(255, 229, 165, .66);
  box-shadow: 0 0 20px rgba(91, 204, 255, .26);
}
.btn-secondary {
  background: rgba(8, 24, 57, .72);
  border-color: rgba(122, 224, 255, .26);
}
.btn-ghost {
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.14);
}
.btn-small { min-height: 38px; padding: 9px 14px; font-size: 13px; }

/* Story / parchment */
.story-screen {
  background: #1f0d06;
  overflow: visible;
  align-items: start;
  padding: 0;
}
.story-stage {
  width: 100%;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(44px, 5vw, 74px) 16px clamp(80px, 8vw, 120px);
  position: relative;
}
.story-counter {
  position: fixed;
  top: clamp(14px, 2vw, 24px);
  right: clamp(14px, 2vw, 28px);
  z-index: 4;
  padding: 7px 12px;
  border-radius: 999px;
  color: rgba(255, 241, 220, .9);
  background: rgba(55, 22, 10, .62);
  border: 1px solid rgba(255, 201, 128, .18);
  font-size: 13px;
  letter-spacing: .06em;
  backdrop-filter: blur(8px);
}
.parchment-holder {
  position: relative;
  width: min(700px, 90vw);
  min-height: min(1080px, calc(100svh - 88px));
  aspect-ratio: 832 / 1280;
}
.parchment-image {
  position: absolute;
  inset: 0;
  background: url("../assets/parchment-scroll.png") center / 100% 100% no-repeat;
  filter: drop-shadow(0 24px 56px rgba(27, 12, 7, .34));
}
.parchment-safe {
  position: absolute;
  inset: 9.6% 10.2% 7.4% 10.4%;
  display: flex;
  flex-direction: column;
  color: var(--ink);
}
.story-subtitle {
  margin: 0 0 8px;
  color: var(--paper-muted);
  font-family: var(--font-ui);
  font-size: clamp(11px, .9vw, 13px);
  font-weight: 650;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.story-title {
  margin: 0 0 12px;
  font-family: var(--font-hand);
  font-size: clamp(27px, 2vw, 36px);
  line-height: 1.08;
  color: var(--paper-title);
  letter-spacing: -.02em;
}
.story-text-wrap {
  flex: 1;
  min-height: 0;
  overflow: visible;
  padding-right: 0;
}
.story-text {
  margin: 0;
  white-space: pre-line;
  font-family: var(--font-hand);
  font-size: clamp(14.8px, 1vw, 17.2px);
  line-height: 1.52;
  color: var(--ink-soft);
}
.story-actions {
  margin-top: 18px;
  justify-content: center;
}
.story-actions .btn-secondary {
  color: #623718;
  border-color: rgba(112, 75, 39, .22);
  background: rgba(128, 83, 42, .08);
}
.story-actions .btn-primary {
  color: #fffaf1;
  background: linear-gradient(180deg, rgba(234, 183, 104, .32), rgba(168, 98, 41, .14)), linear-gradient(135deg, #bb7a37, #884a1f 55%, #613012);
  border-color: rgba(255, 221, 154, .6);
}
.caret::after {
  content: "|";
  animation: blink 1s step-end infinite;
  color: #9b6127;
}

.cinematic-card { width: min(980px, 96vw); }
.cinematic-ring {
  width: 130px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(255, 229, 166, .4);
  box-shadow: 0 0 0 10px rgba(122, 224, 255, .08), 0 0 42px rgba(122, 224, 255, .22);
  background: radial-gradient(circle, rgba(255,255,255,.16), rgba(122,224,255,.06) 56%, transparent 72%);
  animation: pulse 2.2s ease-in-out infinite;
}
.cinematic-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,.22), transparent 42%);
  animation: fadeFlash 2s ease both;
}

/* Hub */
.hub-screen {
  align-items: start;
  padding-top: clamp(18px, 2vw, 28px);
  padding-bottom: clamp(40px, 5vw, 74px);
}
.hub-layout {
  width: min(1480px, 100%);
  display: grid;
  gap: 18px;
  position: relative;
  z-index: 1;
}
.hub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-radius: 22px;
  background: rgba(6, 18, 44, .70);
  border: 1px solid rgba(122, 224, 255, .16);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}
.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-icon { width: 28px; height: 28px; }
.brand-block strong { display: block; font-size: 18px; color: var(--gold-strong); }
.brand-block span { display: block; color: var(--text-faint); font-size: 13px; }
.header-meters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.meter-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
}
.meter-pill b { font-size: 16px; color: var(--gold-strong); }
.meter-pill span { font-size: 12px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .08em; }

.hub-grid {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(460px, 1fr) minmax(290px, 340px);
  gap: 18px;
  align-items: start;
}
.panel {
  width: 100%;
  min-height: 0;
  border-radius: 26px;
  background:
    radial-gradient(circle at 50% 0%, rgba(123, 224, 255, .12), transparent 36%),
    linear-gradient(180deg, rgba(7, 27, 62, .78), rgba(4, 14, 36, .84));
  backdrop-filter: blur(10px);
}
.panel .frame-surface {
  display: none;
}
.panel .frame-content {
  padding: clamp(26px, 2.6vw, 40px);
  background: transparent;
}
.panel-center {
  max-width: 760px;
  justify-self: center;
}
.panel-center .frame-surface {
  display: block;
  opacity: .30;
}
.panel-center .frame-content {
  min-height: 520px;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
}
.panel h2 {
  margin: 0 0 8px;
  font-size: 25px;
  color: var(--gold-strong);
}
.panel-note {
  margin: 0 0 18px;
  color: var(--text-faint);
  font-size: 14px;
  line-height: 1.55;
}
.task-list {
  display: grid;
  gap: 14px;
}
.task-card {
  border-radius: 18px;
  padding: 15px;
  background: rgba(7, 21, 50, .58);
  border: 1px solid rgba(122, 224, 255, .14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}
.task-card.completed {
  background: rgba(12, 45, 41, .48);
  border-color: rgba(138, 255, 205, .22);
}
.task-card.locked { opacity: .84; }
.task-topline,
.task-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.task-day {
  color: var(--gold-strong);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.status-pill {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid rgba(255,255,255,.14);
  white-space: nowrap;
}
.status-pill.open { color: #a5e7ff; background: rgba(45, 140, 255, .12); }
.status-pill.done { color: var(--success); background: rgba(25, 112, 81, .18); }
.status-pill.locked { color: var(--text-faint); background: rgba(255,255,255,.05); }
.task-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 8px;
}
.task-title-row h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}
.task-icon { width: 22px; height: 22px; }
.task-card p {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.52;
}
.reward-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 228, 154, .1);
  color: var(--gold-strong);
  font-size: 13px;
}

.event-crest {
  width: min(220px, 54vw);
  aspect-ratio: 1;
  margin: 0 auto 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  position: relative;
  background:
    radial-gradient(circle at 50% 42%, rgba(255,255,255,.22), rgba(119, 222, 255, .12) 38%, rgba(8, 24, 56, .1) 62%, transparent 72%),
    conic-gradient(from .2turn, rgba(255,225,148,.32), rgba(100,216,255,.08), rgba(255,225,148,.28), rgba(100,216,255,.08), rgba(255,225,148,.32));
  border: 1px solid rgba(255, 226, 154, .22);
  box-shadow: 0 0 42px rgba(112, 224, 255, .13), inset 0 0 40px rgba(255, 255, 255, .06);
}
.event-crest::before,
.event-crest::after {
  content: "";
  position: absolute;
  inset: 13%;
  border-radius: 50%;
  border: 1px solid rgba(255, 226, 154, .28);
}
.event-crest::after {
  inset: 28%;
  border-color: rgba(122, 224, 255, .28);
}
.event-crest-icon {
  width: 70px;
  height: 70px;
  filter: drop-shadow(0 0 16px rgba(255, 232, 166, .26));
}
.event-crest span {
  position: absolute;
  bottom: 25px;
  font-size: 11px;
  letter-spacing: .16em;
  color: var(--gold-strong);
}
.summary-grid {
  width: min(620px, 100%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 22px 0;
}
.summary-grid div {
  padding: 14px 10px;
  border-radius: 18px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.12);
}
.summary-grid strong {
  display: block;
  font-size: 22px;
  color: var(--gold-strong);
  margin-bottom: 4px;
}
.summary-grid span {
  display: block;
  font-size: 12px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.hub-status {
  width: min(620px, 100%);
  margin: 0 0 20px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 226, 154, .16);
  background: rgba(255, 226, 154, .08);
  color: var(--gold-strong);
  line-height: 1.55;
}

.info-stack {
  display: grid;
  gap: 14px;
}
.info-card {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(7, 22, 49, .56);
  border: 1px solid rgba(122, 224, 255, .12);
}
.info-card strong {
  display: block;
  margin-bottom: 6px;
  color: var(--gold-strong);
}
.info-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.55;
}
.panel-actions { margin-top: 4px; }

.dialogue-screen { z-index: 0; }
.dialogue-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 26, .56);
  backdrop-filter: blur(12px);
}
.dialogue-card {
  width: min(980px, 96vw);
  z-index: 1;
}
.dialogue-text {
  min-height: 116px;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1.7;
  white-space: pre-line;
}
.choice-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}
.hidden { display: none; }

.reward-card { width: min(940px, 96vw); }
.reward-burst {
  position: relative;
  width: 170px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}
.reward-icon {
  position: relative;
  z-index: 2;
  width: 84px;
  height: 84px;
  filter: drop-shadow(0 0 18px rgba(255, 226, 154, .3));
}
.reward-count {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 226, 154, .3);
  background: rgba(255, 226, 154, .08);
  color: var(--gold-strong);
  font-size: 26px;
  font-weight: 700;
}
.particle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  margin-top: -5px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,1), rgba(255,220,143,.88) 52%, rgba(255,220,143,0) 70%);
  animation: burst 2.2s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
.particle:nth-child(1) { --x: 0px; --y: -80px; }
.particle:nth-child(2) { --x: 46px; --y: -66px; }
.particle:nth-child(3) { --x: 78px; --y: -10px; }
.particle:nth-child(4) { --x: 58px; --y: 46px; }
.particle:nth-child(5) { --x: 0px; --y: 78px; }
.particle:nth-child(6) { --x: -56px; --y: 46px; }
.particle:nth-child(7) { --x: -78px; --y: -10px; }
.particle:nth-child(8) { --x: -46px; --y: -66px; }
.particle:nth-child(9) { --x: 20px; --y: -92px; }
.particle:nth-child(10) { --x: 88px; --y: 24px; }
.particle:nth-child(11) { --x: 18px; --y: 96px; }
.particle:nth-child(12) { --x: -62px; --y: 82px; }
.particle:nth-child(13) { --x: -90px; --y: 18px; }
.particle:nth-child(14) { --x: -22px; --y: -92px; }
.particle:nth-child(15) { --x: 92px; --y: -42px; }
.particle:nth-child(16) { --x: -94px; --y: -36px; }

.toast-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  display: grid;
  gap: 10px;
}
.toast {
  min-width: min(360px, calc(100vw - 36px));
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(6, 19, 42, .9);
  border: 1px solid rgba(122, 224, 255, .2);
  box-shadow: var(--shadow-soft);
  transition: opacity .2s ease, transform .2s ease;
}
.toast strong {
  display: block;
  margin-bottom: 4px;
  color: var(--gold-strong);
}
.toast span {
  display: block;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.45;
}

.fade-up { animation: fadeUp .5s ease both; }
.shake { animation: shake .45s ease both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes driftStars {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-24px, 18px, 0); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.035); filter: brightness(1.08); }
}
@keyframes burst {
  0%, 100% { transform: translate(0, 0) scale(.3); opacity: 0; }
  18% { opacity: 1; }
  52% { transform: translate(var(--x), var(--y)) scale(1); opacity: 1; }
  100% { transform: translate(calc(var(--x) * 1.12), calc(var(--y) * 1.12)) scale(.35); opacity: 0; }
}
@keyframes blink { 50% { opacity: 0; } }
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}
@keyframes fadeFlash {
  0% { opacity: .55; }
  100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

@media (max-width: 1220px) {
  .hub-grid {
    grid-template-columns: 1fr;
  }
  .panel-center {
    max-width: 100%;
  }
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .frame-content {
    padding: 36px 26px 42px;
  }
  .hub-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-meters {
    width: 100%;
    justify-content: flex-start;
  }
  .parchment-holder {
    width: min(720px, 96vw);
    min-height: calc(100svh - 72px);
  }
  .parchment-safe {
    inset: 9.9% 9.6% 7.8% 9.8%;
  }
  .story-title {
    font-size: clamp(22px, 5.8vw, 30px);
  }
  .story-text {
    font-size: clamp(12.5px, 3.05vw, 14.4px);
    line-height: 1.45;
  }
  .story-actions {
    margin-top: 12px;
  }
  .summary-grid {
    grid-template-columns: 1fr;
  }
  .reward-count {
    font-size: 20px;
  }
}

@media (max-width: 520px) {
  .screen { padding: 14px; }
  .title-xl { font-size: clamp(30px, 11vw, 54px); }
  .title-lg { font-size: clamp(24px, 8vw, 40px); }
  .brand-block strong { font-size: 16px; }
  .brand-block span { font-size: 12px; }
  .meter-pill { width: 100%; justify-content: center; }
  .task-topline,
  .task-bottom,
  .choice-list { flex-direction: column; align-items: stretch; }
  .story-counter {
    top: 12px;
    right: 12px;
    font-size: 11px;
  }
  .parchment-holder {
    width: 98vw;
    min-height: calc(100svh - 54px);
  }
  .parchment-safe {
    inset: 10.2% 8.8% 7.6% 9%;
  }
  .toast-root {
    right: 10px;
    left: 10px;
    bottom: 10px;
  }
  .toast {
    min-width: 0;
  }
}


/* v3.7 page-corner story navigation: no auto-scroll, no inner scroll, visual-novel style */
html,
body {
  overflow-x: hidden;
}

body.story-lock {
  overflow-y: hidden;
}

.story-screen {
  overflow: hidden;
  min-height: 100svh;
  padding: 0;
}

.story-stage {
  min-height: 100svh;
  padding: clamp(18px, 3svh, 34px) 14px;
  place-items: center;
}

.story-counter {
  position: fixed;
  top: clamp(12px, 2svh, 20px);
  right: clamp(12px, 2vw, 26px);
  z-index: 6;
}

.parchment-holder {
  width: min(690px, 92vw, calc((100svh - 58px) * 0.65));
  min-height: 0;
  aspect-ratio: 832 / 1280;
  transform-origin: 50% 54%;
}

.parchment-safe {
  inset: 9.2% 9.8% 8.5% 10.1%;
  overflow: visible;
}

.story-subtitle {
  margin-bottom: 7px;
  font-size: clamp(10px, 1.35svh, 13px);
}

.story-title {
  margin-bottom: 11px;
  font-size: clamp(22px, 3.5svh, 36px);
  line-height: 1.08;
}

.story-text-wrap {
  flex: 1;
  overflow: visible;
  min-height: 0;
}

.story-text {
  font-size: clamp(13px, 2.05svh, 17px);
  line-height: 1.46;
}

.story-hint {
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 7.6%;
  margin: 0;
  color: rgba(98, 55, 24, .66);
  font-family: var(--font-ui);
  font-size: clamp(10px, 1.28svh, 12px);
  text-align: center;
  opacity: 0;
  transform: translateY(5px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
}

.story-hint.visible {
  opacity: 1;
  transform: translateY(0);
}

.page-corner {
  position: absolute;
  right: 7.4%;
  bottom: 5.7%;
  width: clamp(58px, 8.4svh, 82px);
  height: clamp(58px, 8.4svh, 82px);
  border: 0;
  padding: 0;
  background: transparent;
  color: #673816;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(.96);
  transition: opacity .24s ease, transform .24s ease, filter .24s ease;
  z-index: 5;
}

.page-corner.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  animation: cornerPulse 1.9s ease-in-out infinite;
}

.page-corner::before {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  border-radius: 0 0 18px 0;
  background:
    linear-gradient(135deg, transparent 0 44%, rgba(255, 232, 175, .92) 48%, rgba(169, 92, 37, .55) 100%),
    radial-gradient(circle at 70% 70%, rgba(255, 190, 91, .55), transparent 62%);
  box-shadow: inset -8px -8px 15px rgba(76, 33, 13, .18);
  filter: drop-shadow(0 0 12px rgba(255, 198, 104, .44));
}

.page-corner::after {
  content: "›";
  position: absolute;
  right: 13px;
  bottom: 4px;
  color: #673816;
  font-family: var(--font-ui);
  font-size: clamp(30px, 5svh, 42px);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 246, 218, .45);
}

.page-corner span {
  position: absolute;
  right: 0;
  bottom: -24px;
  min-width: 120px;
  color: rgba(255, 239, 210, .88);
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-align: right;
  text-shadow: 0 2px 8px rgba(39, 14, 5, .62);
  opacity: .85;
}

.story-back {
  position: absolute;
  left: 7.8%;
  bottom: 6.4%;
  width: clamp(40px, 6svh, 56px);
  height: clamp(40px, 6svh, 56px);
  border: 1px solid rgba(112, 62, 28, .2);
  border-radius: 999px;
  background: rgba(105, 58, 26, .08);
  color: rgba(93, 51, 21, .76);
  font-size: clamp(28px, 4svh, 38px);
  line-height: 1;
  display: grid;
  place-items: center;
  z-index: 5;
  transition: transform .18s ease, background .18s ease;
}

.story-back:hover {
  transform: translateX(-2px);
  background: rgba(105, 58, 26, .14);
}

.story-back.hidden {
  display: none;
}

.parchment-holder.turning {
  animation: pageTurn .42s ease both;
}

@keyframes cornerPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.18); }
}

@keyframes pageTurn {
  0% { transform: translateX(0) rotate(0deg); opacity: 1; }
  42% { transform: translateX(-10px) rotate(-.45deg); opacity: .76; }
  100% { transform: translateX(0) rotate(0deg); opacity: 1; }
}

@media (max-width: 760px) {
  .story-stage {
    padding: 18px 8px 24px;
  }
  .parchment-holder {
    width: min(94vw, calc((100svh - 44px) * 0.65));
  }
  .parchment-safe {
    inset: 9.8% 9.4% 8.8% 9.8%;
  }
  .story-title {
    font-size: clamp(19px, 3.2svh, 27px);
  }
  .story-text {
    font-size: clamp(12px, 1.85svh, 14.6px);
    line-height: 1.42;
  }
  .page-corner span {
    display: none;
  }
}

@media (max-width: 420px) {
  .story-subtitle {
    letter-spacing: .08em;
  }
  .story-title {
    margin-bottom: 8px;
  }
  .story-text {
    font-size: clamp(11.2px, 1.78svh, 13.4px);
    line-height: 1.38;
  }
  .story-hint {
    display: none;
  }
}


/* === v3.8 story readability + dialogue asset overrides === */
.story-stage {
  align-items: start;
}

.parchment-holder {
  width: min(860px, 76vw, calc((100svh - 34px) * 0.72));
  max-width: 860px;
  min-height: 0;
}

.parchment-safe {
  inset: 8.8% 11.8% 8.2% 13.8%;
}

.story-subtitle,
.story-title {
  text-align: center;
}

.story-subtitle {
  margin: 0 0 10px;
  font-size: clamp(12px, 0.82vw, 14px);
  letter-spacing: .12em;
}

.story-title {
  margin: 0 0 14px;
  font-size: clamp(31px, 2vw, 42px);
  line-height: 1.06;
}

.story-text-wrap {
  padding-inline: clamp(4px, .6vw, 10px);
}

.story-text {
  max-width: 100%;
  font-size: clamp(16px, 1.04vw, 19px);
  line-height: 1.58;
  text-wrap: pretty;
  overflow-wrap: anywhere;
  text-align: left;
}

.story-hint {
  left: 15%;
  right: 15%;
  bottom: 8%;
}

.page-corner {
  right: 8.3%;
  bottom: 6.2%;
}

.story-back {
  left: 9.6%;
  bottom: 6.8%;
}

.dialogue-card {
  width: min(860px, 92vw);
}

.frame-night .frame-surface,
.frame-wave .frame-surface {
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.dialogue-card.frame-card {
  aspect-ratio: 1320 / 740;
}

.dialogue-card .frame-content {
  width: 100%;
  max-width: 100%;
  padding: clamp(34px, 4.4vw, 54px) clamp(52px, 7vw, 92px);
}

.dialogue-card .centered-copy {
  align-items: center;
  text-align: center;
}

.dialogue-card .eyebrow,
.dialogue-card .title-lg,
.dialogue-card .subtitle {
  align-self: center;
  text-align: center;
}

.dialogue-text {
  width: min(100%, 640px);
  margin-inline: auto;
  text-align: left;
}

@media (max-width: 1024px) {
  .parchment-holder {
    width: min(760px, 88vw, calc((100svh - 46px) * 0.7));
  }

  .parchment-safe {
    inset: 9.2% 11.2% 8.4% 12.9%;
  }

  .story-title {
    font-size: clamp(27px, 3.1vw, 36px);
  }

  .story-text {
    font-size: clamp(14.4px, 1.6vw, 17.6px);
  }
}

@media (max-width: 760px) {
  .parchment-holder {
    width: min(94vw, calc((100svh - 38px) * 0.68));
  }

  .parchment-safe {
    inset: 9.6% 10.2% 8.8% 10.8%;
  }

  .story-subtitle {
    font-size: clamp(10px, 1.32svh, 12px);
  }

  .story-title {
    font-size: clamp(21px, 3.15svh, 28px);
  }

  .story-text {
    font-size: clamp(12.2px, 1.82svh, 14.8px);
    line-height: 1.44;
  }

  .story-hint {
    left: 12%;
    right: 12%;
  }

  .dialogue-card {
    width: min(96vw, 760px);
  }

  .dialogue-card.frame-card {
    aspect-ratio: auto;
  }

  .dialogue-card .frame-content {
    padding: clamp(26px, 6vw, 34px) clamp(24px, 5vw, 30px);
  }

  .dialogue-text {
    width: 100%;
  }
}


/* === Dialogue vertical alignment patch === */
.dialogue-card .frame-content {
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: clamp(70px, 7vw, 96px) clamp(52px, 7vw, 92px) clamp(44px, 4vw, 64px);
}

.dialogue-card .dialogue-text {
  width: min(100%, 660px);
  margin-inline: auto;
  margin-top: 0;
  transform: translateY(18px);
  text-align: left;
}

.dialogue-card .choice-list {
  width: min(100%, 660px);
  margin-inline: auto;
  margin-top: 36px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  transform: translateY(18px);
}

.dialogue-card .choice-list.hidden {
  display: none;
}

.dialogue-card .choice-list .btn {
  justify-content: center;
}

@media (max-width: 760px) {
  .dialogue-card .frame-content {
    padding-top: 48px;
    padding-bottom: 38px;
  }

  .dialogue-card .dialogue-text,
  .dialogue-card .choice-list {
    transform: translateY(8px);
  }

  .dialogue-card .choice-list {
    justify-content: center;
  }
}


/* === v3.9 desktop parchment zoom === */
/* Desktop idea: viewport shows about half of the parchment.
   The parchment/text are the heroes; the table is just a background. */
@media (min-width: 900px) {
  .story-screen {
    padding: 0;
    overflow: visible;
  }

  .story-stage {
    min-height: 100svh;
    place-items: start center;
    padding: 22px 12px 130px;
  }

  .parchment-holder {
    width: min(1080px, 78vw, calc(178svh * 0.65));
    max-width: none;
    min-height: 0;
    aspect-ratio: 832 / 1280;
    margin-inline: auto;
  }

  .parchment-safe {
    /* Shift content right, away from the burned left edge. */
    inset: 8.4% 12.2% 8.4% 15.6%;
  }

  .story-subtitle,
  .story-title {
    text-align: center;
  }

  .story-subtitle {
    margin-bottom: 12px;
    font-size: clamp(13px, 0.82vw, 16px);
    letter-spacing: .12em;
  }

  .story-title {
    margin-bottom: 18px;
    font-size: clamp(38px, 2.45vw, 54px);
    line-height: 1.04;
  }

  .story-text-wrap {
    padding-inline: 4px 8px;
  }

  .story-text {
    font-size: clamp(20px, 1.27vw, 25px);
    line-height: 1.56;
    text-align: left;
    overflow-wrap: anywhere;
    text-wrap: pretty;
  }

  .story-hint {
    left: 18%;
    right: 15%;
    bottom: 8.2%;
    font-size: 12px;
  }

  @media (min-width: 900px) {
  .page-corner {
    top: 5.8%;
    right: 1.8%;
    bottom: auto;
  }
}

  .story-back {
    left: 11.2%;
    bottom: 6.9%;
  }

  .story-counter {
    top: 14px;
    right: 18px;
  }
}

/* Do not let the older 1024px rule shrink desktop parchment too much. */
@media (min-width: 900px) and (max-width: 1024px) {
  .parchment-holder {
    width: min(980px, 86vw, calc(168svh * 0.65));
  }

  .story-text {
    font-size: clamp(18px, 1.8vw, 22px);
  }

  .story-title {
    font-size: clamp(32px, 3.4vw, 44px);
  }
}

/* Dialogue: lower content + centered buttons after removing the eyebrow. */
.dialogue-card .frame-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding-top: clamp(78px, 7.4vw, 108px);
  padding-bottom: clamp(48px, 4vw, 68px);
}

.dialogue-card .dialogue-text {
  width: min(100%, 680px);
  margin-inline: auto;
  transform: translateY(22px);
  text-align: left;
}

.dialogue-card .choice-list {
  width: min(100%, 680px);
  margin-inline: auto;
  margin-top: 38px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  transform: translateY(22px);
}

.dialogue-card .choice-list.hidden {
  display: none;
}

.dialogue-card .choice-list .btn {
  justify-content: center;
}


/* === v3.10 desktop story: no page scroll, huge parchment, top corner === */
@media (min-width: 900px) {
  html:has(.story-screen),
  body:has(.story-screen) {
    overflow: hidden;
    height: 100%;
  }

  .story-screen {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100svh;
    min-height: 100svh;
    overflow: hidden;
    padding: 0;
  }

  .story-stage {
    width: 100vw;
    height: 100svh;
    min-height: 100svh;
    overflow: hidden;
    place-items: start center;
    padding: 12px 0 0;
  }

  .story-desk {
    background-size: cover;
    background-position: center 38%;
  }

  .story-counter {
    top: 14px;
    right: 18px;
    z-index: 20;
  }

  .parchment-holder {
    width: min(1180px, 78vw);
    max-width: none;
    min-height: 0;
    aspect-ratio: 832 / 1280;
    margin: 0 auto;
    transform: translateY(0);
  }

  .parchment-safe {
    /* desktop: text moves right from the burned edge, bottom is irrelevant now */
    inset: 8.2% 12.4% 8.4% 15.9%;
  }

  .story-subtitle {
    margin: 0 0 12px;
    text-align: center;
    font-size: clamp(13px, .82vw, 16px);
    letter-spacing: .12em;
  }

  .story-title {
    margin: 0 0 18px;
    text-align: center;
    font-size: clamp(40px, 2.58vw, 58px);
    line-height: 1.03;
  }

  .story-text-wrap {
    padding-inline: 4px 8px;
  }

  .story-text {
    font-size: clamp(22px, 1.38vw, 28px);
    line-height: 1.52;
    text-align: left;
    overflow-wrap: anywhere;
    text-wrap: pretty;
  }

  .story-hint {
    display: none;
  }

  .page-corner {
    top: 7.2%;
    right: 7.8%;
    bottom: auto;
    width: clamp(74px, 7.2vw, 104px);
    height: clamp(74px, 7.2vw, 104px);
    transform: translateY(-8px) scale(.96);
  }

  .page-corner.visible {
    transform: translateY(0) scale(1);
  }

  .page-corner::before {
    clip-path: polygon(100% 0, 100% 100%, 0 0);
    border-radius: 0 18px 0 0;
    background:
      linear-gradient(45deg, transparent 0 43%, rgba(255, 232, 175, .94) 48%, rgba(169, 92, 37, .58) 100%),
      radial-gradient(circle at 76% 26%, rgba(255, 205, 112, .62), transparent 62%);
    box-shadow: inset -8px 8px 15px rgba(76, 33, 13, .16);
  }

  .page-corner::after {
    content: "›";
    right: 14px;
    top: 5px;
    bottom: auto;
    transform: rotate(-35deg);
    font-size: clamp(36px, 4.4vw, 58px);
  }

  .page-corner span {
    right: 4px;
    top: calc(100% - 6px);
    bottom: auto;
    min-width: 150px;
    text-align: right;
    color: rgba(255, 239, 210, .92);
    text-shadow: 0 2px 10px rgba(49, 20, 6, .7);
  }

  .story-back {
    top: 7.8%;
    left: 8.6%;
    bottom: auto;
    width: 52px;
    height: 52px;
    font-size: 34px;
  }
}

/* Fallback for browsers without :has(): JS is not required, but story-screen itself is fixed. */
@supports not selector(:has(*)) {
  @media (min-width: 900px) {
    .story-screen {
      position: fixed;
      inset: 0;
      width: 100vw;
      height: 100svh;
      overflow: hidden;
    }
  }
}

/* === PATCH: sticky parchment side tab === */
/* Desktop only: replace the triangular page corner with a side tab
   that visually grows from the parchment edge. */
@media (min-width: 900px) {
  .page-corner {
    top: 11.4%;
    right: -18px;
    bottom: auto !important;

    width: 98px;
    height: 138px;

    border: 0;
    padding: 0;
    background: transparent;
    color: #673816;

    z-index: 24;
    cursor: pointer;

    opacity: 0;
    pointer-events: none;
    transform: translateX(8px) scale(.98);
    transition: opacity .22s ease, transform .22s ease, filter .22s ease;
  }

  .page-corner.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0) scale(1);
    animation: none;
  }

  .page-corner::before {
    content: "";
    position: absolute;
    inset: 0;

    clip-path: polygon(
      24% 0%,
      100% 0%,
      100% 100%,
      24% 100%,
      0% 72%,
      0% 28%
    );

    border-radius: 0 18px 18px 0;

    background:
      radial-gradient(circle at 34% 18%, rgba(255,255,255,.48), transparent 28%),
      linear-gradient(180deg,
        #fff2bf 0%,
        #f4d88e 25%,
        #d59a4c 70%,
        #a66228 100%);

    box-shadow:
      0 12px 28px rgba(35, 12, 4, .30),
      0 0 18px rgba(255, 206, 116, .26),
      inset 0 2px 0 rgba(255,255,255,.36),
      inset 0 -10px 16px rgba(92, 42, 15, .27);

    filter: brightness(1);
    transition: transform .22s ease, filter .22s ease, box-shadow .22s ease;
  }

  .page-corner::after {
    content: "›";
    position: absolute;
    inset: 0;

    display: grid;
    place-items: center;

    color: #6d3a16;
    font-family: var(--font-ui);
    font-size: 54px;
    font-weight: 900;
    line-height: 1;
    text-shadow: 0 1px 0 rgba(255,255,255,.35);

    transform: translateX(9px);
    pointer-events: none;
    transition: transform .22s ease, filter .22s ease;
  }

  .page-corner span {
    position: absolute;
    left: 50%;
    top: 50%;
    right: auto;
    bottom: auto !important;

    width: 88px;
    min-width: 0;

    transform: translate(-42%, 30px);

    color: rgba(110, 56, 20, .92);
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: .06em;
    text-transform: uppercase;
    text-align: center;
    text-shadow: 0 1px 0 rgba(255,255,255,.32);

    opacity: .95;
    pointer-events: none;
  }

  .page-corner.visible::before {
    animation: stickyTabPulse 1.9s ease-in-out infinite;
  }

  .page-corner:hover {
    transform: translateX(-2px) scale(1.01);
  }

  .page-corner:hover::before {
    filter: brightness(1.07);
    box-shadow:
      0 14px 30px rgba(35, 12, 4, .34),
      0 0 24px rgba(255, 212, 120, .36),
      inset 0 2px 0 rgba(255,255,255,.42),
      inset 0 -10px 16px rgba(92, 42, 15, .24);
  }

  .page-corner:hover::after {
    transform: translateX(13px);
  }

  @keyframes stickyTabPulse {
    0%, 100% {
      filter: brightness(1);
    }
    50% {
      filter: brightness(1.08);
    }
  }
}

/* Keep the old compact corner behavior on mobile/tablets.
   The side tab is intentionally desktop-only. */
@media (max-width: 899px) {
  .page-corner {
    right: 7.4%;
    bottom: 5.7%;
    top: auto;
  }
}

/* === PATCH: sticky parchment tab on mobile too === */
/* The old mobile reset made the control triangular again.
   This block forces the same side-tab shape on phones, only repositioned. */

/* Hide visual text if the <span> is still present in older app.js builds. */
.page-corner span {
  display: none !important;
}

@media (max-width: 899px) {
  .page-corner {
    top: 50%;
    right: -10px;
    bottom: auto !important;

    width: clamp(58px, 15.5vw, 72px);
    height: clamp(84px, 23vw, 102px);

    border: 0;
    padding: 0;
    background: transparent;
    color: #673816;

    z-index: 24;
    cursor: pointer;

    opacity: 0;
    pointer-events: none;
    transform: translate(8px, -50%) scale(.98);
    transition: opacity .22s ease, transform .22s ease, filter .22s ease;
  }

  .page-corner.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translate(0, -50%) scale(1);
    animation: none;
  }

  .page-corner::before {
    content: "";
    position: absolute;
    inset: 0;

    clip-path: polygon(
      24% 0%,
      100% 0%,
      100% 100%,
      24% 100%,
      0% 72%,
      0% 28%
    );

    border-radius: 0 15px 15px 0;

    background:
      radial-gradient(circle at 34% 18%, rgba(255,255,255,.48), transparent 28%),
      linear-gradient(180deg,
        #fff2bf 0%,
        #f4d88e 25%,
        #d59a4c 70%,
        #a66228 100%);

    box-shadow:
      0 10px 22px rgba(35, 12, 4, .28),
      0 0 14px rgba(255, 206, 116, .24),
      inset 0 2px 0 rgba(255,255,255,.36),
      inset 0 -8px 14px rgba(92, 42, 15, .25);

    filter: brightness(1);
    transition: transform .22s ease, filter .22s ease, box-shadow .22s ease;
  }

  .page-corner::after {
    content: "›";
    position: absolute;
    inset: 0;

    display: grid;
    place-items: center;

    color: #6d3a16;
    font-family: var(--font-ui);
    font-size: clamp(36px, 11vw, 48px);
    font-weight: 900;
    line-height: 1;
    text-shadow: 0 1px 0 rgba(255,255,255,.35);

    transform: translateX(6px);
    pointer-events: none;
  }

  .page-corner.visible::before {
    animation: stickyTabPulseMobile 1.9s ease-in-out infinite;
  }

  @keyframes stickyTabPulseMobile {
    0%, 100% {
      filter: brightness(1);
    }
    50% {
      filter: brightness(1.08);
    }
  }
}

/* Very narrow phones: keep the tab inside the viewport a bit more. */
@media (max-width: 420px) {
  .page-corner {
    top: 51%;
    right: -7px;
    width: clamp(54px, 15vw, 64px);
    height: clamp(78px, 22vw, 92px);
  }
}

/* === Desktop performance patch === */
@media (min-width: 1221px) {
  .hub-header,
  .panel,
  .dialogue-backdrop {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .frame-card {
    filter: none;
    box-shadow: var(--shadow-soft);
  }

  .sky-bg::after {
    animation: none;
    opacity: .24;
  }

  .bg-layer,
  .story-desk {
    transform: none;
  }

  .btn::after {
    display: none;
  }

  .portal-core,
  .reward-burst .particle {
    animation-duration: 3.5s;
  }

  .panel,
  .frame-card,
  .task-card,
  .info-card {
    contain: layout paint;
  }
}
/* Soft event rule note */
.voluntary-note {
  width: min(620px, 100%);
  margin: 16px auto 0;
  padding: 14px 16px;
  border-radius: 18px;
  text-align: left;
  background: linear-gradient(180deg, rgba(255, 226, 154, .10), rgba(122, 224, 255, .055));
  border: 1px solid rgba(255, 226, 154, .18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.voluntary-note strong {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--gold-strong);
  font-size: 13px;
  letter-spacing: .04em;
}
.voluntary-note .icon {
  width: 18px;
  height: 18px;
}
.voluntary-note p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.55;
}
