body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background-color: #f0f2f5;
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 15px;
            margin: 0;
            min-height: 100vh;
            user-select: none;
            -webkit-user-select: none;
        }

        h1 {
            color: #333;
            margin: 5px 0 15px 0;
            font-size: 1.8rem;
        }

        .controls {
            background-color: white;
            padding: 15px 20px;
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.05);
            margin-bottom: 15px;
            display: flex;
            gap: 15px;
            align-items: center;
            justify-content: center;
            flex-wrap: wrap;
            width: 100%;
            max-width: 540px;
            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"], select {
            padding: 6px;
            border: 1px solid #ccc;
            border-radius: 4px;
            font-size: 14px;
            background: white;
        }

        input[type="number"] {
            width: 45px;
            text-align: center;
            font-size: 16px;
        }

        .toggle-group {
            display: flex;
            align-items: center;
            gap: 10px;
            background: #f1f5f9;
            padding: 4px 8px;
            border-radius: 6px;
        }

        .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: 12px;
            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;
            white-space: nowrap; 
        }

        button:hover, .link-btn:hover { opacity: 0.9; }
        button:disabled { background-color: #cccccc !important; cursor: not-allowed; opacity: 0.6; }

        .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; }
        .btn-save-image { background-color: #e67e22 !important; display: none; }

        .game-layout {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 15px;
            width: 100%;
            max-width: 450px;
        }

        .stats {
            display: flex;
            justify-content: space-around;
            align-items: center;
            width: 100%;
            font-size: 14px;
            font-weight: bold;
            color: #444;
            background: white;
            padding: 10px 0;
            border-radius: 6px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.02);
        }

        #puzzle-container {
            position: relative;
            background-color: #cbd5e1;
            border-radius: 8px;
            box-shadow: 0 8px 24px rgba(0,0,0,0.15);
            display: grid;
            gap: 2px;
            width: 100%;
            height: 420px; 
            box-sizing: border-box;
            overflow: hidden;
            transition: gap 0.2s ease;
        }

        .tile {
            position: relative;
            background-color: #cbd5e1;
            cursor: pointer;
            border-radius: 2px;
            box-sizing: border-box;
            overflow: hidden;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .tile canvas {
            width: 100%;
            height: 100%;
            object-fit: fill;
            display: block;
        }

        .tile.empty canvas {
            display: none;
        }

        .tile.empty {
            background: #cbd5e1 !important;
            cursor: default;
        }

        .tile-number {
            position: absolute;
            background: rgba(0, 0, 0, 0.6);
            color: white;
            font-weight: bold;
            padding: 2px 6px;
            border-radius: 4px;
            font-size: 14px;
            pointer-events: none;
            display: none;
            z-index: 2;
        }

        .show-numbers .tile-number {
            display: block;
        }

        .navigation-card {
            background: white;
            padding: 12px;
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.05);
            display: flex;
            justify-content: center;
            width: 100%;
            box-sizing: border-box;
        }

        .game-navigation {
            display: flex;
            gap: 10px;
            width: 100%;
            max-width: 320px;
        }

        .btn-nav-number { background-color: #4f46e5 !important; flex: 1; }
        .btn-nav-letter { background-color: #9333ea !important; flex: 1; }

        .reference-panel {
            background: white;
            padding: 12px;
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.05);
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 8px;
            width: 100%;
            box-sizing: border-box;
            display: none; 
        }

        .reference-img {
            width: 100%;
            max-width: 240px;
            height: auto;
            border-radius: 4px;
            border: 1px solid #e2e8f0;
            background: #f1f5f9;
        }

        .reference-title {
            font-size: 12px;
            font-weight: bold;
            color: #64748b;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .overlay {
            position: absolute;
            top: 0; left: 0; width: 100%; height: 100%;
            background-color: rgba(240, 242, 245, 0.85);
            backdrop-filter: blur(4px);
            -webkit-backdrop-filter: blur(4px);
            color: #2c3e50;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.8rem;
            font-weight: bold;
            border-radius: 8px;
            display: none;
            z-index: 10;
        }