:root {
  --bg: #090b0d;
  --surface: #111519;
  --surface-2: #171c21;
  --line: #2a3137;
  --gold: #d5aa4e;
  --gold-bright: #f5d77e;
  --red: #d04444;
  --green: #3ba36d;
  --yellow: #c69335;
  --text: #f2f0e9;
  --muted: #929ba3;
  --shadow: 0 24px 70px rgba(0,0,0,.38);
}

* { box-sizing: border-box; }
html { color-scheme: dark; scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; color: var(--text); background: radial-gradient(circle at 78% 2%, rgba(213,170,78,.09), transparent 26rem), linear-gradient(150deg, #0c1013 0%, var(--bg) 45%, #07090a 100%); font-family: "Arial Narrow", "Segoe UI", Arial, sans-serif; }
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .18; background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px); background-size: 32px 32px; mask-image: linear-gradient(to bottom, black, transparent 75%); }
button, select, input { font: inherit; }
button, select { color: inherit; }
button { border: 0; cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 3px; }
.app-shell { width: min(1500px, 100%); margin: 0 auto; padding: 0 32px 30px; position: relative; }
.topbar { min-height: 126px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(213,170,78,.4); }
.brand-block { position: relative; padding-left: 18px; }
.brand-block::before { content: ""; position: absolute; left: 0; top: 3px; bottom: 2px; width: 4px; background: var(--gold); box-shadow: 0 0 18px rgba(213,170,78,.55); }
.eyebrow, .panel-kicker { margin: 0 0 5px; color: var(--gold); font-size: 11px; font-weight: 800; letter-spacing: .28em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 3px; font-family: Impact, "Arial Black", sans-serif; font-size: clamp(29px, 4vw, 43px); letter-spacing: .05em; font-weight: 400; line-height: 1; }
h1 span { color: var(--gold); }
.subtitle { margin: 0; color: #b9bec1; font-size: 12px; font-weight: 800; letter-spacing: .24em; }
.audio-status { display: flex; align-items: center; gap: 10px; color: #bfc6c9; font-size: 11px; font-weight: 800; letter-spacing: .13em; }
.header-statuses { display: flex; flex-direction: column; align-items: flex-end; gap: 13px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 5px rgba(198,147,53,.11), 0 0 16px var(--yellow); }
.audio-status.is-ready .status-dot { background: var(--green); box-shadow: 0 0 0 5px rgba(59,163,109,.11), 0 0 16px var(--green); }
.audio-status.is-muted .status-dot { background: var(--muted); box-shadow: none; }
main { padding-top: 24px; }
.panel { border: 1px solid var(--line); background: linear-gradient(145deg, rgba(25,30,35,.94), rgba(13,16,19,.97)); box-shadow: var(--shadow); }
.battle-panel { min-height: 330px; display: grid; grid-template-columns: minmax(0,1fr) 340px; overflow: hidden; position: relative; }
.battle-panel::after { content: "259"; position: absolute; left: 22px; bottom: -30px; color: rgba(255,255,255,.018); font: 190px/1 Impact, sans-serif; pointer-events: none; }
.battle-copy { padding: 30px; position: relative; z-index: 1; }
.mode-row { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0 12px; }
.mode-chip { padding: 9px 12px; border: 1px solid #3a4248; background: #151a1e; color: #889198; font-size: 10px; font-weight: 900; letter-spacing: .1em; transition: .2s ease; }
.mode-chip:hover { color: white; border-color: #69747c; }
.mode-chip.is-active { color: #101214; background: var(--mode-accent, var(--gold)); border-color: var(--mode-accent, var(--gold)); box-shadow: 0 0 18px color-mix(in srgb, var(--mode-accent, var(--gold)) 28%, transparent); }
.mode-status { max-width: 650px; min-height: 48px; margin-bottom: 28px; padding: 9px 12px; display: flex; align-items: center; gap: 11px; background: color-mix(in srgb, var(--mode-accent, var(--gold)) 8%, #111519); border: 1px solid color-mix(in srgb, var(--mode-accent, var(--gold)) 42%, #30373c); transition: .25s ease; }
.mode-status > span { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--mode-accent, var(--gold)); box-shadow: 0 0 13px var(--mode-accent, var(--gold)); }
.mode-status p { margin: 0; display: flex; flex-direction: column; gap: 3px; }
.mode-status b { color: color-mix(in srgb, var(--mode-accent, var(--gold)) 72%, white); font-size: 11px; letter-spacing: .12em; }
.mode-status small { color: #8e989e; font-size: 10px; }
.battle-panel[data-mode="Тревога"] .mode-status > span { animation: alertPulse .55s infinite alternate; }
.battle-panel[data-mode="Победа"] .mode-status { box-shadow: inset 0 0 22px rgba(213,170,78,.08); }
.delivery-control { max-width: 760px; margin: 0 0 28px; padding: 12px; display: grid; grid-template-columns: minmax(250px,1fr) minmax(175px,.7fr) 155px; align-items: end; gap: 10px; border: 1px solid #343c42; background: rgba(7,9,11,.52); }
.delivery-buttons { min-height: 42px; display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.delivery-button { padding: 8px; color: #879097; background: #171c20; border: 1px solid #353e44; font-size: 9px; font-weight: 900; letter-spacing: .08em; }
.delivery-button.is-active { color: #101214; background: var(--gold); border-color: var(--gold); }
.delivery-button[data-delivery="telegram"].is-active { color: white; background: #277b52; border-color: #48b77c; box-shadow: 0 0 15px rgba(59,163,109,.22); }
.delivery-control label { display: flex; flex-direction: column; gap: 6px; color: #828c93; font-size: 8px; font-weight: 900; letter-spacing: .1em; }
.delivery-control select { height: 42px; padding: 0 8px; background: #111518; border: 1px solid #343d43; font-size: 10px; }
.prebattle-test { min-height: 42px; padding: 7px; color: var(--gold-bright); background: #2b2315; border: 1px solid #685426; font-size: 9px; font-weight: 900; letter-spacing: .08em; }
.last-label { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .22em; margin-bottom: 8px; }
#lastCommand { margin-bottom: 8px; max-width: 800px; font-family: Impact, "Arial Black", sans-serif; font-size: clamp(34px, 5vw, 64px); font-weight: 400; letter-spacing: .025em; line-height: .96; text-wrap: balance; }
.last-text { margin-bottom: 0; color: #aeb5ba; font-size: 15px; }
.commander-frame { position: relative; min-height: 330px; display: flex; align-items: flex-end; justify-content: center; background: linear-gradient(90deg, transparent, rgba(213,170,78,.04)); isolation: isolate; }
.commander-frame::before { content: "COMMANDER"; position: absolute; right: -37px; top: 90px; transform: rotate(90deg); color: rgba(213,170,78,.3); font-size: 9px; font-weight: 900; letter-spacing: .42em; }
.commander-frame img { position: relative; z-index: 2; width: 100%; height: 315px; object-fit: contain; object-position: center bottom; filter: drop-shadow(0 15px 25px rgba(0,0,0,.7)); transition: transform .2s ease, filter .2s ease; }
.commander-glow { position: absolute; z-index: -1; width: 230px; height: 230px; bottom: 18px; border-radius: 50%; background: radial-gradient(circle, rgba(213,170,78,.22), transparent 68%); transition: .25s ease; }
.commander-state { position: absolute; z-index: 3; right: 16px; bottom: 15px; display: flex; align-items: center; gap: 7px; padding: 7px 10px; background: rgba(5,7,8,.86); border: 1px solid #363d42; color: #a9b0b5; font-size: 9px; letter-spacing: .14em; }
.commander-state span { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.commander-frame[data-state="speaking"] img { animation: commanderSpeak .65s ease-in-out infinite alternate; filter: drop-shadow(0 0 20px rgba(213,170,78,.45)); }
.commander-frame[data-state="speaking"] .commander-glow { transform: scale(1.18); background: radial-gradient(circle, rgba(213,170,78,.38), transparent 68%); }
.commander-frame[data-state="alert"] .commander-glow { transform: scale(1.25); background: radial-gradient(circle, rgba(208,68,68,.6), transparent 68%); animation: alertPulse .7s infinite alternate; }
.commander-frame[data-state="alert"] .commander-state span { background: var(--red); }
.commander-frame[data-state="victory"] .commander-glow { transform: scale(1.3); background: radial-gradient(circle, rgba(245,215,126,.58), transparent 70%); animation: victoryPulse 1.2s infinite alternate; }
.commander-frame[data-state="victory"] .commander-state span { background: var(--gold-bright); }
@keyframes commanderSpeak { to { transform: translateY(-3px) scale(1.012); } }
@keyframes alertPulse { to { opacity: .45; transform: scale(1.05); } }
@keyframes victoryPulse { to { opacity: .65; filter: blur(5px); } }
.intro-panel { margin-top: 18px; padding: 22px 24px 18px; border-color: rgba(213,170,78,.38); }
.intro-heading, .section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; }
.intro-heading h2, .section-heading h2 { margin: 0; font: 400 26px/1 Impact, "Arial Black", sans-serif; letter-spacing: .04em; }
.key-hint { padding: 6px 8px; border: 1px solid #3b4247; color: #848d94; font-size: 9px; font-weight: 900; letter-spacing: .14em; }
.intro-actions { display: grid; grid-template-columns: minmax(0,1fr) 170px; gap: 12px; margin-top: 18px; }
.primary-voice { min-height: 72px; display: flex; align-items: center; justify-content: center; gap: 16px; background: linear-gradient(180deg, var(--gold-bright), #bd8c32); color: #111314; font: 400 clamp(22px, 3.4vw, 34px)/1 Impact, "Arial Black", sans-serif; letter-spacing: .05em; box-shadow: inset 0 1px rgba(255,255,255,.45), 0 10px 25px rgba(213,170,78,.15); transition: .16s ease; }
.primary-voice:hover { transform: translateY(-2px); filter: brightness(1.08); }
.primary-voice.is-playing { animation: buttonPulse 1s infinite alternate; }
.play-mark { display: grid; place-items: center; width: 38px; height: 38px; padding-left: 3px; border: 2px solid currentColor; border-radius: 50%; font-size: 15px; }
.stop-button { background: #251719; border: 1px solid #6a3235; color: #e88989; font-size: 12px; font-weight: 900; letter-spacing: .1em; }
.stop-button:hover, .stop-all:hover { background: #3a1c1f; }
.progress-track { height: 4px; margin-top: 16px; background: #282e33; overflow: hidden; }
.progress-fill { width: 0; height: 100%; background: var(--gold-bright); box-shadow: 0 0 12px var(--gold); transition: width .2s linear; }
.intro-meta { margin-top: 7px; display: flex; justify-content: space-between; color: #727c83; font-size: 9px; font-weight: 800; letter-spacing: .15em; }
.commands-section { padding-top: 34px; }
.stop-all { min-height: 45px; padding: 0 15px; background: #241618; border: 1px solid #71383b; color: #ed9999; font-size: 11px; font-weight: 900; letter-spacing: .1em; }
.stop-all span { margin-left: 8px; color: #9a6063; }
.command-groups { margin-top: 18px; display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.command-group { padding: 16px; background: rgba(17,21,25,.78); border: 1px solid #282f34; }
.command-group { transition: opacity .25s ease, transform .25s ease, border-color .25s ease, box-shadow .25s ease; }
.command-group.is-recommended { border-color: color-mix(in srgb, var(--mode-accent, var(--gold)) 58%, #30373c); box-shadow: inset 0 0 28px color-mix(in srgb, var(--mode-accent, var(--gold)) 7%, transparent), 0 8px 24px rgba(0,0,0,.2); transform: translateY(-2px); }
.command-group.is-recommended .group-title { color: var(--text); }
.command-group.is-secondary { opacity: .52; }
.command-group.is-secondary:hover, .command-group.is-secondary:focus-within { opacity: 1; }
.group-title { display: flex; align-items: center; gap: 9px; margin: 0 0 12px; color: #aab1b6; font-size: 11px; letter-spacing: .17em; }
.group-title::before { content: ""; width: 3px; height: 13px; background: var(--group-accent, var(--gold)); }
.command-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.command-button { min-height: 92px; padding: 14px; text-align: left; position: relative; overflow: hidden; background: linear-gradient(140deg, #1b2125, #14181b); border: 1px solid #333b41; transition: transform .15s ease, border-color .15s ease, filter .15s ease; }
.command-button::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent, var(--gold)); box-shadow: 0 0 16px color-mix(in srgb, var(--accent, var(--gold)) 70%, transparent); }
.command-button:hover { transform: translateY(-2px); border-color: #606b73; filter: brightness(1.08); }
.command-button b { display: block; margin-bottom: 7px; font-size: 15px; line-height: 1.06; letter-spacing: .035em; }
.command-button small { color: #899299; font-size: 10px; line-height: 1.25; }
.command-button .command-key { position: absolute; top: 7px; right: 7px; padding: 3px 5px; border: 1px solid #3b444a; color: #69737a; font-size: 8px; }
.command-button.is-playing { border-color: var(--accent, var(--gold)); animation: buttonPulse .6s infinite alternate; }
.command-button.was-played::after { content: "✓"; position: absolute; right: 8px; bottom: 5px; color: var(--accent, var(--green)); font-weight: 900; }
@keyframes buttonPulse { to { box-shadow: inset 0 0 22px color-mix(in srgb, var(--accent, var(--gold)) 25%, transparent), 0 0 14px color-mix(in srgb, var(--accent, var(--gold)) 20%, transparent); } }
.lower-grid { margin-top: 32px; display: grid; grid-template-columns: 1.25fr .75fr; gap: 16px; }
.settings-panel, .log-panel { padding: 22px; }
.section-heading.compact { align-items: center; }
.section-heading.compact h2 { font-size: 22px; }
.test-voice, .clear-log { min-height: 38px; padding: 0 13px; background: #1a2024; border: 1px solid #3b444b; color: #d0d4d6; font-size: 10px; font-weight: 900; letter-spacing: .1em; }
.test-voice:hover, .clear-log:hover { border-color: var(--gold); color: var(--gold-bright); }
.settings-grid { margin-top: 20px; display: grid; grid-template-columns: 1.4fr .7fr .8fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 7px; color: #929ba2; font-size: 9px; font-weight: 900; letter-spacing: .13em; }
.field select { width: 100%; height: 42px; padding: 0 10px; background: #101417; border: 1px solid #333b41; }
.volume-field { grid-column: 1/-1; flex-direction: row; align-items: center; flex-wrap: wrap; }
.volume-field output { margin-left: auto; color: var(--gold-bright); }
input[type="range"] { width: 100%; accent-color: var(--gold); }
.switch-list { margin-top: 18px; border-top: 1px solid #2c3338; }
.switch-row { min-height: 58px; display: flex; align-items: center; border-bottom: 1px solid #272e33; cursor: pointer; }
.switch-row > span { display: flex; flex-direction: column; gap: 3px; margin-right: auto; }
.switch-row b { font-size: 12px; letter-spacing: .03em; }
.switch-row small { color: #7e888f; font-size: 10px; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-row i { width: 42px; height: 23px; padding: 3px; border-radius: 20px; background: #30373c; transition: .2s; }
.switch-row i::before { content: ""; display: block; width: 17px; height: 17px; border-radius: 50%; background: #838c92; transition: .2s; }
.switch-row input:checked + i { background: rgba(213,170,78,.3); }
.switch-row input:checked + i::before { transform: translateX(19px); background: var(--gold-bright); }
.switch-row input:focus-visible + i { outline: 3px solid var(--gold-bright); outline-offset: 3px; }
.custom-audio { margin-top: 22px; padding: 18px; border: 1px solid rgba(213,170,78,.36); background: rgba(213,170,78,.035); }
.custom-audio-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.custom-audio-heading h3 { margin: 0; font: 400 20px/1 Impact, "Arial Black", sans-serif; letter-spacing: .05em; }
.custom-audio-heading > span { padding: 6px 8px; border: 1px solid #4b4433; color: var(--gold-bright); font-size: 10px; font-weight: 900; letter-spacing: .12em; }
.custom-audio-help { margin: 11px 0 16px; color: #8f989e; font-size: 11px; line-height: 1.4; }
.custom-single-row { display: grid; grid-template-columns: minmax(180px,1fr) 185px; align-items: end; gap: 10px; }
.custom-audio-button, .clear-custom-audio { min-height: 42px; padding: 0 13px; font-size: 10px; font-weight: 900; letter-spacing: .08em; }
.custom-audio-button { background: var(--gold); color: #121416; }
.custom-audio-button:hover { background: var(--gold-bright); }
.custom-audio-button.secondary { color: #d6d8d9; background: #242b30; border: 1px solid #465057; }
.custom-batch-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.clear-custom-audio { margin-left: auto; color: #d18484; background: #251719; border: 1px solid #673235; }
.clear-custom-audio:disabled { opacity: .35; cursor: not-allowed; }
.custom-audio-result { min-height: 16px; margin: 12px 0 0; color: #8d969c; font-size: 10px; line-height: 1.35; }
.custom-audio-result.is-success { color: #68c891; }
.custom-audio-result.is-error { color: #e27b7b; }
.command-log { margin: 18px 0 0; padding: 0; list-style: none; max-height: 330px; overflow: auto; }
.log-item { display: grid; grid-template-columns: 56px 1fr; gap: 9px; padding: 11px 0; border-bottom: 1px solid #293035; }
.log-item time { color: var(--gold); font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.log-item b { display: block; font-size: 11px; line-height: 1.2; }
.log-item small { color: #788188; font-size: 9px; }
.empty-log { margin: 45px 0; text-align: center; color: #555e64; font-size: 10px; font-weight: 900; letter-spacing: .17em; }
footer { min-height: 65px; margin-top: 25px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid #252c30; color: #515a60; font-size: 9px; font-weight: 900; letter-spacing: .18em; }
dialog { width: min(430px, calc(100% - 32px)); padding: 0; color: var(--text); background: #15191c; border: 1px solid #6d3337; box-shadow: 0 30px 100px #000; }
dialog::backdrop { background: rgba(0,0,0,.78); backdrop-filter: blur(4px); }
dialog form { padding: 28px; }
dialog h2 { font: 400 27px/1 Impact, sans-serif; }
dialog p:not(.panel-kicker) { color: #9ca4aa; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }
.dialog-actions button { min-height: 42px; padding: 0 16px; background: #282f34; font-size: 11px; font-weight: 900; }
.dialog-actions .danger-action { background: var(--red); color: white; }

@media (max-width: 1080px) {
  .app-shell { padding-inline: 20px; }
  .command-groups { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .lower-grid { grid-template-columns: 1fr; }
  .delivery-control { grid-template-columns: 1fr 1fr; }
  .delivery-buttons { grid-column: 1/-1; }
}
@media (max-width: 767px) {
  .app-shell { padding-inline: 12px; }
  .topbar { min-height: 108px; }
  .audio-status { align-self: flex-start; margin-top: 18px; }
  .audio-status span:last-child { display: none; }
  .header-statuses { flex-direction: row; align-self: flex-start; gap: 14px; }
  .battle-panel { grid-template-columns: 1fr; }
  .battle-copy { padding: 22px; }
  .mode-status { margin-bottom: 28px; }
  .commander-frame { min-height: 230px; border-top: 1px solid #2d3439; }
  .commander-frame img { height: 230px; }
  .intro-actions { grid-template-columns: 1fr; }
  .primary-voice { min-height: 82px; }
  .stop-button { min-height: 52px; }
  .section-heading:not(.compact) { align-items: stretch; flex-direction: column; }
  .stop-all { width: 100%; }
  .command-groups { grid-template-columns: 1fr; }
  .command-button { min-height: 86px; }
  .settings-grid { grid-template-columns: 1fr 1fr; }
  .field.wide { grid-column: 1/-1; }
  .custom-single-row { grid-template-columns: 1fr; }
  .custom-audio-button { min-height: 48px; }
  .clear-custom-audio { margin-left: 0; }
  .delivery-control { grid-template-columns: 1fr; }
  .delivery-buttons { grid-column: auto; }
}
@media (max-width: 440px) {
  .command-list, .settings-grid { grid-template-columns: 1fr; }
  .field.wide { grid-column: auto; }
  #lastCommand { font-size: 36px; }
  .intro-panel, .settings-panel, .log-panel { padding: 17px; }
  footer { align-items: flex-start; padding-top: 20px; flex-direction: column; justify-content: flex-start; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
