/* ==========================================================================
   Gry Ogrodnicze — Kwiatowe Sudoku
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap');

#gry-sudoku-app {
    --gry-green-dark: #2d5a27;
    --gry-green-mid: #4a7c42;
    --gry-green-light: #7cb342;
    --gry-green-pale: #e8f5e9;
    --gry-green-bg: #f1f8e9;
    --gry-brown: #5d4037;
    --gry-brown-light: #8d6e63;
    --gry-cream: #fff8e7;
    --gry-white: #ffffff;
    --gry-border: #c5e1a5;
    --gry-border-thick: #7cb342;
    --gry-cell-hover: #dcedc8;
    --gry-cell-selected: #c5e1a5;
    --gry-cell-fixed: #f9fbe7;
    --gry-cell-error: #ffcdd2;
    --gry-cell-hint: #fff9c4;
    --gry-shadow: 0 4px 20px rgba(45, 90, 39, 0.15);
    --gry-shadow-sm: 0 2px 8px rgba(45, 90, 39, 0.1);
    --gry-radius: 12px;
    --gry-radius-sm: 8px;
    --gry-font: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;

    font-family: var(--gry-font);
    color: var(--gry-brown);
    max-width: 960px;
    margin: 2rem auto;
    padding: 0 1rem;
    box-sizing: border-box;
}

#gry-sudoku-app *, #gry-sudoku-app *::before, #gry-sudoku-app *::after {
    box-sizing: border-box;
}

/* Header
   ========================================================================== */

.gry-sudoku-wrapper {
    background: var(--gry-white);
    border-radius: var(--gry-radius);
    box-shadow: var(--gry-shadow);
    overflow: hidden;
    border: 2px solid var(--gry-border);
}

.gry-sudoku-header {
    background: linear-gradient(135deg, var(--gry-green-dark), var(--gry-green-mid));
    padding: 1.5rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.gry-sudoku-header::before {
    content: '🌿🌸🌻🌹🌷🌼🌺💮🍀';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    opacity: 0.08;
    letter-spacing: 0.5rem;
    white-space: nowrap;
    pointer-events: none;
}

.gry-sudoku-title {
    margin: 0 0 0.25rem;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--gry-white);
    letter-spacing: 0.02em;
}

.gry-sudoku-title-icon {
    margin-right: 0.3em;
}

.gry-sudoku-subtitle {
    margin: 0;
    font-size: 0.9rem;
    color: rgba(255,255,255,0.85);
    font-weight: 400;
}

/* Controls bar
   ========================================================================== */

.gry-sudoku-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: var(--gry-green-pale);
    border-bottom: 1px solid var(--gry-border);
}

.gry-sudoku-controls-left,
.gry-sudoku-controls-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gry-sudoku-difficulty-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.gry-sudoku-difficulty-group label {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--gry-green-dark);
    margin-right: 0.25rem;
}

.gry-sudoku-timer {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--gry-white);
    border: 1px solid var(--gry-border);
    border-radius: var(--gry-radius-sm);
    padding: 0.4rem 0.8rem;
    font-weight: 700;
    font-size: 1rem;
    color: var(--gry-green-dark);
    font-variant-numeric: tabular-nums;
}

.gry-timer-icon {
    font-size: 1.1rem;
}

/* Buttons
   ========================================================================== */

.gry-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.45rem 1rem;
    border: 2px solid transparent;
    border-radius: var(--gry-radius-sm);
    font-family: var(--gry-font);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.gry-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--gry-shadow-sm);
}

.gry-btn:active {
    transform: translateY(0);
}

.gry-btn-diff {
    background: var(--gry-white);
    border-color: var(--gry-border);
    color: var(--gry-green-mid);
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.gry-btn-diff.active {
    background: var(--gry-green-mid);
    border-color: var(--gry-green-mid);
    color: var(--gry-white);
}

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

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

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

.gry-btn-secondary {
    background: var(--gry-cream);
    color: var(--gry-brown);
    border-color: var(--gry-brown-light);
}

.gry-btn-secondary:hover {
    background: var(--gry-brown-light);
    color: var(--gry-white);
}

.gry-btn-success {
    background: var(--gry-green-light);
    color: var(--gry-white);
    border-color: var(--gry-green-light);
}

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

/* Main layout
   ========================================================================== */

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

.gry-sudoku-board-area {
    flex: 0 0 auto;
    position: relative;
}

.gry-sudoku-sidebar {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-width: 200px;
}

/* Board
   ========================================================================== */

.gry-sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    width: min(450px, calc(100vw - 280px));
    height: min(450px, calc(100vw - 280px));
    border: 3px solid var(--gry-green-dark);
    border-radius: var(--gry-radius-sm);
    overflow: hidden;
    background: var(--gry-green-dark);
    gap: 0;
    box-shadow: var(--gry-shadow-sm);
}

.gry-sudoku-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gry-white);
    font-size: 1.6rem;
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background 0.15s ease;
    border: 0.5px solid var(--gry-border);
    line-height: 1;
    aspect-ratio: 1;
}

.gry-sudoku-cell:hover:not(.gry-cell-fixed) {
    background: var(--gry-cell-hover);
}

.gry-sudoku-cell.gry-cell-selected {
    background: var(--gry-cell-selected) !important;
    box-shadow: inset 0 0 0 2px var(--gry-green-mid);
    z-index: 2;
}

.gry-sudoku-cell.gry-cell-fixed {
    background: var(--gry-cell-fixed);
    cursor: default;
    font-size: 1.6rem;
}

.gry-sudoku-cell.gry-cell-error {
    background: var(--gry-cell-error) !important;
    animation: gry-shake 0.3s ease;
}

.gry-sudoku-cell.gry-cell-hint {
    background: var(--gry-cell-hint) !important;
    animation: gry-pulse 0.5s ease;
}

.gry-sudoku-cell.gry-cell-correct {
    animation: gry-bloom 0.5s ease;
}

/* Thick borders for 3x3 boxes */
.gry-sudoku-cell.gry-border-right {
    border-right: 2px solid var(--gry-green-dark);
}

.gry-sudoku-cell.gry-border-bottom {
    border-bottom: 2px solid var(--gry-green-dark);
}

/* Flower picker
   ========================================================================== */

.gry-sudoku-picker {
    display: none;
    position: absolute;
    z-index: 100;
    background: var(--gry-white);
    border: 2px solid var(--gry-green-mid);
    border-radius: var(--gry-radius);
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    padding: 0.6rem;
    animation: gry-fadeIn 0.15s ease;
}

.gry-sudoku-picker.visible {
    display: block;
}

.gry-picker-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.3rem;
}

.gry-picker-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    width: 52px;
    height: 52px;
    border-radius: var(--gry-radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    border: 2px solid transparent;
    background: var(--gry-green-pale);
    font-size: 1.3rem;
    line-height: 1;
}

.gry-picker-item:hover {
    background: var(--gry-cell-selected);
    border-color: var(--gry-green-mid);
    transform: scale(1.08);
}

.gry-picker-item-name {
    font-size: 0.5rem;
    font-weight: 700;
    color: var(--gry-brown);
    text-align: center;
    line-height: 1;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gry-picker-clear {
    background: var(--gry-cell-error);
    font-size: 1rem;
}

.gry-picker-clear:hover {
    background: #ef9a9a;
    border-color: #e57373;
}

/* Legend
   ========================================================================== */

.gry-sudoku-legend {
    background: var(--gry-green-pale);
    border-radius: var(--gry-radius-sm);
    padding: 1rem;
    border: 1px solid var(--gry-border);
}

.gry-sudoku-legend h3 {
    margin: 0 0 0.6rem;
    font-size: 1rem;
    font-weight: 800;
    color: var(--gry-green-dark);
}

.gry-legend-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
}

.gry-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gry-brown);
    padding: 0.25rem 0.4rem;
    border-radius: 6px;
    background: var(--gry-white);
    border: 1px solid var(--gry-border);
}

.gry-legend-emoji {
    font-size: 1.1rem;
    line-height: 1;
}

.gry-legend-name {
    flex: 1;
}

.gry-legend-count {
    font-size: 0.65rem;
    font-weight: 700;
    color: #9e9e9e;
    min-width: 1.8em;
    text-align: right;
}

.gry-legend-complete {
    background: #c8e6c9;
    border-color: #81c784;
    position: relative;
}

.gry-legend-complete .gry-legend-name {
    text-decoration: line-through;
    text-decoration-color: rgba(0,0,0,0.25);
}

.gry-legend-complete .gry-legend-count {
    color: #2e7d32;
    font-size: 0.8rem;
}

.gry-legend-complete .gry-legend-emoji {
    opacity: 0.6;
}

/* Picker — disabled (all 9 placed) */

.gry-picker-item.gry-picker-disabled {
    opacity: 0.25;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(0.8);
}

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

.gry-sudoku-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.gry-sudoku-actions .gry-btn {
    width: 100%;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
}

/* Rules button */

.gry-btn-rules {
    background: var(--gry-white);
    border-color: var(--gry-border);
    color: var(--gry-green-mid);
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
}

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

/* Rules modal
   ========================================================================== */

.gry-sudoku-rules-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.45);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.gry-sudoku-rules-modal.gry-modal-visible {
    display: flex;
}

.gry-rules-content {
    background: var(--gry-white);
    border-radius: var(--gry-radius);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.25);
    max-width: 520px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 1.75rem 2rem;
    position: relative;
    animation: gry-fadeIn 0.2s ease;
}

.gry-rules-content h3 {
    margin: 0 0 1rem;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--gry-green-dark);
}

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

.gry-rules-close:hover {
    background: var(--gry-border);
}

.gry-rules-body {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--gry-brown);
}

.gry-rules-body p {
    margin: 0.6rem 0;
}

.gry-rules-body ol,
.gry-rules-body ul {
    margin: 0.4rem 0 0.8rem 1.2rem;
    padding: 0;
}

.gry-rules-body li {
    margin-bottom: 0.3rem;
}

/* Messages
   ========================================================================== */

.gry-sudoku-message {
    position: absolute;
    bottom: -3rem;
    left: 0;
    right: 0;
    text-align: center;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 0.5rem;
    border-radius: var(--gry-radius-sm);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.gry-sudoku-message.gry-msg-visible {
    opacity: 1;
}

.gry-sudoku-message.gry-msg-success {
    color: var(--gry-green-dark);
    background: var(--gry-green-pale);
    border: 1px solid var(--gry-border);
}

.gry-sudoku-message.gry-msg-error {
    color: #c62828;
    background: #ffebee;
    border: 1px solid #ffcdd2;
}

.gry-sudoku-message.gry-msg-info {
    color: var(--gry-brown);
    background: var(--gry-cream);
    border: 1px solid #ffe0b2;
}

/* Animations
   ========================================================================== */

@keyframes gry-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

@keyframes gry-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes gry-bloom {
    0% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes gry-fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes gry-celebrate {
    0% { transform: scale(1); }
    10% { transform: scale(1.1) rotate(-2deg); }
    20% { transform: scale(1.1) rotate(2deg); }
    30% { transform: scale(1.1) rotate(-2deg); }
    40% { transform: scale(1.1) rotate(2deg); }
    50% { transform: scale(1); }
}

.gry-sudoku-board.gry-celebrating {
    animation: gry-celebrate 1s ease;
}

/* Responsive
   ========================================================================== */

@media (max-width: 720px) {
    .gry-sudoku-main {
        flex-direction: column;
        align-items: center;
    }

    .gry-sudoku-board {
        width: min(400px, calc(100vw - 3rem));
        height: min(400px, calc(100vw - 3rem));
    }

    .gry-sudoku-sidebar {
        width: 100%;
        max-width: 400px;
    }

    .gry-legend-list {
        grid-template-columns: repeat(3, 1fr);
    }

    .gry-sudoku-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .gry-sudoku-controls-left,
    .gry-sudoku-controls-right {
        justify-content: center;
    }

    .gry-sudoku-actions {
        flex-direction: row;
    }
}

@media (max-width: 480px) {
    .gry-sudoku-board {
        width: min(340px, calc(100vw - 2rem));
        height: min(340px, calc(100vw - 2rem));
    }

    .gry-sudoku-cell {
        font-size: 1.15rem;
    }

    .gry-sudoku-cell.gry-cell-fixed {
        font-size: 1.15rem;
    }

    .gry-sudoku-title {
        font-size: 1.3rem;
    }

    .gry-sudoku-subtitle {
        font-size: 0.8rem;
    }

    .gry-picker-item {
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }

    .gry-picker-item-name {
        font-size: 0.45rem;
    }

    .gry-sudoku-actions {
        flex-direction: column;
    }
}

/* 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-fadeIn 0.3s ease;
}

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

.gry-reward-close:hover {
    background: var(--gry-border);
}

.gry-reward-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

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

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

.gry-reward-code {
    display: inline-block;
    background: var(--gry-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(--gry-green-mid);
    margin: 0.3rem 0 1rem;
}

.gry-reward-link {
    display: inline-block;
    background: var(--gry-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(--gry-green-dark);
}
