:root {
  --bg: #eef2ff;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #c7d2fe;
  --accent: #4f46e5;
  --accent-soft: #e0e7ff;
  --ok: #15803d;
  --bad: #b91c1c;
  --thai: #be123c;
  --shadow: 0 12px 36px rgba(79, 70, 229, 0.12);
  --font-display: 'Outfit', 'Segoe UI', sans-serif;
  --font-thai: 'Sarabun', 'Tahoma', sans-serif;
  --prompt-size: clamp(1.5rem, 5vw, 2.2rem);
}
html.dark body,
body.dark {
  --bg: #0b1020;
  --card: #111827;
  --text: #e5eef7;
  --muted: #94a3b8;
  --border: #312e81;
  --accent: #a5b4fc;
  --accent-soft: #1e1b4b;
  --ok: #4ade80;
  --bad: #fb7185;
  --thai: #fda4af;
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}
body.vs-contrast {
  --bg: #000;
  --card: #000;
  --text: #fff;
  --muted: #fef08a;
  --border: #fff;
  --accent: #fde047;
  --accent-soft: #1a1a00;
  --thai: #fde047;
  --ok: #86efac;
  --bad: #fda4af;
}
body.vs-large {
  --prompt-size: clamp(1.9rem, 6vw, 2.8rem);
}
body.vs-large .vs-choice,
body.vs-large .vs-match-card {
  font-size: 1.15rem;
  min-height: 58px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  padding: 16px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  font-family: var(--font-display);
  color: var(--text);
  background:
    radial-gradient(900px 420px at 0% 0%, rgba(129, 140, 248, 0.28), transparent 55%),
    radial-gradient(800px 360px at 100% 0%, rgba(244, 114, 182, 0.14), transparent 50%),
    var(--bg);
}
.wrap { max-width: 940px; margin: 0 auto; }

.tm-hero-visual {
  background:
    radial-gradient(700px 300px at 10% 0%, rgba(167, 139, 250, 0.3), transparent 60%),
    linear-gradient(145deg, #1e1b4b, #4f46e5 50%, #9d174d) !important;
}
.tm-hero h1 .th,
.tm-lead .th {
  display: block;
  margin-top: 4px;
  font-family: var(--font-thai);
}
.tm-hero h1 .th { font-size: 0.72em; }

.vs-banner {
  margin-top: 12px;
  padding: 12px 14px;
  border: 2px solid var(--accent);
  border-radius: 14px;
  background: var(--accent-soft);
  font-weight: 800;
  line-height: 1.4;
}
.vs-banner em {
  display: block;
  margin-top: 3px;
  font-family: var(--font-thai);
  font-style: normal;
  font-weight: 700;
  opacity: 0.95;
}

.vs-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.vs-panel h2 { margin: 0 0 4px; font-size: 1.1rem; }
.vs-sub { margin: 0 0 12px; color: var(--muted); font-size: 0.85rem; font-weight: 600; }

.vs-a11y {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 12px;
  font-size: 0.82rem;
  font-weight: 700;
}
.vs-a11y label { display: inline-flex; gap: 6px; align-items: center; }

.vs-modes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}
.vs-mode {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 118px;
  padding: 12px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--card) 90%, var(--accent-soft));
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.vs-mode.active,
.vs-mode:hover { border-color: var(--accent); background: var(--accent-soft); }
.vs-mode-ico { font-size: 1.25rem; }
.vs-mode strong { font-size: 0.88rem; }
.vs-mode em {
  font-family: var(--font-thai);
  font-style: normal;
  font-weight: 700;
  color: var(--thai);
  font-size: 0.82rem;
}
.vs-mode small { color: var(--muted); font-size: 0.7rem; font-weight: 600; }

.vs-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}
.vs-chip {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}
.vs-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
body.vs-contrast .vs-chip.active { color: #000; }

.vs-start {
  margin-top: 8px;
  min-height: 46px;
  padding: 10px 16px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
body.vs-contrast .vs-start { color: #000; }

.vs-arena.hidden { display: none; }
.vs-score { font-weight: 800; color: var(--muted); margin: 0 0 10px; }

.vs-prompt {
  text-align: center;
  padding: 18px 12px;
  border: 1px dashed var(--accent);
  border-radius: 16px;
  background: var(--accent-soft);
  margin-bottom: 12px;
}
.vs-prompt-main {
  margin: 0;
  font-size: var(--prompt-size);
  font-weight: 800;
  line-height: 1.45;
}
.vs-prompt-main.is-th { font-family: var(--font-thai); color: var(--thai); }
.vs-prompt-emoji { margin: 0; font-size: clamp(2.6rem, 10vw, 4rem); }
.vs-prompt-sub { margin: 8px 0 0; color: var(--muted); font-weight: 700; font-size: 0.9rem; }

.vs-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-width: 520px;
  margin: 0 auto 10px;
}
.vs-choice {
  min-height: 54px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
}
.vs-choice.ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 22%, transparent); }
.vs-choice.bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 18%, transparent); }

.vs-match-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.vs-match-col { display: flex; flex-direction: column; gap: 8px; }
.vs-match-card {
  min-height: 52px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  font-family: var(--font-thai);
}
.vs-match-card.en { font-family: var(--font-display); }
.vs-match-card.picked { outline: 2px solid var(--accent); }
.vs-match-card.solved { opacity: 0.45; border-color: var(--ok); }
.vs-match-card.bad { outline: 2px solid var(--bad); }

.vs-type-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 10px;
}
.vs-type-row input {
  width: min(280px, 80vw);
  padding: 12px;
  border: 2px solid var(--accent);
  border-radius: 12px;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  background: var(--card);
  color: var(--text);
}
.vs-type-row button {
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.vs-feedback {
  text-align: center;
  min-height: 1.4em;
  font-weight: 800;
  color: var(--muted);
  margin: 8px 0;
}
.vs-feedback.ok { color: var(--ok); }
.vs-feedback.bad { color: var(--bad); }

.vs-done {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  text-align: center;
  background: var(--accent-soft);
}
.vs-done-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 10px;
}
.vs-done-ctas a,
.vs-done-ctas button {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.vs-muted { color: var(--muted); font-weight: 600; }

.vs-tips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.vs-tip {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.vs-tip strong { display: block; color: var(--accent); font-size: 0.8rem; }
.vs-tip span { display: block; margin-top: 4px; color: var(--muted); font-size: 0.78rem; font-weight: 600; }

.vs-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 16px;
  padding: 12px 4px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}
.vs-footer a { color: var(--accent); font-weight: 700; text-decoration: none; }

.mobile-dock { display: none; }
.sc-menu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  background: rgba(15, 23, 42, 0.55);
}
.sc-menu-overlay.open { display: flex; }
.sc-menu-sheet {
  width: min(480px, 100%);
  padding: 16px;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid var(--border);
}
.sc-menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sc-menu-grid a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
}
.sc-menu-grid .th { font-family: var(--font-thai); color: var(--thai); }
.sc-menu-grid .en { font-size: 0.72rem; color: var(--muted); }
.sc-menu-close {
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--accent-soft);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

@media (max-width: 900px) {
  body { padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
  .mobile-dock {
    display: grid;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 9998;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, #0b1020 92%, transparent);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
  }
  .mobile-dock a,
  .mobile-dock button {
    min-height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 14px;
    background: rgba(255,255,255,0.08);
    color: #e2e8f0;
    text-decoration: none;
    font: inherit;
    font-size: 0.62rem;
    font-weight: 700;
    cursor: pointer;
  }
  .mobile-dock .primary { background: color-mix(in srgb, #4f46e5 70%, transparent); border-color: #a5b4fc; }
  .dock-ico { font-size: 1.1rem; }
  .dock-th { font-family: var(--font-thai); font-size: 0.68rem; }
}
@media (max-width: 640px) {
  .vs-choices { grid-template-columns: 1fr; }
  .vs-modes { grid-template-columns: 1fr 1fr; }
}
