/* ХУРДАН ГАР (reaction duel) — flat calm colors; every state change is an instant color swap. No motion. */
#view-reaction {
  --rx-p0: #b5806a;          /* clay — left player */
  --rx-p1: #7f9168;          /* sage — right player */
  --rx-wait: #6f8a96;        /* slate-teal — «Бэлтгэ...» */
  --rx-go: #c9a24a;          /* ochre — «ДАР!» */
  --rx-stop: #a9432f;        /* terracotta — fake «БҮҮ ДАР!» */
  --rx-go-ink: #2b241b;
}
html[data-theme="dark"] #view-reaction {
  --rx-p0: #ca9b85;
  --rx-p1: #aebb98;
  --rx-wait: #4f6670;
  --rx-go: #d8b45e;
  --rx-stop: #a8503c;
}
#view-reaction [hidden] { display: none !important; }
#view-reaction .btn:active { transform: none; }
#view-reaction .rx-p0, #view-reaction .rx-c0 { --rx-pc: var(--rx-p0); }
#view-reaction .rx-p1, #view-reaction .rx-c1 { --rx-pc: var(--rx-p1); }

/* ---------- toolbar ---------- */
#view-reaction .rx-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-bottom: 14px; padding: 10px 12px; border-radius: 18px; }
#view-reaction .rx-seg { display: inline-flex; align-items: center; gap: 3px; padding: 3px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
#view-reaction .rx-seg-label { padding: 0 6px 0 10px; font-size: 12px; font-weight: 800; letter-spacing: .04em; color: var(--ink-3); }
#view-reaction .rx-seg-btn { min-width: 44px; height: 40px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-2); font: inherit; font-size: 14px; font-weight: 800; cursor: pointer; -webkit-tap-highlight-color: transparent; }
#view-reaction .rx-seg-btn:hover { background: var(--surface); color: var(--ink); }
#view-reaction .rx-seg-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
#view-reaction .rx-bar .btn { height: 44px; }
#view-reaction .rx-toggle b { font-weight: 800; color: var(--ink-3); }
#view-reaction .rx-toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent) !important; }
#view-reaction .rx-toggle[aria-pressed="true"] b { color: var(--green-700); }
#view-reaction .rx-new { margin-left: auto; }

/* ---------- duel arena: left half · signal · right half ---------- */
#view-reaction .rx-arena {
  position: relative; display: grid; gap: 12px; padding: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(220px, .85fr) minmax(0, 1fr); grid-template-areas: "h0 sig h1";
  min-height: clamp(400px, 58vh, 660px); border-radius: 24px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
#view-reaction .rx-arena[data-phase="wait"] { background: var(--rx-wait); border-color: transparent; color: #fff; }
#view-reaction .rx-arena[data-phase="stop"] { background: var(--rx-stop); border-color: transparent; color: #fff; }
#view-reaction .rx-arena[data-phase="go"] { background: var(--rx-go); border-color: transparent; color: var(--rx-go-ink); }

#view-reaction .rx-half {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-width: 0; min-height: 200px; padding: 16px 10px; border-radius: 18px;
  border: 3px solid var(--rx-pc); background: var(--surface-2); background: color-mix(in srgb, var(--rx-pc) 13%, var(--surface));
  color: var(--ink); text-align: center; cursor: pointer;
}
#view-reaction .rx-half.rx-p0 { grid-area: h0; }
#view-reaction .rx-half.rx-p1 { grid-area: h1; }
#view-reaction .rx-half.rx-is-win { background: var(--accent-soft); background: color-mix(in srgb, var(--rx-pc) 32%, var(--surface)); box-shadow: inset 0 0 0 3px var(--rx-pc); }
#view-reaction .rx-half.rx-is-lose { opacity: .72; }
#view-reaction .rx-half.rx-is-false { border-style: dashed; border-color: #a9432f; background: var(--surface-2); background: color-mix(in srgb, #a9432f 12%, var(--surface)); }
#view-reaction .rx-arena[data-phase="wait"] .rx-half,
#view-reaction .rx-arena[data-phase="stop"] .rx-half { background: rgba(255, 255, 255, .13); border-color: rgba(255, 255, 255, .55); color: inherit; }
#view-reaction .rx-arena[data-phase="go"] .rx-half { background: rgba(255, 255, 255, .26); border-color: rgba(43, 36, 27, .6); color: inherit; }

#view-reaction .rx-half-top { display: flex; align-items: center; justify-content: center; gap: 8px; max-width: 100%; }
#view-reaction .rx-key { display: inline-grid; place-items: center; flex: none; min-width: 36px; height: 36px; padding: 0 8px; border-radius: 9px; border: 2px solid currentColor; border-bottom-width: 4px; font-family: var(--display, inherit); font-size: 17px; font-weight: 800; line-height: 1; }
#view-reaction .rx-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: clamp(15px, 1.8vw, 22px); font-weight: 800; }
#view-reaction .rx-score { font-family: var(--display, inherit); font-size: clamp(60px, 10vw, 140px); font-weight: 800; line-height: 1; letter-spacing: -.04em; font-variant-numeric: tabular-nums; color: var(--rx-pc); }
#view-reaction .rx-flag { min-height: 1.4em; font-size: clamp(14px, 1.7vw, 20px); font-weight: 800; }
#view-reaction .rx-meta { min-height: 1.3em; font-size: 12.5px; font-weight: 700; color: var(--ink-3); }
#view-reaction .rx-arena[data-phase="wait"] .rx-score,
#view-reaction .rx-arena[data-phase="wait"] .rx-meta,
#view-reaction .rx-arena[data-phase="stop"] .rx-score,
#view-reaction .rx-arena[data-phase="stop"] .rx-meta,
#view-reaction .rx-arena[data-phase="go"] .rx-score,
#view-reaction .rx-arena[data-phase="go"] .rx-meta { color: inherit; }

/* signal column */
#view-reaction .rx-signal { grid-area: sig; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-width: 0; padding: 10px 6px; text-align: center; }
#view-reaction .rx-round { font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
#view-reaction .rx-wordbox { display: grid; place-items: center; width: 100%; min-height: 72px; }
#view-reaction .rx-word { max-width: 100%; font-family: var(--display, inherit); font-weight: 800; line-height: 1.08; letter-spacing: -.02em; overflow-wrap: anywhere; }
#view-reaction .rx-word-xl { font-size: clamp(30px, 4vw, 60px); }
#view-reaction .rx-word-go { font-size: clamp(48px, 7vw, 112px); letter-spacing: .02em; }
#view-reaction .rx-word-md { font-size: clamp(20px, 2.4vw, 32px); }
#view-reaction .rx-sub { margin: 0; max-width: 34ch; min-height: 2.9em; font-size: 14px; font-weight: 700; line-height: 1.45; color: var(--ink-2); }
#view-reaction .rx-actions { display: flex; flex-direction: column; align-items: center; gap: 4px; }
#view-reaction .rx-next { min-height: 48px; padding: 0 22px; font-size: 15px; }
#view-reaction .rx-hint { font-size: 11.5px; font-weight: 700; color: var(--ink-3); }
#view-reaction .rx-ghosted { visibility: hidden; }
#view-reaction .rx-arena[data-phase="wait"] .rx-round,
#view-reaction .rx-arena[data-phase="wait"] .rx-sub,
#view-reaction .rx-arena[data-phase="stop"] .rx-round,
#view-reaction .rx-arena[data-phase="stop"] .rx-sub,
#view-reaction .rx-arena[data-phase="go"] .rx-round,
#view-reaction .rx-arena[data-phase="go"] .rx-sub { color: inherit; }

/* match over — winner card on top of the arena */
#view-reaction .rx-over { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; padding: 12px; overflow: auto; border-radius: 24px; background: rgba(33, 28, 21, .5); }
#view-reaction .rx-ov-card { width: min(480px, 100%); padding: 20px 18px; border-radius: 20px; text-align: center; color: var(--ink); box-shadow: var(--shadow-lg); }
#view-reaction .rx-ov-trophy { font-size: clamp(44px, 7vw, 72px); line-height: 1; }
#view-reaction .rx-ov-card h3 { margin: 8px 0 4px; font-family: var(--display, inherit); font-size: clamp(22px, 3.4vw, 34px); line-height: 1.15; overflow-wrap: anywhere; }
#view-reaction .rx-ov-msg { margin: 0 0 14px; font-weight: 700; color: var(--ink-2); }
#view-reaction .rx-ov-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-bottom: 10px; }
#view-reaction .rx-ov-col { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; padding: 12px 8px; border-radius: 14px; border: 2px solid var(--rx-pc); background: var(--surface-2); background: color-mix(in srgb, var(--rx-pc) 10%, var(--surface)); }
#view-reaction .rx-ov-col b { max-width: 100%; overflow-wrap: anywhere; font-weight: 800; }
#view-reaction .rx-ov-col small { font-size: 12px; font-weight: 700; color: var(--ink-3); }
#view-reaction .rx-ov-win { box-shadow: inset 0 0 0 2px var(--rx-pc); }
#view-reaction .rx-ov-score { font-family: var(--display, inherit); font-size: clamp(34px, 5vw, 52px); font-weight: 800; line-height: 1.1; color: var(--rx-pc); font-variant-numeric: tabular-nums; }
#view-reaction .rx-ov-fast { margin: 0 0 12px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
#view-reaction .rx-ov-actions { display: flex; justify-content: center; }
#view-reaction .rx-ov-actions .btn { min-height: 48px; padding: 0 24px; }
#view-reaction .rx-ov-hint { margin: 6px 0 0; font-size: 11.5px; font-weight: 700; color: var(--ink-3); }

/* ---------- under the arena ---------- */
#view-reaction .rx-foot { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
#view-reaction .rx-history, #view-reaction .rx-records { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 32px; }
#view-reaction .rx-hist-label { margin-right: 2px; font-size: 12px; font-weight: 800; color: var(--ink-3); }
#view-reaction .rx-empty { font-size: 13px; font-weight: 600; color: var(--ink-3); }
#view-reaction .rx-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums; }
#view-reaction .rx-chip b { color: var(--ink); }
#view-reaction .rx-chip-false { border-style: dashed; }
#view-reaction .rx-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--rx-pc, var(--accent)); }
#view-reaction .rx-names { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
#view-reaction .rx-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: 12px; font-weight: 800; color: var(--ink-3); }
#view-reaction .rx-input { height: 44px; }
#view-reaction .rx-help { margin: 0; font-size: 13px; line-height: 1.7; color: var(--ink-3); }
#view-reaction .rx-kbd { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; background: var(--surface); color: var(--ink); font-family: inherit; font-size: 12px; font-weight: 800; line-height: 1.6; text-align: center; }
#view-reaction .rx-solo-actions { display: flex; flex-wrap: wrap; gap: 8px; }
#view-reaction .rx-solo-actions .btn { height: 44px; }

/* ---------- solo ---------- */
#view-reaction .rx-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  min-height: clamp(340px, 54vh, 600px); padding: 20px 16px; border-radius: 24px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); text-align: center; cursor: pointer; box-shadow: var(--shadow);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
#view-reaction .rx-zone[data-phase="wait"] { background: var(--rx-wait); border-color: transparent; color: #fff; }
#view-reaction .rx-zone[data-phase="stop"] { background: var(--rx-stop); border-color: transparent; color: #fff; }
#view-reaction .rx-zone[data-phase="go"] { background: var(--rx-go); border-color: transparent; color: var(--rx-go-ink); }
#view-reaction .rx-zone[data-phase="done"] { background: var(--accent-soft); }
#view-reaction .rx-zone[data-phase="wait"] .rx-round,
#view-reaction .rx-zone[data-phase="wait"] .rx-sub,
#view-reaction .rx-zone[data-phase="wait"] .rx-note,
#view-reaction .rx-zone[data-phase="stop"] .rx-round,
#view-reaction .rx-zone[data-phase="stop"] .rx-sub,
#view-reaction .rx-zone[data-phase="stop"] .rx-note,
#view-reaction .rx-zone[data-phase="go"] .rx-round,
#view-reaction .rx-zone[data-phase="go"] .rx-sub,
#view-reaction .rx-zone[data-phase="go"] .rx-note { color: inherit; }
#view-reaction .rx-zone .rx-wordbox { min-height: clamp(80px, 11vw, 150px); }
#view-reaction .rx-zone .rx-word-xl { font-size: clamp(40px, 7vw, 96px); }
#view-reaction .rx-zone .rx-word-go { font-size: clamp(64px, 12vw, 160px); }
#view-reaction .rx-zone .rx-word-md { font-size: clamp(26px, 4vw, 48px); }
#view-reaction .rx-zone .rx-sub { max-width: 46ch; font-size: 15px; }
#view-reaction .rx-note { margin: 0; min-height: 1.5em; font-size: 13px; font-weight: 800; color: var(--green-700); }
#view-reaction .rx-slots { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; width: min(540px, 100%); }
#view-reaction .rx-slot { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; padding: 8px 4px; border-radius: 12px; border: 1px dashed rgba(127, 120, 105, .55); color: inherit; }
#view-reaction .rx-slot small { font-size: 11px; font-weight: 800; opacity: .75; }
#view-reaction .rx-slot b { font-size: clamp(15px, 2vw, 20px); font-weight: 800; font-variant-numeric: tabular-nums; }
#view-reaction .rx-slot-done { border-style: solid; background: rgba(127, 120, 105, .12); }
#view-reaction .rx-slot-best { border-color: var(--rx-go); background: rgba(201, 162, 74, .22); }

/* ---------- phones: signal on top, the two halves side by side below ---------- */
@media (max-width: 760px) {
  #view-reaction .rx-arena { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "sig sig" "h0 h1"; grid-template-rows: auto minmax(220px, 1fr); gap: 10px; padding: 10px; min-height: clamp(460px, 72vh, 640px); }
  #view-reaction .rx-signal { padding: 4px 2px; gap: 6px; }
  #view-reaction .rx-wordbox { min-height: 64px; }
  #view-reaction .rx-word-xl { font-size: 34px; }
  #view-reaction .rx-word-go { font-size: 56px; }
  #view-reaction .rx-word-md { font-size: 21px; }
  #view-reaction .rx-sub { font-size: 13px; }
  #view-reaction .rx-half { min-height: 0; padding: 12px 6px; }
  #view-reaction .rx-score { font-size: clamp(56px, 18vw, 96px); }
  #view-reaction .rx-new { margin-left: 0; }
}
@media (max-width: 420px) {
  #view-reaction .rx-bar { padding: 8px; gap: 8px; }
  #view-reaction .rx-seg-btn { padding: 0 11px; font-size: 13px; }
  #view-reaction .rx-key { min-width: 30px; height: 30px; font-size: 15px; }
  #view-reaction .rx-name { font-size: 14px; }
  #view-reaction .rx-meta { font-size: 11px; }
  #view-reaction .rx-names { grid-template-columns: 1fr; }
  #view-reaction .rx-slots { gap: 5px; }
  #view-reaction .rx-zone { padding: 16px 10px; }
}
