:root {
    --bg: #f0f4f8;
    --accent: #2563eb;
    --card: #ffffff;
    --text: #1e293b;
}

body {
    background: var(--bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    margin: 0;
}

h1 { margin-bottom: 20px; font-weight: 300; }

#game {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 4px;
    max-width: 420px;
    width: 100%;
    background: var(--card);
    padding: 8px;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
}

.field {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    overflow: hidden;
    max-height: 60px;
    transition:
        transform 0.2s,
        background 0.2s,
        opacity 0.5s ease,
        max-height 0.5s ease,
        font-size 0.5s ease;
}

.field.selected { background: #fef08a; border-color: #eab308; transform: scale(1.1); z-index: 2; }
.field.deleted { background: #f1f5f9; color: #cbd5e1; border-color: transparent; }

.field.collapsing {
    opacity: 0;
    max-height: 0;
    font-size: 0;
    margin: 0;
    padding: 0;
    border-width: 0;
    pointer-events: none;
}

.field.hidden-row { display: none !important; }

.controls { margin-top: 25px; display: flex; gap: 10px; width: 100%; max-width: 420px; }
button {
    flex: 1; padding: 14px; border: none; border-radius: 10px;
    background: var(--accent); color: white; font-weight: 600; cursor: pointer;
    transition: opacity 0.2s;
}
#rules {
            display: none;
    gap: 4px;
    max-width: 420px;
    width: 100%;
    background: var(--card);
    padding: 8px;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
        }
        .pad {
            padding: 10px;
        }
        .js {
            cursor: pointer;
            text-decoration: none;
            color: #0066cc;
        }
        .js:hover {
            text-decoration: underline;
        }
button:disabled { background: #cbd5e1; cursor: not-allowed; }
#undoBtn { background: #64748b; }
