:root {
  --ink: #2f2f33;
  --soft: rgba(47, 47, 51, .62);
  --panel: rgba(255, 255, 255, .62);
  --line: rgba(47, 47, 51, .12);
  --accent: #f2511f;
  --ok: #1fa971;
  --bad: #e5484d;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%; overflow: hidden; background: #e2e0db;
  overscroll-behavior: none; user-select: none; -webkit-user-select: none;
}

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#stage:active { cursor: grabbing; }

body.capture #ui, body.capture #start { display: none; }
body.capture #stage { position: static; }

#ui { position: fixed; inset: 0; pointer-events: none; display: flex; flex-direction: column; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
#ui > * { pointer-events: auto; }

.pill {
  background: var(--panel); border: 1px solid rgba(255, 255, 255, .7); border-radius: 999px;
  backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: 0 6px 24px rgba(60, 50, 40, .12); padding: 8px 14px; font-size: 14px; line-height: 1.2;
}

#top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none; }
#chip { display: flex; gap: 8px; align-items: baseline; }
#chip b { font-weight: 600; color: var(--soft); font-size: 12px; letter-spacing: .04em; }
#chipName { font-weight: 700; font-size: 15px; }
#score b { color: var(--accent); font-size: 16px; }
body:not(.quiz) #score { visibility: hidden; }

#toast {
  align-self: center; margin-top: 12px; opacity: 0; transform: translateY(-6px); transition: .3s; font-weight: 600;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: none; }

#quiz {
  margin: auto auto 12px; width: min(420px, 100%); background: var(--panel); border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, .7); backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
  box-shadow: 0 10px 34px rgba(60, 50, 40, .16); padding: 12px; animation: rise .28s cubic-bezier(.2, .9, .3, 1.2);
}
#quiz[hidden] { display: none; }
#quiz h2 { margin: 2px 4px 10px; font-size: 14px; font-weight: 600; color: var(--soft); }
#quizOpts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#quizOpts button {
  font: inherit; font-size: 15px; font-weight: 600; color: var(--ink); padding: 12px 8px; border-radius: 14px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .78); cursor: pointer; transition: .15s;
}
#quizOpts button:hover { background: #fff; transform: translateY(-1px); }
#quizOpts button:active { transform: scale(.97); }
#quizOpts button.right { background: var(--ok); border-color: var(--ok); color: #fff; }
#quizOpts button.wrong { background: var(--bad); border-color: var(--bad); color: #fff; }
#quizOpts button:disabled { cursor: default; transform: none; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

#bar {
  margin-top: auto; background: var(--panel); border-radius: 22px; border: 1px solid rgba(255, 255, 255, .7);
  backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
  box-shadow: 0 10px 34px rgba(60, 50, 40, .16); padding: 12px 12px 8px; width: min(760px, 100%); align-self: center;
}
#quiz:not([hidden]) + #bar { margin-top: 0; }

#track { position: relative; height: 22px; cursor: pointer; touch-action: none; }
#track::before, #trackFill { content: ""; position: absolute; left: 0; top: 9px; height: 4px; border-radius: 4px; }
#track::before { right: 0; background: rgba(47, 47, 51, .14); }
#trackFill { background: var(--accent); width: 0; }
#knob {
  position: absolute; top: 4px; left: 0; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffb26b, var(--accent) 60%, #b5300c);
  box-shadow: 0 2px 6px rgba(160, 50, 10, .45);
}
#marks i { position: absolute; top: 6px; width: 2px; height: 10px; margin-left: -1px; border-radius: 2px; background: rgba(47, 47, 51, .28); }
#marks i.done { background: #fff; }

#row { display: flex; align-items: center; gap: 2px; margin-top: 2px; }
.grow { flex: 1; }
#time { font-size: 12px; color: var(--soft); font-variant-numeric: tabular-nums; margin-left: 6px; white-space: nowrap; }

button.icon, button.txt {
  border: 0; background: transparent; color: var(--ink); cursor: pointer; border-radius: 12px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center; transition: background .15s; font: inherit;
}
button.icon { width: 38px; }
button.txt { padding: 0 10px; font-size: 13px; font-weight: 600; color: var(--soft); }
button.txt.on { color: var(--accent); }
button.icon:hover, button.txt:hover { background: rgba(47, 47, 51, .08); }
button.icon svg { width: 22px; height: 22px; fill: currentColor; }
#play { background: var(--ink); color: #fff; border-radius: 50%; margin-right: 4px; }
#play:hover { background: #000; }
body:not(.playing) .i-pause, body.playing .i-play, body:not(.muted) .i-muted, body.muted .i-vol { display: none; }

#start {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 20px;
  background: rgba(226, 224, 219, .45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: opacity .45s;
}
#start.gone { opacity: 0; pointer-events: none; }
#card {
  text-align: center; background: rgba(255, 255, 255, .78); border: 1px solid #fff; border-radius: 30px;
  padding: 34px 34px 26px; width: min(380px, 100%); box-shadow: 0 24px 70px rgba(60, 50, 40, .22);
}
.kicker { margin: 0; font-size: 11px; letter-spacing: .32em; color: var(--accent); font-weight: 700; }
#card h1 { margin: 8px 0 10px; font-size: 40px; letter-spacing: .06em; }
.sub { margin: 0 0 22px; color: var(--soft); font-size: 15px; line-height: 1.7; }
#go {
  font: inherit; font-size: 17px; font-weight: 700; color: #fff; border: 0; cursor: pointer; padding: 14px 44px; border-radius: 999px;
  background: linear-gradient(180deg, #ff7a3d, var(--accent)); box-shadow: 0 10px 24px rgba(242, 81, 31, .38); transition: .15s;
}
#go:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(242, 81, 31, .45); }
#go:active { transform: scale(.97); }
#go:disabled { opacity: .6; cursor: progress; }
.hint { margin: 18px 0 0; font-size: 12px; color: rgba(47, 47, 51, .45); }

@media (max-width: 520px) {
  #row { gap: 0; }
  button.icon { width: 34px; }
  button.txt { padding: 0 7px; }
  #time { display: none; }
  #card h1 { font-size: 34px; }
}
