/* Main Styles */
body {
    font-family: var(--font-sans);
    background: url('../assets/images/fond_texture.jpg') center/cover no-repeat fixed;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Overlay sombre sur fond */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.2);
    pointer-events: none;
    z-index: 0;
}

/* Header */
.header {
    position: relative;
    z-index: var(--z-header);
    background: var(--bg-elevated);
    backdrop-filter: blur(10px);
    padding: 0.15rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.15rem;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    flex: 1;
}

.header-left {
    justify-content: flex-start;
}

/* Bouton Accueil */
.btn-home {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #8b949e;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-right: 8px;
}

.btn-home:hover {
    background: rgba(88, 166, 255, 0.15);
    border-color: rgba(88, 166, 255, 0.3);
    color: #58a6ff;
}

.btn-home:active {
    transform: scale(0.95);
}

.header-center {
    display: flex;
    align-items: stretch;
    gap: var(--space-sm);
    justify-content: center;
}

.header-right {
    justify-content: flex-end;
}

.level-info {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.level-name {
    font-size: 1.15rem;
    font-weight: 700;
    white-space: nowrap;
    color: var(--text-primary);
    line-height: 1;
}

.level-subtitle {
    font-size: 0.65rem;
    color: var(--text-secondary);
    line-height: 1;
}

.stat-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 88px;
    padding: 2px 16px;
}

/* Séparateur fin entre les stats (look aéré "pro") */
.stat-group + .stat-group {
    border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-label {
    font-size: 0.56rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    line-height: 1;
}

/* Scopé au header pour ne pas dépendre (ni subir) des `.stat-value` injectés
   globalement par StatsUI / AIPanel — la double classe gagne en spécificité. */
.header-center .stat-value {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--hud-value);
    text-shadow: 0 0 10px var(--hud-value-glow);
    line-height: 1.2;
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    color: #8b949e;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: rgba(120, 200, 255, 0.15);
    border-color: rgba(120, 200, 255, 0.3);
    color: var(--accent-primary);
}

.btn-icon:active {
    transform: scale(0.95);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
    display: block;
}

/* Conserve la compat avec d'éventuels boutons encore en emoji */
.btn-icon .icon {
    font-size: 1rem;
    line-height: 1;
}

/* Indicateur de statut compte (header) — pill propre, pas d'emoji ni de gradient */
.status-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    height: 36px;
    padding: 0 14px;
    margin-right: var(--space-sm);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.status-indicator:hover {
    background: rgba(120, 200, 255, 0.12);
    border-color: rgba(120, 200, 255, 0.3);
}

.status-indicator .status-icon {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.status-indicator .status-label {
    line-height: 1;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

/* Compteur FPS (debug — caché par défaut, togglé via les réglages) */
.fps-display {
    display: none;
    margin-right: var(--space-sm);
    padding: 4px 9px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--accent-primary);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    pointer-events: none;
}

/* Game Container */
.game-container {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    gap: 0.75rem;
}

.canvas-wrapper {
    position: relative;
    width: min(70vw, calc(100vh - 80px));
    aspect-ratio: 1;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 
        0 0 0 1px var(--border-color),
        var(--shadow-lg);
    flex-shrink: 0;
}

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

/* HUD Gauche (cubes contactés) et Droite (controls) - Styles identiques */
.hud-left,
.controls {
    position: relative;
    z-index: var(--z-controls);
    background: var(--bg-elevated);
    backdrop-filter: blur(20px);
    padding: 0.5rem 0.4rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0.3rem;
    box-shadow: var(--shadow-md);
    min-width: 220px;
    max-width: 220px;
    min-height: 400px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    overflow-x: hidden;
}

/* HUD gauche en mode édition : invisible mais garde l'espace */
.hud-left.editor-mode {
    opacity: 0;
    pointer-events: none;
}

/* Scrollbar personnalisée pour HUD */
.hud-left::-webkit-scrollbar,
.controls::-webkit-scrollbar {
    width: 6px;
}

.hud-left::-webkit-scrollbar-track,
.controls::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.hud-left::-webkit-scrollbar-thumb,
.controls::-webkit-scrollbar-thumb {
    background: rgba(120, 200, 255, 0.3);
    border-radius: 3px;
}

.hud-left::-webkit-scrollbar-thumb:hover,
.controls::-webkit-scrollbar-thumb:hover {
    background: rgba(120, 200, 255, 0.5);
}

.control-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    width: 100%;
    padding: 0.35rem 0;
    border-bottom: 1px solid rgba(120, 200, 255, 0.1);
}

.control-section:last-child {
    border-bottom: none;
}

.control-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: center;
    width: 100%;
}

.key-group {
    display: flex;
    gap: var(--space-xs);
}

.key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    min-width: 28px;
    padding: 0.25rem 0.4rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent-primary);
    box-shadow: 
        var(--shadow-sm),
        inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

.cube-key {
    min-width: 36px;
}

.cube-indicator {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Modal Container */
#modalContainer {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: none;
}

/* Notification Container */
.notification-container {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: var(--z-notification);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    pointer-events: none;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
