:root {
  --bg: #050711;
  --panel: rgba(10, 14, 27, 0.93);
  --panel-soft: rgba(255,255,255,.04);
  --line: rgba(255,255,255,.12);
  --text: #f6f8ff;
  --muted: #9faac5;
  --blue: #6bd8ff;
  --violet: #a767ff;
  --gold: #ebc968;
  --green: #67eba9;
  --red: #ff7997;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body.story-page {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif;
  background:
    radial-gradient(circle at 13% 10%, rgba(38,170,255,.18), transparent 28%),
    radial-gradient(circle at 84% 8%, rgba(145,72,255,.22), transparent 31%),
    radial-gradient(circle at 50% 88%, rgba(235,201,104,.08), transparent 34%),
    var(--bg);
}

.story-page [hidden] { display: none !important; }
button, input, a { font: inherit; }

.story-header {
  position: sticky;
  top: 0;
  z-index: 70;
  min-height: 72px;
  padding: 10px 28px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 22px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(3,6,14,.92);
  backdrop-filter: blur(18px);
}

.story-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: white;
  text-decoration: none;
  letter-spacing: .17em;
}
.story-brand span { color: var(--blue); }

.story-header nav {
  display: flex;
  justify-content: center;
  gap: 7px;
}
.story-header nav a {
  padding: 9px 13px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
}
.story-header nav a:hover,
.story-header nav a.active {
  color: white;
  background: rgba(255,255,255,.07);
}

.story-wallet {
  display: flex;
  gap: 8px;
}
.story-wallet span {
  min-width: 96px;
  padding: 8px 11px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255,255,255,.035);
  font-size: .7rem;
}
.story-wallet b { color: var(--gold); }

.story-shell {
  width: min(1580px, calc(100% - 24px));
  margin: 0 auto;
  padding: 30px 0 58px;
}

.chapter-hero {
  min-height: 400px;
  padding: 38px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, .7fr);
  gap: 30px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 31px;
  background:
    linear-gradient(125deg, rgba(255,255,255,.06), transparent 40%),
    radial-gradient(circle at 75% 45%, rgba(167,103,255,.22), transparent 38%),
    rgba(7,11,22,.88);
  box-shadow: 0 28px 82px rgba(0,0,0,.36);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: .72rem;
  font-weight: 1000;
  letter-spacing: .17em;
}

.chapter-copy h1 {
  margin: 0;
  font-size: clamp(3.2rem, 7vw, 7.2rem);
  line-height: .9;
  letter-spacing: -.05em;
}
.chapter-copy h1 span {
  display: block;
  color: transparent;
  background: linear-gradient(120deg, #f9d98a, #ff77d8, #72dcff);
  background-clip: text;
  -webkit-background-clip: text;
}
.chapter-copy > p:not(.eyebrow) {
  max-width: 770px;
  margin: 24px 0;
  color: #c8d2e7;
  line-height: 1.9;
}

.chapter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.primary-action,
.secondary-action {
  min-height: 50px;
  padding: 11px 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 14px;
  text-decoration: none;
  cursor: pointer;
}
.primary-action {
  border: 0;
  color: #130f07;
  font-weight: 1000;
  background: linear-gradient(135deg, #fff0ac, #e5b84d 58%, #b6761c);
}
.secondary-action {
  border: 1px solid var(--line);
  color: white;
  background: rgba(255,255,255,.05);
}

.chapter-progress-card {
  min-height: 220px;
  padding: 28px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 23px;
  border: 1px solid rgba(107,216,255,.24);
  border-radius: 25px;
  background:
    radial-gradient(circle at 35% 40%, rgba(107,216,255,.12), transparent 35%),
    rgba(255,255,255,.035);
}
.progress-ring {
  width: 126px;
  height: 126px;
  display: grid;
  place-content: center;
  text-align: center;
  border-radius: 50%;
  background:
    radial-gradient(circle, #0a0f1d 58%, transparent 60%),
    conic-gradient(var(--green) var(--progress, 0%), rgba(255,255,255,.08) 0);
  box-shadow: 0 0 36px rgba(103,235,169,.12);
}
.progress-ring strong { font-size: 2.1rem; }
.progress-ring span { color: var(--muted); }
.chapter-progress-card p { margin: 0; color: var(--muted); }
.chapter-progress-card > div:last-child > strong {
  display: block;
  margin: 6px 0;
  font-size: 1.2rem;
}
.chapter-progress-card small { color: var(--blue); }

.fair-play-note {
  margin-top: 14px;
  padding: 15px 18px;
  display: flex;
  align-items: center;
  gap: 18px;
  border: 1px solid rgba(103,235,169,.25);
  border-radius: 18px;
  background: rgba(103,235,169,.065);
}
.fair-play-note strong {
  flex: 0 0 auto;
  color: var(--green);
}
.fair-play-note p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.story-map-panel {
  margin-top: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: 0 24px 74px rgba(0,0,0,.28);
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}
.section-head h2 { margin: 0; font-size: 1.55rem; }
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: .68rem;
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.open-dot { background: var(--blue); }
.clear-dot { background: var(--green); }
.lock-dot { background: #5d6375; }

.story-path {
  position: relative;
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}
.story-path::before {
  content: "";
  position: absolute;
  top: 103px;
  left: 7%;
  right: 7%;
  height: 2px;
  background: linear-gradient(90deg, rgba(103,235,169,.45), rgba(107,216,255,.42), rgba(167,103,255,.45));
}

.stage-card {
  position: relative;
  z-index: 1;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #090d18;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.stage-card:not(.locked):hover {
  transform: translateY(-5px);
  border-color: rgba(107,216,255,.45);
  box-shadow: 0 18px 38px rgba(0,0,0,.32);
}
.stage-card.cleared {
  border-color: rgba(103,235,169,.45);
}
.stage-card.locked {
  opacity: .52;
  filter: saturate(.35);
}
.stage-card.locked::after {
  content: "🔒";
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  font-size: 2.3rem;
  background: rgba(2,5,11,.38);
}
.stage-card button {
  width: 100%;
  padding: 0;
  border: 0;
  color: inherit;
  text-align: right;
  background: transparent;
  cursor: pointer;
}
.stage-card.locked button { cursor: not-allowed; }

.stage-art {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 40%, rgba(107,216,255,.14), transparent 34%),
    #11172a;
}
.stage-art img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.stage-art::after {
  content: "";
  position: absolute;
  inset: 45% 0 0;
  background: linear-gradient(transparent, rgba(5,7,17,.94));
}
.stage-number,
.stage-status {
  position: absolute;
  z-index: 3;
  top: 9px;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: .57rem;
  font-weight: 1000;
  backdrop-filter: blur(8px);
}
.stage-number { right: 9px; background: rgba(4,7,14,.82); }
.stage-status { left: 9px; background: rgba(107,216,255,.82); color: #031018; }
.stage-card.cleared .stage-status { background: var(--green); color: #04150e; }
.stage-card.locked .stage-status { background: #6a7080; color: white; }

.stage-copy { padding: 14px; }
.stage-copy h3 {
  margin: 0;
  font-size: .96rem;
}
.stage-copy > p {
  min-height: 38px;
  margin: 6px 0 12px;
  color: var(--muted);
  font-size: .67rem;
  line-height: 1.5;
}
.stage-meta {
  display: grid;
  gap: 6px;
}
.stage-meta span {
  padding: 7px 8px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: .58rem;
  background: rgba(255,255,255,.03);
}
.stage-meta b { color: #dfe8ff; }

.stage-dialog {
  width: min(940px, calc(100% - 24px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 26px;
  color: white;
  background: #080c17;
  box-shadow: 0 38px 110px rgba(0,0,0,.72);
}
.stage-dialog::backdrop {
  background: rgba(1,3,9,.84);
  backdrop-filter: blur(16px);
}
.stage-dialog[open] {
  display: grid;
  grid-template-columns: minmax(300px,.9fr) minmax(0,1.1fr);
}
.dialog-close {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 5;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: white;
  background: rgba(3,6,13,.72);
  cursor: pointer;
}
.stage-dialog-art {
  min-height: 590px;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 7rem;
  background: #101629;
}
.stage-dialog-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.stage-dialog-copy {
  padding: 36px;
  align-self: center;
}
.stage-dialog-copy h2 {
  margin: 0;
  font-size: 2rem;
}
.stage-dialog-copy h3 {
  margin: 8px 0 17px;
  color: var(--gold);
  font-size: 1rem;
}
.stage-dialog-copy > p:not(.eyebrow) {
  color: #cbd4e8;
  line-height: 1.75;
}
.stage-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 15px 0;
}
.stage-tags span {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #dce7ff;
  font-size: .65rem;
  background: rgba(255,255,255,.04);
}

.strategy-box,
.reward-box {
  margin-top: 13px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.035);
}
.strategy-box span,
.reward-box span {
  color: var(--blue);
  font-size: .62rem;
  font-weight: 1000;
}
.strategy-box p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: .75rem;
}
.reward-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.reward-box strong {
  display: block;
  margin-top: 5px;
  color: var(--gold);
  font-size: .78rem;
}
.stage-record {
  margin-top: 13px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: .7rem;
}
.stage-record b { color: white; }

.stage-dialog-actions {
  margin-top: 17px;
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 9px;
}
.stage-dialog-actions a,
.stage-dialog-actions button {
  min-height: 48px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  text-decoration: none;
  cursor: pointer;
}
.stage-dialog-actions a {
  border: 1px solid var(--line);
  color: white;
  background: rgba(255,255,255,.05);
}
.stage-dialog-actions button {
  border: 0;
  color: #130e05;
  font-weight: 1000;
  background: linear-gradient(135deg, #fff0ad, #e5b84e 58%, #b5761c);
}
.stage-dialog-actions button:disabled {
  opacity: .38;
  cursor: not-allowed;
}

.story-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  min-width: 280px;
  max-width: 430px;
  padding: 14px 16px;
  display: grid;
  gap: 4px;
  border: 1px solid rgba(107,216,255,.3);
  border-radius: 14px;
  background: rgba(7,12,24,.95);
  box-shadow: 0 20px 55px rgba(0,0,0,.46);
  backdrop-filter: blur(14px);
}
.story-toast strong { color: var(--blue); }
.story-toast span { color: #cbd4e8; font-size: .74rem; }

@media (max-width: 1180px) {
  .story-header { grid-template-columns: 1fr; }
  .story-header nav,
  .story-wallet { justify-content: center; flex-wrap: wrap; }
  .chapter-hero { grid-template-columns: 1fr; }
  .story-path { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .story-path::before { display: none; }
}

@media (max-width: 720px) {
  .story-shell { width: min(100% - 14px, 1580px); }
  .story-header { padding: 10px; }
  .chapter-hero { padding: 24px 18px; }
  .fair-play-note,
  .section-head { align-items: flex-start; flex-direction: column; }
  .story-path { grid-template-columns: 1fr; }
  .stage-dialog[open] { grid-template-columns: 1fr; }
  .stage-dialog-art { min-height: 280px; max-height: 360px; }
  .stage-dialog-copy { padding: 24px 18px; }
}


/* TAVORYN_STORY_MODE_CHAPTER2_V1 */
.chapter-selector-panel {
  margin-bottom: 14px; padding: 18px 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px;
  border: 1px solid var(--line); border-radius: 22px; background: rgba(7,11,22,.88);
}
.chapter-selector-panel h2 { margin: 0; font-size: 1.35rem; }
.chapter-selector { display: flex; flex-wrap: wrap; gap: 9px; }
.chapter-tab {
  min-width: 190px; padding: 11px 14px; display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center;
  border: 1px solid var(--line); border-radius: 15px; color: var(--text); background: rgba(255,255,255,.035); cursor: pointer; text-align: right;
}
.chapter-tab:hover, .chapter-tab.active { border-color: rgba(107,216,255,.48); background: rgba(107,216,255,.09); }
.chapter-tab.locked { opacity: .55; }
.chapter-tab > b { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: #07101a; background: linear-gradient(135deg,#8de9ff,#806cff); }
.chapter-tab strong { display: block; }
.chapter-tab small { display: block; margin-top: 3px; color: var(--muted); }
.chapter-tab em { color: var(--green); font-style: normal; font-size: .72rem; }
.chapter-line-one { display: block; padding-bottom: 30px; color: var(--text) !important; background: none !important; -webkit-text-fill-color: initial; }
.chapter-lock-note { margin-top: 14px; padding: 15px 18px; border: 1px solid rgba(255,121,151,.28); border-radius: 18px; background: rgba(255,121,151,.07); }
.chapter-lock-note strong { color: var(--red); }.chapter-lock-note p { margin: 5px 0 0; color: var(--muted); }
.dialogue-box { padding: 14px 16px; border: 1px solid rgba(167,103,255,.28); border-radius: 16px; background: linear-gradient(135deg,rgba(167,103,255,.11),rgba(107,216,255,.045)); }
.dialogue-box span { color: #c69bff; font-size: .7rem; font-weight: 1000; letter-spacing: .1em; }.dialogue-box p { margin: 7px 0 0; line-height: 1.75; }.dialogue-box small { display: block; margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line); color: var(--green); line-height: 1.7; }
body.story-page[data-theme="abyss"] { background: radial-gradient(circle at 18% 8%,rgba(0,223,255,.15),transparent 28%),radial-gradient(circle at 82% 12%,rgba(109,42,255,.27),transparent 33%),radial-gradient(circle at 50% 92%,rgba(29,255,210,.09),transparent 34%),#02040c; }
body[data-theme="abyss"] .chapter-hero { border-color: rgba(106,104,255,.28); background: linear-gradient(125deg,rgba(255,255,255,.05),transparent 40%),radial-gradient(circle at 78% 40%,rgba(74,41,255,.3),transparent 38%),radial-gradient(circle at 28% 90%,rgba(0,224,210,.12),transparent 32%),rgba(3,7,18,.93); }
body[data-theme="abyss"] .chapter-copy h1 span:last-child { background: linear-gradient(120deg,#8ffaff,#8674ff,#df5bff); background-clip:text; -webkit-background-clip:text; }
body[data-theme="abyss"] .progress-ring { box-shadow: 0 0 42px rgba(92,93,255,.2); }
@media (max-width: 760px) { .chapter-selector-panel { align-items: stretch; flex-direction: column; }.chapter-selector { display: grid; }.chapter-tab { min-width: 0; }.chapter-tab { grid-template-columns: 38px 1fr auto; } }
