:root {
  --bg: #08261c;
  --bg-2: #0d3a29;
  --chrome: rgba(247, 250, 244, 0.94);
  --chrome-strong: #ffffff;
  --ink: #17231d;
  --muted: #68766f;
  --paper: #fffdf6;
  --paper-edge: #e7dcc5;
  --line: rgba(17, 34, 28, 0.14);
  --gold: #c99a35;
  --gold-2: #f0d27c;
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.34);
  --radius: 8px;
  --zoom: 1;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 10%, rgba(240, 210, 124, 0.2), transparent 28rem),
    linear-gradient(135deg, var(--bg), #061610 58%, #0a2019);
}

button,
input { font: inherit; }

.reader {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}

.topbar {
  position: fixed;
  z-index: 30;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px clamp(14px, 3vw, 28px);
  color: #f9f7eb;
  background: rgba(6, 20, 15, 0.72);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.brand p {
  margin: 2px 0 0;
  color: rgba(249, 247, 235, 0.7);
  font-size: 0.78rem;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 46%, rgba(255,255,255,0.65) 48% 52%, transparent 54%),
    radial-gradient(circle at center, transparent 42%, rgba(255,255,255,0.65) 43% 47%, transparent 48%),
    linear-gradient(145deg, var(--gold-2), var(--gold));
  box-shadow: inset 0 -5px 10px rgba(76, 48, 4, 0.22);
}

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.text-button,
.round-button {
  border: 0;
  cursor: pointer;
  color: inherit;
  background: rgba(255, 255, 255, 0.12);
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

.icon-button:hover,
.text-button:hover,
.round-button:hover { background: rgba(255, 255, 255, 0.22); }

.icon-button:active,
.text-button:active,
.round-button:active { transform: translateY(1px); }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-weight: 800;
}

#menuButton {
  display: none;
  gap: 4px;
}

#menuButton span {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
}

.text-button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 800;
}

.bookmark-action[aria-pressed="true"] {
  color: #092b1f;
  background: var(--gold-2);
}

.drawer {
  position: fixed;
  z-index: 25;
  top: 64px;
  bottom: 0;
  left: 0;
  width: 310px;
  padding: 20px;
  overflow: auto;
  color: #1c2c24;
  background: var(--chrome);
  border-right: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 18px 0 45px rgba(0, 0, 0, 0.16);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.drawer-head strong {
  font-size: 1.15rem;
}

#closeDrawer { display: none; color: #1c2c24; background: rgba(9, 43, 31, 0.08); }

.search {
  display: grid;
  gap: 7px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.search input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.search input:focus { border-color: var(--gold); }

.toc {
  display: grid;
  gap: 6px;
}

.toc button,
.bookmark-list button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  color: #1d2b24;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.toc button:hover,
.toc button.active,
.bookmark-list button:hover { background: rgba(9, 43, 31, 0.08); }

.toc span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.toc span:last-child {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.75rem;
}

.drawer-foot {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.bookmark-list {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.stage {
  grid-column: 2;
  height: 100vh;
  height: 100svh;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  padding: 78px clamp(14px, 4vw, 42px) 14px;
  overflow: hidden;
}

.book-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
}

.book-shadow {
  position: absolute;
  width: min(980px, 86vw);
  height: 42px;
  bottom: 7%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.38);
  filter: blur(20px);
}

.book {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(980px, 86vw);
  height: min(790px, calc(100svh - 92px));
  min-height: 0;
  max-height: calc(100svh - 92px);
  transform: scale(var(--zoom));
  transform-origin: center;
  perspective: 1800px;
  filter: drop-shadow(var(--shadow));
  touch-action: pan-y;
  user-select: none;
}

.page,
.flip-sheet {
  position: relative;
  overflow: hidden;
  padding: clamp(18px, 2.6vw, 34px);
  background:
    linear-gradient(90deg, rgba(0,0,0,0.06), transparent 4%, transparent 94%, rgba(0,0,0,0.045)),
    repeating-linear-gradient(0deg, rgba(0,0,0,0.018), rgba(0,0,0,0.018) 1px, transparent 1px, transparent 9px),
    var(--paper);
  border: 1px solid var(--paper-edge);
}

.page-left {
  border-radius: var(--radius) 0 0 var(--radius);
  box-shadow: inset -22px 0 30px rgba(50, 38, 19, 0.12);
}

.page-right {
  border-radius: 0 var(--radius) var(--radius) 0;
  box-shadow: inset 22px 0 30px rgba(50, 38, 19, 0.1);
}

.page::after {
  content: "";
  position: absolute;
  inset: 16px;
  border: 1px solid rgba(49, 38, 21, 0.08);
  pointer-events: none;
}

.flip-sheet {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50%;
  transform-origin: left center;
  opacity: 0;
  pointer-events: none;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.book.flipping-next .flip-sheet {
  opacity: 1;
  animation: flipNext 520ms ease-in-out;
}

.book.flipping-prev .flip-sheet {
  right: 50%;
  transform-origin: right center;
  border-radius: var(--radius) 0 0 var(--radius);
  opacity: 1;
  animation: flipPrev 520ms ease-in-out;
}

@keyframes flipNext {
  0% { transform: rotateY(0); box-shadow: -8px 0 20px rgba(0,0,0,0.08); }
  100% { transform: rotateY(-174deg); box-shadow: -32px 0 38px rgba(0,0,0,0.22); }
}

@keyframes flipPrev {
  0% { transform: rotateY(0); box-shadow: 8px 0 20px rgba(0,0,0,0.08); }
  100% { transform: rotateY(174deg); box-shadow: 32px 0 38px rgba(0,0,0,0.22); }
}

.cover {
  position: relative;
  height: 100%;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.42), transparent 11%, transparent 92%, rgba(0, 0, 0, 0.18)),
    image-set(url("assets/fifa-cover.png") type("image/png")),
    linear-gradient(145deg, #0d3929, #061611);
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16), inset 0 -80px 120px rgba(0,0,0,0.38);
}

.cover-copy {
  position: absolute;
  inset: auto 18px 18px;
  padding: 10px 12px;
  color: #fff8df;
  background: rgba(4, 18, 13, 0.74);
  border: 1px solid rgba(240, 210, 124, 0.42);
  border-radius: 6px;
  backdrop-filter: blur(8px);
}

.cover-copy h2 {
  margin: 0;
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: clamp(1.2rem, 2.5vw, 1.7rem);
  line-height: 1.05;
}

.cover-copy p {
  margin: 4px 0 0;
  color: var(--gold-2);
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 800;
}

.chapter {
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.page h2 {
  margin: 8px 0 12px;
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: clamp(1.35rem, 2.5vw, 2.15rem);
  line-height: 1.08;
}

.page p,
.page li {
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: clamp(0.74rem, 1vw, 0.92rem);
  line-height: 1.46;
  margin: 0 0 0.58em;
}

.page ul {
  margin: 10px 0 0;
  padding-left: 18px;
}

.story-image {
  margin: 8px 0 10px;
}

.story-image img {
  display: block;
  width: 100%;
  max-height: clamp(96px, 16vh, 140px);
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgba(49, 38, 21, 0.14);
  box-shadow: 0 10px 24px rgba(40, 28, 12, 0.12);
}

.story-image figcaption {
  margin-top: 5px;
  color: rgba(28, 35, 30, 0.66);
  font-family: Inter, system-ui, sans-serif;
  font-size: clamp(0.6rem, 0.78vw, 0.7rem);
  font-weight: 700;
  line-height: 1.32;
}

body.font-large .page p,
body.font-large .page li {
  font-size: clamp(0.82rem, 1.1vw, 0.98rem);
  line-height: 1.42;
}

body.font-large .page h2 {
  font-size: clamp(1.48rem, 2.7vw, 2.28rem);
}

body.font-larger .page p,
body.font-larger .page li {
  font-size: clamp(0.92rem, 1.24vw, 1.08rem);
  line-height: 1.4;
}

body.font-larger .page h2 {
  font-size: clamp(1.62rem, 2.9vw, 2.45rem);
}

.page-number {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18px;
  color: rgba(28, 35, 30, 0.52);
  font-family: Inter, sans-serif;
  font-size: 0.76rem;
  font-weight: 800;
  text-align: center;
}

.ornament {
  width: 84px;
  height: 3px;
  margin: 12px 0;
  background: linear-gradient(90deg, var(--gold), transparent);
}

.stat-card {
  margin-top: 8px;
  padding: 9px 10px;
  border-left: 4px solid var(--gold);
  background: rgba(201, 154, 53, 0.08);
  font-family: Inter, sans-serif;
  font-size: clamp(0.66rem, 0.86vw, 0.78rem);
  line-height: 1.32;
}

body.night {
  --paper: #17211c;
  --paper-edge: #334238;
  --ink: #eceddf;
  --muted: #aab7ae;
  --line: rgba(236, 237, 223, 0.16);
}

body.night .page,
body.night .flip-sheet {
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(255,255,255,0.035), transparent 4%, transparent 94%, rgba(255,255,255,0.03)),
    #17211c;
}

body.night .page::after { border-color: rgba(255,255,255,0.08); }
body.night .stat-card { background: rgba(201, 154, 53, 0.13); }
body.night .page-number { color: rgba(236, 237, 223, 0.52); }

@media (max-width: 980px) {
  .reader { grid-template-columns: 1fr; }
  #menuButton { display: inline-grid; }
  .drawer {
    transform: translateX(-105%);
    transition: transform 220ms ease;
  }
  .drawer.open { transform: translateX(0); }
  #closeDrawer { display: inline-grid; }
  .stage {
    grid-column: 1;
    padding: 76px 12px 10px;
  }
  .book {
    width: min(92vw, 540px);
    height: min(720px, calc(100svh - 86px));
    max-height: calc(100svh - 86px);
    grid-template-columns: 1fr;
  }
  .page-left { display: none; }
  .page-right {
    border-radius: var(--radius);
    box-shadow: inset 16px 0 28px rgba(50, 38, 19, 0.09);
  }
  .flip-sheet { width: 100%; }
}

@media (max-width: 560px) {
  .topbar { height: 58px; gap: 7px; padding: 10px 8px; }
  .brand p { display: none; }
  .brand { gap: 7px; }
  .brand h1 { font-size: 0.84rem; }
  .brand-mark { width: 28px; height: 28px; }
  .top-actions { gap: 4px; }
  .bookmark-action,
  .font-action {
    display: inline-grid;
    place-items: center;
    min-width: 40px;
    min-height: 36px;
    padding: 0 8px;
    font-size: 0.74rem;
  }
  .bookmark-action { min-width: 48px; }
  .icon-button { width: 34px; height: 36px; }
  .drawer { top: 58px; width: min(86vw, 320px); }
  .stage { padding: 68px 10px 8px; }
  .book {
    width: min(94vw, 430px);
    min-height: 0;
    height: min(740px, calc(100svh - 76px));
    max-height: calc(100svh - 76px);
  }
  .page { padding: 18px 18px 34px; }
  .page p,
  .page li {
    font-size: clamp(0.72rem, 3.15vw, 0.86rem);
    line-height: 1.42;
  }
  .page h2 {
    font-size: clamp(1.22rem, 6vw, 1.58rem);
    margin-bottom: 8px;
  }
  .chapter { font-size: 0.68rem; }
  .ornament { margin: 9px 0; }
  .stat-card { font-size: 0.68rem; padding: 9px 10px; }
  .story-image {
    margin: 8px 0 9px;
  }
  .story-image img {
    max-height: 118px;
  }
  .story-image figcaption {
    font-size: 0.64rem;
    line-height: 1.25;
  }
  body.font-large .page p,
  body.font-large .page li {
    font-size: clamp(0.8rem, 3.45vw, 0.92rem);
    line-height: 1.38;
  }
  body.font-larger .page p,
  body.font-larger .page li {
    font-size: clamp(0.88rem, 3.75vw, 1rem);
    line-height: 1.34;
  }
}
