        :root {
            --bg-app: #FFF8E7;
            --bg-panel: #FFFFFF;
            --bg-sunken: #F4F1EB;
            --bg-cell: #FBF9F5;
            --grid-line: #F4F1EB;
            --text-main: #5C4B51;
            --text-muted: #BCAAA4;
            --text-error: #B56576;
            --pink: #FF8BA7;
            --pink-soft: #FFDEE9;
            --green: #B5E48C;
            --green-shadow: #93C47D;
            --green-text: #2D6A4F;
            --blue: #A7C7E7;
            --blue-shadow: #7A9FBF;
            --blue-text: #2B547E;
            --radius-card: 40px;
        }

        *, *::before, *::after {
            box-sizing: border-box;
        }

        body {
            font-family: 'Fredoka', sans-serif;
            background-color: var(--bg-app);
            margin: 0;
            height: 100vh;
            height: 100dvh;
            display: flex;
            flex-direction: column;
            color: var(--text-main);
            overflow: hidden;
            user-select: none;
            -webkit-user-select: none;
            touch-action: none;
        }

        .hidden-screen.hidden-screen { display: none; }

        .title-text {
            font-size: clamp(3.5rem, 6vw, 5.5rem);
            font-weight: 700;
            color: var(--pink);
            text-shadow: 3px 3px 0 var(--bg-panel), 0 8px 15px rgba(255, 139, 167, 0.2);
            letter-spacing: 2px;
            display: inline-block;
            animation: title-bounce 3s ease-in-out infinite;
        }

        @keyframes title-bounce {
            0%, 100% { transform: rotate(-3deg); }
            50%      { transform: rotate(3deg); }
        }

        @media (prefers-reduced-motion: reduce) {
            .title-text { animation: none; }
        }

        .slogan-text {
            font-size: 1.4rem;
            font-weight: 600;
            color: var(--text-muted);
            margin-top: 5px;
            letter-spacing: 1px;
        }

        .level-card {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 15px;
            padding: 20px;
            background: var(--bg-panel);
            border: 4px solid transparent;
            border-radius: var(--radius-card);
            box-shadow: 0 10px 25px rgba(189, 178, 163, 0.2);
            cursor: pointer;
            transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s, box-shadow 0.2s;
        }

        .level-card:hover {
            transform: translateY(-8px) scale(1.03);
            border-color: var(--pink-soft);
            box-shadow: 0 15px 35px rgba(255, 139, 167, 0.2);
        }

        .level-thumb-box {
            width: 100%;
            aspect-ratio: 1 / 1;
            padding: 15px;
            background: var(--bg-sunken);
            border-radius: 25px;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            overflow: hidden;
        }

        .thumb-canvas {
            display: block;
            image-rendering: pixelated;
            width: 100%;
            height: 100%;
            object-fit: contain;
        }

        .load-error {
            align-self: center;
            text-align: center;
            color: var(--text-error);
            font-size: 1.2rem;
            padding: 40px;
        }

        .load-error i {
            font-size: 2.5rem;
            margin-bottom: 15px;
            display: block;
        }

        .game-screen {
            position: relative;
            width: 100%;
            height: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }

        .game-layout {
            position: relative;
            width: 100%;
            max-width: 1200px;
            margin: auto;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 15px;
        }

        .top-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            width: 100%;
            padding: 15px 20px;
            z-index: 10;
        }

        .btn-round {
            width: 60px;
            height: 60px;
            flex-shrink: 0;
            border-radius: 50%;
            border: none;
            background: var(--bg-panel);
            color: var(--pink);
            font-size: 1.5rem;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 10px 25px rgba(189, 178, 163, 0.2);
            cursor: pointer;
            transition: all 0.1s;
        }

        .btn-round:active {
            transform: scale(0.9);
            box-shadow: 0 2px 5px rgba(189, 178, 163, 0.2);
        }

        .reference-box {
            width: 70px;
            height: 70px;
            flex-shrink: 0;
            padding: 10px;
            background: var(--bg-panel);
            border-radius: 20px;
            box-shadow: 0 10px 25px rgba(189, 178, 163, 0.2);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .canvas-area {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 10px 20px 40px 20px;
        }

        .pixel-board {
            padding: 10px;
            background: var(--bg-panel);
            border-radius: 24px;
            box-shadow: 0 10px 25px rgba(189, 178, 163, 0.2);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .main-grid {
            display: grid;
            gap: 1px;
            background-color: var(--grid-line);
            border: 2px solid var(--grid-line);
            border-radius: 14px;
            overflow: hidden;
        }

        .pixel-cell {
            position: relative;
            aspect-ratio: 1 / 1;
            background-color: var(--bg-cell);
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: background-color 0.15s ease;
        }

        @keyframes pop-in {
            from { transform: scale(0.85); }
            to   { transform: scale(1); }
        }

        .hint-dot {
            width: 10%;
            height: 10%;
            border-radius: 50%;
        }

        .pixel-cell.painted .hint-dot { display: none; }

        .bottom-dock {
            width: 100%;
            padding: 10px 20px 20px;
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 10;
        }

        .dock-container {
            max-width: 100%;
            padding: 15px 25px;
            background: var(--bg-panel);
            border-radius: var(--radius-card);
            box-shadow: 0 10px 25px rgba(189, 178, 163, 0.2);
            display: flex;
            flex-wrap: wrap;
            gap: 15px;
            justify-content: center;
        }

        .color-bubble {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            border: 3px solid var(--bg-panel);
            cursor: pointer;
            box-shadow: inset 0 -3px 5px rgba(0, 0, 0, 0.1), 0 4px 8px rgba(0, 0, 0, 0.1);
            transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
        }

        .color-bubble.active {
            transform: scale(1.25);
            border: 4px solid var(--bg-panel);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
        }

        .overlay {
            position: absolute;
            inset: 0;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            background: rgba(255, 248, 231, 0.85);
            backdrop-filter: blur(5px);
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s;
            z-index: 50;
        }

        .overlay.show { opacity: 1; pointer-events: auto; }

        .win-card {
            width: 90%;
            max-width: 400px;
            padding: 30px;
            text-align: center;
            background: var(--bg-panel);
            border-radius: var(--radius-card);
            box-shadow: 0 10px 25px rgba(189, 178, 163, 0.2);
            transform: scale(0.8);
            transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
        }

        .overlay.show .win-card { transform: scale(1); }

        .btn-large {
            padding: 15px 40px;
            font-size: 1.5rem;
            font-weight: 700;
            border: none;
            border-radius: 30px;
            cursor: pointer;
            transition: all 0.1s;
            background: var(--green);
            color: var(--green-text);
            box-shadow: 0 8px 0 var(--green-shadow);
        }

        .btn-large:active {
            transform: translateY(8px);
            box-shadow: 0 0 0 var(--green-shadow);
        }

        .btn-large.secondary {
            background: var(--blue);
            color: var(--blue-text);
            box-shadow: 0 8px 0 var(--blue-shadow);
        }

        .btn-large.secondary:active { box-shadow: 0 0 0 var(--blue-shadow); }

        #home-screen {
            position: relative;
            background-image: radial-gradient(rgba(255, 139, 167, 0.12) 2px, transparent 2px);
            background-size: 28px 28px;
            background-position: -14px -14px;
        }

        #confetti-canvas {
            position: fixed;
            inset: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 100;
        }

        .home-content { position: relative; z-index: 1; }

        #splash-screen {
            background-image: radial-gradient(rgba(255, 139, 167, 0.12) 2px, transparent 2px);
            background-size: 28px 28px;
            background-position: -14px -14px;
        }

        /* ===== Loading screen ===== */
        #loading-screen {
            background-image: radial-gradient(rgba(255, 139, 167, 0.12) 2px, transparent 2px);
            background-size: 28px 28px;
            background-position: -14px -14px;
        }

        .loading-spinner {
            width: 64px;
            height: 64px;
            border-radius: 50%;
            border: 6px solid var(--bg-sunken);
            border-top-color: var(--pink);
            animation: loading-spin 0.9s linear infinite;
        }

        @keyframes loading-spin {
            to { transform: rotate(360deg); }
        }

        .loading-hint {
            margin-top: 22px;
            font-size: 1.15rem;
            font-weight: 600;
            color: var(--text-muted);
            animation: hint-fade 1.6s ease-in-out infinite;
        }

        .loading-subhint {
            margin-top: 6px;
            font-size: 0.95rem;
            font-weight: 500;
            color: var(--text-muted);
            opacity: 0.7;
            animation: hint-fade 1.6s ease-in-out infinite;
        }

        @keyframes hint-fade {
            0%, 100% { opacity: 0.5; }
            50%      { opacity: 1; }
        }

        @media (prefers-reduced-motion: reduce) {
            .loading-hint, .loading-subhint { animation: none; }
            .loading-spinner { animation-duration: 1.6s; }
        }

        .splash-icon {
            width: 130px;
            height: 130px;
            margin-bottom: 25px;
            border-radius: 40px;
            background: var(--bg-panel);
            color: var(--pink);
            font-size: 3.5rem;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 15px 35px rgba(255, 139, 167, 0.2);
        }

        #btn-start {
            font-size: 1.8rem;
            padding: 18px 60px;
        }

        /* ===== Entry & exit animations ===== */

        @keyframes screen-in {
            from { opacity: 0; transform: translateY(12px); }
            to   { opacity: 1; transform: translateY(0); }
        }

        .screen-enter {
            animation: screen-in 0.45s ease-out forwards;
        }
        .screen-enter.entered { animation: none; transform: none; }

        @keyframes card-pop-in {
            from { opacity: 0; transform: scale(0.6) translateY(30px); }
            to   { opacity: 1; transform: scale(1) translateY(0); }
        }
        .level-card {
            opacity: 0;
            animation: card-pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
        }

        @keyframes cell-drop-in {
            from { opacity: 0; transform: scale(0.2); }
            to   { opacity: 1; transform: scale(1); }
        }
        .pixel-cell {
            animation: cell-drop-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
        }
        .pixel-cell.entered { animation: none; }
        .pixel-cell.pop { animation: pop-in 0.12s ease-out !important; }

        @keyframes splash-rise {
            from { opacity: 0; transform: translateY(40px) scale(0.9); }
            to   { opacity: 1; transform: translateY(0) scale(1); }
        }
        @keyframes splash-rise-bounce {
            from { opacity: 0; transform: translateY(40px) scale(0.9) rotate(-3deg); }
            to   { opacity: 1; transform: translateY(0) scale(1) rotate(-3deg); }
        }
        .splash-icon  { animation: splash-rise-bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both, title-bounce 3s ease-in-out infinite 0.6s; }
        #splash-screen .title-text { animation: splash-rise-bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both, title-bounce 3s ease-in-out infinite 0.7s; }
        #splash-screen .slogan-text { animation: splash-rise 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both; }
        #btn-start { animation: splash-rise 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.35s both; }

        @keyframes start-pulse {
            0%, 100% { transform: scale(1); }
            50%      { transform: scale(1.06); }
        }
        #btn-start { will-change: transform; }
        #btn-start:not(:active) { animation: splash-rise 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.35s both, start-pulse 2s ease-in-out 1.2s infinite; }

        @media (prefers-reduced-motion: reduce) {
            .screen-enter, .level-card, .pixel-cell,
            .splash-icon, #splash-screen .title-text, #splash-screen .slogan-text,
            #btn-start { animation: none !important; opacity: 1 !important; }
        }

        @keyframes bubble-in {
            from { opacity: 0; transform: scale(0) translateY(20px); }
            to   { opacity: 1; transform: scale(1) translateY(0); }
        }
        .color-bubble {
            animation: bubble-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
        }
        @media (prefers-reduced-motion: reduce) {
            .color-bubble { animation: none !important; opacity: 1 !important; }
        }

        .info-card {
            position: relative;
            width: 90%;
            max-width: 420px;
            padding: 40px 30px 32px;
            text-align: center;
            background: var(--bg-panel);
            border-radius: var(--radius-card);
            box-shadow: 0 20px 50px rgba(189, 178, 163, 0.35);
            transform: scale(0.8);
            transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
        }

        .overlay.show .info-card { transform: scale(1); }

        .info-close {
            position: absolute;
            top: 18px;
            right: 18px;
            width: 42px;
            height: 42px;
            border: none;
            border-radius: 50%;
            background: var(--bg-sunken);
            color: var(--text-muted);
            font-size: 1.2rem;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.15s;
        }

        .info-close:hover {
            background: var(--pink-soft);
            color: var(--pink);
        }

        .info-close:active { transform: scale(0.9); }

        .info-icon {
            width: 90px;
            height: 90px;
            margin: 0 auto 18px;
            border-radius: 28px;
            background: var(--pink-soft);
            color: var(--pink);
            font-size: 2.4rem;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 8px 20px rgba(255, 139, 167, 0.25);
        }

        .info-title {
            font-size: 2rem;
            font-weight: 700;
            color: var(--pink);
            margin: 0 0 16px;
        }

        .info-text {
            font-size: 1.1rem;
            font-weight: 500;
            line-height: 1.6;
            color: var(--text-main);
            margin: 0 0 14px;
        }

        .info-credit {
            font-size: 0.95rem;
            font-weight: 600;
            color: var(--text-muted);
            margin: 20px 0 0;
        }
