/* PromptArena — brand from agentroot.ru (Cloud.ru): green #26d07c, dark #222, SB Sans Display.
   Single dark theme with soft surfaces: no pure-white panels on a dark page (eye strain),
   text contrast kept within WCAG AA/AAA but below "full white on black". */
@font-face { font-family: 'SB Sans Display'; src: url('/fonts/SBSansDisplay-Regular.woff2') format('woff2'), url('/fonts/SBSansDisplay-Regular.woff') format('woff'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'SB Sans Display'; src: url('/fonts/SBSansDisplay-SemiBold.woff2') format('woff2'), url('/fonts/SBSansDisplay-SemiBold.woff') format('woff'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'SB Sans Display'; src: url('/fonts/SBSansDisplay-Bold.woff2') format('woff2'), url('/fonts/SBSansDisplay-Bold.woff') format('woff'); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  color-scheme: dark;
  /* brand */
  --green: #26d07c;
  --green-hover: #3ddb8c;
  --green-press: #20b86d;
  --green-tint: rgba(38, 208, 124, .12);
  --green-line: rgba(38, 208, 124, .45);
  --team-a: #26d07c;
  --team-b: #ff6a5e;
  --team-b-tint: rgba(255, 106, 94, .12);
  --warn: #f5b041;
  --warn-tint: rgba(245, 176, 65, .12);
  --danger: #ff7a6e;
  --live: #ff4d42;
  /* surfaces (elevation goes lighter) */
  --bg: #141517;
  --header: #1a1b1e;
  --surface: #1f2023;
  --surface-2: #26282c;
  --surface-3: #2e3035;
  --border: #33353b;
  --border-strong: #44474f;
  /* text */
  --text-strong: #eceef2;   /* 14.5:1 on --surface */
  --text: #c9ccd4;          /* 10.9:1 */
  --text-2: #9296a3;        /*  5.8:1 — secondary, still AA for small text */
  --text-3: #6f7380;        /* decorative only */
  --on-green: #10251a;
  /* misc */
  --radius: 6px;
  --radius-sm: 4px;
  --header-h: 60px;
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--green);
  --font-primary: 'SB Sans Display', 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-primary);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'tnum' 0;
}
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
:focus { outline: none; }
:focus-visible { box-shadow: var(--focus); border-radius: var(--radius-sm); }
.hidden { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 12px; line-height: 1.5; }
.strong { font-weight: 600; color: var(--text-strong); }
.err { color: var(--danger); min-height: 16px; }
.ok { color: var(--green); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
::selection { background: var(--green-line); color: var(--text-strong); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ---------- header ---------- */
.topbar {
  height: var(--header-h); display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; background: var(--header); color: var(--text-strong);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 14px; color: inherit; text-decoration: none; }
.brand-logo { height: 20px; width: auto; }
.brand-sep { width: 1px; height: 20px; background: var(--border-strong); }
.brand-name { font-size: 19px; font-weight: 600; letter-spacing: .2px; }
.brand-name b { color: var(--green); font-weight: 600; }
.brand-name .brace { color: var(--green); margin: 0 2px; }
.topnav { display: flex; align-items: center; gap: 16px; }
.linkbtn { background: none; border: 0; color: var(--text); padding: 6px 2px; }
.linkbtn:hover { color: var(--green); }
.load-pill { font-size: 12px; padding: 5px 11px; border: 1px solid var(--border); border-radius: 20px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.load-pill b { color: var(--green); font-weight: 600; }
.user-chip { display: flex; align-items: center; gap: 12px; }
.user-chip .nick { font-weight: 600; color: var(--text-strong); }
.user-chip .elo { font-size: 12px; color: var(--green); font-variant-numeric: tabular-nums; }
.btn-green-sm { background: var(--green); color: var(--on-green); border: 0; border-radius: var(--radius-sm); padding: 8px 16px; font-weight: 600; }
.btn-green-sm:hover { background: var(--green-hover); }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 360px;
  grid-template-rows: minmax(0, 1fr) 172px;
  grid-template-areas: "left center right" "bottom bottom bottom";
  gap: 12px; padding: 12px;
  height: calc(100vh - var(--header-h));
  min-height: 680px;
}
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.col-left { grid-area: left; display: flex; flex-direction: column; }
.col-center { grid-area: center; display: flex; flex-direction: column; min-width: 0; gap: 8px; }
.col-right { grid-area: right; padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.col-bottom { grid-area: bottom; display: flex; flex-direction: column; }
.panel-title { font-weight: 600; font-size: 16px; color: var(--text-strong); }
.col-left .panel-title { padding: 14px 16px 8px; display: flex; justify-content: space-between; align-items: baseline; }
.my-rank { font-size: 12px; font-weight: 400; color: var(--green); }

/* ---------- tournament ---------- */
.round-card { background: linear-gradient(135deg, var(--green-tint), transparent 70%), var(--surface-2); padding: 16px; border-bottom: 1px solid var(--border); }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--green); }
.round-title { font-size: 22px; font-weight: 600; margin-top: 4px; color: var(--text-strong); }
.round-sub { font-size: 12px; color: var(--text-2); margin-top: 4px; }
.lb-wrap { overflow-y: auto; flex: 1; }
.lb { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.lb th { position: sticky; top: 0; background: var(--surface); text-align: left; font-weight: 400; color: var(--text-2); padding: 6px 8px; border-bottom: 1px solid var(--border); cursor: help; }
.lb td { padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.lb td:nth-child(2) { max-width: 110px; overflow: hidden; text-overflow: ellipsis; color: var(--text-strong); }
.lb tbody tr:hover td { background: var(--surface-2); }
.lb tr.me td { background: var(--green-tint); }
.lb tr.me td:nth-child(2) { color: var(--green); font-weight: 600; }
.lb tr.bot td:nth-child(2) { color: var(--text-2); }
.lb .rank { color: var(--text-3); width: 24px; }
.lb tr:nth-child(1) .rank { color: #f0c24b; font-weight: 700; }
.lb tr:nth-child(2) .rank { color: #b9bfcc; font-weight: 700; }
.lb tr:nth-child(3) .rank { color: #d99560; font-weight: 700; }
.lb .empty-row td { color: var(--text-2); white-space: normal; text-align: center; padding: 18px 10px; }

/* ---------- scoreboard ---------- */
.scoreboard {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 18px; position: relative; overflow: hidden;
}
.scoreboard::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, var(--team-a), transparent 40%, transparent 60%, var(--team-b)); }
.sb-team { min-width: 0; }
.sb-b { text-align: right; }
.sb-name { font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-a .sb-name { color: var(--team-a); }
.sb-b .sb-name { color: var(--team-b); }
.sb-sub { font-size: 11.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-mid { text-align: center; padding: 0 20px; }
.sb-score { font-size: 34px; font-weight: 700; line-height: 1; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.sb-score i { font-style: normal; color: var(--text-3); margin: 0 8px; font-weight: 400; }
.sb-score .bump { animation: bump .6s ease-out; display: inline-block; }
@keyframes bump { 0% { transform: scale(1.6); color: var(--green); } 100% { transform: scale(1); } }
.sb-clock { font-size: 12px; color: var(--text-2); display: flex; gap: 8px; justify-content: center; margin-top: 3px; font-variant-numeric: tabular-nums; }
.sb-phase { color: var(--green); text-transform: uppercase; letter-spacing: .06em; }
.sb-phase.ot { color: var(--warn); }

/* ---------- stage ---------- */
.stage { position: relative; flex: 1; min-height: 0; background: #0f1011; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
#arena { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage-badge {
  position: absolute; top: 10px; left: 10px; display: flex; align-items: center; gap: 8px;
  background: rgba(20, 21, 23, .82); backdrop-filter: blur(4px); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 12px 4px 10px; font-size: 12px; color: var(--text); pointer-events: none;
}
.stage-badge:empty { display: none; }
.stage-badge .kind { color: var(--text-2); }
.badge-live { color: var(--live); font-weight: 600; letter-spacing: .06em; }
.badge-replay { color: var(--warn); font-weight: 600; letter-spacing: .06em; }
.badge-mine { background: var(--green); color: var(--on-green); border-radius: 10px; padding: 0 7px; font-weight: 600; }
.overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.tag { position: absolute; transform: translate(-50%, -100%); font-size: 11px; font-weight: 600; white-space: nowrap; pointer-events: none; text-shadow: 0 1px 3px #000, 0 0 2px #000; }
.tag .bar { display: block; height: 3px; width: 26px; margin: 2px auto 0; background: rgba(255,255,255,.2); border-radius: 2px; overflow: hidden; }
.tag .bar i { display: block; height: 100%; background: #ffd23f; }
.pop { position: absolute; transform: translate(-50%, -50%); font-weight: 600; font-size: 13px; white-space: nowrap; pointer-events: none; animation: pop 1.3s ease-out forwards; text-shadow: 0 2px 4px #000; }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -80%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -200%) scale(1); } }
.feed { position: absolute; left: 10px; bottom: 10px; width: 300px; max-width: calc(100% - 20px); display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.feed div { background: rgba(20, 21, 23, .84); color: var(--text); padding: 5px 9px; font-size: 12px; border-left: 3px solid var(--green); animation: feedIn .25s ease-out; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.feed div.b { border-left-color: var(--team-b); }
.feed div.n { border-left-color: var(--text-3); }
@keyframes feedIn { from { opacity: 0; transform: translateX(-12px); } }
.banner { position: absolute; top: 40%; left: 0; right: 0; text-align: center; font-size: 64px; font-weight: 700; color: #fff; pointer-events: none; opacity: 0; letter-spacing: .04em; text-shadow: 0 0 30px rgba(0,0,0,.8); }
.banner.show { animation: banner 2.4s ease-out forwards; }
.banner small { display: block; font-size: 18px; font-weight: 400; margin-top: 6px; }
@keyframes banner { 0% { opacity: 0; transform: scale(2.5); } 12% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(.95); } }
.stage-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--text); font-size: 16px; pointer-events: none; background: radial-gradient(ellipse at center, rgba(0,0,0,.55), rgba(0,0,0,.2)); padding: 20px; }
.stage-msg:empty { display: none; }
.stage-msg .spinner { width: 34px; height: 34px; border: 3px solid var(--border-strong); border-top-color: var(--green); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.speed { position: absolute; top: 10px; right: 10px; display: flex; background: rgba(20, 21, 23, .84); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.speed.hidden { display: none; }
.speed button { background: none; border: 0; color: var(--text-2); padding: 5px 10px; font-size: 12px; }
.speed button:hover { color: var(--text-strong); }
.speed button.active { background: var(--green); color: var(--on-green); font-weight: 600; }

/* ---------- team panels ---------- */
.teams-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.team-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; font-size: 12px; min-height: 60px; box-shadow: inset 0 3px 0 var(--team-a); }
.team-b { box-shadow: inset 0 3px 0 var(--team-b); }
.team-panel:empty::after { content: 'Тактика появится, когда тренер закончит'; color: var(--text-3); }
.tp-head { display: flex; justify-content: space-between; gap: 8px; }
.tp-motto { color: var(--text-2); font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-src { font-size: 10.5px; padding: 1px 7px; border-radius: 10px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.tp-src.llm { background: var(--green-tint); color: var(--green); }
.tp-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; align-items: center; }
.ab { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; position: relative; cursor: help; color: var(--text); transition: opacity .2s; }
.ab .pips { display: inline-flex; gap: 2px; }
.ab .pips i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-3); }
.ab .pips i.on { background: var(--green); }
.team-b .ab .pips i.on { background: var(--team-b); }
.ab.cooldown { opacity: .5; }
.role { padding: 2px 8px; border: 1px solid var(--border); border-radius: 12px; color: var(--text-2); }

/* ---------- prompt panel ---------- */
.field-label { font-size: 13px; font-weight: 600; color: var(--text-strong); display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.field-label .muted { font-weight: 400; }
textarea, input[type=email], input[type=text] {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 13px; color: var(--text-strong); transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 200px; resize: vertical; line-height: 1.5; font-size: 13.5px; }
textarea:hover, input:hover { border-color: var(--border-strong); }
textarea:focus, input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-tint); }
textarea:focus-visible, input:focus-visible { border-radius: var(--radius-sm); }
::placeholder { color: var(--text-3); }
.prompt-meta { display: flex; justify-content: space-between; align-items: flex-start; font-size: 11.5px; color: var(--text-2); gap: 8px; margin-top: 6px; }
.prompt-meta .count { font-variant-numeric: tabular-nums; white-space: nowrap; }
.prompt-meta .count.near { color: var(--warn); }
.prompt-meta .count.short { color: var(--text-3); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.chips span { background: var(--green-tint); color: var(--green); padding: 1px 7px; border-radius: 10px; }
.templates { display: flex; flex-wrap: wrap; gap: 6px; }
.templates button { background: var(--surface-2); border: 1px dashed var(--border-strong); color: var(--text); border-radius: 14px; padding: 4px 10px; font-size: 12px; }
.templates button:hover { border-color: var(--green); color: var(--green); }
.btn-primary {
  width: 100%; background: var(--green); color: var(--on-green); border: 0; border-radius: var(--radius-sm);
  padding: 13px; font-size: 15px; font-weight: 600; transition: background .15s, transform .05s;
}
.btn-primary:hover:not(:disabled) { background: var(--green-hover); }
.btn-primary:active:not(:disabled) { background: var(--green-press); transform: translateY(1px); }
.btn-primary:disabled { background: var(--surface-3); color: var(--text-2); cursor: not-allowed; }
.btn-secondary { width: 100%; background: transparent; color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 12px; font-size: 15px; }
.btn-secondary:hover { border-color: var(--text-2); color: var(--text-strong); }
.kbd-hint { font-size: 11px; color: var(--text-3); text-align: center; margin-top: -6px; }
kbd { font-family: inherit; font-size: 10.5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 3px; padding: 0 4px; color: var(--text-2); }
.attempts { display: flex; gap: 4px; align-items: center; }
.attempts .dot { flex: 1; height: 6px; background: var(--green); border-radius: 3px; }
.attempts .dot.used { background: var(--surface-3); }
.attempts .lbl { font-size: 12px; margin-left: 8px; white-space: nowrap; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.attempts.low .dot:not(.used) { background: var(--warn); }
.warn { background: var(--warn-tint); color: #f3cf8e; font-size: 12px; padding: 8px 10px; border-left: 3px solid var(--warn); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.intro { margin: -4px 0 0; }
details.block { border-top: 1px solid var(--border); padding-top: 10px; }
details.block summary { font-weight: 600; color: var(--text-strong); padding: 2px 0; cursor: pointer; list-style: none; display: flex; justify-content: space-between; }
details.block summary::-webkit-details-marker { display: none; }
details.block summary::after { content: '›'; color: var(--text-2); transform: rotate(90deg); transition: transform .15s; }
details.block[open] summary::after { transform: rotate(-90deg); }
.catalog { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; font-size: 12px; }
.catalog div b { color: var(--text-strong); font-weight: 600; }
.catalog code { font-size: 11px; background: var(--surface-3); padding: 0 5px; border-radius: 3px; color: var(--text-2); }
.my-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.ver { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 12px; background: var(--surface-2); }
.ver.active { border-color: var(--green-line); background: var(--green-tint); }
.ver-head { display: flex; justify-content: space-between; font-weight: 600; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.ver-prompt { color: var(--text-2); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; background: none; border: 0; padding: 0; text-align: left; font-size: 12px; width: 100%; }
.ver-prompt:hover { color: var(--text-strong); }

/* ---------- bottom strip ---------- */
.tabs { display: flex; gap: 2px; padding: 6px 12px 0; border-bottom: 1px solid var(--border); }
.tabs button { background: none; border: 0; padding: 8px 14px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--text-strong); }
.tabs button.active, .tabs button[aria-selected=true] { color: var(--text-strong); border-bottom-color: var(--green); font-weight: 600; }
.tabs b { font-weight: 600; background: var(--surface-3); border-radius: 10px; padding: 0 6px; margin-left: 4px; font-size: 11px; font-variant-numeric: tabular-nums; }
.strip { flex: 1; display: flex; gap: 10px; overflow-x: auto; padding: 10px 12px; align-items: stretch; }
.strip .empty { color: var(--text-2); align-self: center; padding-left: 8px; }
.mcard {
  flex: 0 0 214px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  display: flex; flex-direction: column; transition: border-color .15s, transform .15s; position: relative; overflow: hidden;
  text-align: left; padding: 0; color: inherit;
}
.mcard:hover { border-color: var(--green-line); transform: translateY(-2px); }
.mcard.watching { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.mcard.mine::after { content: 'моя'; position: absolute; top: 4px; right: 4px; font-size: 10px; background: var(--green); color: var(--on-green); padding: 0 6px; border-radius: 8px; font-weight: 600; }
.mcard canvas { width: 100%; height: 58px; display: block; background: #16261d; }
.mc-body { padding: 6px 9px; font-size: 12px; width: 100%; }
.mc-row { display: flex; justify-content: space-between; gap: 6px; }
.mc-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-a { color: var(--team-a); font-weight: 600; }
.mc-b { color: var(--team-b); font-weight: 600; }
.mc-score { font-weight: 700; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.mc-foot { display: flex; justify-content: space-between; color: var(--text-2); font-size: 11px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.live-dot { display: inline-block; width: 7px; height: 7px; background: var(--live); border-radius: 50%; margin-right: 4px; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.kind { text-transform: uppercase; font-size: 10px; letter-spacing: .05em; }
.qcard { flex: 0 0 190px; padding: 10px; background: transparent; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); font-size: 12px; display: flex; flex-direction: column; justify-content: center; gap: 4px; position: relative; }
.qcard.mine { border-color: var(--green-line); }
.qcard .pos { font-size: 22px; font-weight: 700; color: var(--text-strong); font-variant-numeric: tabular-nums; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--surface-3); border: 1px solid var(--border-strong); border-left: 3px solid var(--green); border-radius: var(--radius-sm); color: var(--text-strong); padding: 10px 14px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: toastIn .25s ease-out; max-width: 340px; display: flex; gap: 10px; align-items: center; }
.toast button { background: none; border: 0; color: var(--green); font-weight: 600; padding: 0; white-space: nowrap; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; background: rgba(8, 9, 10, .72); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); width: 462px; max-width: 100%; padding: 26px 26px 22px; position: relative; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal-card.wide { width: 680px; }
.modal-card h2 { margin: 0 0 18px; color: var(--text-strong); font-weight: 600; font-size: 24px; }
.modal-card form { display: flex; flex-direction: column; gap: 10px; }
.modal-x { position: absolute; top: 10px; right: 12px; background: none; border: 0; font-size: 24px; color: var(--text-2); width: 32px; height: 32px; border-radius: var(--radius-sm); }
.modal-x:hover { color: var(--text-strong); background: var(--surface-2); }
.rules p { line-height: 1.6; margin: 0 0 12px; }
.rules b { color: var(--text-strong); }
.confirm-prompt { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 12.5px; color: var(--text); max-height: 160px; overflow-y: auto; white-space: pre-wrap; margin: 0 0 12px; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin-top: 16px; }

@media (max-width: 1200px) {
  .layout { grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: minmax(480px, 1fr) 172px auto; grid-template-areas: "center right" "bottom bottom" "left left"; height: auto; }
  .col-left { max-height: 420px; }
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto; grid-template-areas: "center" "right" "bottom" "left"; padding: 8px; gap: 8px; }
  .stage { min-height: 260px; aspect-ratio: 17 / 10; flex: none; }
  .col-right { overflow: visible; }
  .col-bottom { min-height: 180px; }
  .teams-bar { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; }
  .topnav { gap: 10px; }
  .brand-logo, .brand-sep, .load-pill, .user-chip .elo { display: none; }
  .tabs { overflow-x: auto; }
  .tabs button { white-space: nowrap; padding: 8px 10px; }
  .scoreboard { padding: 8px 10px; }
  .sb-mid { padding: 0 8px; }
  .sb-score { font-size: 28px; }
  .banner { font-size: 44px; }
  .feed { width: auto; right: 10px; }
  .kbd-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  /* keep the goal/result banner readable: a plain fade instead of the zoom */
  .banner.show { animation: bannerFade 2.4s linear forwards !important; }
  @keyframes bannerFade { 0%, 100% { opacity: 0; } 8%, 85% { opacity: 1; } }
}

/* ---------- tournaments ---------- */
.conds { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text); }
.conds li::before { content: '• '; color: var(--green); }
.conds:empty { display: none; }
.lb-tabs { padding: 4px 12px 0; align-items: center; }
.lb-tabs button { padding: 7px 10px; }
.t-select { margin-left: auto; max-width: 150px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px 6px; font-size: 12px; }
.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 0 12px 10px; }
.podium .place { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; background: var(--surface-2); border-radius: var(--radius-sm); border-top: 3px solid var(--border-strong); min-width: 0; }
.podium .p1 { border-top-color: #f0c24b; background: linear-gradient(180deg, rgba(240, 194, 75, .14), transparent), var(--surface-2); }
.podium .p2 { border-top-color: #b9bfcc; }
.podium .p3 { border-top-color: #d99560; }
.podium .medal { font-size: 22px; line-height: 1; }
.podium .pname { font-weight: 600; color: var(--text-strong); font-size: 12.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .ppts { font-size: 11px; color: var(--text-2); }
.t-rounds { margin: 10px 12px 14px; }
.t-round-list { margin: 8px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; }
.t-round-list .r-head { display: flex; justify-content: space-between; gap: 8px; }
.t-round-list .r-running b { color: var(--green); }
.t-round-list .r-pending, .t-round-list .r-skipped { opacity: .75; }

/* ---------- admin ---------- */
.admin { display: flex; flex-direction: column; gap: 12px; }
.admin-status { background: var(--surface-2); border-left: 3px solid var(--green); padding: 10px 12px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 13px; color: var(--text-strong); }
.admin-actions { display: flex; gap: 10px; }
.admin-actions > * { flex: 1; }
.admin-actions button:disabled { opacity: .45; cursor: not-allowed; }
.btn-secondary.danger { color: var(--danger); border-color: rgba(255, 122, 110, .45); }
textarea.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; min-height: 260px; }
.admin-help p { margin: 6px 0; }
.admin-preview { font-size: 12.5px; }
.admin-preview ol { margin: 6px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.admin .linkbtn { align-self: flex-start; }
