* {
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    box-sizing: border-box;
}
html {
    height: 100%;
    overflow: hidden;
}
body {
    position: fixed;
    inset: 0;
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    background: #ffe8d6;
    font-family:
        "Fredoka",
        "Baloo 2",
        ui-rounded,
        -apple-system,
        "Segoe UI",
        Roboto,
        sans-serif;
}

:root {
    --cs-ink: #4a3226;
    --cs-ink-soft: #8a6c5b;
    --cs-ink-faint: #c4afa2;
    --cs-bg-1: #fff9f2;
    --cs-bg-2: #ffe8d6;
    --cs-bg-3: #ffd3ac;
    --cs-panel: #ffffff;
    --cs-amber-1: #f5a623;
    --cs-amber-2: #db7c0f;
    --cs-line: rgba(74, 50, 38, 0.14);
    --cs-r-sm: 10px;
    --cs-r-md: 16px;
    --cs-r-lg: 22px;
    --cs-r-xl: 28px;
    --cs-shadow-sm: 0 2px 8px rgba(74, 50, 38, 0.09);
    --cs-shadow-md: 0 6px 20px rgba(74, 50, 38, 0.13);
    --cs-shadow-lg: 0 20px 56px rgba(74, 50, 38, 0.2);
    --cs-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* App shell: on wide viewports the game presents as a framed, elevated
     "device" rather than a background stretched across the whole window.
     The shell is a FIXED viewport-height box — the page itself never
     scrolls; only individual screens (e.g. the long level list) scroll
     internally, inside their own container. */
.cs-shell {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
    overflow: hidden;
    background: linear-gradient(180deg, var(--cs-bg-1), var(--cs-bg-2) 60%, var(--cs-bg-3));
}

@media (min-width: 720px) {
    .cs-shell {
        align-items: center;
        padding: 5vh 24px;
    }
    .cs-root {
        max-width: 460px;
        height: min(860px, 90vh);
        border-radius: var(--cs-r-xl);
        box-shadow: var(--cs-shadow-lg);
        overflow: hidden;
        position: relative;
        border: 1px solid rgba(255, 255, 255, 0.6);
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

/* Visible keyboard focus without disturbing the mouse/touch experience */
.cs-root button:focus-visible {
    outline: 3px solid var(--cs-amber-1);
    outline-offset: 2px;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-20px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}
@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }
    15% {
        transform: translateX(-5px);
    }
    30% {
        transform: translateX(5px);
    }
    45% {
        transform: translateX(-4px);
    }
    60% {
        transform: translateX(4px);
    }
    75% {
        transform: translateX(-2px);
    }
    90% {
        transform: translateX(2px);
    }
}
@keyframes bounce-in {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.25);
        opacity: 1;
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}
@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
@keyframes bounce-slow {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-14px);
    }
}
@keyframes glow-pulse {
    0%,
    100% {
        box-shadow: inset 0 0 8px rgba(255, 200, 0, 0.4);
    }
    50% {
        box-shadow: inset 0 0 16px rgba(255, 200, 0, 0.7);
    }
}
@keyframes star-earn {
    0% {
        transform: scale(0) rotate(-30deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.4) rotate(10deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}
@keyframes slide-up {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}
@keyframes heart-pop {
    0% {
        transform: scale(1);
    }
    30% {
        transform: scale(1.4);
    }
    60% {
        transform: scale(0.7);
    }
    100% {
        transform: scale(1);
    }
}

/* ═══ Cat Sudoku - Complete Styles ═══ */
.cs-root {
    font-family:
        "Fredoka",
        "Baloo 2",
        ui-rounded,
        -apple-system,
        "Segoe UI",
        Roboto,
        sans-serif;
    width: 100%;
    height: 100%;
    color: var(--cs-ink);
    position: relative;
    overflow: hidden;
}
.cs-screen {
    display: none;
    width: 100%;
    height: 100%;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.cs-screen.active {
    display: flex;
}

/* Menu */
.cs-menu {
    justify-content: flex-start;
    padding: clamp(20px, 6vw, 40px) 24px;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, var(--cs-bg-1), var(--cs-bg-2), var(--cs-bg-3));
}
.cs-menu-paw {
    position: absolute;
    opacity: 0.07;
    font-size: 48px;
    line-height: 1;
}
.cs-menu-cat {
    font-size: clamp(56px, 12vw, 80px);
    line-height: 1;
    margin-bottom: 4px;
    animation: bounce-slow 2.5s ease-in-out infinite;
}
.cs-menu-title {
    font-size: clamp(38px, 8vw, 54px);
    font-weight: 700;
    color: var(--cs-ink);
    margin-bottom: 8px;
    letter-spacing: -1px;
}
.cs-menu-sub {
    font-size: clamp(14px, 3vw, 17px);
    color: var(--cs-ink-soft);
    text-align: center;
    max-width: 380px;
    line-height: 1.6;
    margin-bottom: 22px;
    padding: 0 8px;
}
.cs-rules-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 26px;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: var(--cs-r-md);
    padding: 16px;
    max-width: 320px;
    width: 100%;
    box-shadow: var(--cs-shadow-sm);
    border: 1px solid rgba(255, 255, 255, 0.8);
}
.cs-rule {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--cs-ink);
    font-weight: 600;
}
.cs-rule-i {
    font-size: 20px;
    flex-shrink: 0;
}
.cs-btn {
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    border-radius: var(--cs-r-md);
    transition:
        transform 0.18s var(--cs-ease),
        box-shadow 0.18s var(--cs-ease),
        background-color 0.18s var(--cs-ease);
    outline: none;
    min-height: 44px;
}
.cs-btn:active {
    transform: scale(0.96);
}
.cs-btn-primary {
    padding: 15px 40px;
    background: linear-gradient(135deg, var(--cs-amber-1), var(--cs-amber-2));
    color: white;
    font-size: 19px;
    box-shadow: 0 6px 18px rgba(219, 124, 15, 0.38);
}
.cs-btn-primary:hover {
    box-shadow: 0 8px 22px rgba(219, 124, 15, 0.46);
    transform: translateY(-1px);
}
.cs-btn-secondary {
    padding: 12px 28px;
    background: rgba(255, 255, 255, 0.75);
    color: var(--cs-ink);
    font-size: 15px;
    box-shadow: var(--cs-shadow-sm);
    border: 1px solid rgba(255, 255, 255, 0.9);
}
.cs-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.95);
}
.cs-menu-btns {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}
.cs-menu-foot {
    font-size: 12px;
    color: var(--cs-ink-faint);
    margin-top: 22px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

/* Level Select */
.cs-levels {
    padding: clamp(14px, 4vw, 20px) clamp(14px, 4vw, 20px) 32px;
    background: linear-gradient(180deg, var(--cs-bg-1), var(--cs-bg-2), var(--cs-bg-3));
}
.cs-lv-hdr {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
    width: 100%;
    max-width: 480px;
}
.cs-lv-back {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--cs-r-md);
    background: rgba(255, 255, 255, 0.75);
    font-size: 18px;
    font-weight: 700;
    color: var(--cs-ink);
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: var(--cs-shadow-sm);
    transition:
        background-color 0.18s var(--cs-ease),
        transform 0.18s var(--cs-ease);
}
.cs-lv-back:hover {
    background: white;
}
.cs-lv-back:active {
    transform: scale(0.94);
}
.cs-lv-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--cs-ink);
}
.cs-lv-stars {
    font-size: 13px;
    color: var(--cs-ink-soft);
    margin-bottom: 16px;
    width: 100%;
    max-width: 480px;
    padding-left: 56px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.cs-diff {
    margin-bottom: 20px;
    width: 100%;
    max-width: 480px;
}
.cs-diff-hdr {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.cs-diff-badge {
    padding: 3px 11px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    color: white;
    letter-spacing: 0.5px;
}
.cs-diff-size {
    font-size: 12px;
    color: var(--cs-ink-faint);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.cs-lv-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: clamp(6px, 1.6vw, 10px);
}
.cs-lv-btn {
    aspect-ratio: 1;
    border-radius: var(--cs-r-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    transition:
        transform 0.16s var(--cs-ease),
        box-shadow 0.16s var(--cs-ease);
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.7);
    font-family: inherit;
    min-height: 44px;
}
.cs-lv-btn.open {
    background: white;
    box-shadow: var(--cs-shadow-sm);
    color: var(--cs-ink);
}
.cs-lv-btn.open:hover {
    transform: scale(1.07);
    box-shadow: var(--cs-shadow-md);
}
.cs-lv-btn.open:active {
    transform: scale(0.96);
}
.cs-lv-btn.done {
    background: white;
    box-shadow: var(--cs-shadow-md);
}
.cs-lv-btn.locked {
    background: rgba(196, 175, 162, 0.15);
    color: var(--cs-ink-faint);
    cursor: not-allowed;
    border-color: transparent;
}
.cs-lv-num {
    font-size: 15px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.cs-lv-stars-row {
    display: flex;
    gap: 1px;
    margin-top: 2px;
}
.cs-lv-stars-row span {
    font-size: 8px;
    line-height: 1;
}
.cs-star-on {
    color: var(--cs-amber-1);
}
.cs-star-off {
    color: #e4d6cb;
}

/* Game */
.cs-game {
    padding: clamp(10px, 3vw, 16px) 8px 24px;
    background: linear-gradient(180deg, var(--cs-bg-1), var(--cs-bg-2), var(--cs-bg-3));
    justify-content: flex-start;
}
.cs-g-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 520px;
    margin-bottom: 10px;
    padding: 0 4px;
}
.cs-g-back {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--cs-r-sm);
    background: rgba(255, 255, 255, 0.75);
    font-size: 15px;
    font-weight: 700;
    color: var(--cs-ink);
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: var(--cs-shadow-sm);
    transition:
        background-color 0.18s var(--cs-ease),
        transform 0.18s var(--cs-ease);
}
.cs-g-back:hover {
    background: white;
}
.cs-g-back:active {
    transform: scale(0.94);
}
.cs-g-info {
    text-align: center;
}
.cs-g-lbl {
    font-size: 11px;
    color: var(--cs-ink-faint);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}
.cs-g-size {
    font-size: 14px;
    font-weight: 700;
    color: var(--cs-ink);
    font-variant-numeric: tabular-nums;
}
.cs-g-hearts {
    display: flex;
    gap: 2px;
    align-items: center;
    min-width: 76px;
    justify-content: flex-end;
}
.cs-heart {
    font-size: 20px;
    transition:
        opacity 0.3s,
        transform 0.3s;
}
.cs-heart.lost {
    opacity: 0.25;
    transform: scale(0.75);
}
.cs-counter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 16px;
    background: rgba(255, 255, 255, 0.75);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
    color: var(--cs-ink);
    box-shadow: var(--cs-shadow-sm);
    margin-bottom: 14px;
    font-variant-numeric: tabular-nums;
    border: 1px solid rgba(255, 255, 255, 0.9);
}

/* Grid */
.cs-grid {
    display: grid;
    gap: 0;
    border-radius: var(--cs-r-md);
    overflow: hidden;
    box-shadow: var(--cs-shadow-md);
    touch-action: manipulation;
    max-width: 520px;
    width: min(94vw, calc(var(--cs-cols, 6) * 56px)); /* fallback if svh is unsupported */
    width: min(94vw, 62svh, calc(var(--cs-cols, 6) * 56px));
}
.cs-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition:
        filter 0.12s,
        box-shadow 0.12s;
    position: relative;
    aspect-ratio: 1;
}
.cs-cell:active {
    filter: brightness(0.92);
}
.cs-cell.blocked {
    opacity: 0.55;
}
.cs-cell.flash {
    animation: glow-pulse 0.5s ease-out;
}
@media (hover: hover) and (pointer: fine) {
    .cs-cell:hover {
        filter: brightness(1.06);
        box-shadow: inset 0 0 0 2px rgba(74, 50, 38, 0.25);
    }
}
.cs-cat {
    line-height: 1;
}
.cs-x {
    font-weight: 900;
    color: rgba(74, 50, 38, 0.32);
    line-height: 1;
    pointer-events: none;
}
.cs-lock {
    position: absolute;
    bottom: 1px;
    right: 2px;
    font-size: 7px;
    opacity: 0.4;
    line-height: 1;
}

/* Controls */
.cs-ctrls {
    display: flex;
    gap: 10px;
    margin-top: 18px;
    flex-wrap: wrap;
    justify-content: center;
}
.cs-ctrl {
    padding: 11px 18px;
    border-radius: var(--cs-r-sm);
    font-size: 13px;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-family: inherit;
    transition:
        transform 0.16s var(--cs-ease),
        box-shadow 0.16s var(--cs-ease),
        background-color 0.16s var(--cs-ease);
    box-shadow: var(--cs-shadow-sm);
    min-height: 44px;
}
.cs-ctrl:active {
    transform: scale(0.95);
}
.cs-ctrl.hint {
    background: #fcd34d;
    color: var(--cs-ink);
    border-color: transparent;
}
.cs-ctrl.hint:hover {
    background: #fbbf24;
}
.cs-ctrl.rst {
    background: rgba(255, 255, 255, 0.85);
    color: var(--cs-ink);
}
.cs-ctrl.rst:hover {
    background: white;
}
.cs-ctrl.rls {
    background: rgba(255, 255, 255, 0.85);
    color: var(--cs-ink);
}
.cs-ctrl.rls:hover {
    background: white;
}

/* Overlays */
.cs-overlay {
    position: fixed;
    inset: 0;
    background: rgba(35, 22, 14, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 40;
    animation: fade-in 0.25s ease-out;
}
.cs-card {
    background: var(--cs-panel);
    border-radius: var(--cs-r-lg);
    padding: 28px;
    max-width: 360px;
    width: 100%;
    box-shadow: var(--cs-shadow-lg);
    animation: bounce-in 0.35s var(--cs-ease);
}
.cs-card-c {
    text-align: center;
}
.cs-oi {
    font-size: 52px;
    margin-bottom: 8px;
}
.cs-ot {
    font-size: 24px;
    font-weight: 700;
    color: var(--cs-ink);
    margin-bottom: 4px;
}
.cs-os {
    font-size: 14px;
    color: var(--cs-ink-soft);
    margin-bottom: 20px;
    line-height: 1.5;
}
.cs-ostars {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 8px;
}
.cs-ostars span {
    font-size: 32px;
}
.cs-om {
    font-size: 14px;
    color: var(--cs-ink-soft);
    margin-bottom: 4px;
    font-variant-numeric: tabular-nums;
}
.cs-omsg {
    font-size: 12px;
    color: var(--cs-ink-faint);
    margin-bottom: 20px;
}
.cs-obtns {
    display: flex;
    gap: 12px;
}
.cs-obtns .cs-btn {
    flex: 1;
    padding: 13px 0;
    font-size: 14px;
    border-radius: var(--cs-r-sm);
}
.cs-btn-amb {
    background: var(--cs-amber-2);
    color: white;
    box-shadow: 0 4px 14px rgba(219, 124, 15, 0.32);
}
.cs-btn-amb:hover {
    background: #b8670c;
}
.cs-btn-out {
    background: white;
    border: 2px solid var(--cs-amber-1);
    color: var(--cs-ink);
}
.cs-btn-out:hover {
    background: var(--cs-bg-1);
}

/* Rules */
.cs-rules-c {
    text-align: left;
}
.cs-rr {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
    font-size: 14px;
    color: var(--cs-ink);
    line-height: 1.4;
}
.cs-rr .ri {
    font-size: 22px;
    flex-shrink: 0;
}
.cs-rdiv {
    border: none;
    border-top: 1px solid var(--cs-line);
    margin: 14px 0;
}

/* Confetti */
.cs-conf {
    position: fixed;
    top: -20px;
    pointer-events: none;
    z-index: 50;
    animation: confetti-fall linear forwards;
}

/* Animations */
.cs-anim-shake {
    animation: shake 0.45s ease-in-out;
}
.cs-anim-bounce {
    animation: bounce-in 0.35s ease-out forwards;
}
.cs-anim-star {
    animation: star-earn 0.5s ease-out forwards;
}

@media (max-width: 380px) {
    .cs-rules-grid {
        padding: 12px;
        gap: 8px;
    }
    .cs-rule {
        font-size: 12px;
    }
    .cs-ctrl {
        padding: 9px 14px;
        font-size: 12px;
    }
}

/* Short/landscape viewports (e.g. a phone turned sideways): tighten
     vertical rhythm so the board and controls both stay on screen. */
@media (max-height: 560px) {
    .cs-menu {
        padding: 14px 24px;
    }
    .cs-menu-cat {
        font-size: 40px;
        margin-bottom: 0;
    }
    .cs-menu-title {
        font-size: 30px;
        margin-bottom: 4px;
    }
    .cs-menu-sub {
        margin-bottom: 12px;
    }
    .cs-rules-grid {
        margin-bottom: 14px;
        padding: 10px;
    }
    .cs-menu-foot {
        margin-top: 12px;
    }
    .cs-g-hdr {
        margin-bottom: 6px;
    }
    .cs-counter {
        margin-bottom: 8px;
    }
    .cs-ctrls {
        margin-top: 10px;
    }
}