/* ==========================================================================
   Gry Ogrodnicze — Krzyżówka z hasłem
   ========================================================================== */

:root {
    --cw-green-dark: #2d5a27;
    --cw-green-mid: #4a7c42;
    --cw-green-pale: #e8f5e9;
    --cw-white: #ffffff;
    --cw-brown: #5d4037;
    --cw-border: #c8e6c9;
    --cw-radius: 12px;
    --cw-radius-sm: 6px;
    --cw-key-bg: #fff9c4;
    --cw-key-border: #f9a825;
}

/* Wrapper */

.gry-cw-wrapper {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem;
    font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
    color: var(--cw-brown);
}

/* Header */

.gry-cw-header {
    text-align: center;
    margin-bottom: 1rem;
}

.gry-cw-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--cw-green-dark);
    margin: 0 0 0.3rem;
}

.gry-cw-subtitle {
    font-size: 0.9rem;
    color: #777;
    margin: 0;
}

/* Controls */

.gry-cw-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.gry-cw-theme-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.gry-cw-theme-group label {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--cw-green-dark);
}

.gry-cw-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.45rem 0.9rem;
    border: 2px solid var(--cw-border);
    border-radius: 8px;
    background: var(--cw-white);
    color: var(--cw-green-dark);
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.gry-cw-btn:hover {
    border-color: var(--cw-green-mid);
    background: var(--cw-green-pale);
}

.gry-cw-btn-theme.active {
    background: var(--cw-green-mid);
    color: #fff;
    border-color: var(--cw-green-mid);
}

.gry-cw-timer {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--cw-green-dark);
}

/* Main layout */

.gry-cw-main {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.gry-cw-board-area {
    flex: 1 1 auto;
    overflow-x: auto;
}

.gry-cw-sidebar {
    flex: 0 0 280px;
    min-width: 240px;
}

/* ========== Grid (table) ========== */

.gry-cw-table {
    border-collapse: separate;
    border-spacing: 3px;
    margin: 0 auto;
}

.gry-cw-cell {
    width: 36px;
    height: 36px;
    text-align: center;
    vertical-align: middle;
    font-size: 1.05rem;
    font-weight: 800;
    font-family: 'Nunito', sans-serif;
    text-transform: uppercase;
    padding: 0;
}

.gry-cw-empty {
    background: transparent;
    border: none;
}

.gry-cw-white {
    background: var(--cw-white);
    border: 2px solid var(--cw-border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.12s;
    color: var(--cw-brown);
}

.gry-cw-white:hover {
    border-color: var(--cw-green-mid);
}

.gry-cw-key {
    background: var(--cw-key-bg) !important;
    border-color: var(--cw-key-border) !important;
    position: relative;
}

.gry-cw-key-num {
    position: absolute;
    top: 1px;
    left: 2px;
    font-size: 0.5rem;
    font-weight: 900;
    color: #e65100;
    line-height: 1;
    pointer-events: none;
}

.gry-cw-letter {
    display: block;
    line-height: 36px;
}

.gry-cw-selected {
    border-color: var(--cw-green-dark) !important;
    box-shadow: 0 0 0 2px var(--cw-green-mid);
    z-index: 2;
    position: relative;
}

.gry-cw-row-highlight {
    background: #f1f8e9;
}

.gry-cw-row-highlight.gry-cw-key {
    background: #fff3bf !important;
}

.gry-cw-correct {
    background: #c8e6c9 !important;
    border-color: #66bb6a !important;
    color: var(--cw-green-dark);
}

.gry-cw-wrong {
    background: #ffcdd2 !important;
    border-color: #ef5350 !important;
    color: #c62828;
}

.gry-cw-revealed {
    color: #1565c0;
    background: #e3f2fd !important;
    border-color: #90caf9 !important;
    cursor: default;
}

.gry-cw-num {
    width: 24px;
    text-align: right;
    padding-right: 6px;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--cw-green-mid);
    vertical-align: middle;
    border: none;
    background: none;
}

/* ========== Keyword area ========== */

.gry-cw-keyword-area {
    text-align: center;
    margin: 1.2rem 0 0.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, #fffde7 0%, #fff9c4 100%);
    border-radius: var(--cw-radius);
    border: 2px solid var(--cw-key-border);
}

.gry-cw-keyword-area h3 {
    margin: 0 0 0.6rem;
    font-size: 1rem;
    font-weight: 800;
    color: var(--cw-brown);
}

.gry-cw-keyword-boxes {
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.gry-cw-key-box {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 50px;
    background: var(--cw-white);
    border: 2px solid #ddd;
    border-radius: 6px;
    color: var(--cw-brown);
    text-transform: uppercase;
    transition: all 0.2s;
    position: relative;
}

.gry-cw-key-box-num {
    font-size: 0.55rem;
    font-weight: 800;
    color: #e65100;
    line-height: 1;
    margin-top: 2px;
}

.gry-cw-key-box-letter {
    font-size: 1.3rem;
    font-weight: 900;
    line-height: 1.2;
}

.gry-cw-key-correct {
    border-color: var(--cw-key-border);
    background: var(--cw-key-bg);
    color: #f57f17;
}

.gry-cw-key-found {
    border-color: #66bb6a !important;
    background: #c8e6c9 !important;
    color: var(--cw-green-dark) !important;
    animation: gry-cw-pop 0.4s ease;
}

@keyframes gry-cw-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ========== Clues ========== */

.gry-cw-clues-section {
    margin-bottom: 1rem;
}

.gry-cw-clues-section h3 {
    font-size: 1rem;
    font-weight: 800;
    color: var(--cw-green-dark);
    margin: 0 0 0.5rem;
}

.gry-cw-clues-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.gry-cw-clue {
    display: flex;
    align-items: baseline;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    font-size: 0.85rem;
    line-height: 1.35;
    cursor: pointer;
    transition: background 0.12s;
    counter-increment: none;
}

.gry-cw-clue::before {
    content: attr(value) '. ';
    font-weight: 800;
    color: var(--cw-green-mid);
    min-width: 1.5em;
    flex-shrink: 0;
}

.gry-cw-clue:hover {
    background: var(--cw-green-pale);
}

.gry-cw-clue-active {
    background: #c8e6c9;
    font-weight: 700;
}

/* ========== Actions ========== */

.gry-cw-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.gry-cw-btn-primary {
    background: var(--cw-green-mid);
    color: #fff;
    border-color: var(--cw-green-mid);
}

.gry-cw-btn-primary:hover {
    background: var(--cw-green-dark);
    border-color: var(--cw-green-dark);
}

.gry-cw-btn-success {
    background: #43a047;
    color: #fff;
    border-color: #43a047;
}

.gry-cw-btn-success:hover {
    background: #2e7d32;
    border-color: #2e7d32;
}

.gry-cw-btn-secondary {
    background: var(--cw-white);
    color: var(--cw-green-dark);
    border-color: var(--cw-border);
}

.gry-cw-btn-secondary:hover {
    background: var(--cw-green-pale);
    border-color: var(--cw-green-mid);
}

/* ========== Note & Messages ========== */

.gry-cw-note {
    text-align: center;
    font-size: 0.8rem;
    color: #999;
    margin: 0.8rem 0 0.3rem;
    font-style: italic;
}

.gry-cw-message {
    text-align: center;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 0.5rem;
    border-radius: var(--cw-radius-sm);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    margin-top: 0.5rem;
}

.gry-cw-msg-visible { opacity: 1; }
.gry-cw-msg-success { color: var(--cw-green-dark); background: var(--cw-green-pale); border: 1px solid var(--cw-border); }
.gry-cw-msg-error { color: #c62828; background: #ffebee; border: 1px solid #ffcdd2; }
.gry-cw-msg-info { color: #1565c0; background: #e3f2fd; border: 1px solid #bbdefb; }

/* ========== Reward overlay ========== */

.gry-reward-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.gry-reward-overlay.gry-reward-visible { display: flex; }

.gry-reward-card {
    background: linear-gradient(135deg, #fff 0%, #f1f8e9 100%);
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.25);
    max-width: 420px;
    width: 100%;
    padding: 2rem;
    text-align: center;
    position: relative;
    animation: gry-cw-fadeIn 0.3s ease;
}

@keyframes gry-cw-fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.gry-reward-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--cw-green-pale);
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cw-brown);
}

.gry-reward-close:hover { background: var(--cw-border); }
.gry-reward-icon { font-size: 3rem; margin-bottom: 0.5rem; }

.gry-reward-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--cw-green-dark);
    margin: 0 0 0.5rem;
}

.gry-reward-text {
    font-size: 0.95rem;
    color: var(--cw-brown);
    margin: 0 0 1rem;
    line-height: 1.5;
}

.gry-reward-code {
    display: inline-block;
    background: var(--cw-green-dark);
    color: #fff;
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: 0.15em;
    padding: 0.6rem 1.5rem;
    border-radius: 10px;
    margin-bottom: 0.5rem;
    font-family: 'Courier New', monospace;
    user-select: all;
}

.gry-reward-discount {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--cw-green-mid);
    margin: 0.3rem 0 1rem;
}

.gry-reward-link {
    display: inline-block;
    background: var(--cw-green-mid);
    color: #fff !important;
    text-decoration: none !important;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 0.6rem 1.5rem;
    border-radius: 10px;
    transition: background 0.2s;
}

.gry-reward-link:hover {
    background: var(--cw-green-dark);
}

/* ========== Responsywność ========== */

@media (max-width: 768px) {
    .gry-cw-main {
        flex-direction: column;
    }

    .gry-cw-sidebar {
        flex: none;
        width: 100%;
        min-width: 0;
    }

    .gry-cw-cell {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }

    .gry-cw-letter {
        line-height: 30px;
    }

    .gry-cw-key-box {
        width: 34px;
        height: 38px;
        font-size: 1.1rem;
    }

    .gry-cw-controls {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .gry-cw-cell {
        width: 26px;
        height: 26px;
        font-size: 0.8rem;
    }

    .gry-cw-letter {
        line-height: 26px;
    }

    .gry-cw-key-num {
        font-size: 0.4rem;
    }

    .gry-cw-key-box {
        width: 30px;
        height: 34px;
        font-size: 1rem;
    }

    .gry-cw-num {
        font-size: 0.65rem;
        width: 18px;
    }
}
