.xum-battle {
  --xb-ink: #192e3b; --xb-muted: #4d6273; --xb-line: #b7cddd;
  --xb-panel: #fff; --xb-soft: #edf5fb; --xb-accent: #134d79; --xb-on: #fff;
  color: var(--xb-ink); max-width: 1120px; margin: 0 auto; padding: clamp(12px, 3vw, 28px);
}
body:not(.light) .xum-battle {
  --xb-ink: #edf5fb; --xb-muted: #b5c9d9; --xb-line: #496577;
  --xb-panel: #1a2937; --xb-soft: #203648; --xb-accent: #b5ddff; --xb-on: #142938;
}
.xum-battle [hidden] { display: none !important; }
.xb-top, .xb-side header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.xb-top h2, .xb-side h3 { margin: 0; color: inherit; }
.xb-top h2 { font-size: clamp(26px, 4vw, 38px); }
.xb-intro, .xb-wait { color: var(--xb-muted); margin: 9px 0 16px; }
.xb-kicker { color: var(--xb-muted); font-size: .72rem; font-weight: 750; letter-spacing: .065em; margin: 0 0 5px; }
.xb-arena { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(6px, 2vw, 16px); }
.xb-side { min-width: 0; border: 2px solid var(--xb-line); background: var(--xb-panel); border-radius: 16px; overflow: hidden; overflow-wrap: anywhere; }
.xb-side header { padding: clamp(8px, 2vw, 16px); min-height: 52px; background: var(--xb-soft); font-size: clamp(.79rem, 2vw, 1.05rem); font-weight: 700; }
.xb-side header strong { color: var(--xb-accent); font-size: 1.3em; }
.xb-side.xb-active { border-color: var(--xb-accent); }
.xb-content { padding: clamp(8px, 2vw, 18px); min-height: 160px; }
.xb-content p { margin: 8px 0; }
.xb-content .xb-question { white-space: pre-line; line-height: 1.36; font-size: clamp(.95rem, 2.2vw, 1.4rem); }
.xb-choices, .xb-form { display: grid; gap: 8px; margin-top: 10px; }
.xb-form input { display: block; width: 100%; box-sizing: border-box; background: var(--xb-panel); color: var(--xb-ink); border: 1px solid var(--xb-line); border-radius: 8px; padding: 8px; }
.xum-battle button { border-radius: 9px; padding: 8px; min-height: 40px; font: inherit; line-height: 1.25; cursor: pointer; overflow-wrap: anywhere; }
.xum-battle button:focus-visible, .xb-form input:focus-visible { outline: 2px solid var(--xb-accent); outline-offset: 2px; }
.xum-battle button:disabled { opacity: .65; cursor: wait; }
.xum-battle .xb-choice, .xum-battle .xb-secondary { background: var(--xb-soft); border: 1px solid var(--xb-line); color: var(--xb-ink); }
.xum-battle .xb-choice { text-align: left; }
.xum-battle .xb-primary { background: var(--xb-accent); border: 1px solid var(--xb-accent); color: var(--xb-on); font-weight: 700; }
.xb-error { color: #a02343; }
body:not(.light) .xb-error { color: #ffc0ce; }
.xb-error:empty { display: none; }
.xb-winner { --xb-accent: #065139; border-color: #238b60; background: #dbf7e9; color: #083d2b; }
.xb-loser { --xb-accent: #8b2543; border-color: #b45a75; background: #fbe9ee; color: #60213a; }
.xb-winner header, .xb-loser header { background: transparent; }
body:not(.light) .xb-winner header strong, body:not(.light) .xb-loser header strong { color: inherit; }
.xb-winner .xb-outcome, .xb-loser .xb-outcome, .xb-tie .xb-outcome { font-size: clamp(1rem, 4vw, 2.5rem); }
.xb-winner .xb-outcome { animation: xb-pop .7s ease-out both; }
.xb-loser .xb-outcome { animation: xb-slide .65s ease-out both; letter-spacing: .06em; }
.xb-confetti { color: #165d75; letter-spacing: .1em; animation: xb-confetti 1.1s ease-out both; }
@keyframes xb-pop { from { opacity: 0; transform: translateY(12px) scale(.8); } to { opacity: 1; transform: none; } }
@keyframes xb-slide { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
@keyframes xb-confetti { from { opacity: 0; transform: translateY(13px) scale(.6); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .xum-battle *, .xum-battle *::before, .xum-battle *::after { animation: none !important; }
}

body.xb-playing { overflow: hidden; }
body > .xum-battle:not([hidden]) {
  position: fixed; inset: 0; z-index: 10000; max-width: none; box-sizing: border-box;
  background: var(--xb-panel); overflow: auto; display: flex; flex-direction: column;
  padding: clamp(8px, 2vw, 24px);
}
.xb-arena { flex: 1; align-items: stretch; }
.xb-toolbar { display: flex; flex-wrap: wrap; justify-content: end; gap: 6px; }
.xb-setup { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: 720px; width: 100%; margin: 10px auto; align-items: end; }
.xb-setup input, .xb-setup select, .xb-entry {
  display: block; width: 100%; min-width: 0; box-sizing: border-box; margin-top: 4px;
  padding: 8px; border: 1px solid var(--xb-line); border-radius: 8px;
  background: var(--xb-panel); color: var(--xb-ink); font: inherit;
}
.xb-entry { min-height: 44px; margin: 0; font-size: clamp(18px, 2.2vw, 26px); white-space: pre-wrap; }
.xb-digit { font-size: .5em; }
.xb-question-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 4px; }
.xb-clock { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--xb-accent); }
.xb-clock.xb-clock-low { color: #bf3651; }
body:not(.light) .xb-clock.xb-clock-low { color: #ffc0ce; }
@media (max-width: 500px) { .xb-setup { grid-template-columns: 1fr; } }

body > .xum-battle:not([hidden]) {
  width: 100%; height: 100%; margin: 0; gap: clamp(8px, 1.3vw, 20px);
  background: var(--xb-soft); font-size: clamp(15px, 1.15vw, 23px);
}
.xum-battle .xb-top h2 { font-size: clamp(30px, 3.3vw, 57px); line-height: 1.1; }
.xum-battle .xb-intro { margin: 0; }
.xum-battle .xb-kicker { font-size: .77em; }
.xb-setup { max-width: 960px; margin: auto; padding: clamp(12px, 2.3vw, 32px); background: var(--xb-panel); border: 1px solid var(--xb-line); border-radius: 16px; }
.xb-setup label { font-size: 1em; color: var(--xb-ink); }
.xb-side { display: flex; flex-direction: column; }
.xb-side header { font-size: 1.12em; }
.xb-side header strong { font-size: 1.32em; }
.xb-content { flex: 1; display: flex; flex-direction: column; justify-content: center; min-height: 0; padding: clamp(10px, 2.3vw, 44px); }
.xb-content .xb-question { font-size: clamp(17px, 2.4vw, 42px); line-height: 1.21; }
.xb-content .xb-feedback { font-size: clamp(19px, 2.2vw, 40px); }
.xb-content .xb-wait { margin: 0; text-align: center; font-size: 1.15em; font-weight: 650; }
.xb-side:not(.xb-active,.xb-winner,.xb-loser,.xb-tie) .xb-content { background: var(--xb-soft); }
.xum-battle button { padding: .62em .85em; min-height: 45px; }
.xum-battle .xb-choice { min-height: 52px; }
.xum-battle .xb-choice:hover { border-color: var(--xb-accent); }
.xb-content .xb-clock { font-size: 1.7em; }
.xb-entry { font-size: clamp(18px, 2.5vw, 38px); }
.xb-finished .xb-content { align-items: center; text-align: center; }
.xb-finished .xb-content .xb-outcome { font-size: clamp(24px, 5.5vw, 96px); line-height: 1.1; }
.xb-result-metrics { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; width: 100%; margin: clamp(12px, 2.8vw, 40px) 0 4px; }
.xb-result-metrics > div { flex: 1 1 7em; max-width: 13em; padding: .65em .55em; border: 1px solid currentColor; border-radius: 12px; }
.xb-result-metrics strong, .xb-result-metrics span { display: block; }
.xb-result-metrics strong { font-size: clamp(20px, 3.4vw, 52px); font-variant-numeric: tabular-nums; line-height: 1.2; }
.xb-finished .xb-content > p { font-weight: 700; }
body[data-display=board] > .xum-battle:not([hidden]) { font-size: clamp(17px, 1.55vw, 29px); }
body[data-display=board] .xb-content .xb-question { font-size: clamp(20px, 3.1vw, 54px); }
body[data-display=board] .xum-battle button { min-height: 54px; }
body[data-display=phone] > .xum-battle:not([hidden]) { font-size: 15px; padding: 10px; }
body[data-display=phone] .xb-content { padding: 10px; }
body[data-display=phone] .xb-content .xb-question { font-size: clamp(17px, 3vw, 25px); }
body[data-display=phone] .xb-finished .xb-content .xb-outcome { font-size: clamp(23px, 5vw, 41px); }
@media(max-width: 560px) {
  .xb-content { padding: 8px; }
  .xb-result-metrics { gap: 6px; }
  .xb-arena { gap: 6px; }
  .xum-battle .xb-intro { font-size: .88em; }
}

.xb-arena {grid-template-columns:repeat(var(--xb-players,2),minmax(0,1fr))}
.xb-repeat {margin:12px 0;text-align:center}
@media(max-width:900px){.xb-arena[style] {grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:560px){.xb-arena[style] {grid-template-columns:1fr}.xb-arena .xb-active {order:-1}}
