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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
}

.container {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 100%;
}

header {
    text-align: center;
    margin-bottom: 20px;
    position: relative;
}

h1 {
    color: #667eea;
    font-size: 2.5em;
    margin-bottom: 10px;
}

.score-display {
    font-size: 1.2em;
    color: #555;
    font-weight: 600;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

.score-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.score-divider {
    color: #ccc;
    font-weight: 300;
}

.kpm-display {
    color: #667eea;
}

.kpm-display #kpm {
    font-weight: 700;
    min-width: 28px;
    display: inline-block;
}

/* Statistics button in header */
.stats-button {
    position: absolute;
    top: 0;
    right: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.stats-button:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

.stats-button:active {
    transform: translateY(0) scale(0.98);
}

.keyboard-section {
    margin-bottom: 20px;
}

.direction-info {
    display: flex;
    justify-content: space-around;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.direction-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9em;
}

.direction-arrow {
    font-size: 1.2em;
    color: #667eea;
    font-weight: bold;
}

.direction-label {
    color: #555;
    font-weight: 500;
}

.direction-counter {
    color: #667eea;
    font-weight: 600;
    font-size: 0.9em;
}

.virtual-keyboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #f8f9fa;
    padding: 12px;
    border-radius: 12px;
    max-width: 100%;
    overflow-x: auto;
}

.keyboard-row {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.keyboard-key {
    min-width: 32px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 600;
    color: #333;
    border: 2px solid transparent;
    transition: all 0.2s;
    cursor: default;
    user-select: none;
}

/* Finger color coding - 10-Finger-System QWERTZ */
/* Gleiche Farben für beide Hände (4 Farben) */
.keyboard-key.finger-pinky {
    background: #ff6b6b; /* Rot - Kleiner Finger */
    color: white;
}

.keyboard-key.finger-ring {
    background: #ffa500; /* Orange - Ringfinger */
    color: white;
}

.keyboard-key.finger-middle {
    background: #ffd700; /* Gelb - Mittelfinger */
    color: #333;
}

.keyboard-key.finger-index {
    background: #32cd32; /* Grün - Zeigefinger */
    color: white;
}

/* Active control keys */
.keyboard-key.active-control {
    border: 3px solid #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
    transform: scale(1.1);
    z-index: 10;
    position: relative;
}

.keyboard-key.active-control::after {
    content: attr(data-arrow);
    position: absolute;
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    background: #667eea;
    border-radius: 50%;
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    color: white;
    line-height: 1;
}

/* Active state when key is pressed */
.keyboard-key.active {
    transform: scale(1.15);
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.6);
    z-index: 20;
}

/* Wider keys for space and special keys */
.keyboard-key.wide {
    min-width: 60px;
}

.keyboard-key.extra-wide {
    min-width: 100px;
}

.keyboard-key.keyboard-space {
    min-width: 200px;
    background: #e0e0e0;
    color: #333;
    font-size: 0.75em;
}


.game-area {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

#gameCanvas {
    border: 3px solid #667eea;
    border-radius: 10px;
    background: #f8f9fa;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

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

.overlay-content {
    background: white;
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    max-width: 450px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.overlay-content h2 {
    color: #667eea;
    font-size: 2em;
    margin-bottom: 20px;
}

.overlay-content p {
    color: #666;
    font-size: 1.2em;
    margin-bottom: 20px;
}

#overlayMessage2 {
    font-size: 0.95em;
    color: #999;
    margin-bottom: 15px;
}

.overlay-stats {
    margin-bottom: 20px;
}

.overlay-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 15px;
}

.overlay-stat-item {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 10px;
    text-align: center;
}

.overlay-stat-label {
    font-size: 0.75em;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.overlay-stat-value {
    font-size: 1.4em;
    font-weight: 700;
    color: #667eea;
}

.overlay-fingers-used {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.finger-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: 6px;
}

.finger-badge.pinky { background: #ff6b6b; }
.finger-badge.ring { background: #ffa500; }
.finger-badge.middle { background: #ffd700; color: #333; }
.finger-badge.index { background: #32cd32; }

.finger-badge .finger-count {
    background: rgba(255,255,255,0.3);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.85em;
}

.name-input-section {
    margin-bottom: 20px;
    display: none;
}

.name-input-section.visible {
    display: block;
}

.name-input-section input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1em;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    text-align: center;
    transition: border-color 0.2s;
}

.name-input-section input:focus {
    outline: none;
    border-color: #667eea;
}

.overlay-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.restart-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.1em;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

.restart-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.restart-button:active {
    transform: translateY(0);
}

.stats-button-overlay {
    background: transparent;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 15px 30px;
    font-size: 1.1em;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.stats-button-overlay:hover {
    background: #667eea;
    color: white;
}

.save-hint {
    font-size: 0.85em;
    color: #888;
    margin-top: 10px;
    font-style: italic;
}

/* Statistics Modal */
.stats-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
}

.stats-modal.visible {
    display: flex;
}

.stats-modal-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.stats-modal-content h2 {
    color: #667eea;
    font-size: 1.8em;
    margin-bottom: 15px;
    text-align: center;
}

.stats-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 2em;
    color: #999;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.stats-close:hover {
    color: #667eea;
}

.stats-legend {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8em;
    color: #666;
}

.finger-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.finger-dot.pinky { background: #ff6b6b; }
.finger-dot.ring { background: #ffa500; }
.finger-dot.middle { background: #ffd700; }
.finger-dot.index { background: #32cd32; }

.stats-table-container {
    overflow-y: auto;
    flex: 1;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.stats-table thead {
    position: sticky;
    top: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.stats-table th {
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
}

.stats-table th:first-child {
    text-align: center;
    width: 40px;
}

.stats-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #f0f0f0;
}

.stats-table td:first-child {
    text-align: center;
    font-weight: 700;
    color: #667eea;
}

.stats-table tbody tr:hover {
    background: #f8f9fa;
}

.stats-table tbody tr:nth-child(1) td:first-child { color: #ffd700; }
.stats-table tbody tr:nth-child(2) td:first-child { color: #c0c0c0; }
.stats-table tbody tr:nth-child(3) td:first-child { color: #cd7f32; }

.finger-dots {
    display: flex;
    gap: 4px;
}

.finger-mini {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65em;
    font-weight: 700;
    color: white;
}

.finger-mini.pinky { background: #ff6b6b; }
.finger-mini.ring { background: #ffa500; }
.finger-mini.middle { background: #ffd700; color: #333; }
.finger-mini.index { background: #32cd32; }

.no-stats {
    text-align: center;
    color: #888;
    padding: 40px 20px;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
    }
}

/* Key Change Modal */
.key-change-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    pointer-events: none;
}

.key-change-modal.visible {
    display: flex;
    animation: modalFadeIn 0.3s ease-out;
}

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

.key-change-content {
    background: linear-gradient(145deg, #1a1a2e 0%, #16213e 50%, #0f0f23 100%);
    border-radius: 30px;
    padding: 40px 60px;
    text-align: center;
    position: relative;
    box-shadow: 
        0 0 60px rgba(102, 126, 234, 0.6),
        0 0 100px rgba(118, 75, 162, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.1);
    border: 3px solid transparent;
    background-clip: padding-box;
    animation: contentPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: visible;
}

.key-change-content::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 33px;
    background: linear-gradient(45deg, #667eea, #764ba2, #ff6b6b, #ffd700, #32cd32, #667eea);
    background-size: 400% 400%;
    z-index: -1;
    animation: borderGlow 2s ease infinite;
}

@keyframes borderGlow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

@keyframes contentPop {
    0% { 
        transform: scale(0.3) rotate(-10deg); 
        opacity: 0;
    }
    50% { 
        transform: scale(1.1) rotate(3deg);
    }
    100% { 
        transform: scale(1) rotate(0deg); 
        opacity: 1;
    }
}

.key-change-title {
    font-size: 1.8em;
    font-weight: 900;
    color: transparent;
    background: linear-gradient(90deg, #ffd700, #ff6b6b, #667eea, #32cd32);
    background-size: 200% auto;
    background-clip: text;
    -webkit-background-clip: text;
    animation: textShimmer 1.5s linear infinite;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
    letter-spacing: 4px;
    margin-bottom: 10px;
}

@keyframes textShimmer {
    0% { background-position: 0% center; }
    100% { background-position: 200% center; }
}

.key-change-direction {
    font-size: 1.4em;
    font-weight: 700;
    color: #fff;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.key-change-direction::before {
    content: attr(data-arrow);
    font-size: 1.5em;
    color: #667eea;
    animation: arrowBounce 0.6s ease-in-out infinite;
}

@keyframes arrowBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.key-change-keys {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 25px;
    margin-bottom: 20px;
}

.key-display {
    width: 90px;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    font-size: 2.8em;
    font-weight: 900;
    color: white;
    text-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
    position: relative;
}

.key-display.old {
    background: linear-gradient(145deg, #555, #333);
    box-shadow: 
        0 6px 20px rgba(0, 0, 0, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.1);
    animation: oldKeyFade 1.5s ease-out forwards;
    opacity: 0.7;
}

@keyframes oldKeyFade {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.9); opacity: 0.5; }
    100% { transform: scale(0.85); opacity: 0.4; }
}

.key-display.new {
    animation: newKeyPop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    box-shadow: 
        0 8px 30px rgba(0, 0, 0, 0.4),
        inset 0 3px 0 rgba(255, 255, 255, 0.2);
}

.key-display.new.finger-pinky {
    background: linear-gradient(145deg, #ff8585, #ff4d4d);
    box-shadow: 0 8px 40px rgba(255, 107, 107, 0.6);
}

.key-display.new.finger-ring {
    background: linear-gradient(145deg, #ffb84d, #ff8c00);
    box-shadow: 0 8px 40px rgba(255, 165, 0, 0.6);
}

.key-display.new.finger-middle {
    background: linear-gradient(145deg, #ffe44d, #ffc700);
    box-shadow: 0 8px 40px rgba(255, 215, 0, 0.6);
    color: #333;
}

.key-display.new.finger-index {
    background: linear-gradient(145deg, #5dff5d, #28d428);
    box-shadow: 0 8px 40px rgba(50, 205, 50, 0.6);
}

@keyframes newKeyPop {
    0% { 
        transform: scale(0) rotate(-20deg); 
        opacity: 0;
    }
    60% { 
        transform: scale(1.2) rotate(5deg);
    }
    100% { 
        transform: scale(1) rotate(0deg); 
        opacity: 1;
    }
}

.key-change-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.arrow-main {
    font-size: 3em;
    color: #667eea;
    animation: arrowPulse 0.5s ease-in-out infinite;
    filter: drop-shadow(0 0 10px #667eea);
}

@keyframes arrowPulse {
    0%, 100% { transform: translateX(0); opacity: 1; }
    50% { transform: translateX(5px); opacity: 0.7; }
}

.arrow-spark {
    font-size: 1.2em;
    animation: sparkFlash 0.3s ease-in-out infinite alternate;
}

.arrow-spark:first-child { color: #ffd700; }
.arrow-spark:last-child { color: #ff6b6b; }

@keyframes sparkFlash {
    from { opacity: 0.3; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1.2); }
}

.finger-label {
    font-size: 1.1em;
    font-weight: 700;
    padding: 8px 25px;
    border-radius: 25px;
    display: inline-block;
    color: white;
    animation: labelSlideUp 0.5s ease-out 0.3s backwards;
}

.finger-label.finger-pinky { background: linear-gradient(135deg, #ff6b6b, #ff4757); }
.finger-label.finger-ring { background: linear-gradient(135deg, #ffa500, #ff8c00); }
.finger-label.finger-middle { background: linear-gradient(135deg, #ffd700, #f0c000); color: #333; }
.finger-label.finger-index { background: linear-gradient(135deg, #32cd32, #28a428); }

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

.key-change-hint {
    margin-top: 20px;
    font-size: 1.1em;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    padding: 12px 25px;
    background: rgba(102, 126, 234, 0.3);
    border-radius: 30px;
    border: 2px solid rgba(102, 126, 234, 0.5);
    animation: hintPulse 1.5s ease-in-out infinite;
    letter-spacing: 1px;
}

@keyframes hintPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(102, 126, 234, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 35px rgba(102, 126, 234, 0.7);
    }
}

/* Confetti particles */
.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.confetti-particle {
    position: absolute;
    top: -20px;
    animation: confettiFall linear forwards;
    opacity: 0;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Sparkle ring effect */
.sparkle-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 300px;
    height: 300px;
    transform: translate(-50%, -50%);
    border: 4px solid transparent;
    border-radius: 50%;
    background: 
        linear-gradient(#1a1a2e, #1a1a2e) padding-box,
        linear-gradient(90deg, #667eea, #764ba2, #ff6b6b, #ffd700) border-box;
    opacity: 0;
    animation: ringExpand 1.5s ease-out forwards;
    pointer-events: none;
}

@keyframes ringExpand {
    0% {
        width: 100px;
        height: 100px;
        opacity: 0.8;
    }
    100% {
        width: 500px;
        height: 500px;
        opacity: 0;
    }
}

/* Admin Login Button */
.admin-login-btn {
    margin-top: 20px;
    background: linear-gradient(135deg, #2d3436 0%, #636e72 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 0.95em;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.admin-login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* Login Modal */
.login-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2500;
}

.login-modal.visible {
    display: flex;
}

.login-modal-content {
    background: linear-gradient(145deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 20px;
    padding: 40px;
    max-width: 400px;
    width: 90%;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 2px solid #667eea;
}

.login-modal-content h2 {
    color: #fff;
    text-align: center;
    margin-bottom: 25px;
}

.login-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 2em;
    color: #999;
    cursor: pointer;
    transition: color 0.2s;
}

.login-close:hover {
    color: #ff6b6b;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.login-form input {
    padding: 14px 18px;
    font-size: 1.1em;
    border: 2px solid #444;
    border-radius: 10px;
    background: #0f0f23;
    color: white;
    text-align: center;
}

.login-form input:focus {
    outline: none;
    border-color: #667eea;
}

.login-submit-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px;
    font-size: 1.1em;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s;
}

.login-submit-btn:hover {
    transform: scale(1.02);
}

.login-error {
    color: #ff6b6b;
    text-align: center;
    font-size: 0.9em;
    margin-top: 10px;
    min-height: 20px;
}

/* Level Designer Modal */
.level-designer-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    overflow-y: auto;
    padding: 20px;
}

.level-designer-modal.visible {
    display: flex;
}

.level-designer-content {
    background: linear-gradient(145deg, #0f0f23 0%, #1a1a2e 100%);
    border-radius: 25px;
    padding: 30px;
    max-width: 600px;
    width: 100%;
    max-height: 95vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 
        0 0 60px rgba(102, 126, 234, 0.4),
        0 20px 60px rgba(0, 0, 0, 0.5);
    border: 3px solid transparent;
    background-clip: padding-box;
}

.level-designer-content::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 28px;
    background: linear-gradient(45deg, #667eea, #764ba2, #32cd32, #667eea);
    background-size: 300% 300%;
    z-index: -1;
    animation: borderGlow 3s ease infinite;
}

.level-designer-content h2 {
    color: #fff;
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.8em;
}

.designer-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 2em;
    color: #999;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 10;
}

.designer-close:hover {
    color: #ff6b6b;
}

.level-designer-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.level-name-input {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.level-name-input label {
    color: #aaa;
    font-weight: 600;
    white-space: nowrap;
}

.level-name-input input {
    flex: 1;
    padding: 10px 15px;
    font-size: 1em;
    border: 2px solid #444;
    border-radius: 8px;
    background: #0f0f23;
    color: white;
}

.level-name-input input:focus {
    outline: none;
    border-color: #667eea;
}

.level-tools {
    display: flex;
    gap: 8px;
}

.tool-btn {
    width: 45px;
    height: 45px;
    border: 2px solid #444;
    border-radius: 10px;
    background: #1a1a2e;
    font-size: 1.4em;
    cursor: pointer;
    transition: all 0.2s;
}

.tool-btn:hover {
    border-color: #667eea;
    transform: scale(1.1);
}

.tool-btn.active {
    border-color: #32cd32;
    background: rgba(50, 205, 50, 0.2);
    box-shadow: 0 0 15px rgba(50, 205, 50, 0.4);
}

.level-grid-container {
    background: #0f0f23;
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(20, 20px);
    grid-template-rows: repeat(20, 20px);
    gap: 1px;
    background: #333;
    border-radius: 8px;
    overflow: hidden;
    width: fit-content;
}

.level-cell {
    width: 20px;
    height: 20px;
    background: #2d2d4a;
    cursor: pointer;
    transition: background 0.15s;
}

.level-cell:hover {
    background: #4a4a6a;
}

.level-cell.barrier {
    background: linear-gradient(145deg, #8b4513, #654321);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.level-cell.spawn-zone {
    background: rgba(102, 126, 234, 0.3);
    cursor: not-allowed;
}

.level-designer-actions {
    display: flex;
    justify-content: center;
    margin-bottom: 25px;
}

.save-level-btn {
    background: linear-gradient(135deg, #32cd32 0%, #28a428 100%);
    color: white;
    border: none;
    padding: 14px 40px;
    font-size: 1.1em;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(50, 205, 50, 0.4);
}

.save-level-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(50, 205, 50, 0.5);
}

.saved-levels-section {
    border-top: 2px solid #333;
    padding-top: 20px;
}

.saved-levels-section h3 {
    color: #fff;
    margin-bottom: 15px;
    text-align: center;
}

.saved-levels-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.no-levels {
    color: #666;
    text-align: center;
    padding: 20px;
    font-style: italic;
}

.level-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1a1a2e;
    padding: 12px 15px;
    border-radius: 10px;
    border: 2px solid #333;
    transition: all 0.2s;
}

.level-item:hover {
    border-color: #667eea;
}

.level-item-name {
    color: #fff;
    font-weight: 600;
}

.level-item-actions {
    display: flex;
    gap: 8px;
}

.level-item-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: transform 0.2s;
}

.level-item-btn:hover {
    transform: scale(1.1);
}

.level-item-btn.edit {
    background: #667eea;
}

.level-item-btn.delete {
    background: #ff6b6b;
}

/* Level Change Modal */
.level-change-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 4000;
}

.level-change-modal.visible {
    display: flex;
    animation: levelModalFadeIn 0.4s ease-out;
}

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

.level-change-content {
    background: linear-gradient(145deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
    border-radius: 30px;
    padding: 50px 70px;
    text-align: center;
    position: relative;
    box-shadow: 
        0 0 80px rgba(50, 205, 50, 0.5),
        0 0 120px rgba(102, 126, 234, 0.3);
    border: 4px solid transparent;
    background-clip: padding-box;
    animation: levelContentPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
}

.level-change-content::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 34px;
    background: linear-gradient(45deg, #32cd32, #667eea, #ffd700, #32cd32);
    background-size: 400% 400%;
    z-index: -1;
    animation: borderGlow 2s ease infinite;
}

@keyframes levelContentPop {
    0% { 
        transform: scale(0.2) rotate(-15deg); 
        opacity: 0;
    }
    60% { 
        transform: scale(1.1) rotate(3deg);
    }
    100% { 
        transform: scale(1) rotate(0deg); 
        opacity: 1;
    }
}

.level-confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.level-change-icon {
    font-size: 4em;
    margin-bottom: 15px;
    animation: iconBounce 0.6s ease-in-out infinite;
}

@keyframes iconBounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-10px) scale(1.1); }
}

.level-change-title {
    font-size: 2.2em;
    font-weight: 900;
    color: transparent;
    background: linear-gradient(90deg, #32cd32, #ffd700, #667eea, #32cd32);
    background-size: 200% auto;
    background-clip: text;
    -webkit-background-clip: text;
    animation: textShimmer 1.5s linear infinite;
    text-shadow: 0 0 40px rgba(50, 205, 50, 0.5);
    letter-spacing: 3px;
    margin-bottom: 20px;
}

.level-change-name {
    font-size: 1.8em;
    font-weight: 700;
    color: #fff;
    margin-bottom: 10px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.level-change-number {
    font-size: 1.3em;
    color: #667eea;
    font-weight: 600;
    margin-bottom: 25px;
}

.level-change-number span {
    font-size: 1.4em;
    color: #32cd32;
    font-weight: 900;
}

.level-change-hint {
    font-size: 1em;
    color: rgba(255, 255, 255, 0.8);
    padding: 12px 25px;
    background: rgba(102, 126, 234, 0.25);
    border-radius: 25px;
    border: 2px solid rgba(102, 126, 234, 0.4);
    animation: hintPulse 1.5s ease-in-out infinite;
}

/* Level indicator in header */
.level-display {
    display: none;
    align-items: center;
    gap: 4px;
    color: #32cd32;
    font-weight: 600;
}

.level-display.visible {
    display: inline-flex;
}

@media (max-width: 600px) {
    .container {
        padding: 15px;
    }

    h1 {
        font-size: 1.8em;
    }

    .direction-info {
        font-size: 0.8em;
        gap: 6px;
    }

    .keyboard-key {
        min-width: 28px;
        height: 32px;
        font-size: 0.75em;
    }

    .keyboard-key.wide {
        min-width: 50px;
    }

    .keyboard-key.extra-wide {
        min-width: 80px;
    }

    #gameCanvas {
        width: 100%;
        height: auto;
    }

    .overlay-content {
        padding: 25px;
    }

    .stats-modal-content {
        padding: 20px;
        max-height: 90vh;
    }

    .overlay-buttons {
        flex-direction: column;
    }

    .overlay-stats-grid {
        grid-template-columns: 1fr;
    }

    .level-designer-content {
        padding: 20px;
    }

    .level-designer-controls {
        flex-direction: column;
    }

    .level-change-content {
        padding: 30px 40px;
    }
}
