:root {
  color-scheme: light;
  --ink: #16202a;
  --muted: #607080;
  --line: #d9e1e8;
  --surface: #ffffff;
  --surface-soft: #f4f7f9;
  --accent: #16767a;
  --accent-dark: #0f5f63;
  --shadow: 0 24px 70px rgba(24, 45, 61, 0.16);
  --radius: 22px;
}

* { box-sizing: border-box; }

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

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.page-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vw, 56px);
}

.cdi-player {
  width: min(1180px, 100%);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid rgba(255,255,255,.85);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(16px, 2.4vw, 30px);
  backdrop-filter: blur(16px);
}

.player-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-weight: 750;
  letter-spacing: .11em;
  text-transform: uppercase;
  font-size: .75rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.55rem, 3.2vw, 2.55rem);
  line-height: 1.06;
  letter-spacing: -.035em;
}

.icon-button,
.center-play,
.primary-button,
.secondary-button,
.text-button {
  border: 0;
  cursor: pointer;
}

.icon-button {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  background: var(--surface-soft);
  transition: transform .18s ease, background .18s ease;
}

.icon-button:hover { background: #e7eef1; transform: translateY(-1px); }
.icon-button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.video-stage {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  background: #dce5e9;
  box-shadow: inset 0 0 0 1px rgba(20, 45, 58, .08);
  outline: none;
  cursor: pointer;
}

.video-stage:focus-visible { box-shadow: 0 0 0 4px rgba(22,118,122,.25); }
.video-stage video { width: 100%; height: 100%; display: block; object-fit: cover; }

.scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 52%, rgba(5,17,22,.13) 72%, rgba(5,17,22,.55) 100%);
  opacity: .64;
}

.step-card {
  position: absolute;
  left: clamp(14px, 3vw, 34px);
  bottom: clamp(14px, 3vw, 30px);
  width: min(520px, calc(100% - 100px));
  padding: clamp(12px, 2vw, 19px) clamp(14px, 2.4vw, 22px);
  color: #fff;
  background: rgba(10, 27, 34, .70);
  border: 1px solid rgba(255,255,255,.23);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  transition: opacity .2s ease, transform .2s ease;
}

.step-card.is-hidden { opacity: 0; transform: translateY(10px); pointer-events: none; }
.step-card.is-playing { opacity: .14; }

.step-number {
  display: block;
  font-size: .73rem;
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
  opacity: .78;
}

.step-card h2 {
  margin: 4px 0 3px;
  font-size: clamp(1rem, 2.2vw, 1.45rem);
  line-height: 1.15;
}

.step-card p {
  margin: 0;
  max-width: 62ch;
  font-size: clamp(.78rem, 1.4vw, .98rem);
  line-height: 1.45;
  opacity: .9;
}

.click-hint {
  display: inline-block;
  margin-top: 9px;
  font-size: clamp(.68rem, 1.25vw, .82rem);
  font-weight: 680;
  opacity: .75;
}

.center-play {
  position: absolute;
  right: clamp(14px, 3vw, 34px);
  bottom: clamp(14px, 3vw, 30px);
  width: clamp(48px, 6vw, 68px);
  height: clamp(48px, 6vw, 68px);
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: rgba(22,118,122,.93);
  box-shadow: 0 12px 28px rgba(4,31,35,.28);
  transition: transform .18s ease, opacity .18s ease, background .18s ease;
}
.center-play:hover { transform: scale(1.04); background: var(--accent-dark); }
.center-play.is-hidden { opacity: 0; pointer-events: none; transform: scale(.88); }
.center-play svg { width: 34%; fill: currentColor; transform: translateX(4%); }

.progress-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 15px 2px 10px;
}

.step-dots {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(var(--step-count, 10), minmax(8px, 1fr));
  gap: 6px;
}

.step-dot {
  height: 7px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--line);
  cursor: pointer;
  transition: background .18s ease, transform .18s ease;
}
.step-dot:hover { transform: scaleY(1.45); }
.step-dot.is-complete { background: color-mix(in srgb, var(--accent) 55%, white); }
.step-dot.is-current { background: var(--accent); }

.time-label { flex: 0 0 auto; color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }

.controls {
  display: grid;
  grid-template-columns: 1fr minmax(180px, 1.4fr) 1fr;
  gap: 10px;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  font-weight: 720;
  transition: transform .16s ease, background .16s ease, opacity .16s ease;
}
.primary-button { color: #fff; background: var(--accent); }
.primary-button:hover { background: var(--accent-dark); transform: translateY(-1px); }
.secondary-button { color: var(--ink); background: var(--surface-soft); border: 1px solid var(--line); }
.secondary-button:hover { background: #eaf0f2; transform: translateY(-1px); }
.primary-button svg, .secondary-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
button:disabled { cursor: default; opacity: .38; transform: none !important; }

.utility-row {
  margin-top: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.toggle-label { display: inline-flex; align-items: center; gap: 9px; color: var(--muted); font-size: .88rem; cursor: pointer; }
.toggle-label input { width: 18px; height: 18px; accent-color: var(--accent); }
.text-button { padding: 5px 0; color: var(--accent-dark); background: transparent; font-weight: 720; }
.text-button:hover { text-decoration: underline; }

.keyboard-help { margin: 10px 0 0; color: var(--muted); font-size: .74rem; text-align: center; }
kbd { display: inline-block; min-width: 22px; padding: 2px 5px; border: 1px solid #ccd6db; border-bottom-width: 2px; border-radius: 5px; background: #f8fafb; color: #46545e; font: inherit; font-size: .7rem; }

.cdi-player:fullscreen { width: 100vw; height: 100vh; max-width: none; border-radius: 0; display: flex; flex-direction: column; background: #f6f8f9; padding: 18px; }
.cdi-player:fullscreen .video-stage { flex: 1; min-height: 0; }
.cdi-player:fullscreen .keyboard-help { display: none; }

@media (max-width: 680px) {
  .page-shell { padding: 0; display: block; }
  .cdi-player { min-height: 100vh; border-radius: 0; padding: 14px; }
  .player-header { margin-bottom: 12px; }
  .step-card { width: calc(100% - 82px); }
  .step-card p { display: none; }
  .click-hint { margin-top: 5px; }
  .controls { grid-template-columns: 1fr 1.4fr; }
  #restartButton { grid-column: 1 / -1; }
  .keyboard-help { display: none; }
  .utility-row { align-items: flex-start; flex-direction: column; gap: 9px; }
}

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