/* ==========================================================================
   HEADER & NAVIGATION
   ========================================================================== */
.app-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px;
    background: rgba(15, 23, 42, 0.85);
    border-bottom: 1px solid var(--border-dim);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 30;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(45, 212, 191, 0.2), rgba(56, 189, 248, 0.2));
    border: 1px solid rgba(45, 212, 191, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 16px rgba(45, 212, 191, 0.25);
    flex-shrink: 0;
}

.brand-title {
    font-size: 1.18rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(90deg, #5eead4, #38bdf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.brand-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.header-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.header-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-dim);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-main);
}

.header-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-bright);
}

.header-btn.grade-pill {
    border-color: rgba(56, 189, 248, 0.5);
    background: rgba(56, 189, 248, 0.12);
    color: #7dd3fc;
}

.header-btn.grade-pill:hover {
    background: rgba(56, 189, 248, 0.22);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}

.header-btn.cards-pill {
    border-color: rgba(251, 191, 36, 0.5);
    background: rgba(251, 191, 36, 0.12);
    color: #fde68a;
}

.header-btn.cards-pill:hover {
    background: rgba(251, 191, 36, 0.22);
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.25);
}

.header-btn.cards-pill.card-pulse {
    animation: cardUnlockPulse 1.6s ease-out;
}

@keyframes cardUnlockPulse {
    0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.85); transform: scale(1.06); }
    60% { box-shadow: 0 0 22px 6px rgba(251, 191, 36, 0.45); transform: scale(1.02); }
    100% { box-shadow: none; transform: scale(1); }
}

.header-btn.danger-btn:hover {
    border-color: rgba(244, 63, 94, 0.55);
    color: #fda4af;
    background: rgba(244, 63, 94, 0.12);
}

.solved-stat {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-dim);
}

/* ==========================================================================
   HAUPT-LAYOUT (Zweispaltig auf Desktop, Gestapelt auf Mobil/Tablet)
   ========================================================================== */
.main-layout {
    max-width: 1480px;
    margin: 0 auto;
    padding: 16px;
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(350px, 460px);
    gap: 18px;
    align-items: start;
}

@media (max-width: 1040px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .main-layout {
        padding: 10px;
        gap: 12px;
    }
    .app-header {
        padding: 10px 12px;
    }
}

/* ==========================================================================
   LINKE SPALTE: SPIELFELD-HUD & CANVAS
   ========================================================================== */
.arena-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-lg);
    padding: 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wave-hud {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-md);
    padding: 10px 14px;
}

.wave-info-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 200px;
    flex: 1;
}

.level-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.level-badge {
    font-size: 1.02rem;
    font-weight: 800;
    color: #f8fafc;
}

.boss-forecast {
    font-size: 0.73rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(245, 158, 11, 0.14);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #fcd34d;
}

.boss-forecast.is-boss-level {
    background: rgba(244, 63, 94, 0.2);
    border-color: rgba(244, 63, 94, 0.65);
    color: #fda4af;
    animation: pulseGlow 1.6s infinite alternate;
}

@keyframes pulseGlow {
    0% { box-shadow: 0 0 4px rgba(244, 63, 94, 0.25); }
    100% { box-shadow: 0 0 14px rgba(244, 63, 94, 0.65); }
}

.wave-progress-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wave-progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(15, 23, 42, 0.9);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.wave-progress-fill {
    height: 100%;
    width: 5%;
    background: linear-gradient(90deg, #2dd4bf, #38bdf8);
    border-radius: 999px;
    transition: width 0.25s ease;
}

.wave-enemy-count {
    font-size: 0.74rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.sim-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.speed-group {
    display: inline-flex;
    background: var(--bg-main);
    padding: 3px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-dim);
}

.speed-btn {
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
}

.speed-btn.active {
    background: #38bdf8;
    color: #041322;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

.auto-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 700;
    border: 1px solid rgba(16, 185, 129, 0.45);
    background: rgba(16, 185, 129, 0.14);
    color: #6ee7b7;
}

.auto-btn.farm-mode {
    border-color: rgba(251, 191, 36, 0.55);
    background: rgba(251, 191, 36, 0.15);
    color: #fde68a;
}

.wave-step-btn {
    padding: 6px 9px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 700;
    background: var(--bg-main);
    border: 1px solid var(--border-dim);
    color: var(--text-muted);
}

.wave-step-btn:hover:not(:disabled) {
    color: var(--text-main);
    border-color: var(--border-bright);
}

.canvas-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    min-height: 340px;
    max-height: 640px;
    background: #060a15;
    border-radius: var(--radius-md);
    border: 1px solid rgba(56, 189, 248, 0.18);
    overflow: hidden;
    box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.8);
}

canvas#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

.boss-bar-overlay {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: min(88%, 480px);
    background: rgba(9, 14, 26, 0.88);
    border: 1px solid rgba(244, 63, 94, 0.65);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    box-shadow: 0 6px 24px rgba(244, 63, 94, 0.3);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    z-index: 5;
}

.boss-bar-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.boss-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    font-weight: 800;
    margin-bottom: 5px;
    color: #fda4af;
}

.boss-hp-track {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    overflow: hidden;
}

.boss-hp-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #f43f5e, #fb923c);
    transition: width 0.12s linear;
}

.arena-banner {
    position: absolute;
    top: 66px;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 7px 16px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(56, 189, 248, 0.45);
    color: #e0f2fe;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 6;
    white-space: nowrap;
}

.arena-banner.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.arena-banner.warn {
    border-color: rgba(244, 63, 94, 0.75);
    background: rgba(69, 10, 26, 0.9);
    color: #fecdd3;
}

/* Dramatischer Boss-Alarm über dem Spielfeld */
.boss-warning-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    z-index: 8;
    background: radial-gradient(circle at center, rgba(244, 63, 94, 0.04) 25%, rgba(225, 29, 72, 0.42) 100%);
    box-shadow: inset 0 0 85px rgba(244, 63, 94, 0.78);
}

.boss-warning-overlay.active {
    visibility: visible;
    animation: bossRedAlert 2.65s ease-out forwards;
}

.boss-warning-card {
    text-align: center;
    padding: 16px 28px;
    border-radius: var(--radius-md);
    background: rgba(15, 7, 16, 0.92);
    border: 2px solid #f43f5e;
    box-shadow: 0 0 42px rgba(244, 63, 94, 0.65), inset 0 0 22px rgba(244, 63, 94, 0.25);
    position: relative;
    overflow: hidden;
}

.boss-warning-card::before,
.boss-warning-card::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 6px;
    background: repeating-linear-gradient(
        -45deg,
        #f43f5e,
        #f43f5e 10px,
        #090e1a 10px,
        #090e1a 20px
    );
}

.boss-warning-card::before { top: 0; }
.boss-warning-card::after { bottom: 0; }

.boss-warning-kicker {
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    color: #fb923c;
    margin-bottom: 4px;
}

.boss-warning-title {
    font-size: 1.45rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    color: #fff1f2;
    text-shadow: 0 0 18px rgba(244, 63, 94, 0.9);
}

.boss-warning-name {
    margin-top: 4px;
    font-size: 0.9rem;
    font-weight: 800;
    color: #fde047;
}

@keyframes bossRedAlert {
    0%   { opacity: 0; transform: scale(1.06); }
    12%  { opacity: 1; transform: scale(1); }
    24%  { opacity: 0.45; }
    38%  { opacity: 1; }
    52%  { opacity: 0.55; }
    68%  { opacity: 1; }
    85%  { opacity: 0.92; }
    100% { opacity: 0; visibility: hidden; }
}

.status-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

@media (max-width: 680px) {
    .status-strip {
        grid-template-columns: 1fr;
    }
}

.stat-box {
    background: var(--bg-card);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
}

.stat-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-value {
    font-size: 1.15rem;
    font-weight: 800;
}

.gold-val {
    color: var(--col-gold);
}

.streak-val {
    color: #38bdf8;
}

.base-hp-bar-mini {
    width: 100%;
    height: 7px;
    background: rgba(15, 23, 42, 0.9);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 3px;
}

.base-hp-fill-mini {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #10b981, #2dd4bf);
    transition: width 0.15s linear;
}

/* Taktische Kommandos unter der Arena */
.tactics-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-md);
    padding: 8px 10px;
}

.tactics-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
}

.tactic-btn {
    flex: 1;
    min-width: 120px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 7px 11px;
    border-radius: var(--radius-sm);
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(56, 189, 248, 0.45);
    font-size: 0.78rem;
    font-weight: 700;
    color: #e0f2fe;
}

.tactic-btn.ready:hover:not(:disabled) {
    background: rgba(56, 189, 248, 0.2);
    border-color: #38bdf8;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}

.tactic-btn.tactic-overdrive {
    border-color: rgba(251, 191, 36, 0.45);
    color: #fef08a;
}

.tactic-btn.tactic-overdrive.ready:hover:not(:disabled) {
    background: rgba(251, 191, 36, 0.18);
    border-color: #fbbf24;
}

.tactic-btn.tactic-shield {
    border-color: rgba(45, 212, 191, 0.45);
    color: #99f6e4;
}

.tactic-btn.tactic-shield.ready:hover:not(:disabled) {
    background: rgba(45, 212, 191, 0.18);
    border-color: #2dd4bf;
}

.tactic-cd {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 2px 6px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.08);
}

.tactics-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
}
