:root {
  --bg: #fbf7f1;
  --card: #ffffff;
  --text: #1d1a17;
  --muted: #6f675f;
  --line: #e4dcd1;
  --accent: #e2572b;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --ok: #1f7a4d;
  --think: #a66a00;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14110f;
    --card: #1f1b18;
    --text: #f4eee6;
    --muted: #a59b90;
    --line: #342e29;
    --accent: #ff7a4d;
    --accent-text: #1a0d07;
    --danger: #ff8a80;
    --ok: #5fd39a;
    --think: #ffc257;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}
#app {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}
.screen { display: flex; flex-direction: column; gap: 16px; }
.screen[hidden] { display: none; }

.logo { font-size: 44px; margin: 24px 0 0; letter-spacing: -1px; }
.tag { margin: -12px 0 8px; color: var(--muted); }
h2 { margin: 16px 0 0; font-size: 30px; }
.muted, small { color: var(--muted); font-size: 14px; }
.hint { color: var(--muted); font-size: 14px; margin: 0; }
.error { color: var(--danger); margin: 0; font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span:first-child, legend { font-weight: 600; font-size: 14px; padding: 0; margin-bottom: 6px; }
input[type="text"] {
  font: inherit; color: inherit; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 14px; width: 100%;
}
.choice {
  display: flex; flex-direction: row; align-items: flex-start; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
}
.choice input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.choice span { display: flex; flex-direction: column; }

button {
  font: inherit; font-weight: 600; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; padding: 14px 12px; min-height: 52px; cursor: pointer;
}
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.45; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
button.danger { color: var(--danger); }
button.big { min-height: 64px; font-size: 20px; }
button.link { background: none; border: 0; min-height: 0; padding: 4px 0; color: var(--muted); font-weight: 400; text-decoration: underline; align-self: flex-start; }
button.selected { outline: 3px solid var(--accent); }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 20px;
  padding: 10px 16px; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
}
.pill::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); }
.pill[data-status="listening"]::before { background: var(--ok); }
.pill[data-status="thinking"]::before { background: var(--think); }
.pill[data-status="speaking"]::before { background: var(--accent); animation: pulse 1s infinite; }
.pill[data-status="paused"]::before, .pill[data-status="ended"]::before { background: var(--muted); }
@keyframes pulse { 50% { transform: scale(1.5); opacity: 0.6; } }
@media (prefers-reduced-motion: reduce) { .pill::before { animation: none !important; } }

.banner { background: var(--card); border: 1px solid var(--danger); color: var(--danger); border-radius: 12px; padding: 12px 14px; font-weight: 600; }
.banner[hidden] { display: none; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card[hidden] { display: none; }
#question-text { font-size: 22px; font-weight: 600; line-height: 1.25; }

.scores { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.scores li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; font-size: 20px;
}
.scores li.active { border-color: var(--accent); }
.scores li span { overflow-wrap: anywhere; }
.scores li b { font-size: 26px; font-variant-numeric: tabular-nums; }

.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tally { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tally .muted { grid-column: 1 / -1; }
.tally button { font-size: 15px; font-weight: 500; min-height: 48px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row button { flex: 1; min-width: 52px; }

.log summary { color: var(--muted); font-size: 14px; padding: 8px 0; }
.log ol { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; font-size: 15px; }
.log li { overflow-wrap: anywhere; }
.log li[data-who="kabooy"] { color: var(--accent); }
