/* Flexykon Styles */
:root {
    --flex-bg: #1e1e2e;
    --flex-card: #2a2a3c;
    --flex-primary: #89b4fa;
    --flex-secondary: #a6e3a1;
    --flex-red: #f38ba8;
    --flex-text: #cdd6f4;
    --flex-tile: #313244;
    --flex-tile-active: #45475a;
    --flex-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

body {
    background-color: var(--flex-bg);
    color: var(--flex-text);
    font-family: 'Inter', sans-serif;
    padding-top: 80px;
    /* Space for fixed project header */
}

#game-interface {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    padding-top: 20px;
    /* Reset top padding since body handles it, or adjust if needed */
}

/* Header */
/* Game Specific Header */
header.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    background: var(--flex-card);
    padding: 1rem 2rem;
    border-radius: 12px;
    box-shadow: var(--flex-shadow);
}

/* Base override for Project Header z-index if needed */
.project-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

#timer-display {
    font-size: 2rem;
    font-weight: 800;
    color: var(--flex-text);
}

#timer-display.danger {
    color: var(--flex-red);
    animation: pulse 1s infinite;
}

#score-display {
    font-size: 1.5rem;
    font-weight: 700;
}

#round-info {
    color: #9399b2;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Game Area */
.game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

#input-display {
    display: flex;
    gap: 8px;
    min-height: 60px;
    justify-content: center;
    width: 100%;
}

.input-box {
    width: 50px;
    height: 50px;
    background: var(--flex-card);
    border: 2px solid var(--flex-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.1s;
}

.input-box:hover {
    transform: scale(1.1);
    background: rgba(137, 180, 250, 0.1);
}

#tiles-container {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.tile {
    width: 60px;
    height: 60px;
    background: var(--flex-tile);
    color: var(--flex-text);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
    user-select: none;
}

.tile:hover {
    transform: translateY(-2px);
    background: var(--flex-tile-active);
}

.tile:active {
    transform: translateY(2px);
    box-shadow: none;
}

.tile.used {
    background: transparent;
    color: transparent;
    box-shadow: none;
    pointer-events: none;
    border: 2px dashed #45475a;
}

#submit-btn {
    background: var(--flex-primary);
    color: #11111b;
    border: none;
    padding: 1rem 3rem;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(137, 180, 250, 0.4);
}

#submit-btn:active {
    transform: translateY(1px);
}

/* History Table */
.history-container {
    width: 100%;
    margin-top: 2rem;
    background: var(--flex-card);
    border-radius: 12px;
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #313244;
}

th {
    background: #181825;
    color: #9399b2;
    text-transform: uppercase;
    font-size: 0.8rem;
}

tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

/* Solutions */
#solutions-container {
    background: #181825;
    padding: 1.5rem;
    border-radius: 12px;
    border-left: 4px solid var(--flex-secondary);
    display: none;
    animation: slideIn 0.5s ease;
    margin-bottom: 20px;
}

.solution-word {
    display: inline-block;
    background: rgba(166, 227, 161, 0.1);
    color: var(--flex-secondary);
    padding: 4px 10px;
    border-radius: 4px;
    margin: 4px;
    font-weight: 600;
}

/* Messages */
.message {
    min-height: 24px;
    line-height: 24px;
    text-align: center;
    font-weight: 600;
}

.message.error {
    color: var(--flex-red);
}

.message.success {
    color: var(--flex-secondary);
}

/* Start Screen */
#start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(30, 30, 46, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    text-align: center;
}

#start-screen h1 {
    font-size: 4rem;
    margin-bottom: 1rem;
    background: linear-gradient(45deg, var(--flex-primary), var(--flex-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    /* Fixed compatibility lint */
    -webkit-text-fill-color: transparent;
}

.game-over {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 70vh;
}

.final-card {
    background: var(--flex-card);
    padding: 2.5rem;
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 500px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.final-card h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: #9399b2;
}

.final-score {
    font-size: 5rem;
    font-weight: 900;
    line-height: 1;
    margin: 1.5rem 0;
    background: linear-gradient(to bottom, #fff, var(--flex-primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.summary-table-wrapper {
    margin: 2rem 0;
    background: #181825;
    border-radius: 12px;
    overflow: hidden;
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
}

.summary-table th {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.8rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #9399b2;
}

.summary-table td {
    padding: 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 1rem;
}

.summary-table tr:last-child td {
    border-bottom: none;
}

.restart-btn {
    background: var(--flex-secondary);
    color: #11111b;
    border: none;
    padding: 1.2rem 3rem;
    font-size: 1.2rem;
    font-weight: 800;
    border-radius: 50px;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 1rem;
}

.restart-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(166, 227, 161, 0.3);
}

.animate-in {
    animation: slideUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.shake {
    animation: shake 0.5s;
}

@keyframes shake {
    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(5px);
    }

    50% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }

    100% {
        transform: translateX(0);
    }
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile responsive */
@media (max-width: 600px) {
    #game-interface {
        padding: 10px;
    }

    .game-interface {
        padding: 10px;
    }

    .game-interface {
        padding: 10px;
    }

    header.game-header {
        padding: 0.8rem 0.5rem;
        margin-bottom: 1.5rem;
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        /* Idealnie równe sekcje */
        align-items: center;
    }

    #round-info {
        font-size: 0.7rem;
        text-align: left;
        line-height: 1.2;
        color: #9399b2;
    }

    #timer-display {
        font-size: 1.8rem;
        text-align: center;
        font-weight: 800;
        margin: 0;
    }

    #score-display {
        font-size: 0.8rem;
        text-align: right;
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        line-height: 1.1;
    }

    #score-value {
        font-size: 1.3rem;
        font-weight: 700;
        display: block;
    }

    /* Nowy, elastyczny system kafelków */
    #tiles-container {
        display: flex;
        flex-wrap: nowrap;
        /* Kafelki zawsze w jednym rzędzie */
        justify-content: center;
        width: 100%;
        gap: 4px;
        /* Odstęp między kafelkami */
        margin-bottom: 1.5rem;
        padding: 0;
    }

    .tile {
        flex: 1 1 0;
        /* Każdy kafel dzieli przestrzeń po równo */
        min-width: 0;
        /* Kluczowe dla kurczenia się */
        max-width: 44px;
        /* Maksymalny rozmiar dla krótkich słów */
        height: auto;
        aspect-ratio: 1 / 1.2;
        font-size: clamp(0.9rem, 4.5vw, 1.3rem);
        /* Skaluje się z rozmiarem ekranu */
        border-radius: 6px;
        padding: 0;
        box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
    }

    /* Dla bardzo długich słów (11) zmniejszamy nieco gap */
    .len-11 {
        gap: 3px !important;
    }

    .input-box {
        width: 34px;
        height: 42px;
        font-size: 1.2rem;
        border-radius: 6px;
        border-width: 2px;
    }

    #input-display {
        gap: 4px;
        min-height: 45px;
        justify-content: center;
    }
}

/* Shuffle Button */
#shuffle-btn {
    background: transparent;
    border: 2px solid #45475a;
    color: #9399b2;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    transition: all 0.2s;
}

#shuffle-btn:hover {
    border-color: var(--flex-primary);
    color: var(--flex-primary);
    background: rgba(137, 180, 250, 0.1);
}

#shuffle-btn i {
    font-size: 0.8rem;
}

/* Mode Selection Styles */
.mode-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    border-color: var(--flex-primary) !important;
}

.mode-btn:active {
    transform: translateY(-2px);
}

.challenge-item:hover {
    background: var(--flex-card) !important;
    border-color: var(--flex-primary) !important;
}

.loader {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
}