:root { color-scheme: dark; --bg: #1b1d22; --panel: #262930; --line: #3a3e48; --text: #ddd; --muted: #9aa0ab; --accent: #ffd24a; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.4 sans-serif; }
button { font: inherit; padding: 6px 10px; cursor: pointer; background: #343843; color: var(--text); border: 1px solid var(--line); border-radius: 4px; }
button:hover:not(:disabled) { background: #3f4452; }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: #3c5f8a; border-color: #4d78aa; }
select { font: inherit; background: #343843; color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 4px; }

.layout { display: flex; gap: 12px; padding: 12px; justify-content: center; align-items: flex-start; flex-wrap: wrap; }
canvas { background: #000; cursor: crosshair; max-width: 100%; height: auto; border-radius: 4px; }

.topbar { display: flex; gap: 18px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar .resources { background: none; border: 0; padding: 0; }

.banner { background: #6b4fa0; border-color: #8a6bc4; font-weight: 600; }
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 12px; }
.modal { background: var(--panel); border: 1px solid var(--accent); border-radius: 8px; padding: 18px 20px; max-width: 560px; width: 100%; }
.modal h2 { margin: 0 0 4px; }
.choices { display: flex; gap: 12px; margin: 12px 0; flex-wrap: wrap; }
.choice { flex: 1 1 200px; background: #1f2229; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
.choice.potion { border-color: #c05a6a; }
.choice h3 { margin: 0 0 4px; }
.choice p { margin: 4px 0; }

.slots-box { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.slots { display: flex; gap: 6px; }
.slot { flex: 1; min-height: 34px; padding: 4px 6px; font-size: 12px; text-align: center; border-radius: 4px; border: 1px dashed var(--line); display: flex; align-items: center; justify-content: center; }
.slot.empty { color: var(--muted); }
.slot.full { border-style: solid; border-color: var(--accent); }
.slot.locked.off { opacity: 0.4; }
.fit { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.fit button { text-align: left; font-size: 12px; }
.item.static { cursor: default; }
button.small { padding: 0 6px; }

.board { position: relative; line-height: 0; max-width: 100%; }
.gameover { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; line-height: 1.3; text-align: center; padding: 12px; }
.gameover h2 { margin: 0; font-size: 36px; text-shadow: 0 2px 6px #000; }
.gameover .score { margin: 0; font-size: 20px; text-shadow: 0 2px 6px #000; }
.record { color: var(--accent); font-weight: 700; }
button.big { font-size: 18px; padding: 10px 24px; margin-top: 6px; }

/* три колонки: пустая | ресурсы и кнопка волны по центру | счёт у правого края */
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; }
.topbar .screenctl { grid-column: 1; justify-self: start; display: flex; gap: 6px; align-items: center; }
button.icon { padding: 2px 8px; font-size: 16px; line-height: 1.2; }
select.small { padding: 2px 4px; font-size: 13px; }
.topbar .topcenter { grid-column: 2; display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; }
.topbar .score { grid-column: 3; justify-self: end; font-size: 16px; }
@media (max-width: 700px) {
  .topbar { grid-template-columns: 1fr auto; }
  .topbar .topcenter { grid-column: 1; justify-content: flex-start; }
  .topbar .score { grid-column: 2; }
}
.replaytag { color: var(--accent); font-weight: 600; }
.row.center { justify-content: center; }
progress { width: 100%; height: 10px; margin: 4px 0 8px; accent-color: var(--accent); }

.gamepanel { border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.gamepanel h4 { margin: 0; color: var(--muted); font-weight: 400; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.gamepanel .modeline { margin: 0; font-size: 13px; color: var(--muted); }
.gamepanel .row { align-items: center; }
.admin-link { margin-left: auto; opacity: 0.6; }
.admin-link:hover { opacity: 1; }

.modal.admin { max-width: 860px; max-height: 90vh; overflow: auto; }
.adminhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.adminhead h2 { margin: 0; }
.admin-body { margin-top: 10px; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.stat { flex: 1 1 110px; background: #1f2229; border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; display: flex; flex-direction: column; }
.stat b { font-size: 20px; }
.stat span { color: var(--muted); font-size: 12px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; color: var(--muted); font-weight: 400; padding: 3px 6px; }
.data-table td { padding: 4px 6px; border-top: 1px solid var(--line); }
.data-table tr.me td { color: var(--accent); }
.data-table .actions { white-space: nowrap; text-align: right; }
.filters { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.filters input { font: inherit; padding: 4px 8px; background: #1f2229; color: var(--text); border: 1px solid var(--line); border-radius: 4px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.settings-block { border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; margin-bottom: 12px; }
.settings-block h3 { margin: 0 0 4px; font-size: 15px; }
.season-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .season-grid { grid-template-columns: 1fr; } }
.preview { width: 100%; height: auto; border-radius: 4px; background: #000; display: block; }

.modebadge { color: var(--accent); font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; color: var(--muted); font-size: 13px; }
.field input { font: inherit; padding: 6px 8px; background: #1f2229; color: var(--text); border: 1px solid var(--line); border-radius: 4px; }
.submit { margin: 4px 0; font-size: 14px; }
.submit.ok { color: #8fe38f; }
.submit.err { color: #ff8f8f; }
.board-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.board-table th { text-align: left; color: var(--muted); font-weight: 400; padding: 2px 4px; }
.board-table td { padding: 3px 4px; border-top: 1px solid var(--line); }
.board-table tr.me td { color: var(--accent); font-weight: 600; }

.sidebar { width: 340px; max-width: 100%; display: flex; flex-direction: column; gap: 10px; }
.resources { display: flex; gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; font-size: 16px; flex-wrap: wrap; }
.resources b { font-weight: 600; }
.rate { color: #8fe38f; margin-left: 3px; font-size: 12px; }
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.wavebadge { color: var(--muted); font-size: 13px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; min-height: 96px; }
.card h3 { margin: 0 0 4px; font-size: 15px; }
.card p { margin: 4px 0 8px; color: var(--muted); }
.card.muted { color: var(--muted); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

.tabs { display: flex; gap: 4px; }
.tabs button { flex: 1; border-radius: 4px 4px 0 0; }
.tabs button.on { background: #4a4f5e; border-color: var(--accent); }
.list { display: flex; flex-direction: column; gap: 6px; }
.list p { margin: 0; }
.muted { color: var(--muted); }
.item { display: grid; grid-template-columns: 1fr auto; text-align: left; gap: 2px 8px; }
.item .cost { color: var(--accent); }
.item .desc { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.item.on { outline: 2px solid var(--accent); }
.item.poor { opacity: 0.6; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }

/* ---------- кооператив ---------- */
.pdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: baseline; margin-right: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,0.5); }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check input { margin: 0; }
.owner { margin: 0 0 4px; font-size: 13px; }

.teambar { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; padding: 4px 16px; background: #20232a; border-bottom: 1px solid var(--line); font-size: 13px; }
.chip { padding: 2px 8px; border: 1px solid var(--line); border-left: 4px solid var(--pc); border-radius: 4px; background: #262930; white-space: nowrap; }
.chip.me { background: #2f3441; border-color: var(--pc); }
.chip.away { opacity: 0.55; }

/* награда за босса в кооперативе: панель поверх карты, игра не останавливается */
.rewardpanel { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: min(560px, 96%); background: rgba(38,41,48,0.96); border: 1px solid var(--accent); border-radius: 8px; padding: 8px 12px; line-height: 1.35; z-index: 3; box-shadow: 0 4px 16px rgba(0,0,0,0.5); }
.rewardpanel h3 { margin: 0; font-size: 15px; }
.rewardpanel p { margin: 4px 0; }
.rewardpanel .choices { margin: 6px 0; }
.rewardpanel .choice { flex: 1 1 150px; padding: 6px 8px; }
.bar { position: relative; height: 14px; background: #1f2229; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; margin: 4px 0 8px; }
.bar i { position: absolute; inset: 0 auto 0 0; background: var(--accent); opacity: 0.85; }
.bar span { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 12px; color: #fff; text-shadow: 0 1px 2px #000; }
button.vote { border-left: 4px solid var(--pc); }
button.vote.on { background: #4a4f5e; outline: 2px solid var(--accent); }

.coopstatus { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); background: rgba(180,60,60,0.92); color: #fff; padding: 4px 14px; border-radius: 14px; font-size: 13px; line-height: 1.3; z-index: 4; }
.coop-result { width: auto; min-width: 320px; background: rgba(20,22,27,0.85); line-height: 1.4; text-shadow: none; }
.coop-result td, .coop-result th { padding: 3px 10px; }

.coopdialog { max-width: 640px; max-height: 92vh; overflow: auto; }
.coopdialog h3 { margin: 6px 0; font-size: 15px; }
.coopcols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 700px) { .coopcols { grid-template-columns: 1fr; } }
.lobby .roomcode { font-size: 18px; margin: 6px 0; }
.lobby .roomcode b { font-size: 28px; letter-spacing: 0.15em; color: var(--accent); }
.invite { flex: 1 1 240px; font: inherit; font-size: 13px; padding: 6px 8px; background: #1f2229; color: var(--text); border: 1px solid var(--line); border-radius: 4px; }
.members { list-style: none; padding: 0; margin: 10px 0; display: flex; flex-direction: column; gap: 4px; }
.members li { padding: 6px 10px; background: #1f2229; border: 1px solid var(--line); border-radius: 4px; }
.members li.away { opacity: 0.55; }
.members li.empty { color: var(--muted); border-style: dashed; }

.give { border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.give h4 { margin: 0; color: var(--muted); font-weight: 400; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.give input.amount { width: 84px; font: inherit; padding: 4px 6px; background: #1f2229; color: var(--text); border: 1px solid var(--line); border-radius: 4px; }
.team-table td, .team-table th { padding: 3px 5px; }
.coopboard { border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.coopboard h4 { margin: 0; }

/* ---------- панель пушек под картой, окно у пушки ---------- */
.stage { display: flex; flex-direction: column; gap: 8px; max-width: 100%; min-width: 0; }
.buildbar { display: flex; gap: 8px; }
.build { flex: 1 1 0; min-width: 0; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 2px 8px; text-align: left; border-left: 4px solid var(--tc); padding: 6px 10px; }
.build .key { color: var(--muted); font-size: 12px; border: 1px solid var(--line); border-radius: 3px; padding: 0 5px; }
.build .cost { color: var(--accent); }
.build .desc { grid-column: 1 / -1; color: var(--muted); font-size: 11px; line-height: 1.25; }
.build.on { outline: 2px solid var(--accent); background: #4a4f5e; }
.build.poor { opacity: 0.6; }

kbd { font: inherit; font-size: 11px; padding: 0 5px; margin-left: 4px; border: 1px solid rgba(255,255,255,0.35); border-radius: 3px; background: rgba(0,0,0,0.25); }
button.danger { background: #8a3c3c; border-color: #aa4d4d; }

.popup { position: absolute; z-index: 6; width: 300px; max-width: 64%; max-height: 100%; overflow: auto; line-height: 1.35; background: var(--panel); border: 1px solid var(--accent); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,0.55); }
.popup .card { border: 0; background: none; min-height: 0; }
.popup .card h3 { padding-right: 26px; }
.popup .close { position: absolute; top: 6px; right: 6px; z-index: 1; }

/* маленькие экраны: пушки — компактная строка кнопок под картой, без описаний */
@media (max-width: 700px) {
  .buildbar { gap: 4px; }
  .build { grid-template-columns: 1fr; justify-items: center; gap: 0; padding: 4px 4px; text-align: center; font-size: 13px; }
  .build .key, .build .desc { display: none; }
  .popup { width: 250px; }
  .layout { padding: 6px; }
}

/* панель пушек не шире карты: ширину сцены задаёт только карта */
.buildbar { width: 0; min-width: 100%; }
.build { overflow: hidden; }
.build .name, .build .cost { white-space: nowrap; }

/* специализации пушек */
.specs { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.specs h4 { margin: 0; color: var(--muted); font-weight: 400; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
button.spec { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 1px; border-left: 4px solid var(--tc); }
button.spec span { font-size: 12px; color: var(--muted); }
.specdesc { border-left: 4px solid var(--tc); padding-left: 6px; font-size: 12px; }

/* магия под панелью пушек */
.spellbar { display: flex; gap: 8px; width: 0; min-width: 100%; }
.spell { flex: 1 1 0; min-width: 0; overflow: hidden; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 2px 8px; text-align: left; border-left: 4px solid var(--tc); padding: 5px 10px; }
.spell .key { color: var(--muted); font-size: 12px; border: 1px solid var(--line); border-radius: 3px; padding: 0 5px; }
.spell .name { white-space: nowrap; }
.spell .cost { color: #6fe3ff; white-space: nowrap; }
.spell .desc { grid-column: 1 / -1; color: var(--muted); font-size: 11px; line-height: 1.25; }
.spell.on { outline: 2px solid var(--accent); background: #4a4f5e; }
.spell.poor { opacity: 0.7; }
@media (max-width: 700px) {
  .spellbar { gap: 4px; }
  .spell { grid-template-columns: 1fr; justify-items: center; gap: 0; padding: 4px; text-align: center; font-size: 13px; }
  .spell .key, .spell .desc { display: none; }
}
