/* style.css */

/* Reset some basic styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Body Styles */
body {
    font-family: Arial, sans-serif;
    background-color: #121213;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 0;
    margin: 0;
}

/* Header Container */
.header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    color: white;
    background-color: #1e1e1e;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* User Info on the left */
.user-info {
    font-size: 1.2em;
}

/* Navigation Links on the right */
.nav-links {
    display: flex;
    gap: 15px;
}

.nav-links a {
    color: white;
    text-decoration: none;
    font-size: 1.1em;
}

.nav-links a:hover {
    text-decoration: underline;
}

/* Game Container */
.game-container {
    text-align: center;
    max-width: 320px;
    width: 100%;
    margin: 70px auto 0; /* Top margin for header */
}

/* Logo Header */
.logo-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
}

.logo-header img {
    width: 80px;
    margin-right: 10px;
}

.logo-header h1 {
    margin: 0;
    font-size: 2.5rem;
}

.logo-header p {
    margin: 0;
    font-size: 1.1rem;
}

.logo-header a {
    color: #a64ca6;
    text-decoration: none;
}

.logo-header a:hover {
    text-decoration: underline;
}

/* Grid Styles */
#grid {
    display: grid;
    grid-template-rows: repeat(var(--rows), 1fr);
    gap: 5px;
    margin: 0 auto;
    width: 100%;
    max-width: 320px;
}

.row {
    display: grid;
    grid-template-columns: repeat(var(--cols), 1fr);
    gap: 5px;
}

.tile {
    width: 100%;
    position: relative;
    border: 2px solid #3a3a3c;
    background-color: #121213;
    text-transform: uppercase;
    font-size: 2em;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    aspect-ratio: 1 / 1;
    transition: background-color 0.3s, border-color 0.3s, transform 0.3s;
}

.tile.correct {
    background-color: #892dc3;
    border-color: #892dc3;
    color: #ffffff;
    transform: rotateX(360deg);
}

.tile.present {
    background-color: #b59f3b;
    border-color: #b59f3b;
    color: #ffffff;
    transform: rotateX(360deg);
}

.tile.absent {
    background-color: #3a3a3c;
    border-color: #3a3a3c;
    color: #ffffff;
    transform: rotateX(360deg);
}

/* Keyboard Styles */
#keyboard {
    margin-top: 20px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    max-width: 320px;
}

.keyboard-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    flex-wrap: nowrap; /* Prevent wrapping to maintain layout */
}

.key {
    flex: 1 1 0%;
    margin: 2px;
    padding: 8px; /* Increased padding for larger touch targets */
    background-color: #818384;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-transform: uppercase;
    user-select: none;
    transition: background-color 0.3s;
    font-size: 1em; /* Increased font size */
    max-width: 35px; /* Increased max-width */
    min-width: 0;
}

.key.correct {
    background-color: #892dc3;
}

.key.present {
    background-color: #b59f3b;
}

.key.absent {
    background-color: #3a3a3c;
}

.key:active {
    transform: scale(0.95);
}

.key.enter, .key.back {
    flex: 1.5 1 0%;
    font-size: 0.8em;
    padding: 8px; /* Increased padding */
    max-width: 45px; /* Increased max-width */
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 10;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.8);
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #1e1e1e;
    margin: 10% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 400px;
    border-radius: 10px;
    text-align: center;
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: #ffffff;
    text-decoration: none;
}

/* Result Grid Styles */
#result-grid {
    margin: 20px 0;
}

#result-grid .row {
    display: flex;
    justify-content: center;
    margin-bottom: 5px;
}

#result-grid .tile {
    width: 30px;
    position: relative;
    background-color: #3a3a3c;
    border-radius: 4px;
    font-size: 1em;
    font-weight: bold;
    color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    aspect-ratio: 1 / 1;
    margin: 2px;
}

#result-grid .tile.correct {
    background-color: #892dc3;
}

#result-grid .tile.present {
    background-color: #b59f3b;
}

#result-grid .tile.absent {
    background-color: #3a3a3c;
}

.share-button {
    padding: 10px 20px;
    background-color: #892dc3;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
    font-size: 1em;
}

.share-button:hover {
    background-color: #3a3a3c;
}

/* Word Info Styles */
#word-caption {
    margin-top: 10px;
    font-size: 1em;
}

#word-link {
    display: block;
    margin-top: 5px;
    font-size: 0.9em;
    color: #b59f3b;
    text-decoration: underline;
}

#word-thumbnail {
    display: block;
    margin-top: 5px;
    width: 20px;
}

/* Error Message Styles */
.error-message {
    display: none;
    position: fixed;
    z-index: 20;
    left: 50%;
    top: 30%;
    transform: translate(-50%, -50%);
    background-color: #1e1e1e;
    padding: 20px;
    border: 2px solid #ff4c4c;
    border-radius: 8px;
    text-align: center;
}

.close-error {
    margin-top: 10px;
    padding: 5px 10px;
    background-color: #ff4c4c;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Responsive Design */
@media (max-width: 350px) {
    /* Move the game grid up */
    .game-container {
        margin: 30px auto 0; /* Reduced from 70px to 30px */
    }

    /* Adjust logo header */
    .logo-header img {
        width: 50px;
        margin-right: 5px;
    }

    .logo-header h1 {
        font-size: 1.8em;
    }

    /* Adjust grid tiles */
    .tile {
        font-size: 1.5em; /* Reduced font size for smaller screens */
    }

    /* Adjust keyboard keys */
    .key {
        font-size: 1em; /* Increased from 0.7em */
        padding: 8px; /* Increased padding from 5px */
        max-width: 35px; /* Increased from 25px */
    }

    .key.enter, .key.back {
        flex: 1.5 1 0%;
        font-size: 0.8em;
        padding: 8px; /* Increased padding from 5px */
        max-width: 45px; /* Increased from 30px */
    }

    /* Adjust modal content */
    .modal-content {
        padding: 10px;
        width: 90%;
        max-width: 280px;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Adjust result grid tiles */
    #result-grid .tile {
        width: 22px;
        font-size: 0.7em;
    }

    /* Adjust word thumbnail */
    #word-thumbnail {
        width: 15px;
    }
}

/* Adjust modal size and content for larger screens */
@media (min-width: 768px) {
    .modal-content {
        max-width: 500px;
        padding: 20px;
        font-size: 1em;
    }

    .modal-content h2 {
        font-size: 2em;
    }

    .modal-content h3 {
        font-size: 1.5em;
    }

    .modal-content p, .modal-content a {
        font-size: 1em;
    }

    .share-button {
        font-size: 1em;
        padding: 10px 20px;
    }

    #result-grid .tile {
        width: 35px;
        font-size: 1em;
    }

    /* Adjust game container margin */
    .game-container {
        margin: 80px auto 0; /* Increased from 70px to 80px for larger screens */
    }
}

@media (min-width: 1024px) {
    .modal-content {
        max-width: 650px;
        padding: 30px;
    }

    .modal-content h2 {
        font-size: 2.5em;
    }

    .modal-content h3 {
        font-size: 2em;
    }

    .modal-content p, .modal-content a {
        font-size: 1.2em;
    }

    .share-button {
        font-size: 1.2em;
        padding: 12px 24px;
    }

    #result-grid .tile {
        width: 45px;
        font-size: 1.2em;
    }

    /* Adjust game container margin */
    .game-container {
        margin: 100px auto 0; /* Increased for even larger screens */
    }
}
