/* version 1.00 */
/* Global Styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #e0f2f7 0%, #c8e6c9 100%);
    color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: manipulation;
    user-select: none;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #ffffff;
    padding: 15px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    max-width: 900px;
    width: 98%;
    height: 100%;
    justify-content: space-between;
    box-sizing: border-box;
    border: 1px solid #e0e0e0;
    padding-bottom: calc(15px + env(safe-area-inset-bottom));
}

/* Game Header and Title */
.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.game-title {
    font-size: 2.8rem;
    font-weight: 700;
    background: linear-gradient(45deg, #4CAF50, #2196F3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Grid Layouts - ENLARGED: Maximum square sizes while maintaining aspect ratio */
.grid-container {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    column-gap: 20px;
    row-gap: 8px;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    width: 100%;
    max-width: calc(5 * 120px + 4 * 20px); /* Increased from 95px to 120px */
    flex-shrink: 0;
}

/* Multi-row clueword grid - ENLARGED with obvious separation */
.clueword-grid {
    grid-template-rows: repeat(2, auto);
    margin-bottom: 35px; /* Increased gap from 20px to 35px for obvious separation */
    column-gap: 28px;
    row-gap: 8px;
}

/* Single-row guessword grid */
.guessword-grid.single-row {
    grid-template-rows: auto;
    margin-bottom: 25px;
}

.grid-item {
    background-color: #f0f0f0;
    border: 2px solid #ccc;
    text-align: center;
    font-size: 52px; /* Increased from 42px */
    font-weight: 600;
    color: #333;
    width: 100%;
    aspect-ratio: 1; /* MAINTAINED: Forces square aspect ratio */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px; /* Slightly increased border radius */
    outline: none;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08); /* Enhanced shadow */
}

.grid-item:hover {
    border-color: #81c784;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.grid-item:focus {
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.3);
    transform: translateY(-1px);
}

/* Letter Coloring States */
.colored {
    background-color: #FFD1DC;
    color: #333;
    border: none;
    transition: background-color 0.3s ease;
}

.matched {
    background-color: #ffd54f;
    color: #5d4037;
    border: none;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.correct {
    background-color: #81c784;
    color: white;
    border: none;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

/* Labels */
.guessword-label {
    font-size: 24px;
    font-weight: 600;
    color: #555;
    margin: 0 0 15px 0;
    text-align: center;
    position: relative;
}

.guessword-label::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(45deg, #4CAF50, #2196F3);
    border-radius: 2px;
}

.message {
    font-size: 1.2rem;
    margin-bottom: 20px;
    padding: 10px 20px;
    border-radius: 28px;
    text-align: center;
    color: #555;
    min-height: 0;
    transition: all 0.3s ease;
    font-weight: bold;
    /*background-color: #f5f5f5;
    border: 1px solid #eee;*/
}

/* Keyboard - UNCHANGED to preserve functionality */
.keyboard {
    margin-top: 20px;
    width: 100%;
    max-width: 800px;
}

/* Spacer to push keyboard to bottom */
.spacer {
    flex-grow: 1;
}

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

.key {
    background-color: #dbe4ee;
    border: none;
    border-radius: 8px;
    color: #333;
    cursor: pointer;
    font-size: 20px;
    font-weight: 600;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    min-width: 50px;
    padding: 0 15px;
    user-select: none;
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
}

.key:hover {
    background-color: #c0d1e0;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.key:active {
    background-color: #a7b8c8;
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.key.wide {
    flex-grow: 1.8;
    min-width: 100px;
}

.key.green {
    background-color: #81c784 !important;
    color: white;
    box-shadow: 0 2px 8px rgba(129, 199, 132, 0.4);
}

/* Additional message styles */
.message.success {
    background: linear-gradient(45deg, #81c784 0%, #66bb6a 100%);
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(129, 199, 132, 0.3);
}

.message.error {
    background: linear-gradient(45deg, #ef5350 0%, #e57373 100%);
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(239, 83, 80, 0.3);
}

.gap {
    height: 0;
    width: 100%;
}

/* Mobile base styles (max-width: 600px) - ENLARGED */
@media (max-width: 600px) {
    .container {
        padding: 10px;
        border-radius: 12px;
        height: 100%;
        width: 99%;
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
        justify-content: space-between;
    }

    .game-title {
        font-size: 1.6rem;
        margin-bottom: 15px;
    }

    .grid-container {
        column-gap: 12px; /* Increased from 8px */
        row-gap: 6px; /* Increased from 2px */
        max-width: 360px; /* Increased from 280px */
    }

    .clueword-grid {
        grid-template-rows: repeat(2, auto);
        margin-bottom: 25px; /* Increased gap from 15px to 25px */
        column-gap: 18px; /* Increased from 12px */
        row-gap: 6px;
    }

    .grid-item {
        font-size: 32px; /* Increased from 24px */
        border-radius: 8px; /* Increased from 6px */
        aspect-ratio: 1;
    }

    .guessword-grid {
        grid-template-rows: auto;
        margin-bottom: 20px; /* Increased from 15px */
    }

    .guessword-label {
        margin: 0 0 8px 0;
    }

    .message {
        font-size: 0.8rem;
        margin-bottom: 10px;
        padding: 5px 10px;
    }

    .keyboard {
        margin-top: 15px;
    }

    .keyboard-row {
        margin-bottom: 3px;
        gap: 2px;
    }

    .key {
        height: 48px;
        font-size: 15px;
        padding: 0 8px;
        border-radius: 4px;
        min-width: 30px;
    }

    .key.wide {
        flex-grow: 1.8;
        min-width: 60px;
    }

    .gap {
        height: 0;
    }
}

/* Very small screen adjustments (max-width: 400px) - ENLARGED */
@media (max-width: 400px) {
    .container {
        padding: 8px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }

    .game-title {
        font-size: 1.4rem;
        margin-bottom: 10px;
    }

    .grid-container {
        column-gap: 8px; /* Increased from 4px */
        row-gap: 5px; /* Increased from 3px */
        max-width: 300px; /* Increased from 240px */
    }

    .clueword-grid {
        grid-template-rows: repeat(2, auto);
        margin-bottom: 20px; /* Increased gap from 12px to 20px */
        column-gap: 12px; /* Increased from 8px */
        row-gap: 5px;
    }

    .grid-item {
        font-size: 26px; /* Increased from 20px */
        border-width: 2px; /* Increased from 1px */
        border-radius: 6px; /* Increased from 4px */
        aspect-ratio: 1;
    }

    .guessword-grid {
        grid-template-rows: auto;
        margin-bottom: 16px; /* Increased from 12px */
    }

    .guessword-label {
        font-size: 18px;
        margin: 0 0 5px 0;
    }

    .message {
        font-size: 0.75rem;
        margin-bottom: 8px;
        padding: 4px 8px;
    }

    .keyboard {
        margin-top: 12px;
    }

    .keyboard-row {
        margin-bottom: 4px;
        gap: 3px;
    }

    .key {
        height: 44px;
        font-size: 13px;
        padding: 0 4px;
        border-radius: 3px;
        min-width: 28px;
    }

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

/* ENLARGED: Tall mobile devices - Maximum sizing while maintaining squares */
@media (min-height: 667px) and (max-width: 600px) {
    .grid-container {
        column-gap: 18px; /* Increased from 12px */
        row-gap: 8px; /* Increased from 4px */
        max-width: 420px; /* Increased from 320px */
    }

    .clueword-grid {
        grid-template-rows: repeat(2, auto);
        column-gap: 24px; /* Increased from 16px */
        row-gap: 8px;
        margin-bottom: 30px; /* Increased obvious gap */
    }

    .grid-item {
        font-size: 38px; /* Increased from 28px */
        aspect-ratio: 1;
    }

    .guessword-grid {
        grid-template-rows: auto;
        margin-bottom: 25px;
    }

    .key {
        height: 52px;
        font-size: 16px;
    }
}

/* Medium-tall devices (iPhone X series height) - ENLARGED */
@media (min-height: 750px) and (max-width: 600px) {
    .grid-container {
        column-gap: 22px; /* Increased from 16px */
        row-gap: 10px; /* Increased from 4px */
        max-width: 480px; /* Increased from 360px */
    }

    .clueword-grid {
        grid-template-rows: repeat(2, auto);
        column-gap: 28px; /* Increased from 20px */
        row-gap: 10px;
        margin-bottom: 35px; /* Increased obvious gap */
    }

    .grid-item {
        font-size: 44px; /* Increased from 32px */
        aspect-ratio: 1;
    }

    .guessword-grid {
        grid-template-rows: auto;
        margin-bottom: 28px;
    }

    .key {
        height: 56px;
        font-size: 17px;
    }
}

/* Very tall devices (Pixel 7, iPhone 14 Pro Max) - ENLARGED */
@media (min-height: 852px) and (max-width: 600px) {
    .grid-container {
        column-gap: 26px; /* Increased from 20px */
        row-gap: 12px; /* Increased from 4px */
        max-width: 540px; /* Increased from 400px */
    }

    .clueword-grid {
        grid-template-rows: repeat(2, auto);
        column-gap: 32px; /* Increased from 24px */
        row-gap: 12px;
        margin-bottom: 40px; /* Increased obvious gap */
    }

    .grid-item {
        font-size: 50px; /* Increased from 36px */
        aspect-ratio: 1;
    }

    .guessword-grid {
        grid-template-rows: auto;
        margin-bottom: 32px;
    }

    .key {
        height: 60px;
        font-size: 18px;
    }
}

/* Ultra-tall devices - ENLARGED */
@media (min-height: 900px) and (max-width: 600px) {
    .grid-container {
        column-gap: 30px; /* Increased from 24px */
        row-gap: 14px; /* Increased from 4px */
        max-width: 600px; /* Increased from 440px */
    }

    .clueword-grid {
        grid-template-rows: repeat(2, auto);
        column-gap: 36px; /* Increased from 28px */
        row-gap: 14px;
        margin-bottom: 45px; /* Increased obvious gap */
    }

    .grid-item {
        font-size: 56px; /* Increased from 40px */
        aspect-ratio: 1;
    }

    .guessword-grid {
        grid-template-rows: auto;
        margin-bottom: 35px;
    }

    .key {
        height: 64px;
        font-size: 19px;
    }
}

/* Extra safety for very tall and narrow devices - ENLARGED */
@media (min-height: 1000px) and (max-width: 600px) {
    .grid-container {
        column-gap: 34px; /* Increased from 28px */
        row-gap: 16px; /* Increased from 4px */
        max-width: 660px; /* Increased from 480px */
    }

    .clueword-grid {
        grid-template-rows: repeat(2, auto);
        column-gap: 40px; /* Increased from 32px */
        row-gap: 16px;
        margin-bottom: 50px; /* Increased obvious gap */
    }

    .grid-item {
        font-size: 62px; /* Increased from 44px */
        aspect-ratio: 1;
    }

    .guessword-grid {
        grid-template-rows: auto;
        margin-bottom: 40px;
    }

    .key {
        height: 68px;
        font-size: 20px;
    }
}