/* Kradan Play · เล่นกระดาน — สไตล์ร่วม (token เดียวกับกระดาน: --pri #1e2a5a, --acc #e9a23b, ฟอนต์ Anuphan) */
:root {
  --font: "Anuphan", system-ui, -apple-system, "Segoe UI", sans-serif;
  --pri: #1e2a5a; --pri2: #34458a; --pri-deep: #141d42;
  --acc: #e9a23b; --acc2: #fde9c2; --acc-ink: #5a3d00;
  --bg: #f6f7fb; --surface: #fff; --ink: #1f2328; --muted: #5f6673; --line: #e3e6ee; --hover: #eef1f8;
  --ok: #257a50; --ok-bg: #e2f3ea; --bad: #b23a0a; --bad-bg: #fbe7de;
  --c0: #2f5bd3; --c1: #c2416b; --c2: #18806b; --c3: #e9a23b; /* สีตัวเลือก ก ข ค ง (+รูปทรงต่างกัน ไม่พึ่งสีอย่างเดียว) */
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.6; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--pri2); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--acc); outline-offset: 2px; }

/* ---------- หัวเว็บ ---------- */
.kp-top { background: var(--pri); color: #fff; }
.kp-top-in { max-width: 1100px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; }
.kp-brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.kp-brand-mark { width: 40px; height: 40px; border-radius: 10px; background: #fff; display: grid; place-items: center; }
.kp-brand-mark img { width: 32px; height: 32px; }
.kp-brand-name { display: flex; flex-direction: column; line-height: 1.1; }
.kp-brand-name b { font-size: 19px; }
.kp-brand-name b span { color: var(--acc); }
.kp-brand-name small { font-size: 12px; color: #c9d0f0; }
.kp-top-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- ปุ่ม ---------- */
.btn { min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1.5px solid transparent; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-pri { background: var(--pri); color: #fff; }
.btn-pri:hover { background: var(--pri2); }
.btn-acc { background: var(--acc); color: var(--pri-deep); }
.btn-acc:hover { filter: brightness(1.05); }
.btn-line { background: var(--surface); color: var(--pri); border-color: #c9cde0; }
.btn-line:hover { background: var(--hover); }
.btn-ghost { background: transparent; color: inherit; border-color: rgba(255,255,255,.35); }
.btn-ghost:hover { background: rgba(255,255,255,.1); }
.btn-lg { min-height: 52px; font-size: 18px; padding: 0 24px; }
.btn-icon { width: 44px; padding: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- ตัวแก้คำถาม ---------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 20px 16px 48px; }
.hero-title { margin: 8px 0 4px; font-size: 28px; color: var(--pri); line-height: 1.3; }
.hero-sub { margin: 0 0 20px; color: var(--muted); }
.grid-edit { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 860px) { .grid-edit { grid-template-columns: minmax(0, 1fr); } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.card h2 { margin: 0 0 12px; font-size: 18px; color: var(--pri); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .field .lbl { font-weight: 600; font-size: 15px; }
.field .hint { font-size: 13px; color: var(--muted); }
.input, .select, textarea.input { width: 100%; min-height: 44px; border: 1.5px solid #c9cde0; border-radius: 10px; padding: 8px 12px; background: #fff; }
textarea.input { min-height: 320px; resize: vertical; line-height: 1.55; font-size: 15px; tab-size: 4; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .field { flex: 1 1 160px; }
.check { display: flex; gap: 10px; align-items: center; min-height: 40px; }
.check input { width: 20px; height: 20px; accent-color: var(--pri); }
.actions { display: flex; flex-direction: column; gap: 10px; }
.actions .btn { width: 100%; }
details.help { margin-top: 10px; font-size: 14px; color: var(--muted); }
details.help summary { cursor: pointer; color: var(--pri2); font-weight: 600; min-height: 32px; }
details.help pre { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; font-family: inherit; color: var(--ink); margin: 6px 0 10px; }
.status { font-size: 14px; padding: 10px 12px; border-radius: 10px; margin-top: 10px; }
.status.ok { background: var(--ok-bg); color: var(--ok); }
.status.bad { background: var(--bad-bg); color: var(--bad); }
.status ul { margin: 4px 0 0; padding-left: 20px; }
.preview-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow: auto; }
.preview-list li { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.preview-list li b { color: var(--pri); }
.preview-list .ans { color: var(--ok); font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--pri-deep); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 50; max-width: calc(100% - 32px); box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); }
.share-box { display: flex; gap: 8px; margin-top: 10px; }
.share-box input { flex: 1; min-width: 0; }

/* ---------- เวทีเล่น (ใช้ร่วม ฉายจอ/มือถือ) ---------- */
.stage { min-height: 100vh; min-height: 100dvh; background: var(--pri); color: #fff; display: flex; flex-direction: column; }
.stage-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; flex-wrap: wrap; }
.stage-bar .prog { font-weight: 600; color: #c9d0f0; }
.stage-main { flex: 1; display: flex; flex-direction: column; gap: 18px; padding: 8px 16px 20px; max-width: 1400px; width: 100%; margin: 0 auto; }
.qbox { background: #fff; color: var(--ink); border-radius: 18px; padding: 20px 24px; display: flex; align-items: center; justify-content: center; text-align: center; min-height: 120px; }
.qtext { margin: 0; font-weight: 700; line-height: 1.35; font-size: clamp(22px, 3.4vw, 54px); overflow-wrap: anywhere; }
.timer-row { display: flex; align-items: center; gap: 14px; }
.timer-bar { flex: 1; height: 12px; border-radius: 99px; background: rgba(255,255,255,.18); overflow: hidden; }
.timer-bar i { display: block; height: 100%; width: 100%; background: var(--acc); border-radius: inherit; transform-origin: left; }
.timer-num { min-width: 3ch; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 28px; text-align: right; }
.timer-num.low { color: #ffb4a0; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; flex: 1; }
.choices.n2 { grid-template-rows: 1fr; }
.choice { position: relative; border: 0; border-radius: 16px; padding: 16px 18px 16px 76px; color: #fff; text-align: left; font-weight: 600; font-size: clamp(18px, 2.4vw, 38px); line-height: 1.3; min-height: 84px; display: flex; align-items: center; overflow-wrap: anywhere; transition: opacity .2s, transform .15s; }
.choice .shape { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; display: grid; place-items: center; }
.choice .shape svg { width: 40px; height: 40px; }
.choice .letter { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 46px; text-align: center; font-size: 20px; font-weight: 700; color: inherit; }
.choice.c0 { background: var(--c0); } .choice.c1 { background: var(--c1); } .choice.c2 { background: var(--c2); } .choice.c3 { background: var(--c3); color: var(--pri-deep); }
.choice:not(:disabled):hover { transform: translateY(-2px); }
.choice:disabled { cursor: default; }
.choice.dim { opacity: .28; }
.choice.right { box-shadow: 0 0 0 5px #fff, 0 0 0 10px var(--ok); }
.choice.picked-wrong { box-shadow: 0 0 0 5px #fff, 0 0 0 10px var(--bad); opacity: .8; }
.choice .tag { margin-left: auto; padding-left: 12px; font-size: .6em; white-space: nowrap; }
.stage-foot { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; padding: 0 16px 18px; }
.feedback { text-align: center; font-weight: 700; font-size: clamp(22px, 3vw, 40px); min-height: 1.4em; margin: 0; }
.feedback.ok { color: #9be3bd; } .feedback.bad { color: #ffb4a0; }

/* ทีม (โหมดฉายจอ) */
.teams { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.team-btn { min-height: 52px; padding: 0 18px; border-radius: 12px; border: 2px solid rgba(255,255,255,.5); background: transparent; color: #fff; font-weight: 600; font-size: 18px; display: inline-flex; gap: 10px; align-items: center; }
.team-btn[aria-pressed="true"] { background: #fff; color: var(--pri); border-color: #fff; }
.team-btn .pts { font-variant-numeric: tabular-nums; opacity: .8; }

/* หน้าเริ่ม / สรุป */
.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center; padding: 24px 16px 48px; }
.center h1 { margin: 0; font-size: clamp(28px, 4.5vw, 64px); line-height: 1.25; }
.center p { margin: 0; color: #d3d8f2; font-size: clamp(16px, 1.8vw, 24px); }
.panel { background: #fff; color: var(--ink); border-radius: 18px; padding: 20px; width: 100%; max-width: 560px; text-align: left; }
.panel .field label { color: var(--pri); }
.big-score { font-size: clamp(56px, 9vw, 120px); font-weight: 700; color: var(--acc); line-height: 1; font-variant-numeric: tabular-nums; }
.board { list-style: none; margin: 0; padding: 0; width: 100%; max-width: 720px; display: flex; flex-direction: column; gap: 10px; }
.board li { display: flex; align-items: center; gap: 14px; background: rgba(255,255,255,.1); border-radius: 14px; padding: 12px 18px; font-size: clamp(18px, 2.4vw, 32px); font-weight: 600; }
.board li.first { background: var(--acc); color: var(--pri-deep); }
.board .rank { width: 2ch; text-align: center; }
.board .name { flex: 1; text-align: left; }
.board .pts { font-variant-numeric: tabular-nums; }
.review { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.review li { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.review .q { font-weight: 600; }
.review .yours { color: var(--bad); }
.review .right { color: var(--ok); font-weight: 600; }
.team-names { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

@media (max-width: 640px) {
  .choices { grid-template-columns: 1fr; gap: 10px; }
  .choice { min-height: 64px; padding-left: 64px; font-size: 19px; }
  .choice .shape { left: 12px; width: 40px; height: 40px; }
  .choice .shape svg { width: 32px; height: 32px; }
  .qbox { padding: 16px; min-height: 96px; }
  .qtext { font-size: 22px; }
  .timer-num { font-size: 22px; }
  .team-names { grid-template-columns: 1fr; }
}
/* โหมดฉายจอ: ใช้พื้นที่เต็มจอ ตัวใหญ่ */
.stage.projector .qbox { min-height: 22vh; }
.stage.projector .choice { min-height: 14vh; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
