:root {
  --paper: #f6f5f2;
  --stock: #fff;
  --ink: #211f1e;
  --muted: #635d58;
  --rule: #dfdcd6;
  --red: #85353d;
  --green: #305b4a;
  --display: system-ui, "Hiragino Sans", sans-serif;
  --digits: var(--display);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--paper); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font: 1rem/1.6 var(--display);
  background: var(--paper);
}
button, input { font: inherit; }
button { touch-action: manipulation; }
a { color: var(--red); text-underline-offset: .2em; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 4px 12px;
  padding: .75rem max(1rem, calc((100% - 36rem) / 2));
  border-bottom: 1px solid var(--rule);
  background: var(--stock);
  font-size: 14px;
}
.title { font-weight: 700; font-size: 1rem; }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: #856523; }
.dot.online { background: var(--green); }
.dot.offline { background: var(--red); }

main { max-width: 38rem; margin: auto; padding: 1.25rem 1rem max(1.5rem, env(safe-area-inset-bottom)); }
.card {
  min-width: 0;
  margin: 0 0 .85rem;
  padding: clamp(1rem, 4vw, 1.45rem);
  background: var(--stock);
  border: 1px solid var(--rule);
  border-radius: 1rem;
  overflow-wrap: anywhere;
}
.heading { margin: 0 0 .4rem; font-size: clamp(1.45rem, 5vw, 1.85rem); line-height: 1.3; letter-spacing: -.025em; }
.section-title { margin: 0 0 .4rem; font-size: 1.05rem; }
#challenger { color: var(--red); background: #f6e9e9; border-color: #e7ced0; }
#next-challenge { margin: 0; }
#challenge-form label:not(:first-child) { margin-top: .75rem; }
#challenge-seconds { max-width: 8rem; }
details[open] > .row2 { margin-top: .75rem; }
.card.warn { background: #f5e3de; border-color: var(--red); }
.center { text-align: center; }
.muted { color: var(--muted); font-size: 14px; }
.gold { color: var(--red); }
.mincho, .big, .huge { font-family: var(--display); font-weight: 800; }
.big { font-size: 24px; }
.huge { font-size: clamp(28px, 8vw, 46px); line-height: 1.3; }

label { display: block; font-weight: 700; margin-bottom: 6px; }
input[type="text"], input[type="number"], input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #aaa39c;
  border-radius: .6rem;
  background: var(--stock);
  color: var(--ink);
}
input[type="checkbox"] { accent-color: var(--red); }
.btn {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: .65rem .75rem;
  background: var(--ink);
  color: var(--stock);
  border: 1px solid var(--ink);
  border-radius: .65rem;
  font-weight: 700;
  cursor: pointer;
}
.btn.gold, .btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: var(--stock); border-color: var(--rule); color: var(--ink); }
.btn.small { display: inline-block; width: auto; padding: 6px 10px; font-size: 14px; }
.btn:active:not(:disabled), .choice:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.row2 .btn { font-size: 14px; padding-inline: 6px; }
.key { color: var(--green); font-weight: 700; }
.script { padding: 10px 12px; margin: 10px 0 0; border-left: 2px solid var(--red); background: #f4f2ee; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--rule); }
th { color: var(--red); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
td:last-child { min-width: 65px; }
tr.out { color: var(--muted); }
summary { cursor: pointer; font-weight: 700; }

.qhead { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.qnum { font: 800 18px var(--display); color: var(--red); }
.badge { display: inline-block; padding: 2px 6px; border: 1px solid var(--red); color: var(--red); font-size: 14px; }
.qtext {
  margin: .25rem 0 1rem;
  font: 750 clamp(1.35rem, 5vw, 1.75rem)/1.4 var(--display);
  letter-spacing: -.02em;
}
.timer { height: 5px; border-radius: 99px; overflow: hidden; background: #ebe9e4; }
.timer > i { display: block; height: 100%; background: var(--green); transform-origin: left; }
.timer.hurry > i { background: var(--red); }
.timeleft { color: var(--red); font: 700 26px var(--digits); font-variant-numeric: tabular-nums; }

.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 15px; }
.choice {
  --accent: var(--red);
  --tint: #f8eded;
  min-height: 86px;
  padding: 12px 8px;
  color: var(--ink);
  font: 800 clamp(16px, 4.5vw, 24px)/1.4 var(--display);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, white);
  border-radius: .85rem;
  background: var(--tint);
  cursor: pointer;
  overflow-wrap: anywhere;
}
.choice:nth-child(2) {
  --accent: var(--green);
  --tint: #eaf2ed;
}
.choice:nth-child(3) { --accent: #5c5433; --tint: #e4dfba; }
.choice:nth-child(4) { --accent: #7b4a23; --tint: #ecdbc0; }
.binary .choice {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: .3rem;
  min-height: 7.2rem;
  color: var(--accent);
  font-size: 1rem;
}
.choice-symbol { font-size: 2.6rem; font-weight: 500; line-height: 1; }
.choice .n, .choice .tag { display: block; font: 700 14px var(--digits); }
.choice:disabled { cursor: default; }
.choices.locked .choice:not(.mine), .choices.revealed .choice:not(.mine):not(.correct) { background: #efeade; border-color: var(--rule); }
.choice.mine { box-shadow: inset 0 0 0 2px var(--accent); }
.choice.correct { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .btn:active:not(:disabled), .choice:active:not(:disabled) { transform: none; }
}

.verdict { margin: 4px 0; font: 900 clamp(28px, 7vw, 42px)/1.3 var(--display); }
.verdict.ok { color: var(--red); }
.verdict.ng { color: var(--green); }
.stat { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 26px; margin: 12px 0; }
.stat div { text-align: center; }
.stat b { display: block; font: 700 30px var(--digits); }
ol.rank { list-style: none; margin: 0; padding: 0; }
ol.rank li {
  display: grid;
  grid-template-columns: 2.6em minmax(0, 1fr) auto;
  gap: 7px;
  align-items: baseline;
  padding: 8px 4px;
  border-bottom: 1px solid var(--rule);
  font-weight: 700;
}
ol.rank .r { font-family: var(--display); color: var(--red); }
ol.rank .s { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
ol.rank li.me { background: #f5eee8; }
.bars { display: grid; gap: 8px; }
.bars .row { display: grid; grid-template-columns: 2em 1fr 3.4em; gap: 8px; align-items: center; }
.bars .track { height: 14px; background: #f4f2ee; overflow: hidden; border: 1px solid var(--rule); }
.bars .fill { height: 100%; background: var(--red); }
.bars .row:nth-child(2) .fill { background: var(--green); }

.toast { background: var(--ink); color: var(--stock); text-align: center; }
.toast {
  position: fixed;
  z-index: 40;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  font-size: 14px;
}

#title-form, #challenge-form { display: grid; gap: .65rem; }
#title-form label, #challenge-form label { margin: 0; }
#challenge-controls > :is(form, .btn, .qtext) { margin-top: 1rem; }
.nominee {
  margin: .75rem 0;
  padding: .75rem 1rem;
  text-align: center;
  color: var(--red);
  background: #f8eded;
  border: 1px solid #e7ced0;
  border-radius: .85rem;
  font-size: 1.2rem;
  font-weight: 750;
}
