body {
    margin: 0;
    overflow: hidden;
    background-color: #0d0d13;
    font-family: 'Outfit', sans-serif;
    color: #f0f0f5;
    user-select: none;
    -webkit-user-select: none;
}

canvas {
    display: block;
}

/* HUD en cours de jeu */
#timer-container {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #ff8c00;
    font-family: 'Orbitron', monospace;
    font-size: 28px;
    font-weight: 700;
    background: rgba(10, 10, 15, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 12px 24px;
    border-radius: 16px;
    border: 1px solid rgba(255, 140, 0, 0.2);
    box-shadow: 0 0 20px rgba(255, 140, 0, 0.15);
    z-index: 100;
    letter-spacing: 1.5px;
    transition: color 0.3s ease;
}

.score-display {
    position: absolute;
    top: 85px;
    left: 20px;
    color: #32cd32;
    font-family: 'Orbitron', monospace;
    font-size: 20px;
    font-weight: 700;
    background: rgba(10, 10, 15, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 8px 16px;
    border-radius: 12px;
    border: 1px solid rgba(50, 205, 50, 0.2);
    box-shadow: 0 0 15px rgba(50, 205, 50, 0.15);
    z-index: 100;
    letter-spacing: 1.5px;
}

.level-display {
    position: absolute;
    top: 140px;
    left: 20px;
    color: #00ffff;
    font-family: 'Orbitron', monospace;
    font-size: 20px;
    font-weight: 700;
    background: rgba(10, 10, 15, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 8px 16px;
    border-radius: 12px;
    border: 1px solid rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.15);
    z-index: 100;
    letter-spacing: 1.5px;
}

.bonus-container {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    gap: 12px;
    z-index: 100;
}

.bonus-ui {
    color: #e2e8f0;
    font-family: 'Orbitron', monospace;
    font-size: 14px;
    font-weight: 700;
    background: rgba(20, 20, 25, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 10px 14px;
    border-radius: 10px;
    border: 2px solid #32cd32;
    box-shadow: 0 0 10px rgba(50, 205, 50, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.bonus-ui:hover:not(.disabled) {
    transform: scale(1.05);
    background: rgba(30, 30, 40, 0.9);
    box-shadow: 0 0 20px rgba(50, 205, 50, 0.6);
}

.bonus-ui.disabled {
    opacity: 0.5;
    filter: grayscale(100%);
    cursor: not-allowed;
    border-color: #555;
    box-shadow: none;
}

.bonus-ui.active {
    animation: pulse-glow 1s infinite alternate;
    border-color: #00ffff;
    box-shadow: 0 0 25px rgba(0, 255, 255, 0.8);
    background: linear-gradient(to right, rgba(0, 255, 255, 0.4) var(--progress, 100%), rgba(20, 20, 25, 0.8) var(--progress, 100%));
}

@keyframes pulse-glow {
    0% { box-shadow: 0 0 15px rgba(0, 255, 255, 0.5); }
    100% { box-shadow: 0 0 35px rgba(0, 255, 255, 1); }
}

#debug {
    position: absolute;
    bottom: 20px;
    right: 20px;
    color: rgba(255, 255, 255, 0.7);
    font-family: monospace;
    font-size: 11px;
    background: rgba(10, 10, 15, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    pointer-events: none;
    line-height: 1.5;
    z-index: 100;
}

.options-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(10, 10, 15, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 140, 0, 0.2);
    border-radius: 12px;
    color: #ff8c00;
    padding: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 15px rgba(255, 140, 0, 0.15);
    transition: all 0.3s ease;
    z-index: 100;
}

.options-btn:hover {
    background: rgba(255, 140, 0, 0.1);
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 140, 0, 0.3);
}

/* Menu principal & Overlays */
#menu-overlay,
#win-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(15, 15, 25, 0.65) 0%, rgba(5, 5, 10, 0.85) 100%);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    transition: opacity 0.5s ease;
}

.menu-panel,
.win-card {
    display: none;
    flex-direction: column;
    width: 90%;
    max-width: 500px;
    background: rgba(20, 20, 30, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4), 0 0 40px rgba(255, 140, 0, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.menu-panel.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Titres & Textes */
.game-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 44px;
    font-weight: 900;
    text-align: center;
    margin: 0 0 8px 0;
    letter-spacing: 6px;
    background: linear-gradient(135deg, #ff8c00 0%, #32cd32 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 15px rgba(255, 140, 0, 0.3));
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-logo {
    max-width: 100%;
    max-height: 120px;
}

.game-subtitle {
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    color: rgba(240, 240, 245, 0.8);
    margin: 0 0 35px 0;
    letter-spacing: 1.5px;
}

.panel-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    margin: 0 0 25px 0;
    color: #ff8c00;
    text-shadow: 0 0 10px rgba(255, 140, 0, 0.4);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.panel-title-flex {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Sélecteur de taille */
.menu-section {
    margin-bottom: 30px;
}

.section-title {
    display: block;
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 15px;
    color: rgba(240, 240, 245, 0.7);
    text-align: center;
}

.size-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.size-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 15px 10px;
    color: #f0f0f5;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.15s ease;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.5);
    margin-bottom: 4px;
}

.size-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 6px 0 rgba(0, 0, 0, 0.6);
}

.size-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
}

.size-btn.active {
    background: rgba(255, 140, 0, 0.08);
    border-color: #ff8c00;
    box-shadow: 0 4px 0 #cc7000, 0 0 15px rgba(255, 140, 0, 0.15);
}

.size-btn.active:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #cc7000, 0 0 20px rgba(255, 140, 0, 0.2);
}

.size-btn.active:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #cc7000, 0 0 10px rgba(255, 140, 0, 0.15);
}

.size-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
}

.size-val {
    font-family: 'Orbitron', monospace;
    font-size: 13px;
    color: rgba(240, 240, 245, 0.6);
}

.size-btn.active .size-val {
    color: #ff8c00;
}

/* Boutons */
.menu-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.primary-btn {
    background: linear-gradient(135deg, #ff8c00 0%, #ff4500 100%);
    border: none;
    border-radius: 16px;
    color: #05050a;
    font-family: 'Orbitron', sans-serif;
    font-size: 16px;
    font-weight: 700;
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 6px 0 #a32d00, 0 8px 20px rgba(255, 140, 0, 0.25);
    letter-spacing: 1.5px;
    margin-bottom: 6px;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 0 #a32d00, 0 10px 25px rgba(255, 140, 0, 0.4);
    filter: brightness(1.1);
}

.primary-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #a32d00, 0 4px 10px rgba(255, 140, 0, 0.25);
}

.danger-btn {
    background: linear-gradient(135deg, #ff4500 0%, #cc0000 100%);
    box-shadow: 0 6px 0 #800000, 0 8px 20px rgba(204, 0, 0, 0.25);
}

.danger-btn:hover {
    box-shadow: 0 8px 0 #800000, 0 10px 25px rgba(204, 0, 0, 0.4);
}

.danger-btn:active {
    box-shadow: 0 2px 0 #800000, 0 4px 10px rgba(204, 0, 0, 0.25);
}

.secondary-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    color: #f0f0f5;
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 600;
    padding: 12px 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.5);
    margin-bottom: 4px;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 6px 0 rgba(0, 0, 0, 0.6);
}

.secondary-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
}

.back-btn {
    margin-top: 25px;
    align-self: center;
    width: 200px;
}

/* Panel contenu (Règles & Scores) */
.panel-content {
    flex-grow: 1;
    overflow-y: auto;
    max-height: 350px;
    padding-right: 5px;
}

.panel-content::-webkit-scrollbar {
    width: 6px;
}

.panel-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.panel-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.gallery-panel-content {
    padding: 0;
    overflow: hidden;
    position: relative;
    height: 60vh;
    min-height: 400px;
    border-radius: 12px;
}

.gallery-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.lore-text {
    font-size: 14px;
    line-height: 1.6;
    color: rgba(240, 240, 245, 0.85);
    margin: 0 0 20px 0;
    text-align: center;
}

.rules-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.rule-item {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.rule-icon {
    font-size: 24px;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 24px;
}

.rule-item strong {
    display: block;
    color: #f0f0f5;
    font-size: 15px;
    margin-bottom: 4px;
}

.rule-item p {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: rgba(240, 240, 245, 0.65);
}

/* Scores UI */
.score-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 10px;
    color: rgba(240, 240, 245, 0.6);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: #f0f0f5;
    background: rgba(255, 255, 255, 0.06);
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
    color: #f0f0f5;
}

.score-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.score-table th {
    padding: 12px 10px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    color: rgba(240, 240, 245, 0.5);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-table td {
    padding: 12px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: rgba(240, 240, 245, 0.85);
}

.score-table tr:last-child td {
    border-bottom: none;
}

.score-table tr.empty-row td {
    text-align: center;
    color: rgba(240, 240, 245, 0.35);
    padding: 30px;
}

.rank-val {
    font-weight: 700;
    font-family: 'Orbitron', sans-serif;
}

.rank-1 {
    color: #ffd700;
}

.rank-2 {
    color: #c0c0c0;
}

.rank-3 {
    color: #cd7f32;
}

.score-time {
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    color: #ff8c00;
}

/* Win Screen Overlay */
#win-overlay {
    background: rgba(5, 5, 8, 0.85);
}

.win-card {
    display: flex;
    text-align: center;
    max-width: 450px;
    border-color: rgba(255, 140, 0, 0.3);
    box-shadow: 0 20px 60px rgba(255, 140, 0, 0.1);
}

.win-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 38px;
    font-weight: 900;
    color: #ff8c00;
    margin: 0 0 10px 0;
    letter-spacing: 4px;
    text-shadow: 0 0 15px rgba(255, 140, 0, 0.3);
}

.win-subtitle {
    font-size: 14px;
    color: rgba(240, 240, 245, 0.7);
    margin: 0 0 25px 0;
}

.win-score-box {
    background: rgba(255, 140, 0, 0.05);
    border: 1px solid rgba(255, 140, 0, 0.2);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.win-score-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(240, 240, 245, 0.5);
}

.win-score-value {
    font-family: 'Orbitron', monospace;
    font-size: 32px;
    font-weight: 700;
    color: #ff8c00;
    text-shadow: 0 0 10px rgba(255, 140, 0, 0.3);
}

.win-save-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
}

.win-save-section label {
    font-size: 12px;
    color: rgba(240, 240, 245, 0.6);
}

.win-save-section input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #f0f0f5;
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    padding: 12px 16px;
    transition: all 0.2s ease;
    flex-grow: 1;
}

.win-save-section input:focus {
    outline: none;
    border-color: #ff8c00;
    background: rgba(255, 255, 255, 0.08);
}

/* Formulaires & Options */
.input-row {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.options-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px 0;
}

.option-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 15px 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.option-label {
    font-size: 16px;
    font-weight: 600;
    color: #f0f0f5;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}
.toggle-switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 34px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 3px;
    background-color: #f0f0f5;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .toggle-slider {
    background-color: #ff8c00;
    border-color: #ff8c00;
}
input:checked + .toggle-slider:before {
    transform: translateX(24px);
    background-color: #111;
}

/* Styled Range */
.styled-range {
    -webkit-appearance: none;
    width: 120px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    outline: none;
}
.styled-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ff8c00;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 140, 0, 0.5);
}

.input-row button {
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
}

/* Classes Utilitaires (Excellence Web) */
.hidden {
    display: none !important;
}

.mt-20 {
    margin-top: 20px;
}

.icon-large {
    font-size: 24px;
}

.debug-error-panel {
    position: absolute;
    z-index: 9999;
    bottom: 10px;
    left: 10px;
    background: rgba(255, 0, 0, 0.85);
    color: white;
    padding: 15px;
    border-radius: 8px;
    font-family: monospace;
    max-height: 200px;
    overflow-y: auto;
    font-size: 12px;
    pointer-events: auto;
}

/* Door Code Cyber Panel */
.door-code-panel {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 20, 20, 0.85);
    border: 1px solid #ff8c00;
    border-radius: 12px;
    padding: 15px 30px;
    color: #ff8c00;
    font-family: 'Orbitron', monospace;
    text-align: center;
    box-shadow: 0 0 20px rgba(255, 140, 0, 0.2), inset 0 0 15px rgba(255, 140, 0, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.door-code-title {
    font-size: 11px;
    color: rgba(240, 240, 245, 0.7);
    text-transform: uppercase;
    letter-spacing: 4px;
}

.door-code-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 6px;
    text-shadow: 0 0 15px rgba(255, 140, 0, 0.6);
}

/* Decryption Panel (Top) */
.decryption-panel {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 20, 20, 0.85);
    border: 1px solid #ff8c00;
    border-radius: 12px;
    padding: 10px 25px;
    color: #fff;
    font-family: 'Orbitron', monospace;
    text-align: center;
    box-shadow: 0 0 15px rgba(255, 140, 0, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 250px;
}

.decryption-panel.hidden {
    display: none !important;
}

.decryption-panel.error {
    border-color: #ff0055;
    box-shadow: 0 0 20px rgba(255, 0, 85, 0.6);
    animation: shake 0.4s;
}

@keyframes shake {
    0% {
        transform: translateX(-50%) rotate(0deg);
    }

    25% {
        transform: translateX(calc(-50% - 8px)) rotate(-2deg);
    }

    50% {
        transform: translateX(calc(-50% + 8px)) rotate(2deg);
    }

    75% {
        transform: translateX(calc(-50% - 8px)) rotate(-2deg);
    }

    100% {
        transform: translateX(-50%) rotate(0deg);
    }
}

.decryption-title {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 3px;
}

.decryption-value {
    font-size: 22px;
    font-weight: bold;
    letter-spacing: 6px;
    color: #ff8c00;
    text-shadow: 0 0 10px rgba(255, 140, 0, 0.5);
}

@media (max-width: 768px) {
    #timer-container {
        font-size: 20px;
        padding: 8px 16px;
        top: 15px;
        left: 15px;
    }

    .decryption-panel {
        top: 75px;
        min-width: 200px;
        padding: 8px 20px;
    }

    .door-code-panel {
        bottom: 90px;
    }

    .options-btn {
        top: 15px;
        right: 15px;
        padding: 8px;
    }
}