:root {
    --accent-color: #488df3;
    --accent-color-dark: #3a5a8c;
    --accent-color-light: #f7faff;
}

body {
    background-color: #f8f9fa;
    font-family: 'Roboto', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    align-items: center;
    justify-content: center;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    color: #333;
}

#gameHeader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1vw;
    margin: 0.5vw;
}

#gameLogo {
    height: 4vw;
    width: auto;
    object-fit: contain;
}

h1 {
    color: var(--accent-color);
    margin: 0;
}

p {
    margin: 0 auto;
    padding: 0;
    width: fit-content;
}

button {
    font-size: 1.1vw;
    padding: 0.7vw 1.2vw;
    border-radius: 0.5vw;
    border: none;
    background-color: var(--accent-color);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0.125rem 0.3125rem rgba(0, 0, 0, 0.1);
    font-weight: 500;
}

button:hover {
    background-color: var(--accent-color-dark);
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.15);
}

#gameScreen {
    display: flex;
    flex-direction: row;
    width: 96vw;
    height: 34vw;
    margin: 1vw auto;
    gap: 2vw;
}

#currentLetterScreen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background-color: white;
    border-radius: 1vw;
    box-shadow: 0 0.25rem 0.9375rem rgba(0, 0, 0, 0.05);
    position: relative;
}

#endOfGameScreen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 2vw;
    background-color: white;
    border-radius: 1vw;
    box-shadow: 0 0.25rem 0.9375rem rgba(0, 0, 0, 0.05);
    gap: 1vw;
}

.grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8vw;
    width: 52vw;
}

.rowOfGridFields {
    display: flex;
    flex-direction: row;
    border: 0.12vw solid #e0e0e0;
    border-radius: 0.8vw;
    overflow: hidden;
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.03);
    background-color: white;
    transition: background-color 0.2s ease;
    align-items: center;
}

.gridField {
    width: 5vw;
    height: 5vw;
    border: 0.1vw solid #f0f0f0;
    font-size: 2.8vw;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: none;
    text-align: center;
}

.rowOfGridFields:hover {
    background-color: var(--accent-color-light);
}

#currentLetter {
    font-size: 10vw;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--accent-color);
    font-weight: bold;
    text-shadow: 0.0625rem 0.0625rem 0.125rem rgba(0, 0, 0, 0.1);
}

#scoreDisplayGame {
    font-size: 1.5vw;
    position: absolute;
    top: 0;
    right: 0;
    color: #000000;
    padding: 1vw;
    padding-top: 0.5vw;
    position: absolute;
}

#deleteLetterButton {
    margin-bottom: 1vw;
    bottom: 0;
}

#gameScreenRight {
    display: flex;
    flex-direction: column;
    gap: 1vw;
    width: 42vw;
}

#searchWordContainer{
    background-color: white;
    border-radius: 1vw;
    box-shadow: 0 0.25rem 0.9375rem rgba(0, 0, 0, 0.05);
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
}

#searchWordInput {
    padding: 0.5vw;
    font-size: 1vw;
    border: 0.2vw solid #e0e0e0;
    border-radius: 0.8vw;
    outline: none;
    transition: all 0.3s ease;
    margin: 0.5vw;
    width: 37.4vw;
    color: #393939;
}

#searchWordInput::placeholder {
    color: #bcbcbc; 
}

#searchWordInput:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0.5rem var(--accent-color);
}

#searchWordResult{
    justify-content: center;
    align-items: center;
    font-size: 1.5vw;
    margin-right: 1vw;
}

#shopScreen {
    background-color: white;
    border-radius: 1vw;
    box-shadow: 0 0.25rem 0.9375rem rgba(0, 0, 0, 0.05);
    width: 100%;
    height: 40%;
    position: relative;
}

#shopHeadline{
    padding: 0.5vw;
    font-weight: bold;
    margin-bottom: 0.5vw;
    font-size: 1.5vw;
}

#coinsDisplayGame {
    font-size: 1.5vw;
    position: absolute;
    padding: 0.5vw;
    padding-right: 1vw;
    top: 0vw;
    right: 0vw;
}

#shopItems {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: space-between;
    gap: 1vw;
    padding: 1vw;
    padding-top: 0;
    height: 9vw;
}

.shopItemsName {
    font-size: 1.5vw;
}

.coinContainer{
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.15vw;
    font-size: 1.5vw;
}

.coinContainer img{
    width: 2vw;
    height: 2vw;
}

.shopItem {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 1.2vw;
    background-color: #f8f9fa;
    border-radius: 0.8vw;
    transition: transform 0.2s ease;
    gap: 0.8vw;
}

.shopItem:hover {
    transform: translateY(-0.1875rem);
    box-shadow: 0 0.3125rem 0.625rem rgba(0, 0, 0, 0.05);
}

#foundWordsContainer {
    background-color: white;
    border-radius: 1vw;
    box-shadow: 0 0.25rem 0.9375rem rgba(0, 0, 0, 0.05);
    width: 96vw;
    display: flex;
    flex-direction: column;
}

#foundWordsHeader {
    font-weight: bold;
    margin: 0.4vw 0.8vw;
    margin-bottom: 0;
    font-size: 1vw;
}

#foundWords {
    margin: 0 1vw;
    margin-bottom: 0.4vw;
    min-height: 1.5vw;
    font-size: 1vw;
}

/* ===== UNIFIED POPUP SYSTEM ===== */

/* Base popup overlay styles */
#gameResultsPopup, #highscoreUploadPopup, #explanationPopup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 2vw;
    box-sizing: border-box;
}

/* Base popup content styles */
#popupContent, #highscoreUploadContent, #explanationContent {
    background-color: white;
    border-radius: 1rem;
    padding: 2.5vw;
    box-shadow: 0 1.5vw 4vw rgba(0, 0, 0, 0.3);
    text-align: center;
    width: 100%;
    max-width: 35vw;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    margin: auto;
    animation: popupSlideIn 0.3s ease-out;
}

/* Explanation popup gets special treatment for larger content */
#explanationContent {
    max-width: 40vw;
    text-align: left;
}

/* Popup slide-in animation */
@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translateY(-2vw) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Popup headers */
#popupContent h2, #highscoreUploadContent h2, #explanationContent h2 {
    color: var(--accent-color);
    margin: 0 0 1.5rem 0;
    font-size: 1.75rem;
    font-weight: bold;
    line-height: 1.2;
}

#explanationContent h2 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 2rem;
}

/* Stats section in game results popup */
#popupStats {
    margin: 1.5rem 0;
    padding: 1.5vw;
    background-color: #f8f9fa;
    border-radius: 0.75rem;
    border-left: 0.25rem solid var(--accent-color);
}

#popupStats p {
    font-size: 1.125rem;
    margin: 0.75rem 0;
    color: #333;
    font-weight: 500;
}

/* Button containers */
#popupButtons, #highscoreButtons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 2rem;
}

/* All popup buttons */
#restartButton, #highscoreUploadButton, #leaderboardViewButton, 
#submitHighscoreButton, #cancelHighscoreButton, #closeExplanationButton {
    font-size: 1rem;
    padding: 0.875rem 1.5rem;
    margin: 0;
    width: 100%;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    text-transform: none;
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.1);
}

/* Button color schemes */
#highscoreUploadButton {
    background-color: #28a745;
    color: white;
}

#highscoreUploadButton:hover {
    background-color: #1e7e34;
    transform: translateY(-0.125rem);
    box-shadow: 0 0.25rem 0.75rem rgba(40, 167, 69, 0.3);
}

/* Button hover effects */
#submitHighscoreButton:hover, #leaderboardViewButton:hover,
#restartButton:hover, #cancelHighscoreButton:hover, #closeExplanationButton:hover {
    background-color: var(--accent-color-dark);
    transform: translateY(-0.125rem);
    box-shadow: 0 0.25rem 0.75rem rgba(72, 141, 243, 0.3);
}

/* Highscore form styles */
#highscoreUploadForm p {
    font-size: 1rem;
    margin: 1rem 0;
    color: #333;
    font-weight: 500;
}

#playerNameInput {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 0.125rem solid #e0e0e0;
    border-radius: 0.5rem;
    outline: none;
    transition: all 0.3s ease;
    margin: 1rem auto;
    width: 100%;
    max-width: 20vw;
    color: #333;
    text-align: center;
    box-sizing: border-box;
}

#playerNameInput:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 0.1875rem rgba(72, 141, 243, 0.1);
}

/* Message styles */
#highscoreMessage {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.highscore-update-message {
    font-size: 1rem !important;
    margin-top: 1rem !important;
    font-weight: bold !important;
    margin-bottom: 0 !important;
}

/* Explanation content styles */
#explanationText {
    margin: 1.5rem 0;
}

#explanationText p {
    font-size: 1rem;
    margin: 1rem 0;
    color: #333;
    line-height: 1.5;
}

.explanation-step {
    display: flex;
    align-items: center;
    margin: 1.25rem 0;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 0.75rem;
    border-left: 0.25rem solid var(--accent-color);
}

.step-icon {
    font-size: 2rem;
    margin-right: 1rem;
    min-width: 3rem;
    text-align: center;
}

.step-content p {
    margin: 0;
    font-size: 1rem;
    color: #333;
    font-weight: 500;
}

/* Shop preview in explanation */
.shop-preview {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background-color: var(--accent-color-light);
    border-radius: 0.75rem;
    border: 1px solid #e0e8ff;
}

.shop-preview h3 {
    margin: 0 0 1rem 0;
    font-size: 1.125rem;
    color: var(--accent-color);
    text-align: center;
    font-weight: bold;
}

.shop-items-preview {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.shop-item-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.1);
}

.shop-icon {
    font-size: 1.25rem;
    margin-right: 0.75rem;
}

.shop-text {
    flex: 1;
    font-size: 0.875rem;
    color: #555;
    font-weight: 500;
}

.shop-cost {
    font-size: 0.875rem;
    font-weight: bold;
    color: var(--accent-color);
    background-color: #f0f4ff;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
}

/* ===== RESPONSIVE DESIGN ===== */

/* Tablet styles */
@media (max-width: 768px) {
    #popupContent, #highscoreUploadContent, #explanationContent {
        padding: 1.5rem;
        border-radius: 0.75rem;
        max-width: 90vw;
    }
    
    #popupContent h2, #highscoreUploadContent h2 {
        font-size: 1.5rem;
    }
    
    #explanationContent h2 {
        font-size: 1.75rem;
    }
    
    #popupStats p {
        font-size: 1rem;
    }
    
    .step-icon {
        font-size: 1.75rem;
        min-width: 2.5rem;
    }
}

/* Mobile styles */
@media (max-width: 550px) {
    #gameResultsPopup, #highscoreUploadPopup, #explanationPopup {
        padding: 1rem;
    }
    
    #popupContent, #highscoreUploadContent, #explanationContent {
        padding: 1.25rem;
        border-radius: 1rem;
        max-width: 95vw;
        max-height: 85vh;
    }
    
    #popupContent h2, #highscoreUploadContent h2 {
        font-size: 1.375rem;
        margin-bottom: 1.25rem;
    }
    
    #explanationContent h2 {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    #popupStats {
        padding: 1rem;
        margin: 1.25rem 0;
    }
    
    #popupStats p {
        font-size: 1rem;
        margin: 0.625rem 0;
    }
    
    #popupButtons, #highscoreButtons {
        gap: 0.75rem;
        margin-top: 1.5rem;
    }
    
    #restartButton, #highscoreUploadButton, #leaderboardViewButton,
    #submitHighscoreButton, #cancelHighscoreButton, #closeExplanationButton {
        font-size: 1rem;
        padding: 0.875rem 1.25rem;
        border-radius: 0.75rem;
    }
    
    #highscoreUploadForm p {
        font-size: 1rem;
        margin: 1rem auto;
    }
    
    #playerNameInput {
        font-size: 1rem;
        padding: 0.875rem 1rem;
        border-radius: 0.75rem;
        border-width: 0.125rem;
        margin: 1rem 0;
        max-width: 100%;
    }
    
    #highscoreMessage {
        font-size: 0.875rem;
        padding: 0.75rem 1rem;
        border-radius: 0.5rem;
        margin: 1rem 0;
    }
    
    .explanation-step {
        margin: 1rem 0;
        padding: 1rem;
        border-radius: 0.75rem;
        border-left-width: 0.25rem;
    }
    
    .step-icon {
        font-size: 1.5rem;
        margin-right: 0.75rem;
        min-width: 2.25rem;
    }
    
    .step-content p {
        font-size: 0.9375rem;
    }
    
    .shop-preview {
        margin-top: 1.25rem;
        padding: 1rem;
        border-radius: 0.75rem;
    }
    
    .shop-preview h3 {
        margin-bottom: 0.75rem;
        font-size: 1rem;
    }
    
    .shop-items-preview {
        gap: 0.625rem;
    }
    
    .shop-item-preview {
        padding: 0.75rem;
        border-radius: 0.5rem;
    }
    
    .shop-icon {
        font-size: 1.125rem;
        margin-right: 0.625rem;
    }
    
    .shop-text {
        font-size: 0.875rem;
    }
    
    .shop-cost {
        font-size: 0.8125rem;
        padding: 0.25rem 0.5rem;
        border-radius: 0.375rem;
    }
    
    .highscore-update-message {
        font-size: 0.9375rem !important;
        margin-top: 0.75rem !important;
    }
    
    /* Disable hover effects on mobile */
    #restartButton:hover, #highscoreUploadButton:hover, #leaderboardViewButton:hover,
    #submitHighscoreButton:hover, #cancelHighscoreButton:hover, #closeExplanationButton:hover {
        transform: none;
        box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.1);
    }
}

#closeExplanationButton {
    background-color: var(--accent-color);
    color: white;
    margin-top: 1.5rem;
}

/* ===== HELP AND LEADERBOARD BUTTONS ===== */

/* Help Button */
#helpButton {
    position: fixed;
    bottom: 2vw;
    right: 2vw;
    width: 4vw;
    height: 4vw;
    background-color: var(--accent-color);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5vw;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 999;
}

#helpButton:hover {
    background-color: var(--accent-color-dark);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Leaderboard Button */
#leaderboardButton {
    position: fixed;
    bottom: 2vw;
    right: 7vw;
    width: 4vw;
    height: 4vw;
    background-color: var(--accent-color);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.2vw;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 999;
}

#leaderboardButton:hover {
    background-color: var(--accent-color-dark);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Animation for closing explanation popup */
.explanation-closing {
    animation: shrinkToHelp 0.8s ease-in-out forwards;
}

/* Animation for background fade */
.explanation-background-closing {
    animation: fadeBackground 0.8s ease-in-out forwards;
}

@keyframes shrinkToHelp {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(calc(46vw), calc(46vh)) scale(0);
        opacity: 0;
    }
}

@keyframes fadeBackground {
    0% {
        background-color: rgba(0, 0, 0, 0.7);
    }
    100% {
        background-color: rgba(0, 0, 0, 0);
    }
}

/* ===== MOBILE GAME LAYOUT ===== */

/* Mobile version of the animation */
@media (max-width: 550px) {
    @keyframes shrinkToHelp {
        0% {
            transform: translate(0, 0) scale(1);
            opacity: 1;
        }
        100% {
            transform: translate(calc(48vw), calc(48vh)) scale(0);
            opacity: 0;
        }
    }

    #gameScreen {
        flex-direction: column;
        justify-content: center;
        align-items: center;
        margin: 0;
        margin-bottom: 2vw;
        height: 100%;
    }

    h1{
        font-size: 10vw;
    }

    #gameHeader {
        gap: 2vw;
        margin: 2vw;
    }

    #gameLogo {
        height: 10vw;
    }

    .grid {
        width: 95vw;
        order: 4;
    }

    .rowOfGridFields {
        width: 100%;
        border-radius: 2vw;
    }   

    .gridField {
        width: 9.5vw;
        height: 9.5vw;
        font-size: 7vw;
    }

    #gameScreenRight {
        width: 95vw;
        justify-content: center;
        align-items: center;
    }

    #currentLetterScreen {
        width: 100%; 
        order: 1;
        margin-top: 2vw;
        border-radius: 2vw;
    }

    #currentLetter {
        font-size: 25vw;
    }

    #scoreDisplayGame {
        font-size: 5vw;
        padding: 2vw;
        padding-top: 1vw;
    }

    #shopScreen {
        width: 100%;
        order: 2;
        height: fit-content;
        border-radius: 2vw;
    }

    #shopHeadline {
        font-size: 4vw;
    }

    #coinsDisplayGame {
        font-size: 4vw;
    }

    .coinContainer img{
        width: 5vw;
        height: 5vw;
    }

    .shopItem {
        height: fit-content;
    }

    #shopItems {
        height: fit-content;
        gap: 2vw;
        padding: 2vw;
    }

    .shopItemsName {
        font-size: 3.5vw;
    }

    .shopItemButton {
        margin: 1vw;
        border-radius: 1.7vw;
    }

    .coinContainer {
        font-size: 3.5vw;
    }
    
    #endOfGameScreen {
        width: 100%;
    }

    #foundWordsContainer {
        width: 95vw;
        min-height: 8vw;
        border-radius: 2vw;
        padding-left: 1vw;
    }

    #foundWordsHeader {
        font-size: 3vw;
    }

    #foundWords {
        font-size: 3vw;
    }

    #searchWordContainer {
        width: 95vw;
        order: 3;
        display: flex;
        flex-direction: row;
        justify-content: left;
        align-items: center;
        border-radius: 2vw;
    }

    #searchWordInput {
        font-size: 3vw;
        border-radius: 2vw;
        border-width: 0.6vw;
        padding: 1vw;
        padding-left: 2vw;
        width: 81vw;
        margin: 1vw;
    }

    #searchWordResult {
        font-size: 3.5vw;
        margin-left: 1vw;
        margin-right: 2vw;
    }

    button:hover {
        transform: none;
        background-color: var(--accent-color);
    }

    .rowOfGridFields:hover {
        background-color: white;
    }

    .shopItem:hover {
        transform: none;
        box-shadow: none;
    }

    /* Mobile Help Button */
    #helpButton {
        position: fixed;
        bottom: 4vw;
        right: 4vw;
        width: 12vw;
        height: 12vw;
        font-size: 7vw;
    }

    /* Mobile Leaderboard Button */
    #leaderboardButton {
        position: fixed;
        bottom: 4vw;
        right: 18vw;
        width: 12vw;
        height: 12vw;
        font-size: 6vw;
    }
}
