:root {
  --wine: #5f1930;
  --wine-deep: #32101d;
  --gold: #d6ad5c;
  --gold-light: #f0d797;
  --cream: #fbf5e8;
  --ink: #2b1c21;
  --muted: #76666a;
  --shadow: 0 22px 60px rgba(33, 7, 18, .3);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--wine-deep); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--cream);
  font-family: Georgia, "Times New Roman", serif;
  background:
    linear-gradient(135deg, rgba(28, 5, 14, .92), rgba(83, 20, 44, .74)),
    url("assets/time-portal.png") center / cover fixed;
}

body.swipe-locked { height: 100svh; overflow: hidden; overscroll-behavior: none; }
body.swipe-locked .app-shell { height: 100svh; min-height: 0; overflow: hidden; }
body.swipe-locked .swipe-screen { height: 100%; min-height: 0; }
body.swipe-locked footer { display: none; }

button, a { font: inherit; }
button { touch-action: manipulation; }

.app-shell { width: min(1120px, 100%); min-height: calc(100vh - 52px); margin: 0 auto; padding: 28px 22px; }
.screen { min-height: calc(100vh - 108px); }
.is-hidden { display: none !important; }

.welcome-screen { display: grid; place-items: center; }
.welcome-panel {
  width: min(650px, 100%);
  padding: clamp(34px, 8vw, 72px);
  text-align: center;
  background: linear-gradient(155deg, rgba(49, 13, 29, .92), rgba(19, 7, 12, .88));
  border: 1px solid rgba(240, 215, 151, .42);
  border-radius: 32px 8px 32px 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.eyebrow, .card-kicker, .brand-mark {
  margin: 0 0 12px;
  color: var(--gold-light);
  font-family: Arial, sans-serif;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1 { margin: 0; font-size: clamp(3rem, 9vw, 6.5rem); font-weight: 500; line-height: .88; letter-spacing: -.045em; }
.headline { max-width: 520px; margin: 28px auto 32px; font-size: clamp(1.25rem, 3vw, 1.8rem); line-height: 1.35; }
.tiny-note, .gesture-hint { color: rgba(251, 245, 232, .72); font-family: Arial, sans-serif; font-size: .85rem; }

.primary-button, .secondary-button {
  min-height: 52px;
  padding: 14px 27px;
  border-radius: 999px;
  cursor: pointer;
  font-family: Arial, sans-serif;
  font-size: .96rem;
  font-weight: 800;
  letter-spacing: .02em;
}
.primary-button { border: 1px solid #f1dda5; color: #2b1720; background: linear-gradient(180deg, #f4dfa2, #c79840); box-shadow: 0 10px 28px rgba(210, 167, 78, .25); }
.primary-button:hover { transform: translateY(-1px); filter: brightness(1.06); }
.secondary-button { border: 1px solid rgba(251,245,232,.45); color: var(--cream); background: transparent; }

.compact-header { display: flex; align-items: end; justify-content: center; gap: 28px; padding: 4px 0 18px; text-align: center; }
.compact-header h2, .results-header h2 { margin: 0; font-size: clamp(1.6rem, 4vw, 2.8rem); font-weight: 500; line-height: 1.05; }
.browse-instruction { margin: 9px 0 0; color: rgba(251,245,232,.78); font-family: Arial,sans-serif; font-size: .95rem; }

.swipe-screen { display: flex; flex-direction: column; }
.card-stage { flex: 1; display: grid; place-items: center; min-height: 510px; }
.trope-card {
  position: relative;
  width: min(430px, 92vw);
  height: min(620px, 64vh);
  min-height: 480px;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  touch-action: none;
  overscroll-behavior: contain;
  color: var(--cream);
  background: var(--wine-deep);
  border: 1px solid rgba(240, 215, 151, .52);
  border-radius: 28px;
  box-shadow: var(--shadow);
  transform-origin: 50% 95%;
  will-change: transform, opacity;
  transition: transform .28s cubic-bezier(.2,.8,.2,1), opacity .22s ease;
}
.trope-card:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 4px; }
.trope-card.dragging { cursor: grabbing; transition: none; }
.trope-card.exit-left { transform: translateX(-125vw) rotate(-18deg); opacity: 0; }
.trope-card.exit-right { transform: translateX(125vw) rotate(18deg); opacity: 0; }
.trope-card.enter-from-right { transform: translateX(56px) rotate(2deg) scale(.97); opacity: 0; transition: none; }
.trope-card.enter-from-left { transform: translateX(-56px) rotate(-2deg) scale(.97); opacity: 0; transition: none; }

.swipe-cue { position: absolute; z-index: 4; top: 24px; padding: 8px 13px; opacity: 0; color: #2b1720; background: var(--gold-light); border: 2px solid #fff1c6; border-radius: 999px; box-shadow: 0 8px 20px rgba(20,4,10,.28); font-family: Arial,sans-serif; font-size: .78rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; pointer-events: none; transition: opacity .08s linear, transform .12s ease; }
.swipe-cue-back { left: 22px; transform: rotate(-8deg) scale(.9); }
.swipe-cue-next { right: 22px; transform: rotate(8deg) scale(.9); }
.trope-card.show-back .swipe-cue-back, .trope-card.show-next .swipe-cue-next { opacity: 1; transform: rotate(0) scale(1); }

.card-image { position: absolute; inset: 0; background: url("assets/time-portal.png") center / cover; }
.card-image::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(26,7,14,.08) 10%, rgba(31,8,17,.2) 45%, rgba(25,6,13,.97) 100%); }
.card-copy { position: absolute; z-index: 2; right: 0; bottom: 0; left: 0; padding: 34px 32px 30px; }
.card-copy h3 { margin: 0 0 10px; font-size: clamp(2rem, 7vw, 3.2rem); font-weight: 500; line-height: .98; }
.card-copy > p:not(.card-kicker) { margin: 0; font-size: 1.05rem; line-height: 1.46; }
.tag-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 18px; }
.tag { padding: 6px 9px; border: 1px solid rgba(240,215,151,.45); border-radius: 999px; color: #f7e5b5; background: rgba(93,25,48,.45); font-family: Arial,sans-serif; font-size: .72rem; }

.carousel-actions { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 16px 0 0; }
.arrow-button { min-width: 112px; min-height: 48px; padding: 10px 15px; cursor: pointer; color: var(--cream); background: rgba(35,8,19,.72); border: 1px solid rgba(251,245,232,.35); border-radius: 999px; font-family: Arial,sans-serif; font-size: .86rem; font-weight: 750; }
.arrow-button span { color: var(--gold-light); font-size: 1.45rem; line-height: .5; vertical-align: -.08em; }
.choose-era-button { min-width: 190px; }
.gesture-hint { margin: 10px 0 0; text-align: center; }

.results-screen { padding: 28px 0 58px; }
.results-header { max-width: 760px; margin: 0 auto 22px; text-align: center; }
.results-header p:last-child { font-family: Arial,sans-serif; line-height: 1.55; }
.format-switch { display: flex; width: min(430px, 100%); margin: 0 auto 18px; padding: 5px; background: rgba(35,8,19,.72); border: 1px solid rgba(240,215,151,.32); border-radius: 999px; }
.format-tab { flex: 1; min-height: 44px; padding: 9px 14px; cursor: pointer; color: rgba(251,245,232,.78); background: transparent; border: 0; border-radius: 999px; font-family: Arial,sans-serif; font-size: .84rem; font-weight: 800; }
.format-tab.is-active { color: #2b1720; background: linear-gradient(180deg, #f4dfa2, #c79840); box-shadow: 0 6px 18px rgba(15,3,8,.26); }
.format-tab:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 2px; }
.audible-offer { display: flex; align-items: center; justify-content: space-between; gap: 24px; max-width: 850px; margin: 0 auto 18px; padding: 22px 24px; color: var(--cream); background: linear-gradient(135deg, rgba(94,25,48,.94), rgba(34,8,18,.94)); border: 1px solid rgba(240,215,151,.48); border-radius: 20px 6px 20px 6px; box-shadow: 0 12px 32px rgba(20,4,10,.24); }
.audible-offer-kicker { margin: 0 0 6px; color: var(--gold-light); font-family: Arial,sans-serif; font-size: .72rem; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.audible-offer h3 { margin: 0; font-size: 1.45rem; font-weight: 500; }
.audible-offer div > p:last-child { margin: 7px 0 0; color: rgba(251,245,232,.78); font-family: Arial,sans-serif; font-size: .9rem; line-height: 1.45; }
.audible-offer-button { flex: 0 0 auto; min-width: 145px; padding: 13px 20px; color: #2b1720; background: linear-gradient(180deg, #f4dfa2, #c79840); border: 1px solid #f1dda5; border-radius: 999px; font-family: Arial,sans-serif; font-size: .9rem; font-weight: 900; text-align: center; text-decoration: none; }
.audible-offer-button:hover { filter: brightness(1.06); transform: translateY(-1px); }
.affiliate-note { max-width: 850px; margin: 0 auto 24px; padding: 12px 16px; color: rgba(251,245,232,.82); background: rgba(35,8,19,.58); border: 1px solid rgba(240,215,151,.25); border-radius: 12px; font-family: Arial,sans-serif; font-size: .78rem; line-height: 1.45; text-align: center; }
.results-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.book-card { display: flex; flex-direction: column; min-height: 360px; padding: 25px; color: var(--ink); background: linear-gradient(155deg, #fffaf0, #eee1c6); border: 1px solid #ebd69f; border-radius: 20px 5px 20px 5px; box-shadow: 0 16px 36px rgba(20,4,10,.23); }
.book-era { margin: 0 0 10px; color: var(--wine); font-family: Arial,sans-serif; font-size: .7rem; font-weight: 900; letter-spacing: .11em; text-transform: uppercase; }
.book-card h3 { margin: 0; font-size: 1.55rem; line-height: 1.08; }
.author { margin: 6px 0 16px; color: var(--muted); font-family: Arial,sans-serif; font-size: .88rem; }
.teaser { margin: 0 0 16px; font-size: .98rem; line-height: 1.5; }
.book-meta { margin-top: auto; }
.book-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.book-tags span { padding: 5px 8px; color: #603047; background: #ead5dc; border-radius: 999px; font-family: Arial,sans-serif; font-size: .68rem; font-weight: 700; }
.amazon-button { display: block; padding: 13px 16px; color: #fffaf0; background: var(--wine); border-radius: 999px; font-family: Arial,sans-serif; font-size: .85rem; font-weight: 800; text-align: center; text-decoration: none; }
.amazon-button:hover { background: #7a2340; }
.amazon-button.audible-button { color: #2b1720; background: linear-gradient(180deg, #f4dfa2, #c79840); }
.amazon-button.audible-button:hover { filter: brightness(1.06); }
.results-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

footer { padding: 20px 18px; color: rgba(251,245,232,.66); background: rgba(15,3,8,.65); font-family: Arial,sans-serif; font-size: .7rem; line-height: 1.4; text-align: center; }
footer p { margin: 12px 0 0; }
.social-links { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 9px; }
.social-links span { margin-right: 3px; color: rgba(251,245,232,.82); font-size: .78rem; font-weight: 700; }
.social-links a { padding: 7px 12px; color: var(--gold-light); border: 1px solid rgba(240,215,151,.38); border-radius: 999px; font-size: .75rem; font-weight: 800; text-decoration: none; }
.social-links a:hover { color: #2b1720; background: var(--gold-light); }
.social-links a:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 2px; }
.footer-affiliate { margin: 16px auto 0; }

@media (max-width: 860px) {
  .results-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 600px) {
  body { background-attachment: scroll; }
  .app-shell { min-height: calc(100vh - 44px); padding: 16px 12px; }
  .screen { min-height: calc(100vh - 76px); }
  .welcome-panel { padding: 38px 24px; border-radius: 24px 6px 24px 6px; }
  .compact-header { align-items: center; padding-bottom: 10px; }
  .brand-mark { margin-bottom: 5px; font-size: .66rem; }
  .compact-header h2 { font-size: 1.35rem; }
  .browse-instruction { font-size: .82rem; }
  .card-stage { min-height: 0; }
  .trope-card { width: min(390px, 94vw); height: calc(100svh - 235px); min-height: 430px; max-height: 610px; }
  .trope-card.enter-from-right { transform: translateX(42px) rotate(2deg) scale(.97); }
  .trope-card.enter-from-left { transform: translateX(-42px) rotate(-2deg) scale(.97); }
  .card-copy { padding: 28px 24px 24px; }
  .carousel-actions { gap: 8px; padding-top: 10px; }
  .arrow-button { min-width: 76px; padding: 9px 10px; font-size: .72rem; }
  .choose-era-button { min-width: 156px; padding-right: 17px; padding-left: 17px; font-size: .82rem; }
  .gesture-hint { display: none; }
  .results-grid { grid-template-columns: 1fr; }
  .book-card { min-height: 320px; }
  .audible-offer { align-items: stretch; flex-direction: column; padding: 20px; text-align: center; }
  .audible-offer-button { width: 100%; }
  .social-links span { flex-basis: 100%; margin: 0 0 2px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
