:root {
  --ink: #f4f0e6;
  --muted: #9a958a;
  --stage: #000;
  --bar: rgba(0, 0, 0, 0.72);
  --sub: #ffcc00;
  --sub-upcoming: rgba(255, 204, 0, 0.28);
  --bad: #ff4d4d;
  --font-display: "Syne", sans-serif;
  --font-body: "IBM Plex Sans", sans-serif;
  --font-sub: "IBM Plex Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body.week2-game {
  height: 100%;
}

body.week2-game {
  color: var(--ink);
  font-family: var(--font-body);
  background: var(--stage);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow: hidden;
}

.game-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0.85rem;
  background: var(--bar);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 2;
}

.back-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
}
.back-link:hover {
  color: var(--sub);
}

.bar-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.mode-badge {
  padding: 0.15rem 0.45rem;
  border: 1px solid rgba(255, 204, 0, 0.45);
  color: var(--sub);
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.progress {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.error {
  margin: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--bad);
  color: #fff;
  background: rgba(255, 77, 77, 0.15);
}

.screen {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.screen[hidden] {
  display: none;
}

.screen-play {
  background: #000;
}

.cinema {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  background: #000;
  cursor: text;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cinema-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  user-select: none;
  pointer-events: none;
}

.subtitle-scrim {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: min(42%, 16rem);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.72) 35%, rgba(0, 0, 0, 0.28) 70%, rgba(0, 0, 0, 0) 100%);
  pointer-events: none;
}

.subtitle-band {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 1rem max(1rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  z-index: 1;
}

.subtitle {
  font-family: var(--font-sub);
  font-size: clamp(1.25rem, 3.6vw, 1.9rem);
  line-height: 1.5;
  text-align: center;
  max-width: 44rem;
  white-space: pre-wrap;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.9), 0 1px 2px rgba(0, 0, 0, 0.95), 1px 1px 0 rgba(0, 0, 0, 0.8), -1px -1px 0 rgba(0, 0, 0, 0.8);
}
.subtitle .word {
  white-space: nowrap;
}
.subtitle .ch {
  color: var(--sub-upcoming);
  transition: color 0.08s ease;
}
.subtitle .ch.done {
  color: var(--sub);
}
.subtitle .ch.current {
  color: var(--sub);
  background: rgba(255, 204, 0, 0.16);
  border-radius: 2px;
}
.subtitle .ch.bad,
.subtitle .ch.current.bad {
  color: var(--bad);
  background: rgba(255, 77, 77, 0.28);
}
.subtitle .caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin: 0 -1px;
  vertical-align: text-bottom;
  background: var(--sub);
  animation: caret-blink 1s steps(1) infinite;
}

.type-hint {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.55);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  min-height: 1.2em;
}
.type-hint[hidden] {
  display: none;
}

.capture-input {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  color: transparent;
  background: transparent;
  caret-color: transparent;
  resize: none;
  pointer-events: none;
}

@keyframes caret-blink {
  0%, 50% {
    opacity: 1;
  }
  50.01%, 100% {
    opacity: 0;
  }
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.screen-done {
  overflow: auto;
  background: radial-gradient(ellipse 70% 45% at 50% 0%, rgba(226, 160, 16, 0.18), transparent 55%), #0c0b09;
}

.done-panel {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1.5rem 1.15rem 3rem;
  color: #f4f0e6;
}

.done-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 7vw, 3rem);
  letter-spacing: -0.03em;
  color: var(--sub);
}

.done-lead {
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0.35rem 0 1rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr));
  gap: 0.75rem;
  margin: 0.5rem 0 1.25rem;
}
.stats div {
  padding: 0.75rem 0.85rem;
  border: 1px solid rgba(255, 204, 0, 0.28);
  background: rgba(255, 255, 255, 0.04);
}
.stats dt {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.stats dd {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  margin-top: 0.2rem;
  color: var(--sub);
}

.done-actions {
  display: grid;
  gap: 0.65rem;
  margin-top: 1.25rem;
}

.btn-primary,
.btn-ghost {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0.9rem 1rem;
  cursor: pointer;
  border: 1px solid var(--sub);
}

.btn-primary {
  background: var(--sub);
  color: #111;
}
.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-ghost {
  background: transparent;
  color: var(--sub);
}
.btn-ghost:hover {
  background: rgba(255, 204, 0, 0.08);
}

.screen-done .feedback {
  color: #f4f0e6;
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto;
  }
}