/* styles.css */
:root {
  --bg: #05030c;
  --bg-deep: #030208;
  --panel: rgba(18, 12, 32, 0.66);
  --panel-strong: rgba(22, 14, 38, 0.92);
  --cyan: #38e8f0;
  --cyan-bright: #8ff7ff;
  --magenta: #ef4ed8;
  --magenta-bright: #ff8cf0;
  --purple: #8b5cf6;
  --line-cyan: rgba(56, 232, 240, 0.32);
  --line-magenta: rgba(239, 78, 216, 0.32);
  --text: #f1eefb;
  --muted: rgba(225, 220, 245, 0.56);
  --muted-strong: rgba(225, 220, 245, 0.80);
  --shadow: rgba(0, 0, 0, 0.80);
  --zoom: 1;
  --reader-width: min(94vw, 1240px);
  --radius-page: 16px;
  --transition-fast: 0.18s ease;
  --transition-med: 0.32s ease;
  --mono: 'JetBrains Mono', 'Consolas', ui-monospace, monospace;
  --display: 'Orbitron', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(ellipse at 75% 90%, rgba(239, 78, 216, 0.10) 0%, transparent 40%),
    radial-gradient(ellipse at 10% 10%, rgba(56, 232, 240, 0.08) 0%, transparent 38%),
    radial-gradient(ellipse at 50% 50%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
    linear-gradient(160deg, #030208 0%, #0a0518 50%, #030208 100%);
  font-family: var(--mono);
}

button, input { font: inherit; }
button { cursor: pointer; border: none; background: none; color: inherit; }

/* ── AMBIENT LAYERS ── */
#starfield, .spotlight, .scanlines, .grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
}
#starfield { z-index: 0; opacity: 0.45; }
.spotlight {
  z-index: 1;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 24%), rgba(56, 232, 240, 0.08) 0%, transparent 28rem);
  mix-blend-mode: screen;
  transition: background 0.05s linear;
}
.scanlines {
  z-index: 2;
  opacity: 0.04;
  background-image: repeating-linear-gradient(0deg, transparent 0 2px, rgba(255,255,255,.6) 2px 3px);
}
.grain {
  z-index: 2;
  opacity: 0.04;
  background-image: repeating-radial-gradient(circle at 17% 29%, rgba(255,255,255,.3) 0 1px, transparent 1px 4px);
}

/* ── LOADING SCREEN ── */
.loading {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(3, 2, 8, 0.96);
  backdrop-filter: blur(18px);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
.loading.done { opacity: 0; visibility: hidden; pointer-events: none; }

.loading-card {
  width: min(90vw, 460px);
  padding: 40px 36px 34px;
  border: 1px solid var(--line-cyan);
  border-radius: 18px;
  background: linear-gradient(155deg, rgba(20, 14, 36, 0.97) 0%, rgba(6, 4, 14, 0.97) 100%);
  box-shadow:
    0 32px 100px rgba(0, 0, 0, 0.80),
    0 0 60px rgba(56, 232, 240, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  text-align: center;
}

.loading-mark {
  display: inline-grid; place-items: center;
  width: 80px; height: 80px; margin-bottom: 22px;
  border: 2px solid var(--cyan);
  border-radius: 4px;
  color: var(--cyan-bright);
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  text-shadow: 0 0 24px rgba(143, 247, 255, 0.6);
  box-shadow: 0 0 32px rgba(56, 232, 240, 0.18), inset 0 0 20px rgba(56, 232, 240, 0.06);
  animation: markPulse 2.4s ease-in-out infinite;
}
@keyframes markPulse {
  0%, 100% { box-shadow: 0 0 32px rgba(56,232,240,.16), inset 0 0 20px rgba(56,232,240,.05); }
  50% { box-shadow: 0 0 48px rgba(239,78,216,.26), inset 0 0 28px rgba(239,78,216,.10); }
}

.loading-title { margin-bottom: 24px; font-size: 0.82rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }

.loading-bar { height: 5px; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, 0.06); }
.loading-bar span {
  display: block; width: 0%; height: 100%;
  background: linear-gradient(90deg, var(--purple), var(--cyan), var(--magenta-bright));
  box-shadow: 0 0 24px rgba(143, 247, 255, 0.5);
  border-radius: 999px;
  transition: width 0.38s ease;
}
.loading-text { margin-top: 14px; color: var(--muted); font-size: 0.74rem; }

/* ── MASTHEAD ── */
.masthead {
  position: sticky; top: 0; z-index: 30;
  display: flex; justify-content: space-between; align-items: center; gap: 18px;
  padding: 16px clamp(16px, 3vw, 42px);
  border-bottom: 1px solid var(--line-cyan);
  background: linear-gradient(180deg, rgba(3, 2, 8, 0.92) 0%, rgba(3, 2, 8, 0.50) 100%);
  backdrop-filter: blur(24px) saturate(150%);
}

.brand { display: flex; align-items: center; gap: 14px; text-align: left; transition: opacity var(--transition-fast); }
.brand:hover { opacity: 0.86; }

.brand-logo {
  display: inline-grid; place-items: center;
  width: 46px; height: 50px;
  border: 2px solid var(--cyan);
  border-radius: 4px;
  color: var(--cyan-bright);
  font-family: var(--display);
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: 0 0 28px rgba(56, 232, 240, 0.16), inset 0 0 24px rgba(56, 232, 240, 0.06);
  flex-shrink: 0;
}

.brand strong {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(0.82rem, 1.7vw, 1.05rem);
  letter-spacing: 0.03em;
  line-height: 1.15;
  text-transform: uppercase;
}
.brand em { display: block; margin-top: 3px; color: var(--magenta-bright); font-style: normal; font-size: 0.66rem; letter-spacing: 0.10em; text-transform: uppercase; }

/* ── TOP NAV BUTTONS ── */
.top-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.top-actions button {
  border: 1px solid var(--line-cyan);
  color: var(--text);
  background: linear-gradient(180deg, rgba(24, 18, 40, 0.80) 0%, rgba(8, 6, 16, 0.80) 100%);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 0.72rem;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 8px 24px rgba(0, 0, 0, 0.30);
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.top-actions button:hover {
  transform: translateY(-1px);
  border-color: rgba(143, 247, 255, 0.6);
  box-shadow: 0 0 24px rgba(56, 232, 240, 0.20), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.top-actions button:active { transform: translateY(0); }

/* ── LAYOUT GRID ── */
.masthead, .layout, .footer-note { position: relative; z-index: 5; }

.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: clamp(16px, 2.5vw, 32px);
  max-width: 1680px;
  margin: 0 auto;
  padding: 28px clamp(14px, 3vw, 42px) 16px;
}

/* ── THUMBNAIL PANEL ── */
.thumb-panel {
  align-self: start;
  position: sticky; top: 96px;
  padding: 16px 12px;
  border: 1px solid var(--line-cyan);
  border-radius: 18px;
  background: linear-gradient(170deg, rgba(18, 12, 32, 0.70) 0%, rgba(5, 3, 10, 0.50) 100%);
  backdrop-filter: blur(18px);
  box-shadow: 0 20px 64px rgba(0, 0, 0, 0.40);
}
.panel-title { margin-bottom: 12px; padding: 0 4px; color: var(--cyan-bright); font-size: 0.60rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; }
.thumb-rail { display: grid; gap: 7px; }
.thumb {
  display: grid; grid-template-columns: 16px 1fr; gap: 9px; align-items: center;
  width: 100%; padding: 9px 11px;
  color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.015);
  text-align: left;
  transition: transform var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}
.thumb:hover { transform: translateX(2px); border-color: rgba(56, 232, 240, 0.32); background: rgba(56, 232, 240, 0.04); }
.thumb.active {
  transform: translateX(4px);
  border-color: rgba(239, 78, 216, 0.55);
  background: rgba(239, 78, 216, 0.07);
  box-shadow: 0 0 18px rgba(239, 78, 216, 0.10);
}
.thumb .num { font-size: 0.60rem; font-weight: 800; color: var(--cyan-bright); }
.thumb .name { display: block; font-size: 0.72rem; line-height: 1.25; color: var(--muted-strong); }
.thumb.active .name { color: var(--text); }

/* ── READER AREA ── */
.reader { min-width: 0; padding-bottom: 36px; }
.reader-topline {
  display: flex; justify-content: space-between; gap: 18px; align-items: flex-end;
  margin: 0 auto 20px; max-width: calc(var(--reader-width) + 112px);
}
.eyebrow { color: var(--magenta-bright); font-size: 0.62rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; margin-bottom: 6px; }
h1 {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.3rem, 3vw, 2.5rem);
  line-height: 1.05;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.reader-topline p { color: var(--muted); font-size: 0.82rem; line-height: 1.5; }
.page-count { flex: 0 0 auto; display: flex; align-items: baseline; gap: 6px; font-weight: 800; }
.page-count #pageNow { font-size: 1.9rem; color: var(--cyan-bright); line-height: 1; text-shadow: 0 0 24px rgba(143, 247, 255, 0.24); font-family: var(--display); }
.page-count span:not(#pageNow) { color: rgba(255, 255, 255, 0.22); }

/* ── BOOK SHELL ── */
.book-shell { position: relative; display: grid; grid-template-columns: 56px minmax(0, 1fr) 56px; align-items: start; gap: 16px; }

.book-viewport {
  max-height: calc(100vh - 220px);
  min-height: 600px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line-cyan);
  border-radius: 20px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(239, 78, 216, 0.04) 0%, transparent 34rem),
    rgba(5, 3, 10, 0.50);
  box-shadow:
    0 36px 100px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(12px);
  scrollbar-width: thin;
  scrollbar-color: rgba(56, 232, 240, 0.32) rgba(255, 255, 255, 0.02);
}
.book-viewport::-webkit-scrollbar { width: 6px; }
.book-viewport::-webkit-scrollbar-track { background: rgba(255,255,255,.02); border-radius: 999px; }
.book-viewport::-webkit-scrollbar-thumb { background: rgba(56,232,240,.30); border-radius: 999px; }
.book-viewport:focus { outline: 2px solid rgba(143, 247, 255, 0.32); outline-offset: 3px; }

.book {
  position: relative;
  width: min(calc(var(--reader-width) * var(--zoom)), 100%);
  margin: 0 auto;
  perspective: 2000px;
  transform-style: preserve-3d;
  transition: width var(--transition-fast);
}

.page-stage {
  position: relative;
  width: 100%;
  min-height: 600px;
  border-radius: var(--radius-page);
  background: linear-gradient(165deg, rgba(12, 8, 22, 0.94) 0%, rgba(5, 3, 10, 0.98) 100%);
  border: 1px solid rgba(255, 255, 255, 0.04);
  box-shadow:
    0 40px 100px rgba(0, 0, 0, 0.70),
    0 0 0 1px rgba(56, 232, 240, 0.06),
    0 0 80px rgba(56, 232, 240, 0.04);
  overflow: hidden;
  transition: opacity 0.22s ease;
  padding: clamp(22px, 3.6vw, 50px);
}
.page-stage.fading { opacity: 0; }

.page-glow {
  position: absolute; inset: 0% -6% auto; height: 18%;
  background: radial-gradient(ellipse at 50% 0%, rgba(239, 78, 216, 0.10) 0%, transparent 70%);
  filter: blur(32px); opacity: 0.5; z-index: -1; pointer-events: none;
}
.page-shine {
  position: absolute; inset: 0; border-radius: var(--radius-page);
  background: linear-gradient(112deg, transparent 18%, rgba(255,255,255,0.06) 40%, transparent 56%);
  mix-blend-mode: screen; pointer-events: none; transform: translateX(-150%);
}
.book.turning .page-shine { animation: shineSweep 0.76s ease; }
@keyframes shineSweep { to { transform: translateX(150%); } }

.flip-sheet {
  position: absolute; top: 0; bottom: 0; width: 50%; display: none;
  background-size: 200% 100%; background-repeat: no-repeat;
  backface-visibility: hidden; transform-style: preserve-3d; pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.04);
}
.flip-sheet.next {
  display: block; right: 0; border-radius: 0 var(--radius-page) var(--radius-page) 0;
  background-position: right top; transform-origin: left center;
  animation: flipNext 0.76s cubic-bezier(0.18, 0.80, 0.14, 1) forwards;
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.55);
}
.flip-sheet.prev {
  display: block; left: 0; border-radius: var(--radius-page) 0 0 var(--radius-page);
  background-position: left top; transform-origin: right center;
  animation: flipPrev 0.76s cubic-bezier(0.18, 0.80, 0.14, 1) forwards;
  box-shadow: 8px 0 40px rgba(0, 0, 0, 0.55);
}
@keyframes flipNext { 0% { transform: rotateY(0deg); filter: brightness(1); } 45% { filter: brightness(0.68); } 100% { transform: rotateY(-172deg); filter: brightness(0.24); } }
@keyframes flipPrev { 0% { transform: rotateY(0deg); filter: brightness(1); } 45% { filter: brightness(0.68); } 100% { transform: rotateY(172deg); filter: brightness(0.24); } }

.turn-btn {
  position: sticky; top: 46%; z-index: 10;
  width: 54px; height: 76px;
  border: 1px solid var(--line-cyan);
  border-radius: 999px;
  color: var(--cyan-bright);
  background: linear-gradient(180deg, rgba(22, 16, 38, 0.95) 0%, rgba(5, 3, 10, 0.95) 100%);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.42), 0 0 30px rgba(56, 232, 240, 0.06);
  font-size: 3rem; line-height: 1;
  transition: transform var(--transition-fast), opacity var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}
.turn-btn:hover:not(:disabled) { transform: scale(1.07); border-color: rgba(239, 78, 216, 0.55); box-shadow: 0 0 40px rgba(239, 78, 216, 0.18), 0 16px 48px rgba(0, 0, 0, 0.42); }
.turn-btn:active:not(:disabled) { transform: scale(0.97); }
.turn-btn:disabled { opacity: 0.14; cursor: not-allowed; }

/* ── CONTROL STRIP ── */
.control-strip {
  display: grid; grid-template-columns: auto minmax(120px, 1fr) auto; gap: 14px; align-items: center;
  max-width: calc(var(--reader-width) + 112px); margin: 20px auto 0; padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.04); border-radius: 18px;
  background: rgba(8, 6, 16, 0.60); backdrop-filter: blur(18px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.30);
}
.control-strip button {
  border: 1px solid var(--line-cyan); color: var(--text);
  background: linear-gradient(180deg, rgba(24, 18, 40, 0.80) 0%, rgba(8, 6, 16, 0.80) 100%);
  border-radius: 999px; padding: 9px 20px; font-size: 0.74rem; font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 8px 24px rgba(0,0,0,.26);
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.control-strip button:hover { transform: translateY(-1px); border-color: rgba(143, 247, 255, 0.5); box-shadow: 0 0 20px rgba(56, 232, 240, 0.14); }
.control-strip button:disabled { opacity: 0.18; cursor: not-allowed; transform: none; }

input[type="range"] {
  appearance: none; width: 100%; height: 5px; border-radius: 999px;
  background: linear-gradient(90deg, var(--magenta) var(--progress, 0%), rgba(255,255,255,.07) var(--progress, 0%));
  outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 18px; height: 18px; border: 2px solid #050308; border-radius: 50%;
  background: var(--cyan-bright); box-shadow: 0 0 20px rgba(143,247,255,.5); transition: transform var(--transition-fast);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.14); }
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border: 2px solid #050308; border-radius: 50%;
  background: var(--cyan-bright); box-shadow: 0 0 20px rgba(143,247,255,.5);
}

/* ── FOOTER ── */
.footer-note {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 14px;
  padding: 12px 20px 32px; color: rgba(255, 255, 255, 0.20); font-size: 0.64rem;
  letter-spacing: 0.10em; text-transform: uppercase;
}
.footer-note span { display: flex; align-items: center; gap: 10px; }
.footer-note span::before {
  content: ""; display: inline-block; width: 4px; height: 4px; border-radius: 50%;
  background: var(--magenta-bright); box-shadow: 0 0 10px rgba(255, 140, 240, 0.7); flex-shrink: 0;
}

/* ════════════════════════════════════════════════════════════
   PAGE TEMPLATES
   ════════════════════════════════════════════════════════════ */

.tpl-title {
  text-align: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.5rem, 3.6vw, 2.6rem);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
  text-shadow: 0 0 24px rgba(56, 232, 240, 0.18);
}
.tpl-title.magenta { color: var(--magenta-bright); text-shadow: 0 0 24px rgba(239, 78, 216, 0.22); }
.tpl-title.cyan { color: var(--cyan-bright); text-shadow: 0 0 24px rgba(56, 232, 240, 0.22); }
.tpl-underline { height: 2px; width: clamp(160px, 30%, 380px); margin: 0 auto 30px; background: linear-gradient(90deg, var(--cyan), var(--magenta)); border-radius: 2px; box-shadow: 0 0 12px rgba(143,247,255,0.3); }
.tpl-subtitle { text-align: center; color: var(--magenta-bright); font-size: 0.84rem; font-weight: 600; margin-bottom: 30px; }

/* — COVER — */
.tpl-cover { display: flex; flex-direction: column; align-items: center; min-height: 540px; justify-content: center; text-align: center; gap: 20px; }
.tpl-cover-logo {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(3.2rem, 10vw, 7rem);
  letter-spacing: 0.04em;
  background: linear-gradient(120deg, var(--cyan-bright), var(--purple), var(--magenta-bright));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 36px rgba(143, 247, 255, 0.30));
  animation: coverGlow 4s ease-in-out infinite;
}
@keyframes coverGlow {
  0%, 100% { filter: drop-shadow(0 0 36px rgba(143, 247, 255, 0.30)); }
  50% { filter: drop-shadow(0 0 56px rgba(239, 78, 216, 0.36)); }
}
.tpl-cover-title { font-family: var(--display); font-weight: 700; font-size: clamp(1.1rem, 2.6vw, 1.7rem); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 4px; }
.tpl-cover-season { color: var(--magenta-bright); font-size: 0.88rem; font-weight: 700; letter-spacing: 0.06em; }
.tpl-cover-line { height: 1px; width: 220px; background: linear-gradient(90deg, transparent, var(--cyan), transparent); margin-top: 8px; }

/* — DATA TABLE — */
.tpl-table-wrap { overflow-x: auto; border-radius: 10px; }
.tpl-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; min-width: 560px; }
.tpl-table th, .tpl-table td { padding: 9px 14px; text-align: left; white-space: nowrap; }
.tpl-table thead th {
  color: var(--magenta-bright);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line-cyan);
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
  position: sticky;
  top: 0;
  background: rgba(8, 5, 16, 0.92);
  backdrop-filter: blur(4px);
}
.tpl-table thead th:hover { color: var(--cyan-bright); }
.tpl-table thead th .arrow { font-size: 0.62rem; margin-left: 4px; opacity: 0.4; }
.tpl-table thead th.sorted .arrow { opacity: 1; color: var(--cyan-bright); }
.tpl-table tbody tr { border-bottom: 1px solid rgba(255,255,255,0.04); transition: background var(--transition-fast); }
.tpl-table tbody tr:hover { background: rgba(56, 232, 240, 0.05); }
.tpl-table tbody tr.divider-after { border-bottom: 1px solid var(--line-magenta); }
.tpl-table td.team { color: var(--text); font-weight: 600; }
.tpl-table td.cyan { color: var(--cyan-bright); }
.tpl-table td.muted { color: var(--muted); }
.tpl-table td.pos { color: #7ee787; }
.tpl-table td.neg { color: #ff8a8a; }
.tpl-table tbody tr.faded td { color: var(--muted); opacity: 0.55; }

.tpl-takeaways { margin-top: 26px; }
.tpl-takeaways-title { color: var(--magenta-bright); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 12px; }
.tpl-takeaway-item { display: flex; gap: 10px; align-items: baseline; font-size: 0.80rem; color: var(--muted-strong); line-height: 1.6; margin-bottom: 8px; }
.tpl-takeaway-item .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan-bright); box-shadow: 0 0 8px rgba(143,247,255,0.7); flex-shrink: 0; margin-top: 6px; }

.tpl-insight {
  margin-top: 22px;
  padding: 14px 18px;
  border: 1px solid var(--line-cyan);
  border-radius: 10px;
  background: rgba(56, 232, 240, 0.04);
  color: var(--muted-strong);
  font-size: 0.80rem;
  line-height: 1.6;
}
.tpl-insight strong { color: var(--cyan-bright); }
.tpl-insight em { color: var(--magenta-bright); font-style: normal; }

/* — SCORING / DUAL-COLUMN MINI TABLES — */
.tpl-mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-bottom: 26px; }
.tpl-mini-block { }
.tpl-mini-title { color: var(--magenta-bright); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 10px; }
.tpl-mini-table { width: 100%; font-size: 0.74rem; border-collapse: collapse; }
.tpl-mini-table th { text-align: left; color: var(--cyan-bright); font-size: 0.62rem; letter-spacing: 0.06em; text-transform: uppercase; padding: 4px 8px 6px 0; border-bottom: 1px solid var(--line-cyan); }
.tpl-mini-table td { padding: 5px 8px 5px 0; color: var(--muted-strong); }
.tpl-mini-table tr:first-child td { color: var(--cyan-bright); font-weight: 700; }
.tpl-mini-note { margin-top: 10px; font-size: 0.74rem; color: var(--muted); line-height: 1.6; }
.tpl-mini-note strong { color: var(--text); }

/* — FACT CARDS — */
.tpl-fact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.tpl-fact-card {
  border: 1px solid;
  border-radius: 12px;
  padding: 18px 20px;
  background: rgba(255,255,255,0.012);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  cursor: default;
}
.tpl-fact-card.c-cyan { border-color: var(--line-cyan); }
.tpl-fact-card.c-magenta { border-color: var(--line-magenta); }
.tpl-fact-card.c-purple { border-color: rgba(139, 92, 246, 0.32); }
.tpl-fact-card:hover {
  transform: translateY(-3px);
  background: rgba(255,255,255,0.03);
}
.tpl-fact-card.c-cyan:hover { box-shadow: 0 12px 40px rgba(56, 232, 240, 0.16); border-color: rgba(143, 247, 255, 0.6); }
.tpl-fact-card.c-magenta:hover { box-shadow: 0 12px 40px rgba(239, 78, 216, 0.18); border-color: rgba(255, 140, 240, 0.6); }
.tpl-fact-card.c-purple:hover { box-shadow: 0 12px 40px rgba(139, 92, 246, 0.20); border-color: rgba(167, 139, 250, 0.65); }
.tpl-fact-title { font-size: 0.76rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.tpl-fact-icon {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 0.85rem;
  background: rgba(255,255,255,0.04);
  flex-shrink: 0;
}
.tpl-fact-card.c-cyan .tpl-fact-icon { box-shadow: 0 0 12px rgba(56, 232, 240, 0.35); border: 1px solid rgba(56, 232, 240, 0.4); }
.tpl-fact-card.c-magenta .tpl-fact-icon { box-shadow: 0 0 12px rgba(239, 78, 216, 0.35); border: 1px solid rgba(239, 78, 216, 0.4); }
.tpl-fact-card.c-purple .tpl-fact-icon { box-shadow: 0 0 12px rgba(139, 92, 246, 0.35); border: 1px solid rgba(139, 92, 246, 0.4); }
.tpl-fact-card.c-cyan .tpl-fact-title { color: var(--cyan-bright); }
.tpl-fact-card.c-magenta .tpl-fact-title { color: var(--magenta-bright); }
.tpl-fact-card.c-purple .tpl-fact-title { color: #c4b5fd; }
.tpl-fact-text { font-size: 0.78rem; color: var(--muted-strong); line-height: 1.6; }

/* — GLOSSARY CARDS — */
.tpl-glossary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.tpl-glossary-card {
  border: 1px solid var(--line-magenta);
  border-radius: 14px;
  padding: 18px 22px;
  background: rgba(255,255,255,0.012);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}
.tpl-glossary-card:hover { transform: translateY(-3px); box-shadow: 0 14px 44px rgba(239, 78, 216, 0.14); border-color: rgba(255, 140, 240, 0.55); }
.tpl-glossary-term { color: var(--cyan-bright); font-size: 0.74rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 10px; }
.tpl-glossary-card p { font-size: 0.78rem; color: var(--muted-strong); line-height: 1.65; margin-bottom: 10px; }
.tpl-glossary-card p:last-child { margin-bottom: 0; }
.tpl-glossary-card strong { color: var(--magenta-bright); font-weight: 700; }
.tpl-glossary-card .term-eli5 strong, .tpl-glossary-card .term-why strong { color: var(--cyan-bright); }

/* — RANK MEDAL ROWS — */
.tpl-table tbody tr.rank-gold { background: rgba(255, 200, 40, 0.05); }
.tpl-table tbody tr.rank-gold td.team {
  color: #ffd700;
  font-weight: 700;
  text-shadow: 0 0 14px rgba(255, 215, 0, 0.45);
}
.tpl-table tbody tr.rank-gold:hover { background: rgba(255, 200, 40, 0.09); }

.tpl-table tbody tr.rank-silver { background: rgba(192, 192, 192, 0.035); }
.tpl-table tbody tr.rank-silver td.team {
  color: #d4d4d4;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(200, 200, 200, 0.30);
}
.tpl-table tbody tr.rank-silver:hover { background: rgba(192, 192, 192, 0.07); }

.tpl-table tbody tr.rank-bronze { background: rgba(200, 110, 30, 0.04); }
.tpl-table tbody tr.rank-bronze td.team {
  color: #e8a060;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(205, 127, 50, 0.35);
}
.tpl-table tbody tr.rank-bronze:hover { background: rgba(200, 110, 30, 0.08); }

/* — COVER GLITCH — */
@keyframes glitch {
  0%, 90%, 100% { clip-path: none; transform: none; text-shadow: none; }
  91% {
    clip-path: inset(18% 0 58% 0);
    transform: translate(-5px, 1px) skewX(-3deg);
    filter: drop-shadow(-4px 0 var(--magenta)) drop-shadow(4px 0 var(--cyan));
  }
  92% {
    clip-path: inset(55% 0 12% 0);
    transform: translate(5px, -1px) skewX(3deg);
    filter: drop-shadow(4px 0 var(--magenta)) drop-shadow(-4px 0 var(--cyan));
  }
  93% { clip-path: none; transform: none; filter: none; }
  95% {
    clip-path: inset(35% 0 40% 0);
    transform: translate(-3px, 0);
    filter: drop-shadow(3px 0 var(--cyan));
  }
  96% { clip-path: none; transform: none; filter: none; }
}
.tpl-cover-logo { animation: coverGlow 4s ease-in-out infinite, glitch 8s steps(1) infinite; }

/* — SHORTCUT MODAL — */
.shortcut-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 60;
  background: rgba(3, 2, 8, 0.75);
  backdrop-filter: blur(12px);
  place-items: center;
}
.shortcut-overlay.open { display: grid; }

.shortcut-modal {
  width: min(90vw, 400px);
  border: 1px solid var(--line-cyan);
  border-radius: 18px;
  background: linear-gradient(155deg, rgba(20, 14, 36, 0.98) 0%, rgba(6, 4, 14, 0.98) 100%);
  box-shadow: 0 32px 100px rgba(0,0,0,0.85), 0 0 60px rgba(56,232,240,0.10);
  padding: 28px 30px 24px;
  animation: modalIn 0.18s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.94) translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.shortcut-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 22px;
}
.shortcut-modal-title {
  font-family: var(--display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--cyan-bright);
}
.shortcut-close {
  cursor: pointer; border: none; background: none;
  color: var(--muted); font-size: 1rem;
  transition: color var(--transition-fast);
}
.shortcut-close:hover { color: var(--text); }

.shortcut-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 18px;
  margin-bottom: 20px;
}
.shortcut-grid kbd {
  display: inline-grid; place-items: center;
  min-width: 36px; padding: 4px 8px;
  border: 1px solid var(--line-cyan);
  border-radius: 6px;
  background: rgba(56, 232, 240, 0.06);
  color: var(--cyan-bright);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 2px 0 rgba(56,232,240,0.20);
  white-space: nowrap;
}
.shortcut-grid span {
  align-self: center;
  font-size: 0.78rem;
  color: var(--muted-strong);
}
.shortcut-tip {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 14px;
  line-height: 1.6;
}

/* ── RESPONSIVE ── */
@media (max-width: 1100px) {
  .tpl-mini-grid { grid-template-columns: 1fr; }
  .tpl-fact-grid { grid-template-columns: 1fr; }
  .tpl-glossary-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1060px) {
  .layout { grid-template-columns: 1fr; }
  .thumb-panel { position: relative; top: auto; overflow-x: auto; padding: 12px; }
  .thumb-rail { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
  .thumb { min-width: 170px; flex-shrink: 0; }
  .book-shell { grid-template-columns: 42px minmax(0, 1fr) 42px; gap: 10px; }
  .turn-btn { width: 42px; height: 62px; font-size: 2.4rem; }
}

@media (max-width: 680px) {
  .masthead { flex-direction: column; align-items: flex-start; }
  .top-actions { width: 100%; justify-content: flex-start; }
  .reader-topline { flex-direction: column; align-items: flex-start; }
  .book-shell { grid-template-columns: 1fr; }
  .turn-btn { position: fixed; top: 50%; transform: translateY(-50%); }
  .turn-left { left: 8px; }
  .turn-right { right: 8px; }
  .turn-btn:hover:not(:disabled) { transform: translateY(-50%) scale(1.07); }
  .page-stage { padding: 16px 12px; min-height: 520px; }
  .control-strip { grid-template-columns: 1fr; }
  :root { --reader-width: 96vw; }
}

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