:root {
 --zahf-background: #171321;
 --zahf-surface: #231a31;
 --zahf-surface-raised: #322440;
 --zahf-text: #fff3dc;
 --zahf-muted: #c9bad8;
 --zahf-primary: #f4bc59;
 --zahf-action: var(--zahf-primary);
 --zahf-action-ink: #26162d;
 --zahf-select: #a990ea;
 --zahf-danger: #ff9e99;
 --zahf-friendly: #7bcbff;
 --zahf-hostile: #ff8588;
 --zahf-font: "Baloo Game", "Noto Sans Arabic", Tahoma, sans-serif;
 --zahf-space-unit: 8px;
 --zahf-control-radius: 12px;
 --zahf-min-target: 44px;
 --zahf-playfield: 540px;
}
:root, body { background: var(--zahf-background); color: var(--zahf-text); font-family: var(--zahf-font); }
#game {
 inset: 0 auto auto 50%;
 width: min(100%, var(--zahf-playfield), 76dvh);
 height: 100dvh;
 transform: translateX(-50%);
 background: var(--zahf-background);
 color: var(--zahf-text);
 container: zahf / inline-size;
}
body[data-portrait-blocked] #game { visibility: hidden; }
#portrait-hold {
 position: fixed;
 inset: 0;
 display: grid;
 place-content: center;
 justify-items: center;
 gap: calc(var(--zahf-space-unit) * 2);
 padding: 24px;
 background: radial-gradient(ellipse at center, var(--zahf-surface-raised), var(--zahf-background) 72%);
 text-align: center;
}
#portrait-hold[hidden] { display: none; }
#portrait-hold img { width: 64px; height: 64px; }
#portrait-hold h1 { margin: 0; font-weight: 800; font-size: clamp(1.3rem, 5vw, 2rem); line-height: 1.3; }
#portrait-hold p { margin: 0; color: var(--zahf-muted); }
#game :is(button, summary, a, input):focus-visible {
 outline: 2px solid var(--zahf-select);
 outline-offset: 3px;
}
#game :is(
 .game-panel, .command-header, .command-page, .command-nav, .game-action, .plate-button,
 .icon-button, .padded-plate, .wallet, .page-wallet, .treasury-wallet, .power-cell,
 .battle-intelligence > summary, .battle-toolbox > summary, .toolbox-content, .intelligence-content,
 .planning-bar, .planning-prepared, .placement-dock, .tower-dock, .tower-summary,
 .quick-build, .quick-weapon, .weapon-choice, .building-upgrade, .reward-button,
 .formation-surface, .formation-card, .deploy-role, .formation-count-card, .deploy-panel,
 .result-bank, .result-stats > span, .receipt-stat, #upgrade-receipt, #toast,
 .loading-progress, .loading-meta, .health-track, .energy-track, .result-details, .victory-prize
),
#game[data-screen=battle] .hud-bottom .combat-action > button,
#game #overlay :is(.result-card, #primary, .secondary-button),
#game #command-page :is(.nav-back, .shop-tab, .stage-node, .world-browser button, .weapon-stat) {
 border-color: transparent !important;
 box-shadow: none;
}
#game :is(.game-panel, .command-page, .toolbox-content, .intelligence-content, .quick-build, .placement-dock, .tower-dock, #upgrade-receipt, #toast) {
 background: var(--zahf-surface);
 color: var(--zahf-text);
}
#game #command-page :is(.command-header, .command-nav),
#game :is(.loading-progress, .health-track, .energy-track, .result-bank, .result-stats > span, .receipt-stat, .power-cell, .planning-prepared) {
 background: var(--zahf-surface-raised);
 color: var(--zahf-text);
}
#game #command-page :is(.nav-back, .weapon-stat, .shop-tab) { background: var(--zahf-surface-raised); color: var(--zahf-text); }
#game #command-page :is(.shop-tab.selected,.stage-node.current) { background: var(--zahf-select); color: var(--zahf-action-ink); }
#game #command-page :is(.command-header p, .page-note), #game .game-panel :is(p, label, dt) { color: var(--zahf-muted); }
#game #command-page :is(h2, h3, .panel-link), #game .game-panel :is(h2, h3, dd) { color: var(--zahf-text); }
#game[data-screen=battle] > .hud-top {
 background: linear-gradient(to bottom, #171321f5, #231a31d9 76%, #231a3100);
 color: var(--zahf-text);
 text-shadow: 0 1px 2px var(--zahf-background);
}
#game[data-screen=battle] > .hud-bottom {
 background: linear-gradient(to top, #171321ef, #231a31af 63%, #231a3100);
}
#game[data-screen=battle] :is(.icon-button, .battle-toolbox > summary, .battle-intelligence > summary, .wallet) {
 background: var(--zahf-surface-raised);
 color: var(--zahf-text);
}
#game .health-track:not(.enemy) i { background: var(--zahf-friendly); }
#game .health-track.enemy i { background: var(--zahf-hostile); }
#game :is(.energy-track, .loading-progress) i { background: var(--zahf-action); }
#game[data-screen=battle] .hud-bottom .combat-action > button,
#game :is(.lobby-icon, .plate-button, .game-action, .weapon-choice, .building-upgrade, .reward-button),
#game #overlay .secondary-button {
 background: var(--zahf-surface-raised);
 color: var(--zahf-text);
 text-shadow: none;
}
#game :is(.plate-button, .game-action, .combat-action > button)::before { border-color: transparent; }
#game #overlay .result-card { background: var(--zahf-surface); color: var(--zahf-text); }
#game #overlay :is(#dialog-title,#dialog-copy,#gesture-hint, .result-details) { color: var(--zahf-text); }
#game #overlay .victory-prize { background: var(--zahf-surface-raised); color: var(--zahf-text); }
#game #overlay #primary,
#game[data-screen=battle] .hud-bottom .combat-action > #deploy,
#game :is(.plate-button.gold, .game-action.gold, .lobby-battle-button, .lobby-action-primary) {
 background: var(--zahf-action);
 color: var(--zahf-action-ink);
 text-shadow: none;
}
#game :is(.game-action.red,.plate-button.red) { color: var(--zahf-danger); background: var(--zahf-surface-raised); }
#game #overlay :is(#primary, .secondary-button) { min-height: var(--zahf-min-target); border-radius: var(--zahf-control-radius); }
#game #overlay #primary:disabled, #game[data-screen=battle] .hud-bottom .combat-action > #deploy:disabled { opacity: .65; }
#game #overlay, #game #loading { background-color: var(--zahf-background); }
#game .loading-shade { background: linear-gradient(to bottom, #17132191, #171321ed 78%); }
#game #upgrade-receipt { width: min(480px, calc(100% - 24px)); }
@container zahf (max-width: 540px) {
 #game[data-screen=battle] > .hud-top { display: grid; grid-template: auto auto / auto minmax(0, 1fr); gap: 4px 12px; }
 #game[data-screen=battle] .hud-top .heading { grid-area: 1 / 1 / 2 / -1; }
 #game[data-screen=battle] .hud-top .base-health { grid-area: 2 / 2; }
 #game[data-screen=battle] .hud-top .mission-wave { grid-area: 2 / 1; }
 #game #command-page .shop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
 #game *, #game *::before, #game *::after { animation: none !important; transition: none !important; }
}

/* Live controls use the same flat fills as the lobby. Images remain separate. */
#game[data-screen=battle] .field-actions :is(.combat-action > button, #deployment-picker, #build-entry),
#game[data-screen=battle] #deployment-panel :is(.deployment-roles button, #formation-cycle, #apply-deployment, #close-deployment),
#game[data-screen=battle] .view-tools > .icon-button,
#game .planning-actions > button,
#game :is(.quick-weapon, .shop-tab, .stage-node, .world-browse-arrow, .panel-close) {
 background: var(--zahf-surface-raised);
 border: 0;
 border-radius: var(--zahf-control-radius);
 box-shadow: none;
 color: var(--zahf-text);
 text-shadow: none;
}
#game[data-screen=battle] #deployment-panel .deployment-roles button[aria-pressed=true],
#game[data-screen=battle] .field-actions button[aria-pressed=true] {
 background: var(--zahf-select);
 color: var(--zahf-action-ink);
}
#game[data-screen=battle] #deployment-panel #apply-deployment,
#game[data-screen=battle] .field-actions #deploy:not(:disabled),
#game .planning-actions > #planning-start {
 background: var(--zahf-primary);
 color: var(--zahf-action-ink);
}
#game[data-screen=battle] :is(.field-actions, #deployment-panel, .planning-actions) button::after,
#game[data-screen=battle] :is(.field-actions, #deployment-panel, .planning-actions) button::before {
 background: transparent;
 border: 0;
 box-shadow: none;
}
#game #loading .loading-art { filter: grayscale(1); opacity: .54; }
