:root {
    --font-heading: 'Orbitron', sans-serif;
    --font-body: 'Roboto Mono', monospace;
    --bg-gradient: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    --text-color: #e0e0e0;
    --primary-glow: #00ffff;
    --secondary-glow: #ff00ff;
    --danger-glow: #ff4d4d;
    --success-glow: #4dff88;
    --panel-bg: rgba(10, 25, 47, 0.85);
    --panel-border: rgba(0, 255, 255, 0.2);
    --panel-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    --border-radius-md: 15px;
    --border-radius-sm: 8px;
    --transition-speed: 0.3s;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg-gradient);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
}

#app-container { max-width: 1600px; margin: 0 auto; padding: 20px; }

/* --- Header --- */
header {
    text-align: center;
    padding: 20px;
    margin-bottom: 30px;
    position: relative;
    border-bottom: 1px solid var(--panel-border);
}
h1 {
    font-family: var(--font-heading);
    font-size: 3em;
    text-shadow: 0 0 15px var(--primary-glow);
    background: linear-gradient(45deg, var(--primary-glow), var(--secondary-glow));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 2px;
}
.version-tag { font-size: 0.4em; vertical-align: middle; background: var(--secondary-glow); color: black; padding: 2px 8px; border-radius: 5px; }
.subtitle { font-size: 1.2em; opacity: 0.8; margin-top: 10px; }
.tutorial-toggle {
    position: absolute; top: 20px; right: 20px; background: rgba(255, 255, 255, 0.1);
    padding: 8px 15px; border-radius: 20px; cursor: pointer; transition: all var(--transition-speed) ease;
}
.tutorial-toggle:hover { background: var(--primary-glow); color: #000; transform: scale(1.05); }

/* --- Game Setup Screen --- */
.game-setup-screen h2 { text-align: center; font-family: var(--font-heading); font-size: 2em; margin-bottom: 20px; color: var(--primary-glow); }
.language-selection-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 15px; margin-bottom: 20px; }
.lang-card {
    background: var(--panel-bg); border: 2px solid var(--panel-border); border-radius: var(--border-radius-sm);
    padding: 15px; text-align: center; cursor: pointer; transition: all var(--transition-speed) ease;
}
.lang-card:hover { transform: translateY(-5px); box-shadow: 0 0 15px var(--panel-border); }
.lang-card.selected { border-color: var(--primary-glow); background: rgba(0, 255, 255, 0.1); }
.lang-card-icon { font-size: 2.5em; }
.lang-card-name { font-weight: bold; margin-top: 10px; }
.setup-controls, .save-slot-controls { display: flex; justify-content: center; gap: 15px; margin-top: 20px; }

/* --- Game Screen & Controls --- */
.game-screen { display: flex; flex-direction: column; gap: 20px; }
.top-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 20px; }
.game-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat-card { background: rgba(255, 255, 255, 0.05); padding: 10px 15px; border-radius: var(--border-radius-sm); text-align: center; }
.stat-card .stat-label { font-size: 0.8em; opacity: 0.7; }
.stat-card .stat-value { font-size: 1.5em; font-weight: bold; color: var(--primary-glow); }
.game-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mode-switcher { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,0.2); padding: 5px 10px; border-radius: 20px; }
.mode-indicator { font-weight: bold; color: var(--success-glow); }

.control-btn {
    padding: 10px 20px; font-size: 1em; border: 1px solid var(--panel-border); border-radius: 20px;
    cursor: pointer; font-weight: 500; font-family: var(--font-body);
    background-color: transparent; color: var(--text-color);
    transition: all var(--transition-speed);
}
.control-btn:hover { background-color: var(--primary-glow); color: #000; border-color: var(--primary-glow); }
.start-btn { background-color: var(--success-glow); color: #000; border-color: var(--success-glow); }
.reset-btn { background-color: var(--danger-glow); color: #000; border-color: var(--danger-glow); }
.save-btn { background-color: #4d88ff; color: #000; border-color: #4d88ff; }

.speed-control-wrapper { position: relative; }
.speed-options {
    display: none; position: absolute; bottom: 120%; left: 50%; transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9); border-radius: var(--border-radius-sm); padding: 5px;
    flex-direction: column; gap: 5px; z-index: 10;
}
.speed-control-wrapper:hover .speed-options { display: flex; }
.speed-option { padding: 8px 12px; background: transparent; border: none; color: white; cursor: pointer; text-align: center; }
.speed-option.active { color: var(--primary-glow); font-weight: bold; }

.winner-banner {
    text-align: center; font-size: 2.5em; font-weight: bold; padding: 30px; margin: 0;
    border-radius: var(--border-radius-md); display: none;
    background: linear-gradient(45deg, #ffd700, #ffa500); color: #000;
    box-shadow: 0 0 50px rgba(255, 215, 0, 0.5); animation: fadeIn 0.5s;
}

/* --- Arena & Panels --- */
.arena-container { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
@media (max-width: 1200px) { .arena-container { grid-template-columns: 1fr; } }
.language-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 15px; align-content: start; }

.language-panel {
    background: var(--panel-bg); border-radius: var(--border-radius-md); padding: 20px;
    border: 2px solid var(--panel-border); box-shadow: var(--panel-shadow);
    transition: all var(--transition-speed) ease; opacity: 0; transform: translateY(20px); animation: fadeIn 0.5s forwards;
}
.language-panel.dead { filter: grayscale(100%) brightness(0.5); }
.language-panel.turn-active { border-color: var(--primary-glow); box-shadow: 0 0 20px var(--primary-glow); }

.language-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.language-name { font-size: 1.5em; font-weight: bold; display: flex; align-items: center; gap: 10px; }
.language-type { font-size: 0.7em; padding: 3px 8px; border-radius: 10px; opacity: 0.8; }
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 15px; }
.stat-item { background: rgba(255, 255, 255, 0.05); padding: 10px; border-radius: var(--border-radius-sm); text-align: center; }
.stat-item .stat-label { font-size: 0.8em; opacity: 0.7; }
.stat-item .stat-value-main { font-size: 1.2em; font-weight: bold; }

.health-bar-container { margin-bottom: 15px; }
.health-bar { height: 10px; background: rgba(255, 255, 255, 0.1); border-radius: 5px; overflow: hidden; }
.health-fill { height: 100%; border-radius: 5px; transition: width 0.5s ease; }
.health-text { text-align: center; font-size: 0.9em; margin-top: 5px; }

.attacks-section .section-title { font-size: 1.1em; margin: 15px 0 10px; color: var(--primary-glow); }
.attack-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.attack-btn {
    padding: 10px; border: 1px solid rgba(255,255,255,0.2); border-radius: var(--border-radius-sm);
    cursor: pointer; text-align: left; transition: all var(--transition-speed); background-color: rgba(255,255,255,0.05);
}
.attack-btn:hover { background-color: rgba(0, 255, 255, 0.2); border-color: var(--primary-glow); }
.attack-name { font-size: 1em; font-weight: 500; }
.attack-damage { font-size: 0.8em; opacity: 0.7; }

/* --- Battle Log --- */
.battle-arena { background: var(--panel-bg); border-radius: var(--border-radius-md); padding: 25px; display: flex; flex-direction: column; }
.arena-header { text-align: center; margin-bottom: 20px; }
.arena-title { font-family: var(--font-heading); font-size: 1.8em; color: var(--secondary-glow); }
.battle-log { flex-grow: 1; overflow-y: auto; padding-right: 10px; }
.log-entry {
    padding: 10px; margin-bottom: 8px; border-radius: var(--border-radius-sm);
    border-left: 4px solid; animation: slideIn 0.4s ease-out;
}
.log-timestamp { font-size: 0.7em; opacity: 0.6; float: right; }
.log-system { background: rgba(77, 136, 255, 0.15); border-color: #4d88ff; }
.log-attack { background: rgba(255, 77, 77, 0.15); border-color: var(--danger-glow); }
.log-heal { background: rgba(77, 255, 136, 0.15); border-color: var(--success-glow); }
.log-special { background: rgba(255, 255, 100, 0.15); border-color: #ffff64; }
.log-victory { background: rgba(255, 215, 0, 0.2); border-color: #ffd700; }

/* --- Modal --- */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8); z-index: 1000;
    display: flex; justify-content: center; align-items: center;
    opacity: 0; visibility: hidden; transition: all var(--transition-speed) ease;
}
.modal.show { opacity: 1; visibility: visible; }
.modal-content {
    background: var(--bg-gradient); border: 2px solid var(--primary-glow);
    border-radius: var(--border-radius-md); padding: 30px; width: 90%;
    max-width: 700px; max-height: 85vh; overflow-y: auto;
    box-shadow: 0 0 50px rgba(0, 255, 255, 0.3);
    transform: scale(0.9); transition: transform var(--transition-speed) ease;
}
.modal.show .modal-content { transform: scale(1); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-family: var(--font-heading); font-size: 1.8em; color: var(--primary-glow); }
.close-modal { background: none; border: none; color: white; font-size: 2em; cursor: pointer; }
.modal-body .code-block {
    background: rgba(0, 0, 0, 0.5); padding: 15px; border-radius: var(--border-radius-sm);
    font-family: var(--font-body); margin: 10px 0; overflow-x: auto; color: #b5f2b5;
}
.tutorial-section { margin-bottom: 25px; padding-left: 15px; border-left: 3px solid var(--secondary-glow); }

/* --- Animations & Type Colors --- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } }

.type-script { background-color: #f7df1e; color: #000; }
.type-system { background-color: #61dafb; color: #000; }
.type-markup { background-color: #e34c26; }
.type-style { background-color: #264de4; }
.type-query { background-color: #e38c00; }
.type-support { background-color: #9c27b0; }
.type-shell { background-color: #4EAA25; }

/* Language-specific styles */
.python { border-color: #3776ab; } .python .health-fill { background: #3776ab; }
.javascript { border-color: #f7df1e; } .javascript .health-fill { background: #f7df1e; }
.cpp { border-color: #00599c; } .cpp .health-fill { background: #00599c; }
.go { border-color: #00add8; } .go .health-fill { background: #00add8; }
.php { border-color: #777bb4; } .php .health-fill { background: #777bb4; }
.html { border-color: #e34c26; } .html .health-fill { background: #e34c26; }
.css { border-color: #264de4; } .css .health-fill { background: #264de4; }
.sql { border-color: #e38c00; } .sql .health-fill { background: #e38c00; }
.yaml, .json, .markdown, .bash { border-color: #9c27b0; }
.yaml .health-fill, .json .health-fill, .markdown .health-fill, .bash .health-fill { background: #9c27b0; }