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

body {
    font-family: Arial, sans-serif;
    background: #121213;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    padding: 0;
    margin: 0;
}

.game-menu {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1000;
}

.container {
    text-align: center;
    max-width: 500px;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2vh;
    gap: 2vh;
}

.keyboard {
    align-self: center;
}



.grid {
    display: grid;
    grid-template-rows: repeat(8, 1fr);
    gap: 0.3vh;
    justify-content: center;
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
}

.row {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 5px;
}

.cell {
    width: clamp(30px, 8vw, 50px);
    height: clamp(30px, 4vh, 40px);
    border: 2px solid #3a3a3c;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1rem, 2.5vh, 1.5rem);
    font-weight: bold;
    background: #121213;
    color: white;
}

.cell.filled {
    border-color: #565758;
}

.cell.correct {
    background: #5ba854;
    border-color: #5ba854;
}

.cell.present {
    background: #d4b84a;
    border-color: #d4b84a;
}

.cell.absent {
    background: #6f7375;
    border-color: #6f7375;
}

.keyboard {
    display: grid;
    grid-template-rows: repeat(3, 1fr);
    gap: 0.5vh;
    justify-items: center;
    width: 100%;
    margin: 1vh auto 0;
    justify-self: center;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 0.3vw;
}

.key {
    background: #818384;
    border: none;
    border-radius: 4px;
    color: white;
    font-size: clamp(8px, 1.5vh, 12px);
    font-weight: bold;
    height: clamp(25px, 4vh, 35px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: clamp(20px, 4vw, 30px);
    padding: 0 clamp(4px, 1vw, 8px);
    touch-action: manipulation;
}

.key:hover {
    background: #9ca3a4;
}

.key.wide {
    min-width: clamp(30px, 6vw, 45px);
}

.key.correct {
    background: #5ba854;
}

.key.present {
    background: #d4b84a;
}

.key.absent {
    background: #3a3a3c;
}

.message {
    font-size: clamp(0.9rem, 2vh, 1.1rem);
    font-weight: bold;
    height: 3vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Mobile-specific optimizations */
@media (max-width: 480px) {
    body {
        padding: 0;
        height: 100vh;
        height: 100dvh;
    }
    
    .container {
        padding: 0;
        gap: 1vh;
        height: 100%;
        width: 100%;
        max-width: none;
        justify-content: space-between;
    }
    
    .grid {
        gap: 1px;
        margin: 49px;
        width: calc(100% - 98px);
    }
    
    .cell {
        width: calc((100vw - 98px - 5px) / 6);
        height: calc((100vw - 98px - 5px) / 6);
        font-size: clamp(1rem, 4vw, 1.6rem);
    }
    
    .keyboard {
        gap: 1px;
        position: fixed;
        bottom: 45px;
        left: 20px;
        right: 20px;
        width: calc(100% - 40px);
        margin: 0;
    }
    
    .keyboard-row {
        gap: 1px;
        width: 100%;
    }
    
    .key {
        height: 7vh;
        min-width: 8vw;
        font-size: 2.5vw;
        padding: 0;
        flex: 1;
    }
    
    .key.wide {
        min-width: 12vw;
        flex: 1.5;
    }
    
    .message {
        height: 3vh;
        font-size: 3vw;
    }
}

/* Tablet optimizations */
@media (min-width: 481px) and (max-width: 768px) {
    .cell {
        width: 55px;
        height: 55px;
        font-size: 1.6rem;
    }
    
    .key {
        height: 50px;
        min-width: 38px;
        font-size: 12px;
    }
    
    .key.wide {
        min-width: 58px;
    }
}

/* Large screen optimizations */
@media (min-width: 1200px) {
    .container {
        max-width: 600px;
    }
    
    .cell {
        width: 70px;
        height: 70px;
        font-size: 2.2rem;
    }
    
    .key {
        height: 65px;
        min-width: 50px;
        font-size: 16px;
    }
    
    .key.wide {
        min-width: 75px;
    }
}

.message.win {
    color: #6aaa64;
}

.message.lose {
    color: #f5793a;
}

.how-to-play {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #121213;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.instructions {
    background: #1a1a1a;
    padding: 30px;
    border-radius: 10px;
    max-width: 500px;
    text-align: center;
}

.example {
    margin: 15px 0;
}

.example-row {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-bottom: 10px;
}

.example-cell {
    width: 40px;
    height: 40px;
    border: 2px solid #3a3a3c;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    background: #121213;
    color: white;
}

.example-cell.correct {
    background: #5ba854;
    border-color: #5ba854;
}

.example-cell.present {
    background: #d4b84a;
    border-color: #d4b84a;
}

.example-cell.absent {
    background: #6f7375;
    border-color: #6f7375;
}

#startGame {
    background: #5ba854;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 5px;
    font-size: 1.1rem;
    cursor: pointer;
    margin-top: 20px;
}

#startGame:hover {
    background: #4a9043;
}

#startEasyGame {
    background: #5ba854;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 5px;
    font-size: 1.1rem;
    cursor: pointer;
    margin-top: 20px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

#startEasyGame:hover {
    background: #4a9043;
}
.game-menu {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1000;
}

.user-profile {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 200;
}

.profile-pic {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: #3a3a3c;
    border: 2px solid #565758;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #818384;
    font-size: 20px;
    font-weight: bold;
}

.profile-pic:hover {
    border-color: #5ba854;
}

body.light-mode .profile-pic {
    background: #e0e0e0;
    border-color: #ccc;
    color: #666;
}

body.light-mode .profile-pic:hover {
    border-color: #4a9043;
}

@media (max-width: 768px) {
    .game-menu {
        top: 10px;
        transition: top 0.3s ease;
    }
    
    .game-menu:hover {
        top: 10px;
    }
    
    .game-menu.active {
        top: 10px;
    }
}

#menuToggle {
    background: #818384;
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    line-height: 1;
    min-width: 48px;
    min-height: 48px;
    touch-action: manipulation;
}

#menuToggle:hover {
    background: #9ca3a4;
}

.dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: #1a1a1a;
    border: 1px solid #3a3a3c;
    border-radius: 4px;
    z-index: 100;
    min-width: 180px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.dropdown button {
    background: none;
    color: white;
    border: none;
    padding: 16px 20px;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 16px;
    min-height: 48px;
    touch-action: manipulation;
}

.dropdown button:hover {
    background: #3a3a3c;
}
.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #ccc;
}

.instructions {
    position: relative;
}
.profile-name {
    margin-bottom: 20px;
}

.profile-name input {
    background: #3a3a3c;
    color: white;
    border: 1px solid #565758;
    padding: 8px 12px;
    border-radius: 4px;
    margin-right: 10px;
    width: 150px;
}

.profile-name button {
    background: #5ba854;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
}

.score-history {
    margin-top: 20px;
    max-height: 200px;
    overflow-y: auto;
}

.score-history h3 {
    margin-bottom: 10px;
}

.score-item {
    background: #3a3a3c;
    padding: 8px;
    margin: 5px 0;
    border-radius: 4px;
    font-size: 14px;
}

#backToProfile {
    background: #818384;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 20px;
}
@media (max-width: 768px) {
    #menuToggle {
        padding: 8px 12px;
        font-size: 14px;
        touch-action: manipulation;
        min-width: 36px;
        min-height: 36px;
        opacity: 1;
        visibility: visible;
        display: block;
    }
    
    .dropdown {
        min-width: 180px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
    
    .dropdown button {
        padding: 18px 24px;
        font-size: 18px;
        touch-action: manipulation;
        min-height: 50px;
        display: flex;
        align-items: center;
    }
}
.message {
    padding: 0;
    min-height: 0;
    height: auto;
    line-height: 1;
    text-transform: uppercase;
    margin: 5px 0;
    text-align: center;
}

@media (max-width: 768px) {
    .message {
        margin: 3px 0;
    }
}
.share-btn {
    background: #5ba854;
    color: white;
    border: none;
    padding: 3px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    margin-left: 10px;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes celebrate {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.1) rotate(-5deg); }
    50% { transform: scale(1.2) rotate(5deg); }
    75% { transform: scale(1.1) rotate(-3deg); }
}

.celebrate {
    animation: celebrate 0.8s ease-in-out;
}

.setting-item {
    margin: 15px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-item label {
    font-size: 16px;
    color: white;
}

.toggle-switch {
    width: 50px;
    height: 25px;
    background: #3a3a3c;
    border-radius: 25px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s ease;
}

.toggle-switch.active {
    background: #5ba854;
}

.toggle-slider {
    width: 21px;
    height: 21px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.3s ease;
}

.toggle-switch.active .toggle-slider {
    transform: translateX(25px);
}

/* Light mode styles */
body.light-mode {
    background: #f5f5f5;
    color: #333;
}

body.light-mode .how-to-play {
    background: #f5f5f5;
}

body.light-mode .instructions {
    background: #ffffff;
    border: 1px solid #ddd;
    color: #333;
}

body.light-mode .modal-overlay {
    background: rgba(0, 0, 0, 0.5);
}

body.light-mode .modal-content {
    background: #ffffff;
    border: 1px solid #ddd;
}

body.light-mode .modal-header {
    border-bottom: 1px solid #ddd;
}

body.light-mode .modal-header h2 {
    color: #333;
}

/* Game Footer */
.game-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #121213;
    padding: 6px 10px;
    text-align: center;
    z-index: 50;
}

.game-footer .footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 10px;
    font-weight: 500;
    margin-bottom: 3px;
}

.game-footer .footer-links a {
    color: #818384;
    text-decoration: none;
    padding: 3px 6px;
    border-radius: 3px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.game-footer p {
    color: #818384;
    font-size: 9px;
    font-weight: 500;
    margin: 0;
}

.game-footer .footer-links a:hover {
    color: #5ba854;
    background: rgba(91, 168, 84, 0.1);
}

/* Mobile footer adjustments */
@media (max-width: 480px) {
    .game-footer {
        padding: 4px 8px;
    }
    
    .game-footer .footer-links {
        gap: 4px;
        font-size: 9px;
        margin-bottom: 2px;
    }
    
    .game-footer .footer-links a {
        padding: 2px 4px;
        font-size: 9px;
    }
    
    .game-footer p {
        font-size: 8px;
    }
    
    /* Adjust keyboard position to account for footer */
    .keyboard {
        bottom: 45px;
    }
}

@media (max-width: 320px) {
    .game-footer .footer-links {
        gap: 2px;
        font-size: 8px;
    }
    
    .game-footer .footer-links a {
        padding: 1px 3px;
        font-size: 8px;
    }
    
    .game-footer p {
        font-size: 7px;
    }
}

body.light-mode .game-footer {
    background: #f5f5f5;
}

body.light-mode .game-footer .footer-links a {
    color: #787c7e;
}

body.light-mode .game-footer .footer-links a:hover {
    color: #4a9043;
    background: rgba(74, 144, 67, 0.1);
}

body.light-mode .game-footer p {
    color: #787c7e;
}

body.light-mode .modal-body {
    color: #333;
}

body.light-mode .close-btn {
    color: #333;
}

body.light-mode .close-btn:hover {
    background: #f0f0f0;
}

body.light-mode .setting-item label {
    color: #333;
}

body.light-mode .cell {
    background: #ffffff;
    color: #333;
    border-color: #ccc;
}

body.light-mode .cell.correct {
    background: #4a9043;
    border-color: #4a9043;
    color: white;
}

body.light-mode .cell.present {
    background: #f4c430;
    border-color: #f4c430;
    color: white;
}

body.light-mode .cell.absent {
    background: #999;
    border-color: #999;
    color: white;
}

body.light-mode .key {
    background: #e0e0e0;
    color: #333;
}

body.light-mode .key:hover {
    background: #d0d0d0;
}

body.light-mode .key.correct {
    background: #4a9043;
    color: white;
}

body.light-mode .key.present {
    background: #f4c430;
    color: white;
}

body.light-mode .key.absent {
    background: #999;
    color: white;
}

body.light-mode .local-leaderboard .leaderboard-item {
    background: #f8f8f8;
    border-color: #ddd;
    color: #333;
}

body.light-mode .local-leaderboard .rank {
    color: #2d5a2d;
}

body.light-mode .local-leaderboard .score {
    color: #b8860b;
}

body.light-mode .local-leaderboard .details {
    color: #666;
}

body.light-mode #profileStats {
    background: #f8f8f8;
    border-color: #ddd;
    color: #333;
}

body.light-mode #profileStats span {
    color: #b8860b;
}

body.light-mode #profileStats p {
    color: #333;
}

body.light-mode .how-to-play {
    background: #f5f5f5;
}

body.light-mode .instructions h2 {
    color: #2d5a2d;
}

body.light-mode .example-cell {
    background: #ffffff;
    color: #333;
    border-color: #ccc;
}

body.light-mode .example-cell.correct {
    background: #4a9043;
    color: white;
}

body.light-mode .example-cell.present {
    background: #f4c430;
    color: white;
}

body.light-mode .example-cell.absent {
    background: #999;
    color: white;
}

body.light-mode #startGame {
    background: #4a9043;
}

body.light-mode #startGame:hover {
    background: #2d5a2d;
}

#statisticsData {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#statisticsData p {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    background: #2a2a2a;
    border-radius: 4px;
    border: 1px solid #3a3a3c;
    margin: 0;
    font-weight: bold;
}

#statisticsData span {
    color: #d4b84a;
}

body.light-mode #statisticsData p {
    background: #f8f8f8;
    border-color: #ddd;
    color: #333;
}

body.light-mode #statisticsData span {
    color: #b8860b;
}

#guessDistribution {
    margin-top: 20px;
}

#guessDistribution h3 {
    color: #5ba854;
    margin-bottom: 15px;
    text-align: center;
}

.guess-row {
    display: flex;
    align-items: center;
    margin: 8px 0;
    gap: 10px;
}

.guess-number {
    width: 20px;
    text-align: center;
    font-weight: bold;
    color: white;
}

.progress-bar {
    flex: 1;
    height: 20px;
    background: #3a3a3c;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #5ba854;
    width: 0%;
    transition: width 0.3s ease;
}

.guess-count {
    width: 30px;
    text-align: center;
    font-weight: bold;
    color: #d4b84a;
}

body.light-mode #guessDistribution h3 {
    color: #2d5a2d;
}

body.light-mode .guess-number {
    color: #333;
}

body.light-mode .progress-bar {
    background: #e0e0e0;
}

body.light-mode .progress-fill {
    background: #4a9043;
}

body.light-mode .guess-count {
    color: #b8860b;
}

/* Modal styles */
.modal-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;
}

.modal-content {
    background: #1a1a1a;
    border: 1px solid #3a3a3c;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #3a3a3c;
}

.guess-distribution-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.stats-mode-toggle {
    display: flex;
    gap: 5px;
}

.score-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.stats-mode-btn {
    padding: 8px 12px;
    background: #333;
    color: white;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.stats-mode-btn.active {
    background: #538d4e;
    border-color: #538d4e;
}

.stats-mode-btn:hover {
    background: #555;
}

.stats-mode-btn.active:hover {
    background: #6aaa64;
}

body.light-mode .stats-mode-btn {
    background: #e0e0e0;
    color: #333;
    border-color: #ccc;
}

body.light-mode .stats-mode-btn.active {
    background: #4a9043;
    color: white;
    border-color: #4a9043;
}

body.light-mode .stats-mode-btn:hover {
    background: #d0d0d0;
}

body.light-mode .stats-mode-btn.active:hover {
    background: #2d5a2d;
}



.modal-header h2 {
    color: white;
    margin: 0;
}

.modal-body {
    padding: 20px;
    color: white;
    line-height: 1.5;
}

.local-leaderboard {
    max-height: 200px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.local-leaderboard .leaderboard-item {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 8px 12px;
    margin: 5px 0;
    background: #2a2a2a;
    border-radius: 4px;
    border: 1px solid #3a3a3c;
}

.local-leaderboard .rank {
    font-weight: bold;
    color: #5ba854;
    min-width: 30px;
}

.local-leaderboard .score {
    font-weight: bold;
    color: #d4b84a;
    flex: 1;
    text-align: center;
}

.local-leaderboard .details {
    font-size: 0.9rem;
    color: #818384;
}

.score-details {
    flex: 1;
    text-align: left;
    margin-left: 15px;
}

.score-details .score {
    font-weight: bold;
    color: #d4b84a;
    margin-bottom: 2px;
}

.score-details .details {
    font-size: 0.8rem;
    color: #818384;
}

#profileStats {
    display: flex;
    justify-content: space-between;
    padding: 15px;
    background: #2a2a2a;
    border-radius: 4px;
    border: 1px solid #3a3a3c;
    margin-bottom: 10px;
}

#profileStats p {
    margin: 0;
    font-weight: bold;
    color: white;
}

#profileStats span {
    color: #d4b84a;
}

.modal-body h3 {
    color: #5ba854;
    margin: 15px 0 10px 0;
}

/* New feature styles */
.achievement-notification {
    position: fixed;
    top: 20px;
    right: -300px;
    background: #1a1a1a;
    border: 1px solid #5ba854;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1001;
    transition: right 0.3s ease;
}

.achievement-notification.show {
    right: 20px;
}

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

.achievement-title {
    font-weight: bold;
    color: #5ba854;
}

.achievement-desc {
    font-size: 0.9em;
    color: #ccc;
}

.share-notification {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(50px);
    background: #1a1a1a;
    border: 1px solid #5ba854;
    border-radius: 4px;
    padding: 10px 20px;
    color: white;
    z-index: 1001;
    transition: transform 0.3s ease;
}

.share-notification.show {
    transform: translateX(-50%) translateY(0);
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    margin: 8px 0;
    background: #2a2a2a;
    border-radius: 4px;
    border: 1px solid #3a3a3c;
}

.leaderboard-entry.top-three {
    border-color: #d4b84a;
    background: rgba(212, 184, 74, 0.1);
}

.player-avatar {
    border-radius: 50%;
}

.player-info {
    flex: 1;
}

.player-name {
    font-weight: bold;
    color: white;
}

.player-stats {
    font-size: 0.9em;
    color: #818384;
}

.player-score {
    font-weight: bold;
    color: #d4b84a;
    font-size: 1.1em;
}

body.light-mode .achievement-notification {
    background: #ffffff;
    border-color: #4a9043;
}

body.light-mode .share-notification {
    background: #ffffff;
    border-color: #4a9043;
    color: #333;
}

body.light-mode .leaderboard-entry {
    background: #f8f8f8;
    border-color: #ddd;
}

body.light-mode .leaderboard-entry.top-three {
    border-color: #b8860b;
    background: rgba(184, 134, 11, 0.1);
}

body.light-mode .player-name {
    color: #333;
}

body.light-mode .player-stats {
    color: #666;
}

body.light-mode .player-score {
    color: #b8860b;
}