:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --subtle: #f1f4ef;
  --border: #e2e7df;
  --border-strong: #c8d2c3;
  --ink: #1c241f;
  --ink-2: #4c5951;
  --muted: #76857b;
  --accent: #2c6449;
  --accent-hover: #225039;
  --accent-soft: #e7f1eb;
  --danger: #b5453d;
  --danger-soft: #fbeeed;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(28, 36, 31, 0.045);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, p, ul { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

.shell {
  width: 100%;
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(14px, 2vw, 24px) clamp(14px, 3vw, 44px) calc(32px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 17px; font-weight: 600; flex-shrink: 0;
}
.brand strong { display: block; font-size: 15px; line-height: 1.25; }
.sub { font-size: 12px; color: var(--muted); }

.badge {
  font-size: 12px; font-weight: 500; color: var(--accent);
  background: var(--accent-soft); padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}

.stack { display: flex; flex-direction: column; gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}

h1 { font-size: 20px; font-weight: 600; }
h2 { font-size: 16px; font-weight: 600; }
.lead { color: var(--ink-2); font-size: 14.5px; }
.hint { font-size: 13px; color: var(--muted); }
.tips {
  padding-left: 18px; color: var(--ink-2); font-size: 13.5px;
  display: flex; flex-direction: column; gap: 6px;
}

.form-stack { display: flex; flex-direction: column; gap: 16px; margin-top: 4px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.label { font-size: 14px; font-weight: 600; color: var(--ink); }

.pill-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.pill-row.two-col { grid-template-columns: repeat(2, 1fr); }
.pill-row.best-grid { grid-template-columns: repeat(3, 1fr); }

.pill {
  min-height: 44px; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--ink-2); font-size: 14px; font-weight: 500; transition: all 0.15s;
}
.pill:hover:not(:disabled) { border-color: var(--border-strong); color: var(--ink); }
.pill.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.pill:disabled { opacity: 0.45; cursor: not-allowed; }

.primary-btn {
  width: 100%; min-height: 46px; border: 0; border-radius: 12px;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 600;
  transition: background 0.15s, opacity 0.15s;
}
.primary-btn:hover:not(:disabled) { background: var(--accent-hover); }
.primary-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.error {
  font-size: 13px; color: var(--danger); background: var(--danger-soft);
  padding: 8px 12px; border-radius: 8px;
}

/* Scenario card */
.scenario-card { border-left: 4px solid var(--accent); gap: 8px; }
.scenario-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kicker { font-size: 12.5px; font-weight: 600; color: var(--accent); }
.scenario-text { font-size: 16px; font-weight: 600; color: var(--ink); }
.scenario-goal { font-size: 14.5px; color: var(--ink-2); }

/* Clip card */
.clip-card { gap: 12px; }
.clip-card.is-playing { border-color: var(--accent); }
.clip-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.clip-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.clip-status { font-size: 12px; color: var(--muted); }
.clip-status.unlocked { color: var(--accent); font-weight: 500; }

.player-row { display: flex; align-items: center; gap: 12px; }
.play-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--accent);
  background: var(--accent-soft); color: var(--accent); font-size: 16px;
  display: grid; place-items: center; flex-shrink: 0; transition: all 0.15s;
}
.play-btn.playing { background: var(--accent); color: #fff; }
.progress-wrap { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.progress-bar {
  width: 100%; height: 6px; border-radius: 999px; background: var(--subtle); overflow: hidden;
}
.progress-fill { height: 100%; width: 0%; background: var(--accent); transition: width 0.15s linear; }
.time-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.score-block { display: flex; flex-direction: column; gap: 6px; }
.score-head { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.score-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.score-btn {
  min-height: 40px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--ink-2); font-size: 14px; font-weight: 600;
  transition: all 0.15s;
}
.score-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.score-btn:disabled { opacity: 0.38; cursor: not-allowed; }

.done-card { text-align: center; align-items: center; padding: 36px 22px; }
.done-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 26px; font-weight: 700;
}
.done-actions { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }

@media (min-width: 600px) {
  .pill-row { grid-template-columns: repeat(4, 1fr); }
  .pill-row.two-col { grid-template-columns: repeat(2, 1fr); }
  .pill-row.best-grid { grid-template-columns: repeat(6, 1fr); }
}

@media (min-width: 900px) {
  #view-welcome, #view-done {
    max-width: 760px;
    width: 100%;
    margin: auto;
    padding: 28px 32px;
  }
  #clips-container {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }
  .best-card .primary-btn {
    max-width: 320px;
    align-self: flex-end;
  }
}
