/* ── Reset & Base ── */
:where(#app) *,
:where(#app) *::before,
:where(#app) *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
#app {
    width: 100%;
    max-width: 1200px;
    background: #FFFFFF;
    border-radius: 48px 48px 32px 32px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.05);
    padding: 24px 28px 32px;
    position: relative;
    overflow: hidden;
    transition: all 0.2s;
    border: 2px solid #EFE3CD;
}
@media (max-width: 700px) {
    #app {
        padding: 16px 14px 20px;
        border-radius: 28px;
    }
}
@media (max-width: 480px) {
    #app {
        padding: 12px 10px 16px;
        border-radius: 20px;
    }
}

/* ── Typography ── */
.hf-title {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #123B6D;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.hf-title .emoji {
    font-size: 2.2rem;
}
.hf-sub {
    font-size: 1.1rem;
    color: #2F4A6B;
    font-weight: 400;
    margin-top: 2px;
}
.hf-level-badge {
    background: #E4EFFB;
    color: #123B6D;
    padding: 6px 18px;
    border-radius: 40px;
    font-size: 0.95rem;
    font-weight: 600;
    display: inline-block;
    letter-spacing: 0.3px;
}
.hf-progress-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: #17508F;
}
.hf-feedback {
    font-size: 1.8rem;
    font-weight: 700;
    color: #E95762;
    min-height: 3.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.15s;
}
.hf-feedback .sub {
    font-size: 1rem;
    font-weight: 400;
    color: #2F4A6B;
}

/* ── Buttons ── */
.hf-btn {
    background: #EFE3CD;
    border: none;
    border-radius: 60px;
    padding: 12px 30px;
    font-size: 1.1rem;
    font-weight: 600;
    color: #123B6D;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}
.hf-btn:hover {
    background: #EFE3CD;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}
.hf-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.hf-btn-primary {
    background: #2778D4;
    color: #fff;
    box-shadow: 0 4px 12px rgba(74, 124, 155, 0.25);
}
.hf-btn-primary:hover {
    background: #1F62B0;
    box-shadow: 0 6px 18px rgba(74, 124, 155, 0.30);
}
.hf-btn-pink {
    background: #E95762;
    color: #fff;
    box-shadow: 0 4px 12px rgba(234, 106, 122, 0.25);
}
.hf-btn-pink:hover {
    background: #C13F4A;
    box-shadow: 0 6px 18px rgba(234, 106, 122, 0.30);
}
.hf-btn-green {
    background: #429748;
    color: #fff;
    box-shadow: 0 4px 12px rgba(123, 184, 122, 0.25);
}
.hf-btn-green:hover {
    background: #357A3A;
    box-shadow: 0 6px 18px rgba(123, 184, 122, 0.30);
}
.hf-btn-small {
    padding: 8px 18px;
    font-size: 0.9rem;
}
.hf-btn-icon {
    font-size: 1.3rem;
    line-height: 1;
}

/* ── Top Bar ── */
.top-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
    margin-bottom: 6px;
}
.top-left {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px 16px;
}
.top-right {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
.sound-toggle {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 40px;
    transition: background 0.1s;
    touch-action: manipulation;
}
.sound-toggle:hover {
    background: #EFE3CD;
}

/* ── Progress Bar ── */
.progress-wrap {
    width: 100%;
    height: 8px;
    background: #FFF8EA;
    border-radius: 20px;
    margin: 8px 0 14px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #E95762, #F5A0A6);
    border-radius: 20px;
    transition: width 0.35s ease;
}

/* ── Game Area ── */
.game-area {
    display: flex;
    gap: 20px;
    margin-top: 6px;
    min-height: 400px;
    position: relative;
}
@media (max-width: 700px) {
    .game-area {
        flex-direction: column;
        gap: 24px;
        min-height: 500px;
    }
}

.side {
    flex: 1;
    min-width: 0;
    background: #FFFFFF;
    border-radius: 28px;
    padding: 16px 12px;
    border: 2px dashed #EFE3CD;
    position: relative;
    transition: background 0.2s;
    display: flex;
    flex-direction: column;
}
.side-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #617389;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
    margin-bottom: 10px;
}

/* ── Shape Grid ── no card backgrounds ── */
.side-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
    gap: 14px 12px;
    flex: 1;
    align-content: start;
}
@media (max-width: 480px) {
    .side-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 10px 8px;
    }
}
@media (min-width: 900px) {
    .side-grid {
        grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
        gap: 18px 16px;
    }
}

/* ── Shape Slots – no card, just the shape ── */
.shape-slot {
    aspect-ratio: 1/1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    touch-action: none;
    cursor: grab;
    min-height: 56px;
    min-width: 56px;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    transition: transform 0.15s ease, opacity 0.2s;
}
.shape-slot.draggable {
    cursor: grab;
    background: transparent !important;
    border: none !important;
}
.shape-slot.draggable:hover {
    transform: scale(1.05);
}
.shape-slot.draggable:active {
    cursor: grabbing;
}
.shape-slot.target {
    cursor: pointer;
    background: transparent !important;
    border: none !important;
}
.shape-slot.target:hover {
    transform: scale(1.05);
}
.shape-slot.matched {
    cursor: default;
    pointer-events: none;
    opacity: 0.7;
    transform: scale(0.92);
}
.shape-slot.matched .shape-svg {
    filter: drop-shadow(0 0 6px rgba(123, 184, 122, 0.5));
}
.shape-slot .shape-svg {
    width: 90%;
    height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: transform 0.2s;
}
.shape-slot .shape-svg svg {
    width: 100%;
    height: 100%;
    display: block;
}
.shape-slot.dragging .shape-svg {
    transform: scale(1.15);
}
.shape-slot .match-check {
    position: absolute;
    top: -6px;
    right: -6px;
    font-size: 1.2rem;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}
.shape-slot.matched .match-check {
    opacity: 1;
    transform: scale(1);
}
.shape-slot.selected {
    transform: scale(1.12) !important;
    filter: drop-shadow(0 0 16px rgba(74, 124, 155, 0.5));
}

/* ── Drag Ghost ── */
.drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    width: 90px;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.92;
    transform: translate(-50%, -50%) scale(1.15);
    transition: none;
    will-change: transform, left, top;
    filter: drop-shadow(0 12px 32px rgba(0, 0, 0, 0.18));
}
.drag-ghost .ghost-shape {
    width: 90%;
    height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.drag-ghost .ghost-shape svg {
    width: 100%;
    height: 100%;
    display: block;
}
@media (max-width: 480px) {
    .drag-ghost {
        width: 68px;
        height: 68px;
    }
}

/* ── Toast feedback ── */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.85);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: 24px 40px;
    border-radius: 40px;
    box-shadow: 0 16px 60px rgba(0, 0, 0, 0.12);
    font-size: 2.2rem;
    font-weight: 700;
    color: #123B6D;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 2px solid rgba(255, 255, 255, 0.5);
    text-align: center;
    min-width: 200px;
}
.toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}
.toast .emoji-big {
    font-size: 2.8rem;
    display: block;
    margin-bottom: 4px;
}
@media (max-width: 480px) {
    .toast {
        font-size: 1.6rem;
        padding: 18px 28px;
        min-width: 160px;
    }
    .toast .emoji-big {
        font-size: 2.2rem;
    }
}

/* ── Tutorial ── */
.tutorial-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.tutorial-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.tutorial-card {
    background: #FFFFFF;
    border-radius: 48px;
    max-width: 520px;
    width: 100%;
    padding: 40px 36px 32px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.20);
    text-align: center;
    transform: scale(0.92) translateY(12px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 2px solid #EFE3CD;
}
.tutorial-overlay.active .tutorial-card {
    transform: scale(1) translateY(0);
}
.tutorial-card h2 {
    font-size: 2rem;
    color: #123B6D;
    margin-bottom: 6px;
}
.tutorial-card .steps {
    text-align: left;
    font-size: 1.1rem;
    color: #17508F;
    padding: 12px 0 8px 20px;
    line-height: 2;
}
.tutorial-card .steps li {
    list-style: none;
    position: relative;
    padding-left: 32px;
}
.tutorial-card .steps li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    width: 22px;
    height: 22px;
    background: #E95762;
    border-radius: 50%;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tutorial-card .steps li:nth-child(1)::before {
    content: '1';
}
.tutorial-card .steps li:nth-child(2)::before {
    content: '2';
}
.tutorial-card .steps li:nth-child(3)::before {
    content: '3';
}
.tutorial-card .demo-shapes {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 16px 0 8px;
    font-size: 3rem;
}
.tutorial-card .demo-shapes .arrow {
    font-size: 2rem;
    color: #617389;
}
.tutorial-card .btn-row {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 16px;
}

/* ── Level Complete ── */
.level-complete-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.20);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 15000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s;
}
.level-complete-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.level-complete-card {
    background: #FFFFFF;
    border-radius: 48px;
    max-width: 480px;
    width: 100%;
    padding: 40px 32px 32px;
    text-align: center;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.18);
    transform: scale(0.90) translateY(16px);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 2px solid #EFE3CD;
}
.level-complete-overlay.active .level-complete-card {
    transform: scale(1) translateY(0);
}
.level-complete-card .big-icon {
    font-size: 4rem;
}
.level-complete-card h2 {
    font-size: 2.2rem;
    color: #123B6D;
    margin: 8px 0 4px;
}
.level-complete-card .sub {
    font-size: 1.1rem;
    color: #2F4A6B;
    margin-bottom: 18px;
}
.level-complete-card .btn-row {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ── Confetti ── */
.confetti-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 16000;
    overflow: hidden;
}
.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    opacity: 0;
    animation: confettiFall linear forwards;
}
@keyframes confettiFall {
    0% {
        opacity: 1;
        transform: translateY(-20px) rotate(0deg) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(100vh) rotate(720deg) scale(0.3);
    }
}

/* ── Responsive ── */
@media (max-width: 700px) {
    .hf-title {
        font-size: 1.5rem;
    }
    .hf-title .emoji {
        font-size: 1.6rem;
    }
    .hf-sub {
        font-size: 0.95rem;
    }
    .hf-feedback {
        font-size: 1.4rem;
        min-height: 2.6rem;
    }
    .top-bar {
        gap: 8px 10px;
    }
    .side {
        padding: 12px 8px;
        border-radius: 20px;
    }
    .shape-slot {
        min-height: 48px;
        min-width: 48px;
    }
    .shape-slot .shape-svg {
        width: 86%;
        height: 86%;
    }
    .tutorial-card {
        padding: 28px 20px 24px;
    }
    .tutorial-card h2 {
        font-size: 1.6rem;
    }
    .level-complete-card {
        padding: 28px 20px 24px;
    }
    .level-complete-card h2 {
        font-size: 1.7rem;
    }
}
@media (max-width: 480px) {
    .shape-slot {
        min-height: 40px;
        min-width: 40px;
    }
    .shape-slot .shape-svg {
        width: 82%;
        height: 82%;
    }
    .side-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
        gap: 8px 6px;
    }
    .hf-btn {
        padding: 10px 20px;
        font-size: 0.95rem;
    }
    .hf-btn-small {
        padding: 6px 14px;
        font-size: 0.95rem;
    }
    .toast {
        font-size: 1.3rem;
        padding: 14px 20px;
        min-width: 130px;
    }
    .toast .emoji-big {
        font-size: 1.8rem;
    }
}

.hidden {
    display: none !important;
}
.mt-8 {
    margin-top: 8px;
}
.tap-hint {
    font-size: 0.95rem;
    color: #617389;
    text-align: center;
    margin-top: 6px;
    font-weight: 400;
    letter-spacing: 0.2px;
}
.tap-hint span {
    background: #EFE3CD;
    padding: 2px 10px;
    border-radius: 20px;
    display: inline-block;
}

/* scrollable side */
.side-grid {
    max-height: 480px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #EFE3CD transparent;
    padding-right: 4px;
}
.side-grid::-webkit-scrollbar {
    width: 5px;
}
.side-grid::-webkit-scrollbar-track {
    background: transparent;
}
.side-grid::-webkit-scrollbar-thumb {
    background: #EFE3CD;
    border-radius: 10px;
}
@media (max-width: 700px) {
    .side-grid {
        max-height: 340px;
    }
}
@media (max-width: 480px) {
    .side-grid {
        max-height: 280px;
    }
}

/* highlight for drop target */
.shape-slot.highlight {
    transform: scale(1.10) !important;
    filter: drop-shadow(0 0 20px rgba(74, 124, 155, 0.4));
}
    
