/*!
 * story-run.css - A585 shared story-run layer.
 *
 * Styles the StoryRun HUD (story bar, five-minute clock, rising-beat line) and
 * the finish/score modal. Uses the game-system palette with fallbacks so the
 * layer looks right whether or not game-system.css has loaded yet, and stays
 * readable on the 390px phone viewport the arcade contract checks.
 */

.storyrun {
  --sr-ink: var(--charcoal, #403b33);
  --sr-panel: rgba(255, 255, 255, .94);
  --sr-line: rgba(64, 59, 51, .14);
  --sr-accent: var(--rose, #bc4749);
  --sr-good: #2f8f5b;
  --sr-warn: #d97706;
  box-sizing: border-box;
  width: min(1120px, 100%);
  margin: 0 auto 10px;
  padding: 0 14px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--sr-ink);
}

.storyrun *,
.storyrun *::before,
.storyrun *::after { box-sizing: border-box; }

.storyrun .sr-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--sr-panel);
  border: 1px solid var(--sr-line);
  border-radius: 10px;
  padding: 8px 12px;
  box-shadow: 0 8px 22px rgba(64, 59, 51, .1);
}

.storyrun .sr-lead {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.storyrun .sr-guide {
  display: inline-flex;
  align-items: center;
  font-weight: 900;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .02em;
  color: #fff;
  background: var(--sr-accent);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}

.storyrun .sr-title {
  font-size: .98rem;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.storyrun .sr-clock {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  padding: 5px 12px;
  border-radius: 8px;
  background: rgba(64, 59, 51, .06);
  font-variant-numeric: tabular-nums;
}

.storyrun .sr-time {
  font-weight: 900;
  font-size: 1rem;
}

.storyrun .sr-clock-fill {
  position: absolute;
  left: 4px;
  bottom: 3px;
  height: 3px;
  width: 100%;
  max-width: calc(100% - 8px);
  background: var(--sr-good);
  border-radius: 3px;
  transition: width .25s linear, background .25s linear;
}

.storyrun.is-lowtime .sr-clock-fill { background: var(--sr-warn); }
.storyrun.is-lowtime .sr-time { color: var(--sr-warn); }

.storyrun .sr-story {
  margin-top: 8px;
  background: var(--sr-panel);
  border: 1px solid var(--sr-line);
  border-radius: 10px;
  padding: 10px 12px;
  line-height: 1.5;
}

.storyrun .sr-open {
  margin: 0;
  font-weight: 800;
}

.storyrun .sr-objective {
  margin: 4px 0 0;
  color: rgba(64, 59, 51, .78);
}

.storyrun .sr-beat {
  margin: 6px 0 0;
  font-weight: 800;
  color: var(--sr-accent);
  opacity: 0;
  transform: translateY(3px);
  transition: opacity .3s ease, transform .3s ease;
}

.storyrun .sr-beat.show { opacity: 1; transform: none; }
.storyrun .sr-beat.pulse { animation: sr-pulse .5s ease; }

@keyframes sr-pulse {
  0% { transform: scale(1.0); }
  40% { transform: scale(1.04); }
  100% { transform: scale(1.0); }
}

.storyrun.sr-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  margin: 0;
  width: auto;
  background: rgba(20, 17, 15, .55);
}

.storyrun.sr-modal.show { display: flex; }

.storyrun .sr-modal-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 14px;
  padding: 20px 18px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
  max-height: 92vh;
  overflow: auto;
}

.storyrun .sr-modal-kicker {
  font-size: .72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--sr-accent);
}

.storyrun .sr-modal-card h2 {
  margin: 4px 0 8px;
  font-size: 1.35rem;
  line-height: 1.15;
}

.storyrun .sr-result {
  margin: 0 0 12px;
  line-height: 1.5;
  color: rgba(64, 59, 51, .85);
}

.storyrun .sr-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.storyrun .sr-stats > div {
  background: rgba(64, 59, 51, .05);
  border-radius: 8px;
  padding: 8px 6px;
}

.storyrun .sr-stats span {
  display: block;
  font-size: .66rem;
  font-weight: 900;
  text-transform: uppercase;
  color: rgba(64, 59, 51, .6);
}

.storyrun .sr-stats b { font-size: 1.05rem; }

.storyrun .sr-again,
.storyrun .sr-back {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 12px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.storyrun .sr-again {
  background: var(--sr-accent);
  color: #fff;
  margin-bottom: 8px;
}

.storyrun .sr-back {
  background: rgba(64, 59, 51, .08);
  color: var(--sr-ink);
}

@media (max-width: 460px) {
  .storyrun .sr-title { font-size: .88rem; }
  .storyrun .sr-bar { padding: 7px 10px; }
  .storyrun .sr-story { padding: 9px 10px; font-size: .92rem; }
}
