/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Theme Colors */
    --primary-bg: #1a1a2e;
    --secondary-bg: #16213e;
    --tertiary-bg: #0f3460;

    /* Franchise Colors */
    --dragonball-color: #ff6b35;
    --dragonball-glow: rgba(255, 107, 53, 0.5);
    --onepiece-color: #2196F3;
    --onepiece-glow: rgba(33, 150, 243, 0.5);
    --jujutsu-color: #9C27B0;
    --jujutsu-glow: rgba(156, 39, 176, 0.5);
    --aot-color: #8BC34A;
    --aot-glow: rgba(139, 195, 74, 0.5);

    /* Status Colors */
    --correct-color: #4CAF50;
    --incorrect-color: #f44336;
    --partial-color: #FFC107;

    /* Common values */
    --border-radius: 25px;
    --transition-smooth: all 0.3s ease;
}

body {
    margin: 0;
    padding: 0;
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
    min-height: 100vh;
    background-position: center;
    font-family: 'Segoe UI', 'Arial', sans-serif;
    color: white;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 20% 50%, rgba(255, 107, 53, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(58, 123, 213, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Page-specific backgrounds */
.dragonball-page {
    background-image: url('./backgrounds/dragonball.png');
}

.onepiece-page {
    background-image: url('./backgrounds/onepiece.png');
}

.aot-page {
    background-image: url('./backgrounds/aot.png');
}

.jujutsu-page {
    background-image: url('./backgrounds/jujutsu.jpg');
}

/* Confetti Canvas */
.confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

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

/* Back Button */
.back-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #000000;
    text-decoration: none;
    font-size: 1.1em;
    font-weight: bold;
    padding: 12px 25px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 50px;
    margin-bottom: 20px;
    transition: var(--transition-smooth);
    border: 2px solid rgba(0, 0, 0, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.back-button:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateX(-5px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    border-color: rgba(0, 0, 0, 0.3);
}

.back-icon {
    font-size: 1.2em;
}

/* Franchise Banner */
.franchise-banner {
    text-align: center;
    padding: 15px 30px;
    margin-bottom: 20px;
    border-radius: 50px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: inline-block;
    width: 100%;
}

.banner-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.banner-icon {
    font-size: 2em;
}

.banner-text {
    font-size: 1.2em;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* Franchise-specific banner styles with neon effects */
.dragonball-banner {
    border: 2px solid var(--dragonball-color);
    box-shadow: 0 0 20px var(--dragonball-glow), inset 0 0 20px rgba(255, 107, 53, 0.1);
}

.onepiece-banner {
    border: 2px solid var(--onepiece-color);
    box-shadow: 0 0 20px var(--onepiece-glow), inset 0 0 20px rgba(33, 150, 243, 0.1);
}

.jujutsu-banner {
    border: 2px solid var(--jujutsu-color);
    box-shadow: 0 0 20px var(--jujutsu-glow), inset 0 0 20px rgba(156, 39, 176, 0.1);
}

.aot-banner {
    border: 2px solid var(--aot-color);
    box-shadow: 0 0 20px var(--aot-glow), inset 0 0 20px rgba(139, 195, 74, 0.1);
}

/* Header */
header {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 15px;
    text-align: center;
    color: white;
    margin-bottom: 30px;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    animation: fadeInDown 0.8s ease-out;
}

.header-content {
    flex: 1;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

h1 {
    font-size: clamp(1.5em, 4vw, 2.5em);
    margin-bottom: 10px;
    letter-spacing: 2px;
    font-weight: 900;
    background: linear-gradient(135deg, #ffffff 0%, #ffd700 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.5));
}

.subtitle {
    font-size: 1em;
    opacity: 0.95;
    font-weight: 600;
    letter-spacing: 1px;
}

/* Help Button */
.help-button {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 1.5em;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.help-button:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

/* Game Info Container */
.game-info {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius);
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: fadeInUp 0.8s ease-out;
}

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

/* Search Container */
.search-container {
    margin-bottom: 25px;
    position: relative;
}

#characterSearch {
    width: 100%;
    padding: 18px 25px;
    font-size: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50px;
    outline: none;
    transition: var(--transition-smooth);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    font-weight: 600;
}

/* Franchise-specific search focus with neon glow */
.dragonball-page #characterSearch:focus {
    border-color: var(--dragonball-color);
    box-shadow: 0 0 0 4px var(--dragonball-glow), 0 8px 25px rgba(0, 0, 0, 0.15);
}

.onepiece-page #characterSearch:focus {
    border-color: var(--onepiece-color);
    box-shadow: 0 0 0 4px var(--onepiece-glow), 0 8px 25px rgba(0, 0, 0, 0.15);
}

.jujutsu-page #characterSearch:focus {
    border-color: var(--jujutsu-color);
    box-shadow: 0 0 0 4px var(--jujutsu-glow), 0 8px 25px rgba(0, 0, 0, 0.15);
}

.aot-page #characterSearch:focus {
    border-color: var(--aot-color);
    box-shadow: 0 0 0 4px var(--aot-glow), 0 8px 25px rgba(0, 0, 0, 0.15);
}

#characterSearch:focus {
    transform: translateY(-2px);
}

#characterSearch::placeholder {
    color: rgba(0, 0, 0, 0.4);
    font-weight: 500;
}

/* Suggestions Dropdown */
.suggestions {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: none;
    border-radius: 0 0 20px 20px;
    max-height: 250px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    position: absolute;
    width: 100%;
    z-index: 100;
}

.suggestions::-webkit-scrollbar {
    width: 10px;
}

.suggestions::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 0 0 20px 0;
}

.suggestions::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #3a7bd5, #ff6b35);
    border-radius: 10px;
}

.suggestion-item {
    padding: 15px 20px;
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 15px;
    color: #333;
}

.suggestion-item:hover {
    background: linear-gradient(90deg, rgba(58, 123, 213, 0.15), transparent);
    padding-left: 25px;
    transform: translateX(5px);
}

.suggestion-avatar {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: contain;
    object-position: center 30%;
    border: 2px solid #e0e0e0;
    flex-shrink: 0;
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.suggestion-name {
    font-weight: 600;
    font-size: 16px;
}

/* Header Row & Guess Row Grid */
.header-row,
.guess-row {
    display: grid;
    gap: 10px;
    margin-bottom: 15px;
}

/* Column configurations for each game */
body.dragonball-page .header-row,
body.dragonball-page .guess-row {
    grid-template-columns: repeat(9, 1fr);
}

body.onepiece-page .header-row,
body.onepiece-page .guess-row {
    grid-template-columns: repeat(10, 1fr);
}

body.jujutsu-page .header-row,
body.jujutsu-page .guess-row {
    grid-template-columns: repeat(11, 1fr);
}

body.aot-page .header-row,
body.aot-page .guess-row {
    grid-template-columns: repeat(9, 1fr);
}

/* Header Cells with neon effect per franchise */
.header-cell {
    text-align: center;
    padding: 15px 8px;
    background: rgba(58, 123, 213, 0.4);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    color: white;
}

/* Franchise-specific header neon effects */
.dragonball-page .header-cell {
    background: rgba(255, 107, 53, 0.3);
    box-shadow: 0 0 15px var(--dragonball-glow);
}

.onepiece-page .header-cell {
    background: rgba(33, 150, 243, 0.3);
    box-shadow: 0 0 15px var(--onepiece-glow);
}

.jujutsu-page .header-cell {
    background: rgba(156, 39, 176, 0.3);
    box-shadow: 0 0 15px var(--jujutsu-glow);
}

.aot-page .header-cell {
    background: rgba(139, 195, 74, 0.3);
    box-shadow: 0 0 15px var(--aot-glow);
}

/* Guesses Container */
.guesses-container {
    margin-top: 20px;
}

/* Guess Row Animation */
.guess-row {
    animation: slideIn 0.4s ease-out;
}

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

/* Guess Cells */
.guess-cell {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 15px 8px;
    border-radius: 12px;
    text-align: center;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateX(-30px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.5);
    font-size: 0.85em;
    color: #333;
    min-height: 80px;
    word-break: break-word;
}

.guess-cell.animate-in {
    animation: cellSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes cellSlideIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Status Colors with Glow Effects */
.guess-cell.correct {
    background: linear-gradient(135deg, #4CAF50 0%, #66BB6A 100%);
    color: white;
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.5), 0 0 20px rgba(76, 175, 80, 0.3);
    border-color: rgba(255, 255, 255, 0.3);
    animation: cellSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards, correctPulse 0.6s ease-out;
}

@keyframes correctPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.guess-cell.incorrect {
    background: linear-gradient(135deg, #f44336 0%, #EF5350 100%);
    color: white;
    box-shadow: 0 8px 25px rgba(244, 67, 54, 0.5), 0 0 20px rgba(244, 67, 54, 0.3);
    border-color: rgba(255, 255, 255, 0.3);
}

.guess-cell.partial {
    background: linear-gradient(135deg, #FFC107 0%, #FFD54F 100%);
    color: #333;
    box-shadow: 0 8px 25px rgba(255, 193, 7, 0.5), 0 0 20px rgba(255, 193, 7, 0.3);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Character Image in Cell */
.character-image {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    object-fit: contain;
    object-position: center 30%;
    filter: drop-shadow(0 3px 8px rgba(0,0,0,0.15));
}

/* Win Message */
.win-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    background: linear-gradient(135deg, #4CAF50, #8BC34A);
    color: white;
    padding: 25px 40px;
    border-radius: 20px;
    text-align: center;
    font-size: 1.4em;
    display: none;
    animation: victorySlideDown 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 15px 40px rgba(76, 175, 80, 0.5), 0 0 30px rgba(76, 175, 80, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-weight: bold;
    max-width: 90%;
}

.win-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.win-icon {
    font-size: 1.5em;
}

@keyframes celebration {
    0% { transform: scale(0.5) rotate(-10deg); opacity: 0; }
    50% { transform: scale(1.15) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes victorySlideDown {
    0% { 
        transform: translateX(-50%) translateY(-150px) scale(0.5);
        opacity: 0; 
    }
    60% { 
        transform: translateX(-50%) translateY(10px) scale(1.1);
    }
    100% { 
        transform: translateX(-50%) translateY(0) scale(1);
        opacity: 1; 
    }
}

/* Wrong Feedback */
.wrong-feedback {
    background: linear-gradient(135deg, #f44336, #EF5350);
    color: white;
    padding: 15px 25px;
    border-radius: 15px;
    text-align: center;
    font-size: 1.1em;
    font-weight: bold;
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    opacity: 0;
    z-index: 1001;
    box-shadow: 0 10px 30px rgba(244, 67, 54, 0.5);
    transition: all 0.3s ease;
}

.wrong-feedback.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    20%, 60% { transform: translateX(calc(-50% - 10px)) translateY(0); }
    40%, 80% { transform: translateX(calc(-50% + 10px)) translateY(0); }
}

/* Controls / New Game Button */
.controls {
    text-align: center;
    margin-top: 25px;
}

.new-game-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    background-size: 200% 200%;
    color: white;
    border: none;
    padding: 18px 50px;
    font-size: 1.2em;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.4);
    transition: all 0.4s ease;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.new-game-btn:hover {
    background-position: 100% 50%;
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.6);
}

.new-game-btn:active {
    transform: translateY(-1px);
}

.btn-icon {
    font-size: 1.2em;
}

/* Legacy button support */
button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 18px 50px;
    font-size: 1.1em;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    transition: var(--transition-smooth);
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.5);
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 25px;
    padding: 35px;
    max-width: 500px;
    width: 100%;
    position: relative;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.1);
    animation: modalSlideIn 0.3s ease-out;
    color: white;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 2em;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: var(--transition-smooth);
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: white;
    transform: rotate(90deg);
    box-shadow: none;
}

.modal-content h2 {
    font-size: 1.8em;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #ffd700, #ff6b35);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-body {
    font-size: 1em;
    line-height: 1.7;
}

.modal-body p {
    margin-bottom: 15px;
}

.modal-body ul {
    margin: 15px 0;
    padding-left: 20px;
}

.modal-body li {
    margin-bottom: 10px;
}

.modal-body h3 {
    font-size: 1.2em;
    margin: 20px 0 10px;
    color: #ffd700;
}

/* Color Guide in Modal */
.color-guide {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 15px 0;
}

.guide-item {
    display: flex;
    align-items: center;
    gap: 15px;
}

.color-box {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    flex-shrink: 0;
}

.color-box.correct {
    background: linear-gradient(135deg, #4CAF50, #66BB6A);
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.color-box.partial {
    background: linear-gradient(135deg, #FFC107, #FFD54F);
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
}

.color-box.incorrect {
    background: linear-gradient(135deg, #f44336, #EF5350);
    box-shadow: 0 0 10px rgba(244, 67, 54, 0.5);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .header-cell,
    .guess-cell {
        font-size: 0.75em;
        padding: 12px 6px;
    }

    .character-image {
        width: 55px;
        height: 55px;
    }
}

@media (max-width: 992px) {
    .header-row,
    .guess-row {
        gap: 8px;
    }

    .header-cell,
    .guess-cell {
        font-size: 0.7em;
        padding: 10px 5px;
        border-radius: 10px;
    }

    .character-image {
        width: 50px;
        height: 50px;
    }

    h1 {
        font-size: 1.5em;
    }
}

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

    h1 {
        font-size: 1.3em;
        letter-spacing: 1px;
    }

    header {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .help-button {
        width: 40px;
        height: 40px;
        font-size: 1.3em;
    }

    .franchise-banner {
        padding: 12px 20px;
    }

    .banner-icon {
        font-size: 1.5em;
    }

    .banner-text {
        font-size: 1em;
    }

    .game-info {
        padding: 20px 15px;
    }

    #characterSearch {
        padding: 15px 20px;
        font-size: 16px;
    }

    /* Scrollable grid on mobile */
    .header-row,
    .guess-row {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .header-row::-webkit-scrollbar,
    .guess-row::-webkit-scrollbar {
        display: none;
    }

    body.dragonball-page .header-row,
    body.dragonball-page .guess-row,
    body.aot-page .header-row,
    body.aot-page .guess-row {
        grid-template-columns: repeat(9, minmax(80px, 1fr));
    }

    body.onepiece-page .header-row,
    body.onepiece-page .guess-row {
        grid-template-columns: repeat(10, minmax(80px, 1fr));
    }

    body.jujutsu-page .header-row,
    body.jujutsu-page .guess-row {
        grid-template-columns: repeat(11, minmax(80px, 1fr));
    }

    .header-cell,
    .guess-cell {
        min-width: 80px;
        font-size: 0.65em;
        padding: 10px 5px;
    }

    .character-image {
        width: 45px;
        height: 45px;
    }

    .new-game-btn,
    button {
        padding: 15px 35px;
        font-size: 1em;
    }

    .win-message {
        font-size: 1.1em;
        padding: 20px;
    }

    .modal-content {
        padding: 25px 20px;
        margin: 10px;
    }

    .modal-content h2 {
        font-size: 1.5em;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.1em;
    }

    .subtitle {
        font-size: 0.85em;
    }

    .back-button {
        padding: 10px 18px;
        font-size: 0.95em;
    }

    .franchise-banner {
        padding: 10px 15px;
    }

    .banner-text {
        font-size: 0.9em;
        letter-spacing: 1px;
    }

    .header-cell,
    .guess-cell {
        min-width: 70px;
        font-size: 0.6em;
        padding: 8px 4px;
    }

    .character-image {
        width: 40px;
        height: 40px;
    }

    .guess-cell {
        min-height: 65px;
    }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus states for accessibility */
.back-button:focus,
.help-button:focus,
.new-game-btn:focus,
button:focus,
#characterSearch:focus {
    outline: 3px solid #ffd700;
    outline-offset: 3px;
}

.modal-close:focus {
    outline: 2px solid #ffd700;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .back-button,
    .help-button,
    .controls,
    .modal,
    .confetti-canvas,
    .wrong-feedback {
        display: none !important;
    }

    body {
        background: white !important;
    }

    .game-info {
        background: white;
        box-shadow: none;
        border: 1px solid #ccc;
    }

    .guess-cell,
    .header-cell {
        border: 1px solid #333;
        color: black;
    }
}

/* ================================
   STATS MODAL
   ================================ */

.stats-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

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

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

.stats-content {
    background: linear-gradient(135deg, #1e1e2e 0%, #2a2a3e 100%);
    border-radius: 24px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.stats-header {
    padding: 32px 32px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stats-title {
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
}

.stats-icon {
    font-size: 32px;
}

.stats-close {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stats-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.stats-body {
    padding: 32px;
}

.streak-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.streak-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s;
}

.streak-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.streak-value {
    font-size: 32px;
    font-weight: 700;
    font-family: 'Space Mono', monospace;
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.streak-value.fire {
    animation: pulse 2s ease-in-out infinite;
}

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

.streak-label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.streak-emoji {
    font-size: 24px;
    margin-bottom: 8px;
    display: block;
}

.distribution-title {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.distribution-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.distribution-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.distribution-label {
    font-family: 'Space Mono', monospace;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    width: 20px;
    text-align: right;
}

.distribution-bar-container {
    flex: 1;
    height: 32px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.distribution-bar {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    border-radius: 8px;
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 12px;
    min-width: 32px;
}

.distribution-bar.best {
    background: linear-gradient(90deg, #ffd700, #ffed4e);
}

.distribution-bar.fail {
    background: linear-gradient(90deg, #f44336, #EF5350);
}

.distribution-count {
    font-family: 'Space Mono', monospace;
    font-size: 13px;
    font-weight: 700;
    color: rgba(0, 0, 0, 0.8);
}

.share-container {
    margin-top: 32px;
    padding-top: 32px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.share-button {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.share-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

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

.share-button.copied {
    background: linear-gradient(135deg, #4CAF50, #8BC34A);
}

.reset-button {
    width: 100%;
    padding: 12px 24px;
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    border-radius: 12px;
    color: #f44336;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 12px;
}

.reset-button:hover {
    background: rgba(244, 67, 54, 0.2);
    border-color: rgba(244, 67, 54, 0.5);
}

.stats-button {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.stats-button:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

/* FLIP ANIMATION */
.guess-cell {
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.guess-cell.flip {
    animation: flip 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes flip {
    0% {
        transform: rotateX(0deg);
    }
    50% {
        transform: rotateX(90deg);
    }
    100% {
        transform: rotateX(0deg);
    }
}

/* SHAKE ANIMATION */
.guess-row.shake {
    animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
    20%, 40%, 60%, 80% { transform: translateX(8px); }
}

/* RESPONSIVE */
@media (max-width: 600px) {
    .stats-content {
        max-height: 95vh;
    }
    
    .stats-header {
        padding: 24px 20px 20px;
    }
    
    .stats-title {
        font-size: 24px;
    }
    
    .stats-body {
        padding: 24px 20px;
    }
    
    .streak-container {
        grid-template-columns: 1fr;
    }
    
    .streak-value {
        font-size: 28px;
    }
}

/* ============================================
   STATS MODAL
   ============================================ */

.stats-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

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

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

.stats-content {
    background: linear-gradient(135deg, #1e1e2e 0%, #2a2a3e 100%);
    border-radius: 24px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.stats-header {
    padding: 32px 32px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stats-title {
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
}

.stats-icon {
    font-size: 32px;
}

.stats-close {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stats-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.stats-body {
    padding: 32px;
}

.streak-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.streak-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s;
}

.streak-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.streak-value {
    font-size: 32px;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.streak-value.fire {
    animation: pulse 2s ease-in-out infinite;
}

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

.streak-label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.streak-emoji {
    font-size: 24px;
    margin-bottom: 8px;
    display: block;
}

.distribution-title {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.distribution-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.distribution-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.distribution-label {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    width: 20px;
    text-align: right;
}

.distribution-bar-container {
    flex: 1;
    height: 32px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.distribution-bar {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    border-radius: 8px;
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 12px;
    min-width: 32px;
}

.distribution-bar.best {
    background: linear-gradient(90deg, #ffd700, #ffed4e);
}

.distribution-count {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    font-weight: 700;
    color: rgba(0, 0, 0, 0.8);
}

.share-container {
    margin-top: 32px;
    padding-top: 32px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.share-button {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.share-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.share-button.copied {
    background: linear-gradient(135deg, #4CAF50, #8BC34A);
}

.reset-button {
    width: 100%;
    padding: 12px 24px;
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    border-radius: 12px;
    color: #f44336;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 12px;
}

.reset-button:hover {
    background: rgba(244, 67, 54, 0.2);
    border-color: rgba(244, 67, 54, 0.5);
}

/* Bouton Stats dans le header */
.stats-button {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 12px 20px;
    border-radius: 50px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stats-button:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

/* ============================================
   ANIMATIONS AMÉLIORÉES
   ============================================ */

/* Flip animation pour les cases */
@keyframes flipIn {
    0% {
        transform: rotateX(90deg);
        opacity: 0;
    }
    100% {
        transform: rotateX(0deg);
        opacity: 1;
    }
}

.guess-cell.animate-in {
    animation: flipIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Shake animation pour mauvaise réponse */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.guess-row.shake {
    animation: shake 0.5s;
}

/* RESPONSIVE */
@media (max-width: 600px) {
    .stats-content {
        max-height: 95vh;
    }

    .stats-header {
        padding: 24px 20px 20px;
    }

    .stats-title {
        font-size: 24px;
    }

    .stats-body {
        padding: 24px 20px;
    }

    .streak-container {
        grid-template-columns: 1fr;
    }

    .streak-value {
        font-size: 28px;
    }
}
