/**
 * 5-ECZKI - Game Styles
 * Wordle-style Polish word game
 */

/* === CSS Variables === */
:root {
    /* Tile Colors */
    --tile-correct: #538d4e;
    --tile-present: #b59f3b;
    --tile-absent: #3a3a3c;
    --tile-border: #3a3a3c;
    --tile-filled: #565758;
    --tile-text: var(--color-text-primary);

    /* Keyboard Colors */
    --kb-base-bg: #818384;
    --kb-correct: #6da068;
    --kb-present: #b5a55d;
    --kb-absent: #3a3a3c;
    --kb-text: #ffffff;
}

/* === Game Container === */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: var(--space-md);
    min-height: calc(100vh - 80px);
}

/* === Game Board === */
.game-wrapper {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: var(--space-md) 0;
}

.board-container {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    gap: 5px;
    width: 350px;
    max-width: 100%;
    aspect-ratio: 5/6;
}

.board-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
}

.tile {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid var(--tile-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--color-text-primary);
    background-color: transparent;
    line-height: 1;
    border-radius: var(--radius-sm);
    user-select: none;
}

.tile[data-status="filled"] {
    border-color: var(--tile-filled);
    animation: pop 0.1s;
    color: var(--color-text-primary);
}

/* Specific colors */
.tile[data-status="correct"] {
    background-color: var(--tile-correct);
    border-color: var(--tile-correct) !important;
    color: #ffffff !important;
}

.tile[data-status="present"] {
    background-color: var(--tile-present);
    border-color: var(--tile-present) !important;
    color: #ffffff !important;
}

.tile[data-status="absent"] {
    background-color: var(--tile-absent);
    border-color: var(--tile-absent) !important;
    color: #ffffff !important;
}

.tile.animated {
    transition: transform 0.6s;
}

/* Disable animations when requested */
.game-container.no-animations .tile {
    animation: none !important;
    transition: none !important;
}

/* === Keyboard === */
.keyboard {
    width: 100%;
    max-width: 500px;
    padding: 0 8px var(--space-lg) 8px;
    margin: 0 auto;
}

.kb-row {
    display: flex;
    width: 100%;
    margin: 0 auto 6px;
    touch-action: manipulation;
    justify-content: center;
}

.kb-key {
    height: 52px;
    margin: 0 3px;
    border-radius: var(--radius-sm);
    background-color: var(--kb-base-bg);
    color: var(--kb-text);
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-transform: uppercase;
    flex: 1;
    border: none;
    transition: transform 0.1s, background-color 0.2s;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.kb-key:active {
    transform: scale(0.95);
}

.kb-key.big {
    flex: 1.5;
    font-size: 0.75rem;
}

.kb-row:last-child .kb-key {
    max-width: 40px;
}

.kb-key[data-status="correct"] {
    background-color: var(--kb-correct);
}

.kb-key[data-status="present"] {
    background-color: var(--kb-present);
}

.kb-key[data-status="absent"] {
    background-color: var(--kb-absent);
}

/* === Result Overlay === */
#result-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 3000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.result-box {
    background-color: var(--color-bg-secondary, #1a1a1a);
    border: 1px solid var(--color-border);
    padding: 2.5rem;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    min-width: 320px;
    max-width: 90%;
    animation: pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.result-label {
    font-size: 1.1rem;
    color: var(--color-text-secondary, #a3a3a3);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 1px;
}

.result-word {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--color-accent, #6366f1);
    margin-bottom: 2rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    text-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.btn-play-again {
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-hover) 100%);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 16px 32px;
    font-size: 1.2rem;
    font-weight: 800;
    border-radius: 16px;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 100%;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    letter-spacing: 1px;
}

.btn-play-again:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
    background: linear-gradient(135deg, var(--color-accent-hover) 0%, var(--color-accent) 100%);
}

.btn-play-again:active {
    transform: scale(0.96);
}

/* === Toast === */
#game-toast {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translate(-50%, 0);
    background-color: var(--color-text-primary, #ffffff);
    color: var(--color-bg-primary, #000000);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 700;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 3100;
    box-shadow: var(--shadow-md);
    text-align: center;
}

#game-toast.show {
    opacity: 1;
}

/* === Game Header === */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: var(--space-md);
}

.game-title {
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: 2px;
}

.game-controls {
    display: flex;
    gap: var(--space-sm);
}

.game-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--color-text-primary);
    cursor: pointer;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    transition: all 0.3s ease;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.game-btn:hover {
    background-color: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.game-btn:active {
    transform: scale(0.95);
}

.game-btn.off {
    opacity: 0.4;
    filter: grayscale(100%);
}

/* === Difficulty Selector === */
.difficulty-options {
    margin: 0;
    text-align: center;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    flex: 1;
    padding: var(--space-md) 0 var(--space-xl);
}

.difficulty-title {
    margin-bottom: 1.5rem;
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--color-text-secondary, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 4px;
}

.difficulty-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-width: 400px;
    padding: 0 var(--space-md);
}

/* Custom styling for difficulty buttons */
.diff-btn {
    position: relative;
    width: 100%;
    padding: 24px 20px 22px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
    color: white;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
        border-color 0.3s ease,
        box-shadow 0.3s ease,
        background-color 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* Pseudo-element for smooth gradient glow transitions */
.diff-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
    border-radius: 18px;
    pointer-events: none;
}

/* Base borders & backgrounds */
.diff-btn.easy {
    border-color: rgba(83, 141, 78, 0.15);
}

.diff-btn.easy::before {
    background: radial-gradient(ellipse at 50% -20%, rgba(83, 141, 78, 0.25) 0%, transparent 70%);
}

.diff-btn.mix {
    border-color: rgba(181, 159, 59, 0.15);
}

.diff-btn.mix::before {
    background: radial-gradient(ellipse at 50% -20%, rgba(181, 159, 59, 0.2) 0%, transparent 70%);
}

.diff-btn.hard {
    border-color: rgba(120, 50, 50, 0.15);
}

.diff-btn.hard::before {
    background: radial-gradient(ellipse at 50% -20%, rgba(120, 50, 50, 0.25) 0%, transparent 70%);
}

/* Ensure content stays above the pseudo-element glow */
.diff-btn>* {
    position: relative;
    z-index: 1;
}

/* HOVER EFFECTS - Simple & Effective */
.diff-btn:hover {
    transform: translateY(-4px);
}

.diff-btn:active {
    transform: translateY(0px) scale(0.97) !important;
    transition-duration: 0.1s;
}

.diff-btn:hover::before {
    opacity: 1;
    /* Fade in the gradient smoothly */
}

.diff-btn.easy:hover {
    border-color: rgba(83, 141, 78, 0.5) !important;
    box-shadow: 0 10px 25px rgba(83, 141, 78, 0.15), 0 0 0 1px rgba(83, 141, 78, 0.2) !important;
    background: rgba(255, 255, 255, 0.04);
}

.diff-btn.mix:hover {
    border-color: rgba(181, 159, 59, 0.5) !important;
    box-shadow: 0 10px 25px rgba(181, 159, 59, 0.15), 0 0 0 1px rgba(181, 159, 59, 0.2) !important;
    background: rgba(255, 255, 255, 0.04);
}

.diff-btn.hard:hover {
    border-color: rgba(120, 50, 50, 0.5) !important;
    box-shadow: 0 10px 25px rgba(120, 50, 50, 0.15), 0 0 0 1px rgba(120, 50, 50, 0.2) !important;
    background: rgba(255, 255, 255, 0.04);
}

/* Tile row */
.diff-tiles {
    display: flex;
    gap: 5px;
}

.diff-tile {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #ffffff;
    line-height: 1;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s ease;
}

.diff-btn:hover .diff-tile {
    transform: translateY(-2px) scale(1.05);
    /* Fun bouncy hover effect on tiles */
}

.diff-tile.dt-correct {
    background-color: var(--tile-correct, #538d4e);
}

.diff-tile.dt-present {
    background-color: var(--tile-present, #b59f3b);
}

.diff-tile.dt-absent {
    background-color: var(--tile-absent, #3a3a3c);
}

/* Labels */
.diff-label {
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-text-primary, #fff);
}

.diff-sub {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-secondary, #94a3b8);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Entrance animation */
@keyframes diffSlideIn {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.diff-btn:nth-child(1) {
    animation: diffSlideIn 0.5s 0.55s backwards cubic-bezier(0.16, 1, 0.3, 1);
}

.diff-btn:nth-child(2) {
    animation: diffSlideIn 0.5s 0.68s backwards cubic-bezier(0.16, 1, 0.3, 1);
}

.diff-btn:nth-child(3) {
    animation: diffSlideIn 0.5s 0.81s backwards cubic-bezier(0.16, 1, 0.3, 1);
}

/* === Onboarding Screen === */
.ob-panel {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: var(--color-bg-primary, #121213);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.35s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.ob-panel.ob-exit {
    animation: obSlideOut 0.45s ease-in forwards;
}

@keyframes obSlideOut {
    to {
        opacity: 0;
        transform: translateX(-100%);
    }
}

.ob-screen {
    width: 100%;
    max-width: 400px;
    padding: 32px 24px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.ob-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text-primary, #d7dadc);
    text-align: center;
    margin: 0;
    letter-spacing: 0.5px;
}

.ob-example {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.ob-word {
    display: flex;
    gap: 5px;
    justify-content: center;
}

.ob-tile {
    width: 48px;
    height: 48px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
    color: #ffffff;
    text-transform: uppercase;
    background-color: var(--tile-absent, #3a3a3c);
}

.ob-tile.ob-correct {
    background-color: var(--tile-correct, #538d4e);
}

.ob-tile.ob-present {
    background-color: var(--tile-present, #b59f3b);
}

.ob-hint {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--color-text-secondary, #a0a4a8);
    margin: 0;
    text-align: center;
    max-width: 320px;
}

.ob-hint strong {
    color: #d7dadc;
}

.ob-footer {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--color-text-secondary, #818384);
    text-align: center;
    margin: 4px 0 0;
}

.ob-footer strong {
    color: var(--color-text-primary, #d7dadc);
}

.ob-btn {
    padding: 15px 48px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    -webkit-tap-highlight-color: transparent;
}

.ob-btn.ob-start {
    background: var(--tile-correct, #538d4e);
    color: #fff;
    min-width: 220px;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.ob-btn.ob-start:hover {
    filter: brightness(1.15);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(83, 141, 78, 0.3);
}

.ob-btn:active {
    transform: scale(0.96) !important;
}

/* Difficulty entrance from right */
@keyframes diffEnterFromRight {
    from {
        opacity: 0;
        transform: translateX(80px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.diff-enter {
    animation: diffEnterFromRight 0.45s 0.5s cubic-bezier(0.16, 1, 0.3, 1) both !important;
}

/* === Animations === */
@keyframes pop {
    50% {
        transform: scale(1.1);
    }
}

@keyframes flip {
    0% {
        transform: rotateY(0);
    }

    50% {
        transform: rotateY(90deg);
    }

    100% {
        transform: rotateY(0);
    }
}

.flip {
    animation: flip 0.6s ease forwards;
}

@keyframes shake {

    10%,
    90% {
        transform: translateX(-1px);
    }

    20%,
    80% {
        transform: translateX(2px);
    }

    30%,
    50%,
    70% {
        transform: translateX(-4px);
    }

    40%,
    60% {
        transform: translateX(4px);
    }
}

.shake {
    animation: shake 0.5s;
}

/* === Responsive === */
@media (max-width: 600px) {
    .game-container {
        max-width: 100vw;
        padding: 0 0 10px 0;
    }

    .game-header {
        margin: 15px 0 10px 0;
        padding: 0 12px 10px 12px;
        width: 100%;
    }

    .game-title {
        display: none;
    }

    .game-controls {
        width: 100%;
        display: flex;
        justify-content: space-between;
    }

    .board-container {
        width: 85vw;
        max-width: 350px;
    }

    .tile {
        font-size: 1.75rem;
    }

    .keyboard {
        width: 100vw;
        max-width: 100vw;
        padding: 0 2px 20px 2px;
    }

    .kb-row {
        width: 100%;
        margin-bottom: 4px;
        padding: 0 2px;
    }

    .kb-key {
        height: 54px;
        margin: 0 1px;
        font-size: 0.85rem;
        border-radius: 4px;
    }

    .difficulty-buttons {
        max-width: 340px;
        gap: 14px;
    }

    .diff-btn {
        padding: 20px 16px 18px;
        gap: 10px;
    }

    .diff-tile {
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }

    .diff-label {
        font-size: 1.05rem;
    }
}