/* Global styles */
:root {
    --primary-color: #6a5acd;
    --secondary-color: #ff6b6b;
    --tertiary-color: #4ecdc4;
    --accent-color: #ffbe0b;
    --correct-color: #6aaa64;
    --present-color: #c9b458;
    --absent-color: #787c7e;
    --background-color: #f5f5f5;
    --text-color: #333;
    --border-radius: 8px;
    --animation-duration: 0.5s;
    --header-gradient: linear-gradient(135deg, var(--primary-color), var(--tertiary-color));
    --footer-gradient: linear-gradient(135deg, var(--tertiary-color), var(--primary-color));
}

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

body {
    font-family: 'Arial', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.hidden {
    display: none !important;
}

/* Welcome screen styles */
.welcome-form {
    background-color: white;
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    margin-top: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

.btn:hover {
    background-color: #5a4aad;
}

/* Logo and Game title styles */
.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.logo {
    height: 50px;
    width: auto;
    margin-right: 10px;
    animation: logoSpin 3s infinite alternate;
}

@keyframes logoSpin {
    0% {
        transform: rotate(-5deg);
    }
    100% {
        transform: rotate(5deg);
    }
}

/* Game title animation */
.game-title {
    font-size: 3rem;
    font-weight: bold;
    text-align: center;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: titlePulse 2s infinite alternate;
}

@keyframes titlePulse {
    0% {
        transform: scale(1);
        text-shadow: 0 0 10px rgba(106, 90, 205, 0.5);
    }
    100% {
        transform: scale(1.05);
        text-shadow: 0 0 20px rgba(255, 107, 107, 0.7);
    }
}

/* Game screen styles */
#game-screen {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 100vh;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--header-gradient);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 100%;
    color: white;
    border-bottom: 3px solid var(--accent-color);
    animation: headerGlow 3s infinite alternate;
}

/* Base flex layout for header components */
.game-header .game-title-container {
    flex: 2;  /* Give more space to the title by default */
}

.player-info {
    flex: 1;  /* Give less space to the player info by default */
    display: flex;
    justify-content: flex-end;  /* Align the pseudo button to the right */
}

@keyframes headerGlow {
    0% {
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    }
    100% {
        box-shadow: 0 4px 20px rgba(106, 90, 205, 0.5);
    }
}

.game-header .logo-container {
    margin-bottom: 0;
    justify-content: flex-start;
}

.game-header .logo {
    height: 40px;
}

.game-header .game-title {
    font-size: 2.2rem;
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3), 0 0 10px rgba(255, 255, 255, 0.5);
    background: linear-gradient(45deg, var(--accent-color), white, var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: titleRainbow 4s infinite alternate;
    letter-spacing: 2px;
    white-space: nowrap;  /* Prevent title from wrapping on all screen sizes */
}

@keyframes titleRainbow {
    0% {
        filter: hue-rotate(0deg);
    }
    100% {
        filter: hue-rotate(90deg);
    }
}

.player-info {
    font-weight: bold;
    font-size: 1.2rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.player-settings-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: rgba(255, 255, 255, 0.2);
    padding: 8px 15px;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    border: none;
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: playerPulse 2s infinite alternate;
}

.player-settings-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.settings-icon {
    fill: white;
    width: 20px;
    height: 20px;
}

@keyframes playerPulse {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(1.05);
    }
}

.language-selector select {
    padding: 8px 12px;
    border-radius: var(--border-radius);
    border: 2px solid var(--accent-color);
    background-color: rgba(255, 255, 255, 0.9);
    font-weight: bold;
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

.language-selector select:hover {
    background-color: var(--accent-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.game-board {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 20px;
}

/* Words grid styles */
.words-grid {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    gap: 5px;
    margin-bottom: 20px;
    width: 100%;
    max-width: 600px; /* Increased to accommodate longer words */
}

.grid-row {
    display: grid;
    gap: 5px;
}

.grid-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    border: 2px solid #ccc;
    border-radius: 4px;
    text-transform: uppercase;
    transition: transform var(--animation-duration), background-color var(--animation-duration);
    min-width: 30px; /* Ensure cells don't get too small */
}

.grid-cell.filled {
    border-color: #888;
}

.grid-cell.correct {
    background-color: var(--correct-color);
    border-color: var(--correct-color);
    color: white;
}

.grid-cell.present {
    background-color: var(--present-color);
    border-color: var(--present-color);
    color: white;
}

.grid-cell.absent {
    background-color: var(--absent-color);
    border-color: var(--absent-color);
    color: white;
}

.grid-cell.reveal {
    animation: flipIn var(--animation-duration) forwards;
}

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

/* Keyboard styles */
.keyboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 500px;
}

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

.key {
    min-width: 40px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #d3d6da;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    text-transform: uppercase;
    transition: background-color 0.2s;
}

.key:hover {
    background-color: #bbbec2;
}

.key.wide {
    min-width: 65px;
}

.key.correct {
    background-color: var(--correct-color);
    color: white;
}

.key.present {
    background-color: var(--present-color);
    color: white;
}

.key.absent {
    background-color: var(--absent-color);
    color: white;
}

/* SVG icons for special keys */
.key svg {
    width: 24px;
    height: 24px;
}

/* Game over modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: var(--border-radius);
    max-width: 90%;
    width: 400px;
    text-align: center;
}

#game-result {
    font-size: 1.8rem;
    margin-bottom: 15px;
}

#secret-word-display {
    font-size: 1.2rem;
    margin-bottom: 20px;
}

#game-summary {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    margin: 20px 0;
    font-family: monospace;
    font-size: 1.5rem;
}

.summary-square {
    width: 20px;
    height: 20px;
    margin: 0 2px;
}

.summary-square.correct {
    background-color: var(--correct-color);
}

.summary-square.present {
    background-color: var(--present-color);
}

.summary-square.absent {
    background-color: var(--absent-color);
}

#copy-result-btn {
    margin-right: 10px;
}

/* Footer styles */
.game-footer {
    padding: 15px;
    text-align: center;
    background: var(--footer-gradient);
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 100%;
    color: white;
    border-top: 3px solid var(--accent-color);
    animation: footerGlow 3s infinite alternate;
    position: relative;
    overflow: hidden;
}

.game-footer::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    background: linear-gradient(45deg, 
        rgba(255, 255, 255, 0) 0%, 
        rgba(255, 255, 255, 0.1) 50%, 
        rgba(255, 255, 255, 0) 100%);
    animation: footerShine 5s infinite linear;
    z-index: 1;
    pointer-events: none;
}

.game-footer p {
    position: relative;
    z-index: 2;
}

@keyframes footerGlow {
    0% {
        box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.2);
    }
    100% {
        box-shadow: 0 -4px 20px rgba(78, 205, 196, 0.5);
    }
}

@keyframes footerShine {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.game-footer a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: bold;
    transition: all 0.3s ease;
    padding: 2px 5px;
    border-radius: 4px;
}

.game-footer a:hover {
    background-color: rgba(255, 255, 255, 0.2);
    text-shadow: 0 0 5px var(--accent-color);
    transform: scale(1.05);
}

/* Responsive styles */
@media (max-width: 768px) {
    .game-header {
        flex-direction: row;
        gap: 10px;
        padding: 12px;
    }

    .game-header .game-title-container {
        flex: 3;  /* Give more space to the title container */
    }

    .player-info {
        flex: 1;  /* Give less space to the player info */
        margin: 0;
        display: flex;
        justify-content: flex-end;  /* Maintain right alignment */
    }

    .logo {
        height: 40px;
    }

    .game-title {
        font-size: 2.5rem;
    }

    .game-header .logo-container {
        justify-content: flex-start;
        margin-bottom: 0;
    }

    .game-header .logo {
        height: 35px;
    }

    .game-header .game-title {
        font-size: 2rem;
        white-space: nowrap;  /* Prevent title from wrapping */
    }

    .player-settings-btn {
        padding: 6px 12px;
        font-size: 1.1rem;
        min-width: 0;  /* Allow button to shrink if needed */
    }

    .settings-icon {
        width: 18px;
        height: 18px;
    }

    .language-selector select {
        padding: 6px 10px;
    }

    .key {
        min-width: 30px;
        height: 50px;
        font-size: 0.9rem;
    }

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

@media (max-width: 480px) {
    /* Maintain row layout but adjust sizes */
    .game-header .game-title-container {
        flex: 4;  /* Give even more space to the title container on very small screens */
    }

    .player-info {
        flex: 1;
    }

    .logo {
        height: 30px;
    }

    .game-title {
        font-size: 2rem;
    }

    .game-header .logo {
        height: 28px;
    }

    .game-header .game-title {
        font-size: 1.7rem;
        letter-spacing: 1px;
        white-space: nowrap;  /* Ensure title doesn't wrap */
    }

    .player-info {
        font-size: 1rem;
        display: flex;
        justify-content: flex-end;  /* Maintain right alignment */
    }

    .player-settings-btn {
        padding: 5px 8px;  /* Reduce padding to save space */
        font-size: 0.9rem;  /* Slightly smaller font */
        gap: 4px;  /* Reduce gap between icon and text */
    }

    .settings-icon {
        width: 16px;
        height: 16px;
    }

    /* Settings icon is handled in a separate media query for very small screens */

    .game-footer {
        padding: 12px 10px;
        font-size: 0.9rem;
    }

    .game-footer a {
        padding: 2px 4px;
    }

    .grid-cell {
        font-size: 1.2rem;
    }

    .key {
        min-width: 25px;
        height: 45px;
        font-size: 0.8rem;
    }

    .key.wide {
        min-width: 40px;
    }
}

/* Very small screens - hide settings icon to save more space */
@media (max-width: 360px) {
    .settings-icon {
        display: none;
    }

    /* Further optimize header for tiny screens */
    .game-header .game-title-container {
        flex: 5;  /* Give even more space to the title */
    }

    .player-settings-btn {
        padding: 4px 6px;  /* Minimal padding */
    }
}
