/* General Design Tokens */
:root {
    --bg-dark: #070913;
    --bg-darker: #04050a;
    --glass-bg: rgba(15, 23, 42, 0.45);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-hover: rgba(255, 255, 255, 0.18);
    
    --color-wash-gold: #ffd700;
    --color-wash-purple: #a855f7;
    --color-wash-purple-glow: rgba(168, 85, 247, 0.4);
    
    --color-alice-cyan: #22d3ee;
    --color-alice-pink: #ec4899;
    --color-alice-blue-glow: rgba(34, 211, 238, 0.4);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --font-heading: 'Cinzel', Georgia, serif;
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    --shadow-glow-wash: 0 0 15px var(--color-wash-purple-glow);
    --shadow-glow-alice: 0 0 15px var(--color-alice-blue-glow);
}

/* Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: radial-gradient(circle at 50% 50%, #111827 0%, #030712 100%);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    padding: max(1.25rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1.25rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    gap: 1.5rem;
}

#shared-support-box {
    max-width: 650px;
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
}

#app-container {
    max-width: 1400px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-darker);
}
::-webkit-scrollbar-thumb {
    background: #1e293b;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #334155;
}

/* Glassmorphism Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.glass-panel:hover {
    border-color: var(--glass-border-hover);
}

/* Main Header */
#main-header {
    text-align: center;
    padding: 10px 0;
}

#main-header h1 {
    font-family: var(--font-heading);
    font-size: 2.8rem;
    font-weight: 900;
    letter-spacing: 2px;
    text-transform: uppercase;
    background: linear-gradient(90deg, var(--color-wash-gold) 0%, #ffffff 50%, var(--color-alice-cyan) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px rgba(255, 255, 255, 0.1));
}

.glow-text {
    animation: textGlow 6s infinite alternate;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-top: 5px;
    letter-spacing: 1px;
}

/* Main Layout Grid */
#battle-workspace {
    display: grid;
    grid-template-columns: 320px 1fr 320px;
    gap: 20px;
    align-items: start;
}

@media (max-width: 1200px) {
    #battle-workspace {
        grid-template-columns: 1fr;
    }
}

/* Faction Panels */
.faction-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: relative;
    overflow: hidden;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 16px;
}

.avatar {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid transparent;
    background: var(--bg-darker);
}

.border-gold {
    border-color: var(--color-wash-gold);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.35);
}

.border-blue {
    border-color: var(--color-alice-cyan);
    box-shadow: 0 0 12px rgba(34, 211, 238, 0.35);
}

.profile-title h2 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
}

.badge {
    display: inline-block;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 6px;
    margin-top: 4px;
}

.badge-gold {
    background: rgba(255, 215, 0, 0.15);
    color: var(--color-wash-gold);
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.badge-blue {
    background: rgba(34, 211, 238, 0.15);
    color: var(--color-alice-cyan);
    border: 1px solid rgba(34, 211, 238, 0.3);
}

/* Progress Bars */
.bar-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bar-container label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bar-bg {
    background: var(--bg-darker);
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 6px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bar-health {
    background: linear-gradient(90deg, #ef4444, #f87171);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

.bar-energy {
    background: linear-gradient(90deg, var(--color-wash-purple), #c084fc);
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.4);
}

.bar-ink {
    background: linear-gradient(90deg, var(--color-alice-cyan), var(--color-alice-pink));
    box-shadow: 0 0 8px rgba(34, 211, 238, 0.4);
}

/* Buttons and Spawners */
.spawn-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.spawn-controls h3 {
    font-size: 0.95rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
    margin-bottom: 4px;
}

.btn {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    outline: none;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120%;
    height: 120%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.3s ease;
}

.btn:hover::before {
    transform: translate(-50%, -50%) scale(1);
}

kbd {
    background: #020617;
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Faction Button Styles */
.btn-wash:hover {
    border-color: var(--color-wash-purple);
    box-shadow: 0 0 10px var(--color-wash-purple-glow);
    background: rgba(168, 85, 247, 0.15);
}

.btn-alice:hover {
    border-color: var(--color-alice-cyan);
    box-shadow: 0 0 10px var(--color-alice-blue-glow);
    background: rgba(34, 211, 238, 0.15);
}

/* Ultimate buttons */
.btn-ult {
    font-family: var(--font-heading);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    margin-top: 10px;
}

.btn-wash.btn-ult:not(.btn-disabled) {
    border-color: var(--color-wash-gold);
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.3) 0%, rgba(255, 215, 0, 0.2) 100%);
    animation: pulseGold 2s infinite;
}

.btn-alice.btn-ult:not(.btn-disabled) {
    border-color: var(--color-alice-pink);
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.3) 0%, rgba(236, 72, 153, 0.2) 100%);
    animation: pulsePink 2s infinite;
}

.btn-disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Faction Stats */
.faction-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 12px;
    border: 1px solid rgba(255,255,255,0.03);
}

.stat-row {
    display: flex;
    justify-content: space-between;
}

.stat-row span:last-child {
    font-weight: 800;
    color: var(--text-primary);
}

/* Center Simulation Area */
#simulation-center {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#canvas-container {
    position: relative;
    padding: 6px;
    line-height: 0;
    overflow: hidden;
    background: #02040a;
}

#battle-canvas {
    width: 100%;
    height: auto;
    border-radius: 12px;
    background: #050610;
    display: block;
}

#floating-msg-box {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(4, 6, 15, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    pointer-events: none;
    opacity: 0.9;
    transition: opacity 0.3s ease;
    text-align: center;
    white-space: nowrap;
}

/* Simulation Controls */
#simulation-controls {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 20px;
}

.btn-control {
    flex: 1;
    min-width: 100px;
    justify-content: center;
    padding: 8px 12px;
    font-size: 0.85rem;
}

.btn-control:hover {
    border-color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
}

/* Footer / Tabs Section */
#info-footer {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tabs {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    gap: 8px;
}

.tab-link {
    background: none;
    border: none;
    outline: none;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 10px 18px;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    transition: all 0.2s ease;
    position: relative;
}

.tab-link:hover {
    color: var(--text-primary);
}

.tab-link.active {
    color: var(--text-primary);
}

.tab-link.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, var(--color-wash-gold), var(--color-alice-cyan));
    border-radius: 2px;
}

.tab-content {
    display: none;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-secondary);
    padding: 6px 0;
    min-height: 100px;
}

.tab-content.active {
    display: block;
}

.lore-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

@media (max-width: 800px) {
    .lore-grid {
        grid-template-columns: 1fr;
    }
}

.lore-grid h4 {
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Shortcuts Table */
.shortcuts-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.shortcuts-table th, .shortcuts-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.shortcuts-table th {
    color: var(--text-primary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

/* Battle Log */
.log-stream {
    max-height: 140px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    font-family: monospace;
    font-size: 0.8rem;
}

.log-entry {
    padding: 2px 4px;
}

.log-wash {
    color: var(--color-wash-purple);
}

.log-alice {
    color: var(--color-alice-cyan);
}

.log-system {
    color: #a3e635;
}

.log-wash-ult {
    color: var(--color-wash-gold);
    font-weight: bold;
}

.log-alice-ult {
    color: var(--color-alice-pink);
    font-weight: bold;
}

/* Keyframe Animations */
@keyframes textGlow {
    0% { filter: drop-shadow(0 2px 4px rgba(255, 215, 0, 0.15)); }
    100% { filter: drop-shadow(0 2px 12px rgba(34, 211, 238, 0.3)); }
}

@keyframes pulseGold {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.5);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 215, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0);
    }
}

@keyframes pulsePink {
    0% {
        box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.5);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(236, 72, 153, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(236, 72, 153, 0);
    }
}

@media (max-width: 640px) {
    body {
        justify-content: flex-start;
    }

    #simulation-controls {
        flex-direction: column;
        padding: 12px;
    }

    .btn-control {
        flex: none;
        width: 100%;
        min-width: 0;
        min-height: 2.75rem;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .tab-link {
        flex: 1 1 auto;
        text-align: center;
        padding: 10px 12px;
        font-size: 0.8rem;
    }

    .shortcuts-table {
        font-size: 0.85rem;
    }

    .shortcuts-table th,
    .shortcuts-table td {
        padding: 6px 8px;
    }
}
