@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@500;600;700;800;900&family=Roboto:wght@400;500;700&display=swap');

:root {
  color-scheme: dark;
  --background: #071226;
  --surface: #0d1d3a;
  --text: #f8fbff;
  --muted: #c9d6ed;
  --blue: #2b3cd6;
  --blue-bright: #0069b4;
  --red: #ed1c24;
  --red-bright: #ff0053;
  --line: rgba(255, 255, 255, 0.17);
  --shadow: 0 24px 80px rgba(0, 8, 30, 0.58);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-family: Roboto, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(115deg, rgba(43, 60, 214, 0.26), transparent 42%),
    radial-gradient(circle at 100% 20%, rgba(237, 28, 36, 0.2), transparent 34rem),
    var(--background);
}

button { font: inherit; }

.app-shell {
  width: min(100%, 650px);
  height: 100vh;
  margin: 0 auto;
  padding: clamp(14px, 3vw, 32px) clamp(12px, 4vw, 56px);
}

.story-board {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  height: 100%;
  min-height: 0;
}

.candidate-rail {
  display: flex;
  gap: clamp(12px, 2vw, 20px);
  align-items: center;
  min-height: 82px;
  padding: 3px 4px 7px;
  overflow-x: auto;
  scrollbar-width: none;
}

.candidate-rail::-webkit-scrollbar { display: none; }

.candidate-tab {
  position: relative;
  flex: 0 0 auto;
  padding: 3px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  background: linear-gradient(135deg, var(--blue-bright), var(--red) 70%);
  box-shadow: 0 10px 28px rgba(0, 105, 180, 0.28);
  transition: transform 180ms ease, filter 180ms ease, box-shadow 180ms ease;
}

.candidate-tab::after {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: inherit;
  content: "";
  opacity: 0;
  transform: scale(1.12);
  transition: opacity 180ms ease, transform 180ms ease;
}

.candidate-tab:hover, .candidate-tab:focus-visible { transform: translateY(-3px); }
.candidate-tab:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--background), 0 0 0 5px var(--red); }
.candidate-tab.is-active { box-shadow: 0 12px 32px rgba(237, 28, 36, 0.42); }
.candidate-tab.is-active::after { opacity: 1; transform: scale(1.08); }

.candidate-tab__ring {
  display: block;
  width: clamp(58px, 7vw, 76px);
  height: clamp(58px, 7vw, 76px);
  padding: 3px;
  border: 2px solid var(--background);
  border-radius: 50%;
  background: var(--surface);
}

.candidate-tab__ring img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.story-progress {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 4px;
  min-height: 4px;
  padding: 0 3px;
}

.story-progress__bar {
  position: relative;
  flex: 1;
  height: 4px;
  min-height: 4px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(0, 105, 180, 0.72);
}

.story-progress__bar.is-complete {
  background: rgba(237, 28, 36, 0.72);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.28), 0 1px 5px rgba(0, 0, 0, 0.85);
}

.story-progress__fill {
  position: absolute;
  inset: 0;
  transform: scaleX(0);
  transform-origin: left;
  background: var(--red);
}

.story-progress__bar.is-active .story-progress__fill {
  animation: story-progress-fill 6s linear forwards;
}

.story-progress__bar:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.story-progress__bar.is-complete .story-progress__fill {
  transform: scaleX(1);
  background: var(--red);
}

.story-board.is-paused .story-progress__bar.is-active .story-progress__fill {
  animation-play-state: paused;
}

@keyframes story-progress-fill {
  0% {
    transform: scaleX(0);
    background: var(--red);
  }
  100% {
    transform: scaleX(1);
    background: #050505;
  }
}

.story-toggle {
  display: grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  color: var(--background);
  cursor: pointer;
  background: rgba(255, 255, 255, 0.92);
  font-family: Arial, sans-serif;
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.story-toggle.is-paused {
  color: #fff;
  background: var(--red);
}

.story-toggle:hover, .story-toggle:focus-visible {
  border-color: #fff;
  background: var(--blue-bright);
  color: #fff;
  outline: none;
  transform: scale(1.08);
}

.story-intro {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 7px 12px 10px;
  border-bottom: 0;
  color: rgba(248, 251, 255, 0.84);
  font-family: Montserrat, Roboto, ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(0.72rem, 1.5vw, 0.98rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.story-intro__copy {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  gap: 0.35em 0.55em;
  align-items: baseline;
  min-width: 0;
}

.story-intro__copy > span {
  white-space: nowrap;
}

.story-intro__controls {
  display: flex;
  width: 100%;
  gap: 12px;
  align-items: center;
}

.story-intro__controls .story-progress {
  flex: 1 1 auto;
  max-width: none;
}

.story-intro strong {
  display: block;
  max-width: 100%;
  color: #fff;
  font-size: clamp(1rem, 5vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.055em;
  line-height: 1;
  white-space: nowrap;
}

.story-intro .story-toggle {
  flex-basis: 34px;
  width: 34px;
  height: 34px;
  margin-right: 2px;
  font-size: 1.05rem;
}

.story-stage {
  position: relative;
  min-height: 0;
}

.story-card {
  position: absolute;
  inset: 0;
  display: none;
}

.story-card.is-active { display: block; }

.story-slide {
  position: relative;
  display: none;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: clamp(20px, 3vw, 34px);
  background: var(--surface);
  box-shadow: var(--shadow);
  isolation: isolate;
}

.story-slide.is-active { display: block; }

.story-slide::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  content: "";
  background: linear-gradient(180deg, rgba(4, 2, 8, 0.04) 42%, rgba(4, 2, 8, 0.92) 100%);
}

.story-slide__media { position: absolute; inset: 0; }

.story-slide__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.story-slide[data-image-fit="contain"] .story-slide__media {
  display: grid;
  place-items: center;
  background: #050b18;
}

.story-slide[data-image-fit="contain"] .story-slide__media img {
  object-fit: contain;
}

.story-rank {
  position: absolute;
  right: clamp(18px, 4vw, 54px);
  bottom: clamp(18px, 4vw, 48px);
  z-index: 2;
  color: rgba(255, 255, 255, 0.36);
  font-size: clamp(6rem, 19vw, 15rem);
  font-weight: 900;
  letter-spacing: -0.12em;
  line-height: 0.72;
  pointer-events: none;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.86), 0 0 2px rgba(0, 0, 0, 0.95);
  user-select: none;
}

.story-slide__copy {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 3;
  padding: clamp(22px, 5vw, 52px);
  cursor: pointer;
  background: linear-gradient(180deg, transparent, rgba(4, 2, 8, 0.3));
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.52);
}

.story-slide__copy p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.story-slide.is-expanded .story-slide__copy {
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
  padding: clamp(28px, 7vw, 80px);
  background: rgba(4, 2, 8, 0.82);
  backdrop-filter: blur(8px);
}

.story-slide.is-expanded .story-slide__copy p {
  display: block;
  overflow: visible;
  -webkit-line-clamp: unset;
}

.story-slide__meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  color: #ff8b9a;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.story-slide h2 {
  width: 100%;
  max-width: none;
  margin: 0;
  font-size: clamp(1.65rem, 4vw, 3.3rem);
  line-height: 1.04;
  letter-spacing: -0.045em;
}

.story-slide p {
  width: 100%;
  max-width: none;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: clamp(0.82rem, 1.4vw, 1rem);
  line-height: 1.5;
}

.story-slide--empty { display: grid; place-items: center; color: var(--muted); }

@media (max-width: 640px) {
  .app-shell { padding: 10px 10px 12px; }
  .story-board { gap: 10px; }
  .story-intro { padding-left: 4px; }
  .story-intro__controls { flex-basis: 100%; }
  .story-intro__controls .story-progress { max-width: none; }
  .candidate-rail { min-height: 70px; gap: 10px; }
  .story-slide__copy { padding: 22px 20px 24px; }
  .story-slide.is-expanded .story-slide__copy { padding: 24px 20px; }
  .story-slide h2 { font-size: clamp(1.55rem, 8vw, 2.2rem); }
}
