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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a237e 0%, #4a148c 100%);
    color: #fff;
    height: 100vh;
    overflow: hidden;
}

.game-page {
    display: none;
    height: 100vh;
    padding: 20px;
}

.game-page.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Page d'accueil */
.game-title {
    margin-top: 10vh;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.game-title h1 {
    color: #4fc3f7;
    font-weight: 800;
    letter-spacing: 2px;
}

.game-title h2 {
    color: #e1bee7;
    font-weight: 300;
}

#play-btn {
    background: linear-gradient(45deg, #2196f3, #9c27b0);
    border: none;
    border-radius: 50px;
    font-size: 1.5rem;
    transition: transform 0.3s, box-shadow 0.3s;
}

#play-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

#top-scores .list-group-item {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    backdrop-filter: blur(10px);
}

/* Règles et introduction */
.rules-content, .intro-content {
    max-width: 800px;
    margin: 0 auto;
    background: rgba(255,255,255,0.1);
    padding: 30px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.control-item {
    text-align: center;
    padding: 15px;
    background: rgba(255,255,255,0.15);
    border-radius: 10px;
}

.control-item .key {
    display: block;
    font-size: 1.6rem;
    font-weight: bold;
    margin-bottom: 5px;
    color: #4fc3f7;
}

.subject-card {
    background: rgba(255,255,255,0.1);
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 20px;
}

.subject-title.snt {
    color: #4fc3f7;
    border-bottom: 3px solid #4fc3f7;
    padding-bottom: 10px;
}

.subject-title.nsi {
    color: #ba68c8;
    border-bottom: 3px solid #ba68c8;
    padding-bottom: 10px;
}

.timer-info {
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 10px;
    margin-top: 30px;
}

/* Jeu principal */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
}

.timer {
    font-size: 2.5rem;
    font-weight: bold;
    font-family: monospace;
    color: #4fc3f7;
    text-shadow: 0 0 10px rgba(79,195,247,0.5);
}

.level-info {
    font-size: 1.5rem;
    font-weight: bold;
    color: #e1bee7;
}

#game-map-wrapper {
    background: rgba(0,0,0,0.5);
    border-radius: 15px;
    padding: 20px;
    height: calc(100vh - 200px);
    overflow: auto;
}

#game-map {
    display: inline-block;
    background: rgba(0,0,0,0.7);
    padding: 10px;
    border-radius: 5px;
}

.map-row {
    display: flex;
    height: 30px;
}

.map-cell {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    position: relative;
    transition: all 0.2s;
}

.map-cell.wall {
    background: #37474f;
    color: #78909c;
}

.map-cell.path {
    background: #263238;
    color: #b0bec5;
}

.map-cell.start {
    background: #1b5e20;
    color: #a5d6a7;
}

.map-cell.exit {
    background: #b71c1c;
    color: #ef9a9a;
}

.map-cell.player {
    background: #4fc3f7 !important;
    color: white !important;
    transform: scale(1.2);
    z-index: 10;
    border-radius: 5px;
}

.map-cell.item {
    background: #ff9800 !important;
    color: white !important;
}

.map-cell.door {
    background: #7b1fa2 !important;
    color: #e1bee7 !important;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

.game-messages {
    margin-top: 20px;
    padding: 15px;
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    min-height: 60px;
}

/* Console */
#game-console {
    background: rgba(0,0,0,0.7);
    border-radius: 15px;
    padding: 20px;
    height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

.console-header {
    border-bottom: 2px solid #4fc3f7;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.console-section {
    background: rgba(255,255,255,0.05);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.console-section h4 {
    color: #4fc3f7;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.inventory {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.inventory-item {
    width: 50px;
    height: 50px;
    background: rgba(255,255,255,0.1);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    position: relative;
}

.inventory-item img {
    max-width: 100%;
    max-height: 100%;
}

.controls-list .control-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.controls-list .key {
    color: #4fc3f7;
    font-weight: bold;
    min-width: 60px;
}

.stats div {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.game-log {
    height: 200px;
    overflow-y: auto;
    font-size: 0.9rem;
    line-height: 1.4;
}

.game-log .log-entry {
    padding: 5px;
    margin-bottom: 5px;
    background: rgba(255,255,255,0.05);
    border-radius: 3px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(10px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Popups */
.modal-content {
    background: linear-gradient(135deg, #1a237e 0%, #4a148c 100%);
    color: white;
    border: 2px solid #4fc3f7;
}

.modal-header {
    border-bottom: 1px solid rgba(79,195,247,0.3);
}

.answer-option {
    padding: 12px;
    margin: 8px 0;
    background: rgba(255,255,255,0.1);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.answer-option:hover {
    background: rgba(255,255,255,0.2);
    border-color: #4fc3f7;
}

.answer-option.selected {
    background: rgba(79,195,247,0.3);
    border-color: #4fc3f7;
}

.answer-option.correct {
    background: rgba(76,175,80,0.3);
    border-color: #4caf50;
}

.answer-option.incorrect {
    background: rgba(244,67,54,0.3);
    border-color: #f44336;
}

/* Page de fin */
.score-card {
    background: linear-gradient(45deg, #2196f3, #9c27b0);
    padding: 40px;
    border-radius: 20px;
    width: 300px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.score-number {
    font-size: 4rem;
    font-weight: bold;
    color: white;
    text-shadow: 0 0 20px rgba(255,255,255,0.5);
}

.score-label {
    font-size: 1.2rem;
    opacity: 0.9;
    letter-spacing: 3px;
}

#ranking-info {
    background: rgba(255,255,255,0.1);
    padding: 15px;
    border-radius: 10px;
    max-width: 500px;
    margin: 0 auto;
}

.final-stats {
    background: rgba(255,255,255,0.05);
    padding: 20px;
    border-radius: 15px;
    max-width: 800px;
    margin: 0 auto;
}

.stat-box {
    padding: 15px;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #4fc3f7;
    margin-top: 10px;
}

/* Responsive */
@media (max-width: 768px) {
    .game-title h1 {
        font-size: 2.5rem;
    }
    
    .game-title h2 {
        font-size: 1.2rem;
    }
    
    .timer {
        font-size: 1.8rem;
    }
    
    .map-cell {
        width: 20px;
        height: 20px;
        font-size: 14px;
    }
    
    #game-map-wrapper {
        height: calc(100vh - 250px);
    }
}

/* Instructions de navigation */
.instruction-panel {
    border: 2px solid #4fc3f7;
    background: rgba(79, 195, 247, 0.1) !important;
}

.instruction-panel h5 {
    color: #4fc3f7;
    margin-bottom: 15px;
}

.instruction-panel .key {
    display: inline-block;
    width: 30px;
    height: 30px;
    background: rgba(79, 195, 247, 0.3);
    border-radius: 5px;
    text-align: center;
    line-height: 30px;
    font-weight: bold;
}

/* États des portes */
.map-cell.door.opened {
    background: #388e3c !important;
    color: #c8e6c9 !important;
    animation: none;
}

.map-cell.door.locked {
    background: #d32f2f !important;
    color: #ffcdd2 !important;
    animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

/* Boutons avec touches */
.btn-with-key {
    position: relative;
    padding-left: 40px;
}

.btn-with-key::before {
    content: attr(data-key);
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 25px;
    height: 25px;
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
}