:root {
  --bg: #0f172a;
  --panel: #111827;
  --muted: #334155;
  --text: #e5e7eb;
  --accent: #22c55e;
  --accent2: #60a5fa;
  --danger: #ef4444;
  --warning: #eab308;
  --shadow: rgba(0,0,0,.35);
  --card: #0b1220;
}

* { box-sizing: border-box; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: #334155 #020617; }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: #020617; }
::-webkit-scrollbar-thumb { background-color: #334155; border-radius: 6px; border: 3px solid #020617; }
::-webkit-scrollbar-thumb:hover { background-color: #475569; }

html { height: 100%; }

body {
  margin: 0;
  background: radial-gradient(1200px 800px at 20% 0%, #0b1220 0%, var(--bg) 60%);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  height: 100vh;
  overflow: hidden; 
  display: flex;
  flex-direction: column;
}

body.logged-out header,
body.logged-out main,
body.logged-out footer { display: none !important; }

/* --- LOGIN SCREEN --- */
#login-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: #0f172a; z-index: 10000;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.login-wrapper { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 20px; width: 100%; margin: auto; }
.login-logo { max-width: 200px; height: auto; display: block; filter: drop-shadow(0 0 10px rgba(96,165,250,0.3)); }
.login-subtitle { color: #94a3b8; font-weight: 400; margin: 0; letter-spacing: 1px; font-size: 14px; text-transform: uppercase; font-family: 'Courier New', monospace; }
.login-panel { padding: 30px 40px; border-top: 2px solid var(--accent2); width: 100%; max-width: 380px; background: #111827; box-shadow: 0 0 50px rgba(0,0,0,0.5); border-radius: 12px; }
.login-panel input { background: #020617; border: 1px solid #334155; transition: border-color 0.3s, box-shadow 0.3s; font-size: 14px; padding: 12px; }
.login-panel input:focus { border-color: var(--accent2); box-shadow: 0 0 10px rgba(96, 165, 250, 0.2); }

/* --- HEADER --- */
header {
  padding: 0 15px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid #1f2937; background: rgba(15, 23, 42, 0.95); height: 60px; flex-shrink: 0; z-index: 40;
}
#mobile-menu-btn { display: none; cursor: pointer; color: var(--text); background: transparent; border: none; }

/* --- MAIN LAYOUT --- */
main { flex: 1; position: relative; display: flex; overflow: hidden; min-height: 0; }
.container { display: grid; grid-template-columns: 260px 1fr; gap: 16px; padding: 16px; width: 100%; height: 100%; overflow: hidden; }

/* Sidebar */
aside.panel {
    background: linear-gradient(180deg, rgba(30,41,59,0.3), rgba(30,41,59,0.1));
    border: 1px solid #1f2937; border-radius: 8px; padding: 14px;
    display: flex; flex-direction: column; gap: 6px; height: 100%; overflow-y: auto; 
}
.sidebar-header { margin: 0 0 10px 0; padding-bottom: 8px; border-bottom: 1px solid #334155; font-size: 11px; color: #64748b; letter-spacing: 1px; text-transform: uppercase; }

.nav-btn { appearance: none; border: 1px solid transparent; color: #94a3b8; background: transparent; padding: 10px 12px; border-radius: 6px; cursor: pointer; transition: all .15s ease; font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; }
.nav-btn:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav-btn.active { background: linear-gradient(90deg, rgba(96,165,250,.15), rgba(96,165,250,.0)); border: 1px solid rgba(96,165,250,.3); color: var(--text); box-shadow: 0 0 10px rgba(96, 165, 250, 0.1); }
.nav-btn.danger:hover { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* Main Content Area */
#main-content { position: relative; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; height: 100%; min-width: 0; padding-right: 5px; }
#main-content > div { height: auto !important; min-height: 100%; }
#main-content > #ab-root { height: 100% !important; overflow: hidden !important; }
.ab-list-panel, .ab-details-panel, #main-content { -webkit-overflow-scrolling: touch; }

/* Panels & Forms */
.panel { background: #111827; border: 1px solid #1f2937; border-radius: 8px; padding: 20px; box-shadow: 0 4px 6px rgba(0,0,0,0.2); display: flex; flex-direction: column; min-height: 0; }
input, select, textarea { width: 100%; background: #0b1220; color: var(--text); border: 1px solid #334155; border-radius: 6px; padding: 10px 12px; outline: none; font-family: inherit; font-size: 13px; transition: border-color 0.2s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent2); }

/* Buttons */
.btn { appearance: none; border: 1px solid #334155; color: var(--text); background: #1f2937; padding: 8px 12px; border-radius: 6px; cursor: pointer; transition: all .15s ease; font-weight: 600; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { background: #334155; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent2); border-color: var(--accent2); color: #0f172a; }
.btn.primary:hover { background: #3b82f6; }
.btn.primary.active { background: #3b82f6; border-color: #3b82f6; color: #0f172a; }
.btn.danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn.danger:hover { background: var(--danger); color: white; }
.btn.ghost { background: transparent; border-color: transparent; color: #94a3b8; }
.btn.ghost:hover { background: rgba(255,255,255,0.05); color: var(--text); border-color: #334155; }

/* Dashboard */
.dashboard-top-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.dash-card { background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.01)); border: 1px solid #374151; border-radius: 8px; padding: 15px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.dash-card.good { border-color: var(--accent); background: rgba(34,197,94,0.05); }
.dash-card-label { font-size: 11px; color: #94a3b8; text-transform: uppercase; margin-bottom: 5px; letter-spacing: 0.5px; }
.dash-card-value { font-size: 24px; font-weight: 800; color: var(--text); }
.feedback-row { display: flex; align-items: center; padding: 15px; border-bottom: 1px solid #1f2937; cursor: pointer; transition: background 0.2s; }
.feedback-row:hover { background: rgba(255, 255, 255, 0.03); }
.fb-icon { font-size: 16px; }

/* --- ARMY BUILDER SCOPE --- */
#ab-root {
    --bg-dark: #020617; --bg-panel: #0f172a; --text-main: #e5e7eb; --text-muted: #94a3b8; --border: #334155;
    --accent-terran: #38bdf8; --accent-zerg: #a855f7; --accent-protoss: #eab308;
    --accent-success: #22c55e; --accent-danger: #ef4444; --current-accent: var(--accent-terran);
    font-family: 'Segoe UI', sans-serif; height: 100%; display: flex; flex-direction: column; overflow: hidden;
    background-color: var(--bg-dark); color: var(--text-main);
}
#ab-root.theme-Terran { --current-accent: var(--accent-terran); }
#ab-root.theme-Zerg { --current-accent: var(--accent-zerg); }
#ab-root.theme-Protoss { --current-accent: var(--accent-protoss); }

.ab-top-bar { background: var(--bg-panel); border-bottom: 1px solid var(--border); padding: 10px 15px; display: grid; grid-template-columns: auto 1fr auto; gap: 15px; align-items: center; z-index: 50; }
.ab-config-row { display: flex; gap: 10px; align-items: center; }
.ab-resources-display { display: flex; gap: 15px; justify-content: flex-start; align-items: center; background: #020617; padding: 5px 15px; border-radius: 8px; border: 1px solid var(--current-accent); min-height: 50px; flex-wrap: nowrap; }
.ab-res-box { text-align: center; min-width: 50px; flex-shrink: 0; }
.ab-res-label { font-size: 9px; color: var(--text-muted); text-transform: uppercase; font-weight: 700; }
.ab-res-val { font-size: 16px; font-weight: 800; line-height: 1; }
.res-ok { color: var(--accent-success); } .res-err { color: var(--accent-danger); }
.ab-divider { width: 1px; height: 30px; background: #334155; flex-shrink: 0; }

.ab-tabs-bar { display: flex; gap: 2px; background: var(--bg-panel); padding: 0 10px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.ab-tab-btn { padding: 12px 15px; cursor: pointer; font-size: 12px; font-weight: bold; border-bottom: 3px solid transparent; color: var(--text-muted); text-transform: uppercase; white-space: nowrap; }
.ab-tab-btn.active { color: var(--current-accent); border-bottom-color: var(--current-accent); background: rgba(255,255,255,0.05); }

.ab-content-area { flex: 1; overflow: hidden; display: none; }
.ab-content-area.active { display: grid; grid-template-columns: 380px 1fr; }
.ab-list-panel { background: rgba(15, 23, 42, 0.4); border-right: 1px solid var(--border); overflow-y: auto; padding: 15px; }
.ab-details-panel { background: radial-gradient(circle at top, #1e293b 0%, #020617 100%); overflow-y: auto; padding: 20px; }

.ab-game-card { background: #1e293b; border: 1px solid var(--border); padding: 12px; margin-bottom: 10px; border-radius: 6px; cursor: pointer; transition: 0.2s; }
.ab-game-card:hover { border-color: var(--current-accent); transform: translateX(2px); }
.ab-game-card.selected { border-color: var(--accent-success); background: rgba(34, 197, 94, 0.1); }
.ab-card-name { font-weight: bold; font-size: 13px; color: white; }
.ab-card-cost { background: rgba(0,0,0,0.3); padding: 2px 6px; border-radius: 4px; font-size: 11px; color: var(--current-accent); font-weight: bold; float: right; }

.ab-unit-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 6px; padding: 10px; margin-bottom: 10px; }
.ab-unit-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.ab-unit-name { font-weight: bold; font-size: 13px; color: white; }
.ab-add-btn { background: #1e293b; border: 1px solid var(--border); width: 100%; padding: 10px; cursor: pointer; color: var(--text-muted); font-size: 12px; margin-top: 5px; border-radius: 4px; display: flex; justify-content: space-between; transition: 0.2s; align-items: center; }
.ab-add-btn:hover { border-color: var(--current-accent); color: white; background: #334155; }

.ab-roster-item { background: rgba(30, 41, 59, 0.6); border-left: 3px solid var(--current-accent); margin-bottom: 8px; padding: 10px 15px; border-radius: 4px; display: flex; justify-content: space-between; align-items: flex-start; }
.ab-roster-title { font-size: 13px; font-weight: bold; display: flex; align-items: center; gap: 8px; }
.ab-upgrade-pill { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; padding: 2px 6px; border-radius: 10px; border: 1px solid var(--border); color: var(--text-muted); cursor: pointer; background: rgba(0,0,0,0.2); margin-right: 5px; }
.ab-upgrade-pill.active { background: rgba(34, 197, 94, 0.15); border-color: var(--accent-success); color: var(--accent-success); }

/* --- RULES MODULE --- */
.rule-page-container { display: flex; flex-direction: column; gap: 20px; padding-bottom: 40px; }
.rule-unit-row { display: flex; gap: 20px; padding: 20px; background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.005)); border: 1px solid #334155; border-radius: 8px; align-items: stretch; }
.unit-admin { flex: 2; display: flex; flex-direction: column; gap: 10px; border-right: 1px dashed #334155; padding-right: 20px; }
.unit-feedback { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 300px; }
.unit-header { font-size: 10px; text-transform: uppercase; font-weight: 700; color: #94a3b8; margin-bottom: 5px; display: flex; justify-content: space-between; }
.rule-textarea { width: 100%; background: #0b1220; border: 1px solid #334155; color: #e5e7eb; border-radius: 8px; padding: 12px; font-family: 'Courier New', Courier, monospace; font-size: 13px; line-height: 1.6; resize: vertical; min-height: 100px; }

.editor-wrapper { border: 1px solid #334155; border-radius: 8px; background: #0b1220; overflow: hidden; display: flex; flex-direction: column; flex: 1; }
.editor-toolbar { display: flex; gap: 4px; padding: 6px; background: #111827; border-bottom: 1px solid #334155; }
.format-btn { width: 28px; height: 28px; background: transparent; border: 1px solid transparent; color: #94a3b8; border-radius: 4px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.format-btn:hover { background: rgba(255,255,255,0.05); color: white; }
.rich-editor { flex: 1; padding: 12px; color: #e5e7eb; font-family: 'Courier New', Courier, monospace; font-size: 13px; line-height: 1.6; outline: none; overflow-y: auto; min-height: 200px; }
.visual-ref-placeholder { border: 1px dashed #475569; background: rgba(0,0,0,0.2); padding: 10px; border-radius: 8px; flex: 1; display: flex; flex-direction: column; justify-content: center; }
.machine-tabs { display: flex; gap: 4px; padding: 8px 0; margin-bottom: 10px; border-bottom: 1px solid #1f2937; flex-wrap: wrap; }
.tab-btn { background: transparent; border: none; color: #64748b; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600; transition: all .2s; }
.tab-btn:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.tab-btn.active { background: var(--accent2); color: #0f172a; }
.add-tab-btn { background: rgba(255, 255, 255, 0.05); border: 1px dashed #334155; color: #94a3b8; padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.section-controls { display: flex; gap: 4px; margin-left: 10px; padding-left: 10px; border-left: 1px solid #334155; align-items: center; }
.ctrl-btn { background: transparent; border: 1px solid #334155; color: #64748b; width: 24px; height: 24px; border-radius: 4px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 10px; }

.rating-control { background: #111827; padding: 10px; border-radius: 8px; border: 1px solid #334155; margin-top: auto; }
.clarity-scale-container { display: flex; gap: 4px; align-items: center; justify-content: space-between; width: 100%; margin-top: 6px; }
.clarity-dot { flex: 1; height: 24px; border-radius: 4px; background-color: #0b1220; border: 1px solid #334155; color: #64748b; font-weight: 700; font-size: 10px; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; transition: all 0.2s; }
.clarity-dot:hover { border-color: var(--accent2); color: #fff; transform: translateY(-1px); }
.clarity-dot.active { background-color: var(--accent); border-color: var(--accent); color: white; transform: scale(1.05); }
.clarity-dot[data-val="1"].active, .clarity-dot[data-val="2"].active, .clarity-dot[data-val="3"].active { background-color: var(--danger); border-color: var(--danger); }
.clarity-dot[data-val="4"].active, .clarity-dot[data-val="5"].active, .clarity-dot[data-val="6"].active { background-color: var(--warning); border-color: var(--warning); color: #000; }

/* --- FACTION & CARDS GRID --- */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; padding: 20px; }
.card-entry { background: #1e293b; border: 1px solid #334155; border-radius: 8px; overflow: hidden; transition: transform 0.2s, border-color 0.2s; display: flex; flex-direction: column; }
.card-entry:hover { border-color: var(--accent2); transform: translateY(-2px); box-shadow: 0 0 15px rgba(96, 165, 250, 0.15); }
.card-faces-row { display: flex; gap: 10px; padding: 10px; background: #0b1220; justify-content: center; align-items: center; height: 200px; }
.face-thumb { flex: 1; height: 100%; position: relative; cursor: pointer; border-radius: 4px; overflow: hidden; border: 1px solid transparent; transition: all 0.2s; }
.face-thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-name-label { padding: 8px; background: #1e293b; border-top: 1px solid #334155; color: var(--text); font-size: 12px; font-weight: 700; text-align: center; text-transform: uppercase; }

/* --- UNIT CARDS (Classic Dark Style) --- */
.sc-card-wrapper {
    width: 900px;
    min-height: 600px; 
    height: auto; 
    background: #e2e8f0;
    color: #0f172a;
    font-family: 'Roboto', sans-serif;
    position: relative;
    overflow: visible; 
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    flex-shrink: 0;
    padding-bottom: 40px; 
}

/* UNIT HEADER THEMES */
.theme-terran .sc-card-header { background: linear-gradient(90deg, #0369a1, #0ea5e9); border-bottom: 5px solid #0f172a; }
.theme-zerg .sc-card-header { background: linear-gradient(90deg, #581c87, #a855f7); border-bottom: 5px solid #2e1065; }
.theme-protoss .sc-card-header { background: linear-gradient(90deg, #854d0e, #eab308); border-bottom: 5px solid #422006; }

.sc-card-header { height: 70px; display: flex; align-items: center; padding: 0 20px; justify-content: space-between; color: white; z-index: 2; }
.sc-card-title { font-size: 32px; font-weight: 900; text-transform: uppercase; letter-spacing: 1.5px; text-shadow: 2px 2px 0px rgba(0,0,0,0.5); }

/* INFO BAR (Stats & Matrix) */
.sc-info-bar { display: flex; justify-content: space-between; align-items: flex-start; padding: 10px 20px 5px 20px; background: #e2e8f0; z-index: 5; flex-shrink: 0; }
.sc-stat-grid { display: flex; gap: 5px; }
.sc-stat-box { background: rgba(15, 23, 42, 0.95); border: 1px solid rgba(255,255,255,0.4); border-radius: 5px; width: 50px; height: 55px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.sc-stat-val { font-size: 24px; font-weight: bold; line-height: 1; color: white; }
.sc-stat-label { font-size: 9px; text-transform: uppercase; color: #cbd5e1; margin-top: 2px; font-weight: bold; }

/* SQUAD MATRIX */
.sc-squad-matrix { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.sc-tiers-container { display: flex; border: 2px solid #475569; border-radius: 6px; background: #e2e8f0; overflow: hidden; box-shadow: 0 2px 5px rgba(0,0,0,0.3); }
.sc-tier-box { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 55px; height: 45px; background: #f8fafc; border-right: 1px solid #cbd5e1; }
.sc-tier-box:last-child { border-right: none; }
.sc-tier-models { font-size: 10px; font-weight: 700; color: #64748b; background: #e2e8f0; width: 100%; text-align: center; padding-bottom: 2px; }
.sc-tier-supply { font-size: 18px; font-weight: 900; color: #0f172a; line-height: 1; padding-top: 2px; }
.sc-cost-container { display: flex; gap: 5px; background: rgba(15, 23, 42, 0.9); padding: 4px 8px; border-radius: 4px; border: 1px solid rgba(255,255,255,0.2); }
.sc-cost-label { color: #94a3b8; font-size: 10px; font-weight: bold; text-transform: uppercase; margin-right: 2px; }
.sc-cost-value { color: #eab308; font-size: 14px; font-weight: 900; }

/* BODY & PHASES */
.sc-card-body { flex: 1; padding: 5px 20px 10px 20px; background: repeating-linear-gradient(45deg, #f8fafc, #f8fafc 15px, #e2e8f0 15px, #e2e8f0 30px); display: flex; flex-direction: column; gap: 10px; position: relative; }
.sc-phase-section { background: white; border: 2px solid #3b82f6; border-radius: 6px; overflow: hidden; box-shadow: 2px 2px 8px rgba(0,0,0,0.1); position: relative; z-index: 2; }
.sc-phase-header { background: #3b82f6; color: white; padding: 4px 12px; font-weight: 800; text-transform: uppercase; font-size: 13px; display: flex; align-items: center; gap: 10px; letter-spacing: 0.5px; }

/* WEAPON TABLE */
.sc-weapon-table { width: 100%; border-collapse: collapse; font-size: 12px; font-family: 'Segoe UI', sans-serif; }
.sc-weapon-table th { background: #e2e8f0; color: #334155; font-weight: bold; text-align: center; padding: 6px; border-bottom: 2px solid #cbd5e1; border-right: 1px solid rgba(0,0,0,0.05); }
.sc-weapon-table td { padding: 6px 4px; text-align: center; border-bottom: 1px solid #e2e8f0; color: #0f172a; font-weight: 600; }
.col-name { text-align: left !important; padding-left: 10px !important; width: 18%; font-weight: 900 !important; font-size: 13px; background: rgba(0,0,0,0.02); }
.col-keywords { text-align: left !important; font-size: 11px; color: #334155; padding-left: 10px !important; line-height: 1.2; width: 40%; } 
.col-surge { font-size: 11px; width: 10%; }
.col-pts { width: 40px; text-align: center !important; border-left: 1px solid rgba(0,0,0,0.1); background: rgba(0,0,0,0.03); }
.text-red { color: #dc2626; font-weight: 900; }
.weapon-link { font-size: 9px; font-weight: 800; color: #475569; font-style: italic; margin-top: 2px; letter-spacing: 0.5px; text-transform: uppercase; }

.sc-ability-row { padding: 6px 12px; font-size: 12px; border-bottom: 1px solid #e2e8f0; display: flex; gap: 8px; align-items: baseline; }
.sc-ability-name { font-weight: 800; color: #0f172a; white-space: nowrap; font-size: 13px; min-width: 150px; }
.sc-ability-desc { color: #334155; line-height: 1.3; flex: 1; }
.upgrade-cost-badge { background: #dc2626; color: white; font-weight: 800; padding: 2px 4px; border-radius: 4px; font-size: 10px; border: 1px solid #991b1b; display: inline-block; min-width: 30px; text-align: center; }

.skill-tag { font-size: 9px; font-weight: 900; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; margin-left: 5px; white-space: nowrap; display: inline-block; letter-spacing: 0.5px; }
.skill-tag.passive { color: #15803d; background: #dcfce7; border: 1px solid #86efac; }
.skill-tag.active { color: #1d4ed8; background: #dbeafe; border: 1px solid #93c5fd; }
.skill-tag.reaction { color: #b45309; background: #fef3c7; border: 1px solid #fcd34d; }
.skill-tag.default { color: #475569; background: #f1f5f9; border: 1px solid #cbd5e1; }

.sc-watermark {
    position: absolute;
    top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(-30deg);
    font-size: 80px; font-weight: 900; color: #000; opacity: 0.04;
    white-space: nowrap; pointer-events: none; z-index: 0;
    text-transform: uppercase; border: 5px solid #000; padding: 10px 40px; border-radius: 20px;
}
.sc-phase-section.any-phase { border-color: #64748b; }
.sc-phase-section.any-phase .sc-phase-header { background: #64748b; }
.sc-keyword-footer {
    background: #0f172a; color: white; padding: 10px 20px;
    font-size: 12px; text-transform: uppercase; font-weight: bold;
    display: flex; justify-content: space-between; align-items: center; letter-spacing: 1px;
    position: absolute; bottom: 0; left: 0; width: 100%;
    border-bottom-left-radius: 8px; border-bottom-right-radius: 8px; box-sizing: border-box; z-index: 10;
}
.sc-beta-warning { color: #f7f4f4; font-weight: 900; margin-left: 20px; font-size: 12px; text-shadow: 0 0 5px rgba(0,0,0,0.8); letter-spacing: 0.5px; }

/* --- TACTICAL CARD (LIGHT THEME REDESIGN) --- */

.tactical-card-wrapper {
    width: 600px;
    min-height: 840px; 
    background: #f8fafc; /* Light BG */
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    font-family: 'Roboto', 'Segoe UI', sans-serif;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border: 2px solid #cbd5e1;
    color: #0f172a;
}

/* Header Gradients */
.tactical-card-wrapper.theme-terran .tac-header { background: linear-gradient(90deg, #0369a1, #0284c7); }
.tactical-card-wrapper.theme-zerg .tac-header { background: linear-gradient(90deg, #6b21a8, #9333ea); }
.tactical-card-wrapper.theme-protoss .tac-header { background: linear-gradient(90deg, #854d0e, #ca8a04); }

.tac-header {
    height: 110px;
    padding: 0 30px;
    display: flex;
    align-items: center;
    position: relative;
    z-index: 1;
}

.tac-title {
    font-size: 36px; font-weight: 900; text-transform: uppercase; color: white;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.3); width: 80%; line-height: 1; letter-spacing: 0.5px;
    margin-top: 20px; /* Space for the tag */
}

/* Resource Badge (+1 PE/CP) */
.tac-resource-badge {
    position: absolute; top: 35px; right: 25px;
    width: 90px; height: 90px;
    background: white; border-radius: 50%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    z-index: 10; border: 4px solid white;
}
.theme-terran .tac-resource-badge { color: #0284c7; }
.theme-zerg .tac-resource-badge { color: #9333ea; }
.theme-protoss .tac-resource-badge { color: #ca8a04; }

.tac-res-val { font-size: 38px; font-weight: 900; line-height: 0.9; }
.tac-res-label { font-size: 14px; font-weight: 900; text-transform: uppercase; }

/* Unique Tag (UPDATED: Top Left) */
.tac-unique-tag {
    position: absolute; 
    top: 15px; 
    left: 20px; 
    background: #facc15; 
    color: #000;
    font-weight: 900; 
    font-size: 12px; 
    padding: 4px 10px; 
    border-radius: 6px;
    text-transform: uppercase; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 5; 
    letter-spacing: 1px;
}

/* Slots Strip */
.tac-slots-row {
    display: flex; gap: 10px; padding: 30px 20px 10px 20px;
    justify-content: center; background: #f8fafc;
}
.tac-slot-box {
    border: 2px solid #e2e8f0; border-radius: 6px; padding: 8px 12px;
    text-align: center; font-size: 14px; font-weight: 900;
    color: #cbd5e1; text-transform: uppercase; flex: 1; background: white;
}
.tac-slot-box.active {
    border-color: #64748b; color: #0f172a; background: #f1f5f9;
}

/* Body Content */
.tac-body { flex: 1; padding: 20px; display: flex; flex-direction: column; gap: 15px; }

/* Ability Cards */
.tac-ability-card {
    background: white; border: 2px solid #e2e8f0; border-radius: 12px;
    padding: 15px; box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex; flex-direction: column; gap: 8px;
}
.tac-ability-header { display: flex; align-items: center; gap: 10px; }

.tac-tag-pill {
    font-size: 11px; font-weight: 800; text-transform: uppercase;
    padding: 4px 10px; border-radius: 6px; color: #0f172a;
}
.pill-reaction { background: #fef08a; border: 1px solid #facc15; }
.pill-active { background: #bae6fd; border: 1px solid #38bdf8; }
.pill-passive { background: #e2e8f0; border: 1px solid #94a3b8; }
.pill-phase { background: #334155; color: white; }

.tac-ability-name { font-size: 18px; font-weight: 900; text-transform: uppercase; color: #0f172a; }
.tac-ability-text { font-size: 16px; line-height: 1.4; color: #334155; font-weight: 500; }

.tac-footer {
    padding: 15px 20px; background: #e2e8f0; color: #64748b;
    font-size: 10px; font-weight: bold; display: flex; justify-content: space-between;
    text-transform: uppercase; border-top: 1px solid #cbd5e1;
}

/* --- MISSION CARDS --- */
.mission-card-wrapper {
    width: 600px; height: 900px; 
    background-color: #e2e8f0;
    background-image: radial-gradient(#cbd5e1 15%, transparent 16%), radial-gradient(#cbd5e1 15%, transparent 16%); 
    background-size: 20px 20px; background-position: 0 0, 10px 10px;
    font-family: 'Roboto', 'Segoe UI', sans-serif; color: #0f172a;
    position: relative; overflow: hidden; display: flex; flex-direction: column;
    border-radius: 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); border: 8px solid #cbd5e1;
}
.mission-header {
    height: 110px; background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%); color: white;
    display: flex; align-items: center; padding: 0 210px 0 30px; 
    position: relative; border-bottom: 4px solid #334155; z-index: 5;
}
.mission-title { font-size: 32px; font-weight: 900; text-transform: uppercase; letter-spacing: 1.5px; text-shadow: 0 2px 4px rgba(0,0,0,0.5); flex: 1; line-height: 1.1; word-wrap: break-word; }
.mission-stats-container {
    position: absolute; top: 0; right: 20px; 
    display: flex; flex-direction: column; align-items: center; z-index: 20; 
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5)); 
}
.mission-stats-row { display: flex; background: #e2e8f0; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px; overflow: hidden; border: 2px solid #475569; border-top: none; }
.mission-stat-box { min-width: 80px; width: auto; padding: 0 10px; height: 75px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: linear-gradient(to bottom, #f8fafc, #cbd5e1); border-right: 1px solid #94a3b8; text-align: center; }
.mission-stat-box:last-child { border-right: none; background: #0f172a; color: white; }
.ms-val { font-size: 22px; font-weight: 900; line-height: 1.1; margin-bottom: 2px; }
.ms-label { font-size: 9px; text-transform: uppercase; font-weight: 700; opacity: 0.8; }
.mission-length-badge {
    background: #0f172a; color: #eab308; font-size: 15px; font-weight: 800;
    padding: 6px 20px 4px 20px; text-transform: uppercase; margin-top: -2px;
    clip-path: polygon(15% 0, 85% 0, 100% 100%, 0% 100%);
    min-width: 140px; text-align: center; letter-spacing: 1px; position: relative; z-index: 5;
}
.mission-body { flex: 1; padding: 30px; display: flex; flex-direction: column; gap: 15px; margin-top: 10px; }
.mission-section {
    background: white; border: 2px solid #64748b; border-radius: 8px; position: relative;
    clip-path: polygon(0 10px, 10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%);
    padding: 2px; background-color: #64748b; 
}
.mission-section-inner {
    background: white; padding: 10px 15px 15px 15px; height: 100%;
    clip-path: polygon(0 10px, 10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%);
}
.ms-header { background: #334155; color: white; display: inline-block; padding: 6px 12px; font-size: 16px; font-weight: 900; text-transform: uppercase; border-radius: 4px; margin-bottom: 10px; }
.ms-text { font-size: 18px; line-height: 1.5; font-weight: 600; color: #0f172a; }
.mission-footer { height: 40px; display: flex; justify-content: space-between; align-items: center; padding: 0 20px; font-size: 10px; color: #64748b; background: #e2e8f0; border-top: 2px solid #cbd5e1; }
.mission-format-tag { background: #334155; color: white; padding: 5px 15px; font-weight: bold; text-transform: uppercase; transform: skewX(-15deg); }
.mission-format-tag span { display: block; transform: skewX(15deg); }

/* --- DIALOGS & OVERLAYS --- */
.card-modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); z-index: 1000; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(5px); }
.upload-panel { background: #1e293b; border-bottom: 1px solid #334155; padding: 15px; display: none; gap: 10px; align-items: center; flex-wrap: wrap; }
.upload-panel.visible { display: flex; }
.dialog-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); z-index: 10000; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); animation: fadeIn 0.2s ease-out; }
.dialog-box { background: #0f172a; border: 1px solid var(--accent2); box-shadow: 0 0 40px rgba(0,0,0,0.7); border-radius: 8px; width: 90%; max-width: 400px; padding: 20px; display: flex; flex-direction: column; gap: 15px; animation: scaleIn 0.2s ease-out; }
.dialog-title { font-size: 16px; font-weight: bold; color: var(--text); }
.dialog-msg { font-size: 13px; color: #94a3b8; line-height: 1.5; }
.dialog-input { width: 100%; background: #020617; border: 1px solid #334155; padding: 10px; color: white; border-radius: 4px; margin-top: 5px; }
.dialog-input:focus { border-color: var(--accent2); outline: none; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { transform: scale(0.9); } to { transform: scale(1); } }

footer { padding: 12px 16px; font-size: 11px; color:#64748b; border-top: 1px solid #1f2937; text-align: center; background: #0b1220; flex-shrink: 0; }

/* --- RESPONSIVENESS --- */
@media (max-width: 768px) {
    html, body { height: auto; overflow-y: auto; display: block; }
    .container { display: block; padding: 10px; height: auto; overflow: visible; }
    #main-content { height: auto; min-height: calc(100vh - 80px); overflow: visible; display: block; }
    #main-content > #ab-root { height: auto !important; overflow: visible !important; }
    #mobile-menu-btn { display: block; }
    aside.panel { position: fixed; top: 0; left: 0; bottom: 0; width: 280px; background: #0f172a; z-index: 100; border-right: 1px solid var(--accent2); box-shadow: 10px 0 30px rgba(0,0,0,0.7); transform: translateX(-105%); transition: transform 0.3s ease-in-out; border-radius: 0; height: 100vh; }
    aside.panel.open { transform: translateX(0); }
    #mobile-nav-backdrop { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 90; backdrop-filter: blur(2px); }
    .dashboard-top-row { grid-template-columns: 1fr; }
    .btn { min-height: 44px; }
    input, select, textarea { font-size: 16px !important; }
    header h1 span { display: none; } 
    .user-info { display: none; }
    .rule-unit-row { flex-direction: column; }
    .unit-admin { border-right: none; border-bottom: 1px solid #334155; padding-bottom: 20px; padding-right: 0; }
    .clarity-scale-container { flex-wrap: wrap; }
    .clarity-dot { flex: 1 0 15%; max-width: 40px; margin-bottom: 5px; }
    
    .ab-top-bar { display: flex; flex-direction: column; align-items: stretch; gap: 10px; height: auto; }
    .ab-content-area.active { display: flex; flex-direction: column; }
    .ab-list-panel { flex: 0 0 40%; border-right: none; border-bottom: 1px solid var(--border); }
}

/* Hover Preview */
#hover-preview-panel {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    z-index: 9999; pointer-events: none; display: none;
    box-shadow: 0 0 50px rgba(0,0,0,0.8); border: 2px solid var(--accent2);
    border-radius: 8px; background: #000; max-width: 90vw; max-height: 90vh;
}
#hover-preview-panel img { max-width: 100%; max-height: 80vh; display: block; border-radius: 6px; }

/* Modal Content */
.card-modal-content {
    background: #0f172a; border: 1px solid #334155; border-radius: 12px;
    width: 95%; max-width: 1200px; height: 90vh; display: flex;
    overflow: hidden; box-shadow: 0 0 50px rgba(0,0,0,0.8);
}
.modal-visuals {
    flex: 2; background: #0b1220; padding: 20px; overflow-y: auto;
    display: flex; flex-direction: column; align-items: center;
    border-right: 1px solid #334155; position: relative;
}
.modal-feedback {
    flex: 1; min-width: 350px; background: #1e293b; padding: 20px;
    overflow-y: auto; display: flex; flex-direction: column; gap: 15px;
}
.fb-section { background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid #334155; }
.fb-label { font-size: 11px; color: var(--accent2); font-weight: 700; margin-bottom: 5px; display: block; text-transform: uppercase; }
.fb-textarea { width: 100%; height: 80px; background: #020617; border: 1px solid #475569; color: white; padding: 8px; font-size: 12px; border-radius: 4px; resize: vertical; }

@media (max-width: 900px) {
    .card-modal-content { flex-direction: column; height: 95vh; width: 100%; border-radius: 0; }
    .modal-visuals { flex: 1; border-right: none; border-bottom: 1px solid #334155; min-height: 300px; }
    .modal-feedback { flex: 2; min-width: 100%; }
    .sc-card-wrapper-preview { transform: scale(0.45) !important; transform-origin: top center !important; margin-bottom: -300px; }
    .modal-img-preview { max-width: 100%; height: auto; }
}

/* Printing Utilities */
#print-staging-area {
    position: fixed; top: 0; left: 0; z-index: -1000; background: white;
    visibility: hidden; transform: translateZ(0); 
}
#print-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(15, 23, 42, 0.95); z-index: 100000;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: white; font-family: sans-serif;
}