/* Reset et styles de base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: #e0e0e0;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(120, 119, 198, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

/* En-tête */
.header {
    text-align: center;
    margin-bottom: 40px;
    padding: 20px;
    position: relative;
}

.datetime {
    font-size: 1.2rem;
    font-weight: 300;
    margin-bottom: 10px;
    color: #a0a0ff;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(170, 170, 255, 0.5);
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    background: linear-gradient(90deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
    animation: titleGlow 3s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    from {
        text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
    }
    to {
        text-shadow: 0 0 30px rgba(255, 255, 255, 0.6);
    }
}

.subtitle {
    font-size: 1.1rem;
    color: #a0a0a0;
    font-style: italic;
}

/* Coffre-fort */
.safe-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 40px 0;
    position: relative;
    min-height: 400px;
}

.safe {
    width: 350px;
    height: 400px;
    position: relative;
    perspective: 1000px;
}

.safe-body {
    width: 100%;
    height: 350px;
    background: linear-gradient(145deg, #4a4a4a, #2a2a2a);
    border-radius: 20px 20px 10px 10px;
    position: relative;
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.5),
        inset 0 -10px 30px rgba(0, 0, 0, 0.3);
    border: 3px solid #3a3a3a;
    overflow: hidden;
}

.safe-door {
    width: 100%;
    height: 100%;
    background: linear-gradient(145deg, #5a5a5a, #3a3a3a);
    border-radius: 20px 20px 10px 10px;
    position: relative;
    transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transform-origin: left center;
    transform-style: preserve-3d;
    box-shadow: 
        inset 0 10px 30px rgba(0, 0, 0, 0.4),
        inset 0 -5px 15px rgba(255, 255, 255, 0.1);
    border: 2px solid #4a4a4a;
}

.safe-door::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 10px;
    width: 20px;
    height: 100px;
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0.1) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0.1) 100%);
    border-radius: 10px;
    transform: translateY(-50%);
}

.safe-door::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 10px;
    width: 20px;
    height: 100px;
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0.1) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0.1) 100%);
    border-radius: 10px;
    transform: translateY(-50%);
}

.door-handle {
    position: absolute;
    top: 50%;
    right: 30px;
    width: 40px;
    height: 60px;
    background: linear-gradient(145deg, #8a8a8a, #5a5a5a);
    border-radius: 15px;
    transform: translateY(-50%);
    box-shadow: 
        0 5px 15px rgba(0, 0, 0, 0.4),
        inset 0 2px 5px rgba(255, 255, 255, 0.2);
    border: 2px solid #6a6a6a;
    cursor: pointer;
    transition: all 0.3s ease;
}

.door-handle:hover {
    background: linear-gradient(145deg, #9a9a9a, #6a6a6a);
    transform: translateY(-50%) scale(1.05);
}

.door-handle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    background: linear-gradient(145deg, #a0a0a0, #707070);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.lock {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80px;
    height: 80px;
    transform: translate(-50%, -50%);
    z-index: 10;
}

.lock-body {
    width: 100%;
    height: 100%;
    background: linear-gradient(145deg, #6a6a6a, #4a4a4a);
    border-radius: 50%;
    border: 5px solid #5a5a5a;
    box-shadow: 
        0 0 20px rgba(0, 0, 0, 0.5),
        inset 0 5px 15px rgba(0, 0, 0, 0.3);
    position: relative;
}

.lock-body::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    background: #3a3a3a;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.lock-dial {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    background: linear-gradient(145deg, #a0a0a0, #707070);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border: 3px solid #8a8a8a;
    box-shadow: 
        0 0 15px rgba(0, 0, 0, 0.4),
        inset 0 3px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.lock-dial::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 30px;
    background: #3a3a3a;
    transform: translate(-50%, -50%) rotate(45deg);
    border-radius: 2px;
}

.lock-dial:hover {
    transform: translate(-50%, -50%) rotate(10deg);
}

.safe-shadow {
    position: absolute;
    bottom: -20px;
    left: 0;
    width: 100%;
    height: 20px;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.3) 0%, transparent 70%);
    border-radius: 50%;
}

.safe-base {
    width: 100%;
    height: 50px;
    background: linear-gradient(145deg, #3a3a3a, #2a2a2a);
    border-radius: 0 0 20px 20px;
    position: relative;
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.3);
    border: 2px solid #4a4a4a;
    border-top: none;
}

.safe-base::before,
.safe-base::after {
    content: '';
    position: absolute;
    bottom: -10px;
    width: 20px;
    height: 15px;
    background: linear-gradient(145deg, #4a4a4a, #2a2a2a);
    border-radius: 5px 5px 0 0;
}

.safe-base::before {
    left: 20px;
}

.safe-base::after {
    right: 20px;
}

.light-effect {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 0;
    animation: lightPulse 4s ease-in-out infinite;
}

@keyframes lightPulse {
    0%, 100% {
        opacity: 0.5;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(1.1);
    }
}

/* Interface de code */
.code-interface {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 30px 0;
    position: relative;
    z-index: 10;
}

.display {
    width: 300px;
    height: 80px;
    background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
    border-radius: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.5),
        inset 0 2px 10px rgba(255, 255, 255, 0.1);
    border: 3px solid #4a4a4a;
    position: relative;
    overflow: hidden;
}

.display::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 10px;
    background: linear-gradient(90deg, 
        rgba(255, 100, 100, 0.3) 0%,
        rgba(255, 200, 100, 0.3) 50%,
        rgba(100, 200, 255, 0.3) 100%);
}

.display-text {
    font-size: 3rem;
    font-weight: bold;
    color: #ff6b6b;
    letter-spacing: 8px;
    text-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
    font-family: 'Courier New', monospace;
    animation: displayPulse 2s ease-in-out infinite;
}

@keyframes displayPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    width: 300px;
    background: linear-gradient(145deg, #3a3a3a, #2a2a2a);
    padding: 20px;
    border-radius: 20px;
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.5),
        inset 0 2px 10px rgba(255, 255, 255, 0.05);
    border: 2px solid #4a4a4a;
}

.key {
    height: 60px;
    font-size: 1.5rem;
    font-weight: bold;
    color: #e0e0e0;
    background: linear-gradient(145deg, #5a5a5a, #3a3a3a);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 
        0 5px 15px rgba(0, 0, 0, 0.3),
        inset 0 2px 5px rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.key::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.key:hover::before {
    opacity: 1;
}

.key:hover {
    background: linear-gradient(145deg, #6a6a6a, #4a4a4a);
    transform: translateY(-3px);
    box-shadow: 
        0 8px 20px rgba(0, 0, 0, 0.4),
        inset 0 2px 5px rgba(255, 255, 255, 0.2);
}

.key:active {
    transform: translateY(1px);
    box-shadow: 
        0 2px 10px rgba(0, 0, 0, 0.3),
        inset 0 2px 5px rgba(255, 255, 255, 0.1);
}

.key.clear {
    background: linear-gradient(145deg, #ff6b6b, #cc5252);
    color: white;
}

.key.clear:hover {
    background: linear-gradient(145deg, #ff8787, #e05252);
}

.key.enter {
    background: linear-gradient(145deg, #48dbfb, #0abde3);
    color: white;
    grid-column: span 1;
}

.key.enter:hover {
    background: linear-gradient(145deg, #68e0fc, #2abde3);
}

/* Messages */
.message-container {
    margin: 20px 0;
    text-align: center;
    min-height: 30px;
}

.message {
    font-size: 1.2rem;
    padding: 10px 20px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #4a4a4a;
    display: inline-block;
    animation: messageFadeIn 0.5s ease-out;
}

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

.message.success {
    color: #48dbfb;
    border-color: #48dbfb;
    text-shadow: 0 0 10px rgba(72, 219, 251, 0.5);
}

.message.error {
    color: #ff6b6b;
    border-color: #ff6b6b;
    text-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

.message.warning {
    color: #feca57;
    border-color: #feca57;
    text-shadow: 0 0 10px rgba(254, 202, 87, 0.5);
}

/* Historique des tentatives */
.attempts {
    margin-top: 30px;
    text-align: center;
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 15px;
    border: 1px solid #4a4a4a;
}

.attempts h3 {
    margin-bottom: 15px;
    color: #a0a0a0;
    font-size: 1.1rem;
}

#attempts-list {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
    text-align: left;
    padding: 0 20px;
}

#attempts-list li {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #c0c0c0;
    font-size: 0.95rem;
}

#attempts-list li:last-child {
    border-bottom: none;
}

#attempts-list li::before {
    content: '•';
    color: #ff6b6b;
    margin-right: 10px;
}

/* Animations du coffre */
.safe-door.open-attempt {
    animation: doorShake 0.5s ease;
}

@keyframes doorShake {
    0%, 100% { transform: translateX(0) rotateY(0); }
    20% { transform: translateX(-5px) rotateY(-2deg); }
    40% { transform: translateX(5px) rotateY(2deg); }
    60% { transform: translateX(-3px) rotateY(-1deg); }
    80% { transform: translateX(3px) rotateY(1deg); }
}

.safe-door.fake-open {
    animation: fakeOpen 1.5s ease-out forwards;
}

@keyframes fakeOpen {
    0% {
        transform: rotateY(0);
    }
    30% {
        transform: rotateY(-15deg);
    }
    70% {
        transform: rotateY(-5deg);
    }
    100% {
        transform: rotateY(0);
    }
}

.lock.unlock-attempt {
    animation: lockShake 0.5s ease;
}

@keyframes lockShake {
    0%, 100% { transform: translate(-50%, -50%) rotate(0); }
    20% { transform: translate(-50%, -50%) rotate(-10deg); }
    40% { transform: translate(-50%, -50%) rotate(10deg); }
    60% { transform: translate(-50%, -50%) rotate(-5deg); }
    80% { transform: translate(-50%, -50%) rotate(5deg); }
}

.lock.fake-unlock {
    animation: fakeUnlock 1.5s ease-out forwards;
}

@keyframes fakeUnlock {
    0% {
        transform: translate(-50%, -50%) rotate(0);
    }
    30% {
        transform: translate(-50%, -50%) rotate(-45deg);
    }
    70% {
        transform: translate(-50%, -50%) rotate(-20deg);
    }
    100% {
        transform: translate(-50%, -50%) rotate(0);
    }
}

/* Effets de lumière lors des tentatives */
@keyframes successFlash {
    0%, 100% {
        box-shadow: 0 0 20px rgba(72, 219, 251, 0.5);
    }
    50% {
        box-shadow: 0 0 40px rgba(72, 219, 251, 0.8);
    }
}

@keyframes errorFlash {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 107, 107, 0.5);
    }
    50% {
        box-shadow: 0 0 40px rgba(255, 107, 107, 0.8);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
    
    .safe {
        width: 280px;
        height: 320px;
    }
    
    .safe-body {
        height: 280px;
    }
    
    .display {
        width: 250px;
        height: 70px;
    }
    
    .display-text {
        font-size: 2.5rem;
        letter-spacing: 6px;
    }
    
    .keypad {
        width: 250px;
        gap: 10px;
    }
    
    .key {
        height: 50px;
        font-size: 1.2rem;
    }
    
    .light-effect {
        width: 300px;
        height: 300px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5rem;
    }
    
    .datetime {
        font-size: 1rem;
    }
    
    .safe {
        width: 220px;
        height: 260px;
    }
    
    .safe-body {
        height: 220px;
    }
    
    .display {
        width: 200px;
        height: 60px;
    }
    
    .display-text {
        font-size: 2rem;
        letter-spacing: 4px;
    }
    
    .keypad {
        width: 200px;
        gap: 8px;
    }
    
    .key {
        height: 45px;
        font-size: 1rem;
    }
}
