:root {
            --grid-rows: 3;
            --grid-cols: 3;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
            background-color: #f0f2f5;
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 15px;
            margin: 0;
            box-sizing: border-box;
            min-height: 100vh;
            user-select: none;
            -webkit-user-select: none;
        }

        h1 {
            color: #333;
            margin: 10px 0;
            font-size: 1.8rem;
        }

        .controls {
            background-color: white;
            padding: 12px 20px;
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.05);
            margin-bottom: 15px;
            display: flex;
            gap: 12px;
            align-items: center;
            justify-content: center;
            flex-wrap: wrap;
            width: 100%;
            max-width: 500px;
            box-sizing: border-box;
        }

        .input-group {
            display: flex;
            align-items: center;
            gap: 6px;
        }

        label {
            font-weight: bold;
            color: #555;
            font-size: 0.95rem;
        }

        input[type="number"] {
            width: 45px;
            padding: 6px;
            border: 1px solid #ccc;
            border-radius: 4px;
            font-size: 16px;
            text-align: center;
        }

        .btn-group {
            display: flex;
            gap: 6px;
            flex-wrap: wrap;
            justify-content: center;
            width: 100%;
            margin-top: 5px;
        }

        button, .link-btn {
            padding: 10px 14px;
            border: none;
            border-radius: 6px;
            background-color: #007bff;
            color: white;
            font-size: 13px;
            font-weight: bold;
            cursor: pointer;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            transition: opacity 0.2s, background-color 0.2s;
            touch-action: manipulation;
            box-sizing: border-box;
        }

        button:hover, .link-btn:hover { opacity: 0.9; }

        .btn-easy { background-color: #2ecc71 !important; }
        .btn-moderate { background-color: #f39c12 !important; }
        .btn-harder { background-color: #e74c3c !important; }
        .btn-pause { background-color: #7f8c8d !important; }
        .btn-solver { background-color: #4f46e5 !important; }

        button:disabled {
            background-color: #cccccc !important;
            cursor: not-allowed;
            opacity: 0.6;
        }

        #save-btn {
            background-color: #9b59b6;
            display: none; 
        }

        .stats {
            display: flex;
            justify-content: space-around;
            align-items: center;
            width: 100%;
            max-width: 500px;
            font-size: 15px;
            font-weight: bold;
            color: #444;
            margin-bottom: 15px;
            background: white;
            padding: 10px 0;
            border-radius: 6px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.02);
            flex-wrap: wrap;
            gap: 8px;
        }

        .puzzle-wrapper {
            width: 100%;
            max-width: 420px;
            display: flex;
            flex-direction: column;
            align-items: center;
            margin-bottom: 30px; 
        }

        #puzzle-container {
            position: relative;
            background-color: #bdc3c7;
            border: none;
            border-radius: 8px;
            box-shadow: 0 8px 24px rgba(0,0,0,0.15);
            display: grid;
            grid-template-rows: repeat(var(--grid-rows), 1fr);
            grid-template-columns: repeat(var(--grid-cols), 1fr);
            gap: 3px;
            width: min(90vw, 420px);
            height: calc((min(90vw, 420px) / var(--grid-cols)) * var(--grid-rows));
            box-sizing: border-box;
            touch-action: auto; 
        }

        .tile {
            background-color: #4caf50;
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: calc((min(90vw, 420px) / var(--grid-cols)) * 0.35);
            font-weight: bold;
            cursor: pointer;
            border-radius: 4px;
            transition: background-color 0.1s, transform 0.05s;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            box-sizing: border-box;
        }

        .tile:active { transform: scale(0.97); }

        .tile.empty {
            background-color: #bdc3c7;
            cursor: default;
            box-shadow: none;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .tile.empty svg {
            width: 50%;
            height: 50%;
            fill: #ef0b0b;
            opacity: 0;
            transform: scale(0.5);
            transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }

        .tile.empty.won-graphic svg {
            opacity: 1;
            transform: scale(1);
        }

        .overlay {
            position: absolute;
            top: 0; left: 0; width: 100%; height: 100%;
            background-color: rgba(240, 242, 245, 0.6);
            backdrop-filter: blur(4px);
            -webkit-backdrop-filter: blur(4px);
            color: #2c3e50;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            font-size: 1.8rem;
            font-weight: bold;
            text-align: center;
            padding: 20px;
            box-sizing: border-box;
            border-radius: 8px;
            display: none;
            z-index: 10;
            text-shadow: 0 1px 2px rgba(255,255,255,0.8);
        }

        .scroll-tip {
            margin-top: 15px;
            color: #7f8c8d;
            font-size: 0.85rem;
            font-weight: bold;
            display: none;
            animation: bounce 2s infinite;
        }

        .sub-board-navigation {
            display: flex;
            gap: 10px;
            width: 100%;
            max-width: 420px;
            justify-content: center;
            margin-bottom: 60px;
        }

        .btn-variant-image { background-color: #16a34a !important; flex: 1; }
        .btn-variant-cw { background-color: #e77f08 !important; flex: 1; }
        .btn-variant-letter { background-color: #9333ea !important; flex: 1; }

        @keyframes bounce {
            0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
            40% { transform: translateY(-6px); }
            60% { transform: translateY(-3px); }
        }