:root {
  --bg: #f2eee4;
  --card: #fffdf7;
  --ink: #1c211e;
  --muted: #6c716b;
  --line: #e4ddcd;
  --soft: #f6f2e8;
  --felt: #0e3f2f;
  --felt-2: #0a3125;
  --felt-hi: #17604a;
  --pen: #d23a24;
  --pen-soft: rgba(210, 58, 36, 0.08);
  --gold: #c9a45c;
  --ok: #1f7a55;
  --input: #ffffff;
  --shadow: 0 1px 0 rgba(60, 45, 20, 0.04), 0 8px 24px -12px rgba(60, 45, 20, 0.18);
  --tw: clamp(19px, calc((100vw - 50px) / 14.4), 34px);
  --sans: "Zen Kaku Gothic New", system-ui, -apple-system, "Hiragino Sans", sans-serif;
  --serif: "Shippori Mincho B1", "Hiragino Mincho ProN", serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101412;
    --card: #181d1a;
    --ink: #e9e5dc;
    --muted: #9aa097;
    --line: #2a312d;
    --soft: #1e2420;
    --felt: #0c3326;
    --felt-2: #08261c;
    --felt-hi: #15553f;
    --pen: #ff6b52;
    --pen-soft: rgba(255, 107, 82, 0.1);
    --ok: #4fc08d;
    --input: #111513;
    --shadow: 0 8px 24px -14px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #101412;
  --card: #181d1a;
  --ink: #e9e5dc;
  --muted: #9aa097;
  --line: #2a312d;
  --soft: #1e2420;
  --felt: #0c3326;
  --felt-2: #08261c;
  --felt-hi: #15553f;
  --pen: #ff6b52;
  --pen-soft: rgba(255, 107, 82, 0.1);
  --ok: #4fc08d;
  --input: #111513;
  --shadow: 0 8px 24px -14px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { overflow-x: hidden; scroll-padding-top: 64px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; }

/* ---------- 牌 ---------- */

.tile {
  --w: var(--tw);
  position: relative;
  display: inline-block;
  flex: none;
  width: var(--w);
  height: calc(var(--w) * 4 / 3);
  vertical-align: bottom;
}
/* 牌の本体はCSS、絵柄だけ素材 */
.tile::before {
  content: "";
  position: absolute;
  inset: 0 0.5px;
  border-radius: calc(var(--w) * 0.13);
  border: 1px solid #c4bba8;
  background:
    var(--face, none) 50% 42% / 80% 78% no-repeat,
    linear-gradient(180deg, #ffffff 0%, #fbf8f1 78%, #e9e0cd 82%, #ddd2bb 100%);
  box-shadow: 0 1px 2px rgba(40, 30, 10, 0.18);
}
.tile.back::before {
  border-color: #a8651a;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 40%),
    linear-gradient(180deg, #eaa646 0%, #d98a2b 78%, #b9701f 82%, #a6621a 100%);
}
.tile.side { width: calc(var(--w) * 4 / 3); height: var(--w); }
.tile.side::before {
  inset: auto;
  left: 50%;
  top: 50%;
  width: var(--w);
  height: calc(var(--w) * 4 / 3);
  transform: translate(-50%, -50%) rotate(-90deg);
}
.tile.inline { --w: 1.15em; vertical-align: -0.3em; margin: 0 0.1em; }

.hand {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 6px calc(var(--tw) * 0.32);
}
.grp { display: inline-flex; align-items: flex-end; }
.grp.win { gap: 3px; }
.win-label {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  color: var(--muted);
  writing-mode: vertical-rl;
  letter-spacing: 0.1em;
  padding-top: 2px;
}
.tile-row { display: inline-flex; align-items: flex-end; vertical-align: middle; }
.tile-row.small { --tw: 22px; }

/* ---------- ヘッダー ---------- */

.top {
  position: relative;
  color: #f3efe4;
  background:
    radial-gradient(120% 140% at 85% -20%, var(--felt-hi) 0%, transparent 55%),
    radial-gradient(90% 120% at 0% 120%, var(--felt-2) 0%, transparent 60%),
    var(--felt);
  overflow: hidden;
}
.top::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .5 0'/></filter><rect width='120' height='120' filter='url(%23n)'/></svg>");
  mix-blend-mode: overlay;
}
.top-inner {
  position: relative;
  z-index: 1;
  max-width: 820px;
  margin: 0 auto;
  padding: 28px 16px 22px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.kicker {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: rgba(243, 239, 228, 0.72);
  display: flex;
  align-items: center;
  gap: 8px;
}
.badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 1px 8px;
  border: 1px solid rgba(201, 164, 92, 0.7);
  color: var(--gold);
  border-radius: 999px;
}
.top h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(30px, 7vw, 44px);
  line-height: 1.15;
  letter-spacing: 0.04em;
}
.top h1 .sp { display: none; }
.exam {
  margin: 10px 0 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 15px;
  color: var(--gold);
  letter-spacing: 0.06em;
}
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.tabs button {
  border: 0;
  background: transparent;
  color: rgba(243, 239, 228, 0.75);
  padding: 8px 18px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 16px;
  line-height: 1.25;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 96px;
}
.tabs button small { font-size: 11px; font-weight: 500; opacity: 0.8; }
.tabs button[aria-selected="true"] {
  background: #f8f4ea;
  color: var(--felt);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* ---------- 問題ナビ ---------- */

.qnav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.qnav::-webkit-scrollbar { display: none; }
/* 収まる時は中央、はみ出す時は左端から横スクロール */
.qnav > :first-child { margin-left: auto; }
.qnav > :last-child { margin-right: auto; }
body[data-tab="essay"] .qnav { display: none; }
.chip {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 40px;
  padding: 3px 8px 2px;
  border-radius: 10px;
  text-decoration: none;
  border: 1px solid var(--line);
  background: var(--card);
  line-height: 1.2;
}
.chip b { font-family: var(--serif); font-size: 16px; }
.chip small { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.full { border-color: color-mix(in srgb, var(--felt-hi) 55%, var(--line)); }
.chip.full small { color: var(--felt-hi); font-weight: 700; }

/* ---------- 本文 ---------- */

main {
  max-width: 820px;
  margin: 0 auto;
  padding: 16px 12px 8px;
  display: grid;
  gap: 16px;
}
main > * { min-width: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px 14px;
}

.sec-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--ink);
  margin-bottom: 12px;
}
.sec-title { display: flex; align-items: baseline; gap: 4px; font-family: var(--serif); }
.sec-label { font-size: 15px; font-weight: 600; }
.sec-no { font-size: 34px; font-weight: 800; line-height: 1; }
.sec-meta { display: flex; align-items: center; gap: 10px; }
.pts {
  font-size: 13px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 10px;
  white-space: nowrap;
}
.sec-score { font-family: var(--serif); color: var(--pen); font-size: 15px; white-space: nowrap; }
.sec-score b { font-size: 26px; }

.prompt p { margin: 0; font-weight: 500; }
.prompt .note, .note { margin-top: 4px; font-size: 14px; color: var(--muted); font-weight: 400; }

/* 例 */
.examples { margin: 14px 0 4px; display: grid; gap: 8px; }
.example {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--soft);
  border-radius: 12px;
  --tw: clamp(16px, calc((100vw - 96px) / 14.6), 28px);
}
.ex-tag {
  grid-row: span 2;
  align-self: start;
  font-family: var(--serif);
  font-weight: 800;
  font-size: 14px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
  color: var(--muted);
}
.ex-q { min-width: 0; }
.ex-a { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.ex-a > span:first-child { font-size: 11px; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }

/* 小問 */
.items { display: grid; }
.item {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 4px 8px;
  padding: 16px 0;
  border-top: 1px dashed var(--line);
}
.items .item:first-child { border-top: 0; }
.item[hidden] { display: none; }
.ibody { min-width: 0; display: grid; gap: 10px; container-type: inline-size; }
.ibody > .hand, .ibody > .hand-wrap .hand { --tw: min(36px, calc(100cqw / 14.3)); }
.ex-q { container-type: inline-size; }
.ex-q > .hand, .ex-q > .hand-wrap .hand { --tw: min(28px, calc(100cqw / 14.6)); }
.ibody.row { grid-template-columns: 1fr auto; align-items: center; gap: 12px; }
.inum {
  position: relative;
  font-family: var(--serif);
  font-weight: 800;
  font-size: 20px;
  line-height: 1.5;
  text-align: center;
}
.stmt { margin: 0; }
.stmt.fill { line-height: 2.3; }
.hint { margin: -4px 0 0; font-size: 13px; color: var(--muted); }
.hand-wrap { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 10px; }
.seat {
  font-size: 13px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 7px;
  white-space: nowrap;
}

/* 入力 */
.ans { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.t-count .ans, .t-score .ans, .t-scenario .ans { flex-wrap: nowrap; }
.num, .txt {
  font-size: 18px;
  height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--input);
  outline: none;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.num { text-align: right; }
.num:focus, .txt:focus { border-color: var(--felt-hi); box-shadow: 0 0 0 3px color-mix(in srgb, var(--felt-hi) 22%, transparent); }
.num::placeholder, .txt::placeholder { color: color-mix(in srgb, var(--muted) 60%, transparent); }
.txt.wide { width: min(100%, 320px); }
.txt.blank {
  width: 8.5em;
  height: 38px;
  margin: 0 6px;
  text-align: center;
  border-width: 0 0 2px;
  border-radius: 6px 6px 0 0;
  background: var(--soft);
}
.txt.blank.short { width: 4.5em; }
.unit { font-weight: 700; }
.slash { font-size: 22px; color: var(--muted); padding-top: 16px; }
.score-ko { align-items: flex-start; }
.score-ko label { display: grid; gap: 0; }
.score-ko small { font-size: 11px; color: var(--muted); padding-left: 4px; }
input:disabled, button:disabled { cursor: default; }
input:disabled { opacity: 1; -webkit-text-fill-color: var(--ink); background: var(--soft); }

.tg {
  min-width: 52px;
  height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--card);
  font-size: 22px;
  font-weight: 700;
  font-family: var(--serif);
  cursor: pointer;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
}
.tg:active:not(:disabled) { transform: scale(0.96); }
.tg.on { background: var(--felt); border-color: var(--felt); color: #f8f4ea; }
.players .tg { min-width: 56px; }

.maru { flex-wrap: nowrap; }

.wait { gap: 10px; }
.wait-tiles { display: flex; gap: 4px; flex-wrap: wrap; --tw: clamp(26px, calc((100vw - 140px) / 9.6), 40px); }
.tile-btn, .pick-tile {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 6px;
  transition: transform 0.12s, filter 0.12s, opacity 0.12s;
}
.tile-btn { opacity: 0.42; filter: grayscale(0.4); }
.tile-btn.on { opacity: 1; filter: none; transform: translateY(-5px); }
.tile-btn.on .tile::after, .pick-tile.on .tile::after {
  content: "";
  position: absolute;
  inset: -3px -2px -3px;
  border-radius: 6px;
  box-shadow: 0 0 0 2.5px var(--felt-hi);
}
.wait .none { height: calc(var(--tw, 34px) * 1.2); }

.hand.pick { gap: 0; padding-top: 10px; }
.pick-tile.on { transform: translateY(-10px); }

/* 8問目 */
.scenario {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}
.sc-block { background: var(--soft); border-radius: 12px; padding: 10px 12px; }
.sc-block h4 { margin: 0 0 4px; font-size: 13px; color: var(--muted); font-weight: 500; }
.sc-block table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.sc-block th { text-align: left; font-weight: 700; padding: 2px 0; }
.sc-block td { text-align: right; padding: 2px 0; }

/* ---------- 採点 ---------- */

.pen {
  position: absolute;
  left: 50%;
  top: 15px;
  width: 50px;
  height: 50px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.pen svg { width: 100%; height: 100%; overflow: visible; }
.pen path {
  fill: none;
  stroke: var(--pen);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw 0.45s ease-out forwards;
  opacity: 0.88;
}
.pen.ng { width: 40px; height: 40px; top: 12px; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .pen path { animation: none; stroke-dashoffset: 0; } }

.item.is-ng { background: linear-gradient(90deg, var(--pen-soft), transparent 70%); margin: 0 -14px; padding-left: 14px; padding-right: 14px; }

.explain {
  border-left: 3px solid var(--pen);
  padding: 6px 0 6px 12px;
  display: grid;
  gap: 6px;
  font-size: 15px;
}
.explain.is-ok { border-left-color: var(--line); color: var(--muted); }
.ex-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.ex-line b { color: var(--pen); font-size: 12px; border: 1px solid currentColor; border-radius: 4px; padding: 0 6px; }
.explain.is-ok .ex-line b { color: var(--muted); }
.ex-tiles { display: flex; flex-wrap: wrap; gap: 4px; }
.ex-rank { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; }
.rk {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px 2px 4px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
}
.rk b { color: var(--ink); }
.rk.best { background: color-mix(in srgb, var(--pen) 12%, var(--card)); color: var(--ink); }
.rk.mine { box-shadow: inset 0 0 0 1.5px var(--felt-hi); }

.summary { border-color: color-mix(in srgb, var(--pen) 35%, var(--line)); }
.sum-top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.sum-score { font-family: var(--serif); color: var(--pen); display: flex; align-items: baseline; gap: 6px; }
.sum-score .big { font-size: 64px; font-weight: 800; line-height: 1; }
.sum-score .of { font-size: 18px; font-weight: 600; }
.sum-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sum-rows { display: grid; gap: 4px; margin-top: 14px; }
.sum-row {
  display: grid;
  grid-template-columns: 4.5em 1fr 3.5em;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-size: 14px;
  padding: 3px 0;
}
.sum-bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.sum-bar i { display: block; height: 100%; background: var(--pen); border-radius: 99px; }
.sum-pt { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ---------- ボタン・下のバー ---------- */

.btn {
  height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--card);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
}
.btn.primary { background: var(--pen); border-color: var(--pen); color: #fff; padding: 0 22px; }
.btn.ghost.on { background: var(--felt); color: #f8f4ea; border-color: var(--felt); }

.bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px max(12px, calc((100vw - 820px) / 2 + 12px)) calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.progress { flex: 1; min-width: 0; display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.progress b { color: var(--ink); font-size: 16px; font-variant-numeric: tabular-nums; }
.pbar { height: 5px; border-radius: 9px; background: var(--soft); overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--felt-hi); transition: width 0.2s; }
.timer {
  height: 44px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--card);
  padding: 0 12px;
  display: grid;
  line-height: 1.1;
  cursor: pointer;
  text-align: center;
}
.timer .tm { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 16px; }
.timer .tm-state { font-size: 10px; color: var(--muted); }
.timer.running { border-color: var(--felt-hi); }
.timer.over .tm { color: var(--pen); }
.bar-note { font-size: 13px; color: var(--muted); }
.bar-score { flex: 1; text-decoration: none; font-family: var(--serif); color: var(--pen); }
.bar-score b { font-size: 28px; }

/* ---------- 論述 ---------- */

.essay-intro p { margin: 0; }
.essay-intro ul { margin: 6px 0; padding-left: 1.2em; }
.board-wrap { margin: 4px -4px 0; }
.board {
  --bt: 5.35cqw;
  container-type: inline-size;
  position: relative;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  aspect-ratio: 1;
  border-radius: 10px;
  background:
    radial-gradient(70% 70% at 50% 45%, var(--felt-hi) 0%, transparent 100%),
    var(--felt);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25), inset 0 0 40px rgba(0, 0, 0, 0.35);
}
.seat-layer { position: absolute; inset: 0; }
.board .tile { --w: var(--bt); }
.river {
  position: absolute;
  left: 33.9%;
  top: 67.6%;
  display: flex;
  flex-direction: column;
}
.river-row { display: flex; align-items: flex-end; min-height: calc(var(--bt) * 4 / 3); }
.tile.gap::before { display: none; }
.board .tile.drawn { margin-left: 1.4cqw; }
.tile.tsumogiri::before { filter: brightness(0.74) saturate(0.6); }
.tile.called::after {
  content: "";
  position: absolute;
  inset: 0;
  border: max(2px, 0.45cqw) solid #e8202a;
  border-radius: 2px;
}
.seat-hand {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1.6%;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}
.melds { display: inline-flex; gap: 1.6cqw; margin-left: 2.4cqw; align-items: flex-end; }
.meld { display: inline-flex; align-items: flex-end; }
.board-center {
  position: absolute;
  left: 33.9%;
  top: 33.9%;
  width: 32.2%;
  height: 32.2%;
  border-radius: 1.2cqw;
  background: #f7f3ea;
  color: #2b2b2b;
  box-shadow: 0 0.6cqw 2cqw rgba(0, 0, 0, 0.3);
  font-size: 2.3cqw;
  line-height: 1.3;
}
.seat-label { position: absolute; display: flex; gap: 0.8cqw; align-items: baseline; white-space: nowrap; }
.seat-label b { font-weight: 700; }
.seat-label span { font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.seat-label.at-top { top: 1.4cqw; left: 50%; transform: translateX(-50%); }
.seat-label.at-bottom { bottom: 1.4cqw; left: 50%; transform: translateX(-50%); }
.seat-label.at-left, .seat-label.at-right { top: 50%; writing-mode: vertical-rl; text-orientation: upright; transform: translateY(-50%); letter-spacing: 0; }
.seat-label.at-left { left: 1.2cqw; }
.seat-label.at-right { right: 1.2cqw; }
.seat-label.at-left span, .seat-label.at-right span { text-orientation: upright; }
.seat-label.me b { color: #c12d1c; }
.seat-label.dealer b::after { content: "親"; font-size: 0.75em; margin-left: 0.4cqw; padding: 0 0.4cqw; border-radius: 0.6cqw; background: #2b2b2b; color: #f7f3ea; }
.seat-label.at-left.dealer b::after { margin: 0.4cqw 0 0; }
.round-info {
  position: absolute;
  inset: 22% 18%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.6cqw;
  text-align: center;
}
.round-info b { font-size: 2.9cqw; }
.round-info > span { font-size: 2.1cqw; color: #666; }
.dora { display: flex; align-items: center; gap: 1cqw; font-size: 2cqw; color: #666; }
.dora .tile { --w: 4.2cqw; }

.my-hand {
  margin-top: 14px;
  padding: 12px;
  border-radius: 12px;
  background: var(--soft);
  display: grid;
  gap: 6px;
  justify-items: center;
  --tw: clamp(19px, calc((100vw - 76px) / 14.2), 38px);
}
.mh-label { font-size: 12px; color: var(--muted); justify-self: start; }
.my-hand .tile.drawn { margin-left: calc(var(--tw) * 0.4); }
.essay-q { margin-top: 14px; font-weight: 500; }
.essay-ans { position: relative; margin-top: 10px; }
.essay-ans textarea {
  width: 100%;
  min-height: 180px;
  padding: 12px 14px 28px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--input);
  font-size: 16px;
  line-height: 1.8;
  resize: vertical;
  outline: none;
}
.essay-ans textarea:focus { border-color: var(--felt-hi); box-shadow: 0 0 0 3px color-mix(in srgb, var(--felt-hi) 22%, transparent); }
.essay-ans .count { position: absolute; right: 12px; bottom: 10px; font-size: 12px; color: var(--muted); }

/* ---------- フッター ---------- */

.foot {
  max-width: 820px;
  margin: 8px auto 0;
  padding: 16px 16px 24px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}
.foot p { margin: 0 0 4px; }
.foot .links { display: flex; flex-wrap: wrap; gap: 4px 14px; }

/* ---------- 画面幅 ---------- */

@media (max-width: 560px) {
  .top-inner { padding: 22px 16px 18px; }
  .top h1 .sp { display: inline; }
  .tabs { width: 100%; }
  .tabs button { flex: 1; }
  .ibody.row { grid-template-columns: 1fr; }
  .card { padding: 16px 12px; }
  .item.is-ng { margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
  .item.t-count, .item.t-wait, .item.t-score, .item.t-discard { grid-template-columns: 1fr; gap: 2px; }
  .item.t-count .inum, .item.t-wait .inum, .item.t-score .inum, .item.t-discard .inum { width: 30px; }
  .scenario { grid-template-columns: 1fr; }
  .sum-score .big { font-size: 54px; }
  .btn { padding: 0 14px; }
}

@media (min-width: 720px) {
  .card { padding: 24px 26px; }
  .item.is-ng { margin: 0 -26px; padding-left: 26px; padding-right: 26px; }
  .item { grid-template-columns: 36px 1fr; gap: 4px 12px; }
  .t-count .ibody, .t-score .ibody { grid-template-columns: 1fr auto; align-items: end; }
  .t-count .explain, .t-score .explain { grid-column: 1 / -1; }
}

/* ---------- 期の切り替え ---------- */

.exam-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.pill {
  border: 1px solid rgba(201, 164, 92, 0.45);
  background: rgba(0, 0, 0, 0.18);
  color: rgba(243, 239, 228, 0.82);
  font-family: var(--serif);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.04em;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.pill.on { background: var(--gold); border-color: var(--gold); color: #1d2a22; }
.tabs button[hidden] { display: none; }

/* ---------- 記号選択 ---------- */

.blank-box {
  display: inline-block;
  min-width: 3.5em;
  margin: 0 4px;
  padding: 0 8px;
  border-bottom: 2px solid var(--muted);
  background: var(--soft);
  border-radius: 4px 4px 0 0;
  text-align: center;
}
.blank-box.filled { border-bottom-color: var(--felt-hi); font-weight: 700; }
.options { display: grid; gap: 6px; }
.opt {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--card);
  text-align: left;
  cursor: pointer;
  line-height: 1.5;
}
.opt-key {
  flex: none;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
  font-family: var(--serif);
  font-weight: 800;
  font-size: 15px;
}
.opt.on { background: var(--felt); border-color: var(--felt); color: #f8f4ea; }
.opt.on .opt-key { border-color: #f8f4ea; }
.opt.right:not(.on) { border-color: var(--pen); border-style: dashed; }

/* ---------- 用語・記述 ---------- */

.ibody.term-row { grid-template-columns: 1fr auto; }
.term-row .stmt b { font-size: 18px; }
.chars { color: var(--muted); font-size: 14px; margin-left: 4px; }
.txt.term { width: 7em; text-align: center; font-size: 20px; }
.free-ans textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--input);
  font-size: 16px;
  line-height: 1.7;
  resize: vertical;
  outline: none;
}
.free-ans textarea:focus { border-color: var(--felt-hi); }
.free-ans textarea:disabled { background: var(--soft); -webkit-text-fill-color: var(--ink); opacity: 1; }
.explain.self { border-left-color: var(--felt-hi); }
.model { margin: 0; font-weight: 700; font-size: 16px; }
.criteria { margin: 0; font-size: 13px; color: var(--muted); }
.self-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.self-row > span { font-size: 13px; color: var(--muted); margin-right: 4px; }
.self-btn { font-size: 15px; font-family: var(--sans); min-width: 0; padding: 0 12px; height: 40px; }

/* ---------- 採点の状態 ---------- */

.pen.part { width: 40px; height: 40px; top: 13px; }
.item.is-part, .item.is-pending { background: linear-gradient(90deg, color-mix(in srgb, var(--gold) 12%, transparent), transparent 70%); margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
.explain.is-na { border-left-color: var(--line); color: var(--muted); font-size: 13px; }
.ex-cap { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.sum-row.na { opacity: 0.55; }
.note.pending { color: var(--pen); }
.scenario.single { grid-template-columns: minmax(0, 320px); }

@media (max-width: 560px) {
  .ibody.term-row { grid-template-columns: 1fr auto; }
  .item.is-part, .item.is-pending { margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
}
@media (min-width: 720px) {
  .item.is-part, .item.is-pending { margin: 0 -26px; padding-left: 26px; padding-right: 26px; }
}

@media (max-width: 560px) {
  .exam-pills { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; width: 100%; }
  .pill { font-size: 13px; padding: 5px 0; letter-spacing: 0; }
  .brand { width: 100%; }
}
