:root {
  --bg: #000;
  --card: #000;
  --line: #2f3336;
  --text: #e7e9ea;
  --sub: #71767b;
  --blue: #1d9bf0;
  --pink: #f91880;
  --green: #00ba7c;
  --red: #f4212e;
  --mark: rgba(255, 212, 0, 0.32);
  --choice: #16181c;
  --choice-hover: #1d1f23;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #fff;
    --card: #fff;
    --line: #eff3f4;
    --text: #0f1419;
    --sub: #536471;
    --mark: rgba(255, 212, 0, 0.55);
    --choice: #f7f9f9;
    --choice-hover: #eff3f4;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.app {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.home { color: var(--sub); text-decoration: none; font-size: 14px; }
.home:hover { color: var(--text); }
.hud { display: flex; gap: 16px; font-size: 14px; color: var(--sub); }
.hud b { color: var(--text); font-variant-numeric: tabular-nums; }

.screen { padding: 0 0 24px; flex: 1; }

/* ---------- タイトル ---------- */
.title {
  margin: 28px 16px 4px;
  font-size: clamp(26px, 7vw, 38px);
  line-height: 1.25;
  letter-spacing: 0.01em;
}
.title__em {
  color: var(--blue);
  background: linear-gradient(transparent 62%, var(--mark) 62%);
}
.lead { margin: 0 16px 16px; color: var(--sub); font-size: 15px; }

/* ---------- 投稿カード ---------- */
.post {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.post__avatar {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: color-mix(in srgb, var(--c, #555) 30%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c, #555) 60%, transparent);
}
.post__main { flex: 1; min-width: 0; }
.post__head {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
}
.post__name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.post__badge {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  flex: 0 0 auto;
  align-self: center;
}
.post__meta { color: var(--sub); overflow: hidden; text-overflow: ellipsis; }
.post__body { font-size: 16px; margin-top: 2px; }
.line { margin: 0; overflow-wrap: anywhere; }
.line--key { border-radius: 3px; }
.post.is-revealed .line--key {
  background: linear-gradient(transparent 55%, var(--mark) 55%);
  animation: mark 0.6s ease-out;
}
@keyframes mark { from { background-size: 0 100%; } to { background-size: 100% 100%; } }
.post .line--key { background-repeat: no-repeat; }


.post__actions {
  display: flex;
  justify-content: space-between;
  max-width: 420px;
  margin-top: 10px;
  color: var(--sub);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* ---------- タイマー ---------- */
.timer { height: 4px; background: var(--line); }
.timer__bar {
  height: 100%;
  width: 100%;
  background: var(--blue);
  transform-origin: left center;
}
.timer__bar.is-low { background: var(--red); }

/* ---------- 問題と選択肢 ---------- */
.question { padding: 16px 16px 4px; display: flex; gap: 6px; }
.question__label { margin: 0; color: var(--blue); font-weight: 700; font-size: 18px; }
.question__text { margin: 0; font-weight: 700; font-size: 18px; }

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 16px;
}
.choice {
  position: relative;
  min-height: 56px;
  padding: 10px 12px 10px 36px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--choice);
  text-align: left;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.choice::before {
  content: attr(data-key);
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--sub);
  font-size: 13px;
  font-weight: 700;
}
.choice:hover:not(:disabled) { background: var(--choice-hover); border-color: var(--sub); }
.choice:active:not(:disabled) { transform: scale(0.98); }
.choice:disabled { cursor: default; opacity: 0.55; }
.choice.is-correct { opacity: 1; border-color: var(--green); background: color-mix(in srgb, var(--green) 18%, var(--choice)); }
.choice.is-wrong { opacity: 1; border-color: var(--red); background: color-mix(in srgb, var(--red) 18%, var(--choice)); }

/* ---------- 判定 ---------- */
@keyframes unfold { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.feedback {
  margin: 4px 16px 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  animation: unfold 0.2s ease-out;
}
.feedback__mark { margin: 0; font-size: 22px; font-weight: 800; }
.feedback__mark small { margin-left: 8px; font-size: 14px; font-weight: 700; color: var(--sub); }
.feedback__mark.ok { color: var(--green); }
.feedback__mark.ng { color: var(--red); }
.feedback__text { margin: 4px 0 12px; color: var(--sub); font-size: 14px; }
.feedback__text b { color: var(--text); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
}
.btn:hover { opacity: 0.88; }
.btn--start { margin-top: 12px; background: var(--blue); color: #fff; min-width: 160px; }
.btn--x { background: var(--text); color: var(--bg); }
.btn--ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.feedback .btn { width: 100%; }

/* ---------- 結果 ---------- */
.post--result { margin-top: 16px; }
.post--result .post__body { font-size: 17px; }
.result-actions { display: grid; gap: 10px; padding: 16px; }

.review-title { margin: 8px 16px 4px; font-size: 18px; }
.review { list-style: none; margin: 0; padding: 0; }
.review li {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.review__q { font-weight: 700; }
.review__q .ok { color: var(--green); }
.review__q .ng { color: var(--red); }
.review__lines { margin: 6px 0 0; color: var(--sub); }
.review__lines .key { color: var(--text); background: linear-gradient(transparent 55%, var(--mark) 55%); }
.review__note { margin-top: 4px; color: var(--sub); font-size: 12px; }

.foot {
  padding: 20px 16px 32px;
  color: var(--sub);
  font-size: 12px;
  text-align: center;
  border-top: 1px solid var(--line);
}
.foot a { color: var(--sub); }

@media (max-width: 380px) {
  .choices { grid-template-columns: 1fr; }
  .choice { min-height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
