@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Inter:wght@300;400;600&display=swap');

:root {
    --neon-blue: #00f3ff;
    --neon-pink: #ff00ff;
    --neon-green: #00ff9d;
    --neon-yellow: #ffee00;
    --bg-dark: #0a0a0f;
    --panel-bg: #11111a;
    --border-color: #2d3748;
}

/* --- Base Reset & Typography --- */
body {
    background-color: var(--bg-dark);
    font-family: 'Inter', sans-serif;
    color: #e2e8f0;
    margin: 0;
    padding: 0;
}

h1, .font-cyber {
    font-family: 'Orbitron', sans-serif;
}

/* --- Layout Grid --- */
.app-container {
    display: grid;
    height: 100vh;
    width: 100vw;
    grid-template-rows: auto 1fr auto; /* Mobile Default: Header, Board, Footer */
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1rem;
    box-sizing: border-box;
}

/* Desktop Layout */
@media (min-width: 768px) {
    .app-container {
        grid-template-rows: 1fr;
        grid-template-columns: 250px 1fr 0px; /* Default: Hidden Trainer */
        gap: 2rem;
        padding: 2rem;
        transition: grid-template-columns 0.3s ease;
    }

    .app-container.trainer-active {
        grid-template-columns: 250px 1fr 200px; /* Active: Show Trainer */
    }
}

/* --- Panels --- */
.panel-left {
    display: flex;
    flex-direction: row; /* Mobile: Horizontal strip */
    justify-content: space-between;
    align-items: center;
    background: var(--panel-bg);
    padding: 1rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
}

@media (min-width: 768px) {
    .panel-left {
        flex-direction: column;
        justify-content: flex-start;
        gap: 2rem;
        align-items: stretch;
    }
}

.panel-center {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 0; /* Important for grid overflow */
}

.panel-right {
    background: var(--panel-bg);
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
    opacity: 0;
    width: 0;
    padding: 0;
    border: none;
}

/* Show Trainer Panel when active */
.panel-right.active {
    opacity: 1;
    width: 100%; /* Mobile: Full width in its grid cell? No, handled by grid usually */
    padding: 1rem;
    border: 1px solid var(--border-color);
}

@media (min-width: 768px) {
    .panel-right.active {
        width: 100%; /* Fills the 200px column */
    }
}

.panel-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* --- Header & Stats Components --- */
.header-group {
    text-align: left;
}

.game-title {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #22d3ee, #2563eb);
    -webkit-background-clip: text;
    color: transparent;
}

.level-badge {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.stats-grid {
    display: flex;
    gap: 1rem;
}

@media (min-width: 768px) {
    .stats-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
        width: 100%;
    }
}

.stat-box {
    background: rgba(255, 255, 255, 0.03);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    text-align: center;
}

.stat-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #94a3b8;
}

.stat-value {
    font-family: 'Orbitron', monospace;
    font-size: 1.2rem;
    font-weight: bold;
}

.progress-group {
    width: 100%;
}

.xp-bar-container {
    width: 100%;
    height: 6px;
    background: #2d3748;
    border-radius: 3px;
    overflow: hidden;
}

.xp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--neon-blue), var(--neon-pink));
    width: 0%;
    transition: width 0.5s ease;
}

.accuracy-group {
    display: flex;
    gap: 1rem;
    justify-content: space-around;
    width: 100%;
    background: rgba(0,0,0,0.2);
    padding: 0.5rem;
    border-radius: 0.5rem;
}

.acc-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- Game Board --- */
.board-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 12px;
    /* Responsive Sizing: Fit within the container but maintain aspect ratio */
    width: min(100%, 60vh);
    aspect-ratio: 1;
}

.cell {
    background-color: var(--panel-bg);
    border: 1px solid #2d3748;
    border-radius: 12px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

.cell.active {
    border-color: var(--neon-blue);
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.3);
}

.sphere {
    width: 0%;
    height: 0%;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #ffffff, var(--neon-blue));
    box-shadow: 0 0 20px var(--neon-blue), 0 0 40px var(--neon-blue);
    opacity: 0;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cell.active .sphere {
    width: 60%;
    height: 60%;
    opacity: 1;
}

/* --- Trainer List --- */
.trainer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
}

.trainer-list {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 4px;
}

/* Scrollbar styling */
.trainer-list::-webkit-scrollbar {
    width: 4px;
}
.trainer-list::-webkit-scrollbar-track {
    background: #1a1a2e;
}
.trainer-list::-webkit-scrollbar-thumb {
    background: #4a5568;
    border-radius: 2px;
}

.trainer-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 8px;
    background: rgba(255,255,255,0.02);
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.75rem;
}

.trainer-item.highlight {
    background: rgba(255, 238, 0, 0.1);
    border-left: 3px solid var(--neon-yellow);
}

/* --- Controls --- */
.btn-neon {
    position: relative;
    overflow: hidden;
    transition: all 0.2s;
    height: 80px;
    border-radius: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.btn-neon:active {
    transform: scale(0.96);
}

.btn-pos {
    border: 2px solid var(--neon-blue);
    color: var(--neon-blue);
    background: rgba(0, 243, 255, 0.05);
}

.btn-pos.triggered {
    background: var(--neon-blue);
    color: #000;
    box-shadow: 0 0 30px var(--neon-blue);
}

.btn-aud {
    border: 2px solid var(--neon-pink);
    color: var(--neon-pink);
    background: rgba(255, 0, 255, 0.05);
}

.btn-aud.triggered {
    background: var(--neon-pink);
    color: #000;
    box-shadow: 0 0 30px var(--neon-pink);
}

.key-hint {
    font-size: 0.6rem;
    opacity: 0.6;
    margin-top: 4px;
}

/* --- Overlays --- */
.overlay-container {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(10px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.overlay-container.hidden {
    display: none;
}

.overlay-content {
    background: #111827;
    border: 1px solid #374151;
    padding: 2rem;
    border-radius: 1.5rem;
    text-align: center;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.settings-card {
    background: rgba(255,255,255,0.03);
    padding: 1.5rem;
    border-radius: 1rem;
    margin-bottom: 2rem;
}

.action-buttons {
    display: flex;
    gap: 1rem;
}

.btn-primary {
    flex-grow: 1;
    padding: 1rem;
    background: linear-gradient(to right, #0891b2, #2563eb);
    color: white;
    font-weight: bold;
    border-radius: 0.75rem;
    transition: transform 0.2s;
}
.btn-primary:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(8, 145, 178, 0.4);
}

.btn-secondary {
    padding: 1rem;
    background: #1f2937;
    color: #9ca3af;
    font-weight: bold;
    border-radius: 0.75rem;
    border: 1px solid #374151;
}

/* --- Feedback & Effects --- */
.feedback-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
    font-weight: bold;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.3s, transform 0.3s;
    z-index: 10;
}
.feedback-correct { color: var(--neon-green); text-shadow: 0 0 20px var(--neon-green); }
.feedback-wrong { color: #ff0055; text-shadow: 0 0 20px #ff0055; }

.show-feedback {
    opacity: 1;
    transform: scale(1.2);
}

.scanline {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,0) 50%, rgba(0,0,0,0.1) 50%, rgba(0,0,0,0.1));
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 999;
    opacity: 0.3;
}

.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: #1f2937;
    border: 1px solid var(--neon-yellow);
    color: var(--neon-yellow);
    padding: 12px 24px;
    border-radius: 8px;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
    text-align: center;
    box-shadow: 0 0 20px rgba(255, 238, 0, 0.2);
}
.toast.show {
    transform: translateX(-50%) translateY(0);
}

.level-up-effect {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, rgba(255, 255, 0, 0.5) 0%, rgba(255, 0, 255, 0.3) 20%, rgba(10, 10, 15, 0) 70%);
    opacity: 0;
    transition: opacity 0.5s ease-out;
    pointer-events: none;
    z-index: 100;
}
.level-up-effect.show {
    opacity: 1;
    animation: pulseGlow 1.5s forwards;
}

@keyframes pulseGlow {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(2); opacity: 0; }
}
