:root {
    --primary-neon: #00ff88;
    --secondary-neon: #00d4ff;
    --accent-red: #ff4d4d;
    --bg-deep: #050a14;
    --card-glass: rgba(255, 255, 255, 0.05);
    --border-glass: rgba(255, 255, 255, 0.1);
    --pitch-dark: #0a1f13;
    --pitch-line: rgba(0, 255, 136, 0.3);
    --text-muted: #94a3b8;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Pretendard', sans-serif; }

body.gaming-theme {
    background-color: var(--bg-deep);
    color: white;
    height: 100vh;
    overflow: hidden;
    background: radial-gradient(circle at top, #0a1931 0%, #050a14 100%);
}

.overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: url('https://www.transparenttextures.com/patterns/carbon-fibre.png');
    opacity: 0.1; pointer-events: none;
}

.app-wrapper { position: relative; z-index: 1; display: flex; flex-direction: column; height: 100vh; }

/* Header & Nav */
.main-nav {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 40px; background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(15px); border-bottom: 2px solid var(--border-glass);
}

.logo-area { display: flex; align-items: center; gap: 15px; }
.logo-area .icon { font-size: 2.2rem; }
.logo-text { display: flex; flex-direction: column; }
.tagline { font-size: 0.65rem; color: var(--secondary-neon); font-weight: 800; letter-spacing: 2px; }

.glitch-text {
    font-weight: 900; font-size: 1.8rem; letter-spacing: 1px;
    color: #fff; text-shadow: 2px 2px var(--accent-red), -2px -2px var(--secondary-neon);
}

.strategy-badge {
    background: var(--primary-neon); color: black;
    padding: 4px 12px; border-radius: 50px; font-size: 0.8rem; font-weight: 900;
}

.top-controls { display: flex; align-items: center; gap: 20px; }
.formation-selector { display: flex; flex-direction: column; align-items: flex-end; }
.formation-selector label { font-size: 0.6rem; color: var(--text-muted); margin-bottom: 2px; }
.formation-selector select {
    background: #000; border: 1px solid var(--border-glass); color: white;
    padding: 5px 10px; border-radius: 4px; font-weight: bold; font-size: 0.85rem;
}

.exit-btn {
    padding: 6px 15px; border: 1px solid var(--accent-red); color: var(--accent-red);
    text-decoration: none; font-weight: bold; font-size: 0.75rem; border-radius: 4px;
}

/* Stadium Layout */
.stadium-layout { display: flex; flex: 1; overflow: hidden; }

.pitch-container {
    flex: 2.5; padding: 20px; display: flex; flex-direction: column;
    justify-content: center; align-items: center;
}

.pitch {
    width: 100%; max-width: 850px; height: 85%;
    background: #111; border: 3px solid var(--pitch-line);
    border-radius: 20px; position: relative;
    box-shadow: 0 0 50px rgba(0,0,0,1);
    background-image: 
        linear-gradient(var(--pitch-line) 2px, transparent 2px),
        linear-gradient(90deg, var(--pitch-line) 2px, transparent 2px);
    background-size: 50% 100%, 100% 25%;
    background-position: center;
}

.players-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; flex-direction: column; justify-content: space-around;
    padding: 10px 0; z-index: 2;
}

.formation-row { display: flex; justify-content: center; gap: 15px; width: 100%; }

/* Player Slot & Card */
.player-slot {
    width: 90px; height: 120px;
    background: rgba(0,0,0,0.5); border: 2px dashed rgba(255,255,255,0.1);
    border-radius: 10px; display: flex; flex-direction: column;
    justify-content: center; align-items: center; cursor: pointer;
    transition: all 0.2s; position: relative;
}

.player-slot:hover { border-color: var(--primary-neon); background: rgba(0, 255, 136, 0.05); }

.plus-icon { font-size: 1.5rem; color: rgba(255,255,255,0.2); }
.pos-tag { font-size: 0.65rem; font-weight: 900; color: var(--text-muted); margin-top: 5px; }

/* Modern Structured Stock Card */
.stock-card {
    width: 100%; height: 100%;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border-radius: 10px; padding: 0;
    display: flex; flex-direction: column;
    position: relative; overflow: hidden;
    animation: cardIn 0.4s ease-out;
    border: 1px solid rgba(255,255,255,0.1);
}

.card-header {
    padding: 6px 8px;
    display: flex; justify-content: space-between; align-items: center;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.pos-label {
    font-size: 0.75rem; font-weight: 900;
    letter-spacing: 0.5px;
}

.country-tag {
    font-size: 0.6rem; font-weight: 700;
    color: var(--text-muted);
    display: flex; align-items: center; gap: 3px;
}

.card-body {
    flex: 1;
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    padding: 10px 5px;
    text-align: center;
}

.stock-card .name {
    font-size: 0.85rem; font-weight: 800;
    color: #fff; margin-bottom: 2px;
    display: block; width: 100%;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.stock-card .ticker-sub {
    font-size: 0.55rem; font-weight: 600;
    color: var(--secondary-neon);
    opacity: 0.7;
}

.card-footer {
    padding: 5px 8px;
    background: rgba(0,0,0,0.2);
    display: flex; justify-content: space-between; align-items: center;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.role-text {
    font-size: 0.55rem; font-weight: 800;
    color: #fff; opacity: 0.9;
}

.stock-card .change-val {
    font-size: 0.6rem; font-weight: 900;
}

/* Position-Specific Themes (Overriding) */
.stock-card.card-fw { border: 2px solid #ff4d4d; box-shadow: 0 4px 15px rgba(255, 77, 77, 0.3); }
.stock-card.card-fw .pos-label { color: #ff4d4d; }
.stock-card.card-fw .card-header { border-bottom: 1px solid rgba(255, 77, 77, 0.2); }

.stock-card.card-mf { border: 2px solid #00d4ff; box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3); }
.stock-card.card-mf .pos-label { color: #00d4ff; }
.stock-card.card-mf .card-header { border-bottom: 1px solid rgba(0, 212, 255, 0.2); }

.stock-card.card-df { border: 2px solid #00ff88; box-shadow: 0 4px 15px rgba(0, 255, 136, 0.3); }
.stock-card.card-df .pos-label { color: #00ff88; }
.stock-card.card-df .card-header { border-bottom: 1px solid rgba(0, 255, 136, 0.2); }

.stock-card.card-gk { border: 2px solid #bf5af2; box-shadow: 0 4px 15px rgba(191, 90, 242, 0.3); }
.stock-card.card-gk .pos-label { color: #bf5af2; }
.stock-card.card-gk .card-header { border-bottom: 1px solid rgba(191, 90, 242, 0.2); }

@keyframes cardIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.stock-card .flag { position: absolute; top: 5px; left: 5px; font-size: 0.8rem; }
.stock-card .condition { position: absolute; top: 5px; right: 5px; font-size: 0.8rem; }
.stock-card .condition.up { color: var(--primary-neon); }
.stock-card .condition.down { color: var(--accent-red); }

.stock-card .role-badge {
    font-size: 0.55rem;
    font-weight: 900; padding: 1px 4px; border-radius: 2px; margin-bottom: 5px;
}

.stock-card .name {
    font-size: 0.8rem; font-weight: 800; margin: 2px 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%;
}

.stock-card .change { font-size: 0.65rem; font-weight: bold; margin-top: auto; }

/* Coach Advice Panel */
.coach-advice-panel {
    width: 100%; max-width: 850px; margin-top: 15px;
    background: rgba(30, 41, 59, 0.8); backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass); border-radius: 12px; padding: 15px;
    display: flex; align-items: center; gap: 20px;
}

.coach-header { display: flex; flex-direction: column; align-items: center; min-width: 120px; border-right: 1px solid var(--border-glass); }
.coach-icon { font-size: 2rem; }
.coach-header h3 { font-size: 0.7rem; color: var(--primary-neon); margin-top: 5px; }

.coach-content { flex: 1; font-size: 0.85rem; line-height: 1.5; color: #f8fafc; font-weight: 600; }

.rec-list { display: flex; gap: 10px; overflow-x: auto; padding: 5px; }
.rec-tag {
    background: rgba(0, 212, 255, 0.1); border: 1px solid var(--secondary-neon);
    color: var(--secondary-neon); padding: 4px 10px; border-radius: 4px;
    font-size: 0.75rem; white-space: nowrap; font-weight: bold;
}

/* Sidebar & Market */
.transfer-market {
    flex: 1; background: rgba(0,0,0,0.5); border-left: 2px solid var(--border-glass);
    display: flex; flex-direction: column; padding: 20px;
}

.market-header h2 { font-size: 1rem; color: var(--secondary-neon); margin-bottom: 15px; letter-spacing: 1px; }

.search-input-wrapper input {
    width: 100%; background: #000; border: 1px solid var(--border-glass);
    padding: 10px 15px; border-radius: 6px; color: white; outline: none;
}

.stock-grid { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 10px 0; }

.market-item {
    background: var(--card-glass); padding: 10px 15px; border-radius: 6px;
    display: flex; justify-content: space-between; align-items: center;
    cursor: pointer; transition: 0.2s; border-left: 3px solid transparent;
}

.market-item:hover { background: rgba(255,255,255,0.08); border-left-color: var(--primary-neon); }

/* My Roster */
.my-roster-section {
    margin-top: 15px; padding-top: 10px; border-top: 1px solid var(--border-glass);
    flex: 1; display: flex; flex-direction: column;
}

.roster-grid { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 5px; }

.roster-item {
    background: rgba(0, 212, 255, 0.05); border: 1px solid var(--border-glass);
    padding: 6px 12px; border-radius: 6px; display: flex; justify-content: space-between;
    align-items: center; cursor: pointer; transition: 0.2s;
}

.roster-item.active-in-squad { border-color: var(--primary-neon); background: rgba(0, 255, 136, 0.1); }

.release-btn {
    background: rgba(255, 77, 77, 0.2); color: var(--accent-red);
    border: 1px solid var(--accent-red); width: 18px; height: 18px;
    border-radius: 4px; display: flex; align-items: center; justify-content: center;
    font-size: 0.5rem; margin-left: 8px;
}

/* Stats & OVR */
.squad-stats { margin-top: 15px; padding-top: 10px; border-top: 1px solid var(--border-glass); }

.total-score-container {
    margin-bottom: 15px; padding: 12px;
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.1) 0%, rgba(0, 212, 255, 0.1) 100%);
    border: 1px solid var(--primary-neon); border-radius: 10px;
    display: flex; justify-content: space-between; align-items: center;
}

.ovr-value { font-size: 2rem; font-weight: 900; color: #fff; text-shadow: 0 0 10px var(--primary-neon); }

.stat-item { margin-bottom: 6px; }
.bar-bg { width: 100%; height: 5px; background: rgba(255,255,255,0.05); border-radius: 3px; }
.bar-fill { height: 100%; background: var(--primary-neon); transition: width 0.5s ease-out; }

.squad-summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.summary-item { background: #000; padding: 8px; border-radius: 6px; text-align: center; border: 1px solid var(--border-glass); }
.summary-item label { font-size: 0.5rem; color: var(--secondary-neon); display: block; font-weight: 900; }
.summary-item span { font-size: 0.9rem; font-weight: 800; }

/* Modal */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); z-index: 100; justify-content: center; align-items: center; }
.modal-content { background: var(--bg-deep); width: 90%; max-width: 500px; padding: 25px; border-radius: 12px; border: 1px solid var(--border-glass); }

.loading-spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid rgba(255,255,255,.3); border-radius: 50%; border-top-color: var(--primary-neon); animation: spin 1s linear infinite; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Utilities */
.up { color: var(--accent-red); }
.down { color: var(--secondary-neon); }
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: var(--border-glass); border-radius: 10px; }
