/* CSS RESET & DESIGN SYSTEM */
:root {
    --bg-gradient: linear-gradient(180deg, #0284c7 0%, #0369a1 40%, #0f172a 100%);
    --card-bg: rgba(15, 23, 42, 0.75);
    --card-border: rgba(255, 255, 255, 0.2);
    --glass-blur: blur(8px);

    --primary-cyan: #06b6d4;
    --primary-blue: #3b82f6;
    --primary-purple: #8b5cf6;
    --primary-pink: #ec4899;
    --primary-yellow: #f59e0b;
    --primary-green: #10b981;

    --font-heading: 'Fredoka', cursive, sans-serif;
    --font-body: 'Outfit', sans-serif;
    --font-handwriting: 'Dancing Script', 'Caveat', 'Itim', cursive, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: 
        radial-gradient(ellipse at 15% 15%, rgba(14, 165, 233, 0.28) 0%, transparent 45%),
        radial-gradient(ellipse at 85% 25%, rgba(168, 85, 247, 0.25) 0%, transparent 45%),
        radial-gradient(ellipse at 50% 75%, rgba(236, 72, 153, 0.22) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 85%, rgba(59, 130, 246, 0.25) 0%, transparent 45%),
        linear-gradient(180deg, #070a14 0%, #0c1222 40%, #050811 100%);
    background-attachment: fixed;
    font-family: var(--font-body);
    color: #ffffff;
}

#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 100;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* HEADER HUD */
.app-header {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--card-border);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 40;
    height: 70px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 2.2rem;
    animation: float 3s ease-in-out infinite alternate;
}

.logo-text-group {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(90deg, #38bdf8, #818cf8, #f472b6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 1px;
}

.logo-subtitle {
    font-size: 0.75rem;
    color: #94a3b8;
    letter-spacing: 2px;
    font-weight: 600;
}

.hud-stats {
    display: flex;
    gap: 12px;
    align-items: center;
}

.stat-pill {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 8px 18px;
    border-radius: 30px;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(8px);
}

.coin-pill {
    background: rgba(245, 158, 11, 0.25);
    border-color: var(--primary-yellow);
    color: #fef08a;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.3);
}

.btn-shop-badge {
    background: linear-gradient(135deg, #ec4899, #8b5cf6);
    color: #fff;
    font-family: var(--font-heading);
    font-size: 1.05rem;
    padding: 10px 20px;
    border-radius: 30px;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(236, 72, 153, 0.4);
    transition: transform 0.2s;
}

.btn-shop-badge:active {
    transform: scale(0.95);
}

.btn-secret-badge {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    padding: 10px 18px;
    border-radius: 30px;
    border: 2px solid #fef08a;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-secret-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(245, 158, 11, 0.6);
}

.btn-secret-badge:active {
    transform: scale(0.95);
}

/* NAVIGATION TABS */
.nav-tabs {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 12px 20px;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    z-index: 30;
}

.nav-tab {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 600;
    padding: 12px 26px;
    border-radius: 24px;
    border: 2px solid transparent;
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
}

.nav-tab.active {
    background: linear-gradient(135deg, var(--primary-cyan), var(--primary-blue));
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 25px rgba(6, 182, 212, 0.4);
    transform: translateY(-2px) scale(1.02);
}

/* GRADE SELECTION BAR */
.grade-selector-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 10px 24px;
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 2px solid var(--primary-cyan);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 25;
}

.grade-label {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    color: #fef08a;
    display: flex;
    align-items: center;
    gap: 6px;
}

.grade-pill-group {
    display: flex;
    gap: 10px;
}

.grade-pill {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    padding: 8px 22px;
    border-radius: 25px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.grade-pill:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    transform: translateY(-2px);
}

.grade-pill.active {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #0f172a;
    border-color: #fef08a;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.5);
    transform: scale(1.06);
}

/* MAIN CONTENT WORKSPACE (iPad Scroll Fix) */
.main-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 20px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 100vw;
}

.module-view {
    display: none;
    width: 100%;
    max-width: 1100px;
    animation: fadeIn 0.35s ease;
}

.module-view.active {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.module-header {
    text-align: center;
}

.module-header h2 {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    color: #ffffff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.module-header p {
    color: #bae6fd;
    font-size: 1.05rem;
}

/* INTERACTIVE TASK MENU STYLES */
.task-menu-container {
    background: rgba(15, 23, 42, 0.75);
    border: 1.5px solid var(--card-border);
    border-radius: 24px;
    padding: 18px 24px;
    margin-bottom: 10px;
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.task-menu-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: #fef08a;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.task-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.task-card-item {
    background: rgba(255, 255, 255, 0.07);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    text-align: left;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

.task-card-item * {
    pointer-events: none;
}

.task-card-item:hover {
    background: rgba(56, 189, 248, 0.18);
    border-color: #38bdf8;
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 10px 25px rgba(56, 189, 248, 0.3);
}

.task-card-item:active {
    transform: scale(0.97);
}

.task-card-item.active {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.35), rgba(59, 130, 246, 0.35));
    border-color: #38bdf8;
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.5);
    transform: translateY(-2px);
}

.task-card-icon {
    font-size: 2.2rem;
    flex-shrink: 0;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    transition: transform 0.2s;
}

.task-card-item:hover .task-card-icon {
    transform: scale(1.15) rotate(5deg);
}

.task-card-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.task-card-name {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
}

.task-card-desc {
    font-size: 0.8rem;
    color: #94a3b8;
    line-height: 1.3;
}

.task-card-badge {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    white-space: nowrap;
    transition: all 0.2s;
}

.task-card-item.active .task-card-badge {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.empty-prompt-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 45px 24px;
    gap: 12px;
    border: 2px dashed rgba(255, 255, 255, 0.25);
    background: rgba(15, 23, 42, 0.4);
    border-radius: 24px;
    margin-top: 10px;
}

.empty-prompt-card .prompt-icon {
    font-size: 3.5rem;
    animation: bounce 2s infinite;
}

.empty-prompt-card h3 {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    color: #38bdf8;
}

.empty-prompt-card p {
    color: #cbd5e1;
    font-size: 1rem;
}

/* CARDS & BUTTONS */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: var(--glass-blur);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.btn {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 16px;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
}

.btn-purple {
    background: linear-gradient(135deg, var(--primary-purple), #7c3aed);
    color: #fff;
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.btn-green {
    background: linear-gradient(135deg, var(--primary-green), #059669);
    color: #fff;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-sub {
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 10px 20px;
}

.btn-sub.active,
.btn-sub:hover {
    background: var(--primary-purple);
    color: #fff;
    border-color: #ffffff;
}

.subnav-toggle {
    display: none !important;
}

/* 1. AQUARIUM MODULE & SIDEBAR PANEL STYLES */
.aquarium-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 10px 18px;
    backdrop-filter: blur(8px);
    width: 100%;
}

.status-toggles {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.status-lbl {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    color: #94a3b8;
}

.btn-status {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    padding: 6px 14px;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-status.active,
.btn-status:hover {
    background: rgba(6, 182, 212, 0.3);
    border-color: var(--primary-cyan);
    color: #fff;
}

.aquarium-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* SIDE-BY-SIDE LAYOUT: CANVAS + SCROLLABLE SIDEBAR */
.aquarium-main-row {
    display: flex;
    gap: 16px;
    width: 100%;
    align-items: stretch;
}

.aquarium-container {
    position: relative;
    flex: 1;
    height: 480px;
    border-radius: 28px;
    border: 3px solid rgba(56, 189, 248, 0.4);
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7), inset 0 0 50px rgba(0, 0, 0, 0.5), 0 0 35px rgba(14, 165, 233, 0.25);
    background: linear-gradient(180deg, #0284c7 0%, #0369a1 40%, #0c4a6e 80%, #0f172a 100%);
    transition: background 0.5s ease;
}

#aquarium-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: pointer;
    touch-action: none;
}

/* SCROLLABLE SIDEBAR PANEL */
.aquarium-sidebar-panel {
    width: 250px;
    max-height: 480px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-title {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    color: #38bdf8;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    padding-bottom: 4px;
}

.sidebar-scroll-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-item-pill {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #e2e8f0;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-item-pill.active,
.sidebar-item-pill:hover {
    background: rgba(6, 182, 212, 0.25);
    border-color: var(--primary-cyan);
    color: #fff;
}

.sidebar-item-pill.selected {
    background: rgba(245, 158, 11, 0.25);
    border-color: #fbbf24;
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.4);
}

.sidebar-action-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-sidebar-act {
    border: none;
    border-radius: 8px;
    padding: 3px 7px;
    font-size: 0.72rem;
    font-family: var(--font-heading);
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn-sidebar-act:active {
    transform: scale(0.95);
}

.btn-sidebar-act:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-pick-fish {
    background: linear-gradient(135deg, var(--primary-purple), #7c3aed);
    color: #fff;
}

.btn-place-deco {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
}

.btn-select-deco {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
}

.btn-retrieve {
    background: linear-gradient(135deg, #f43f5e, #e11d48);
    color: #fff;
}

.dirty-water-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(101, 163, 13, 0);
    pointer-events: none;
    transition: background 0.5s ease;
}

.sponge-cursor {
    position: absolute;
    font-size: 2.8rem;
    pointer-events: none;
    z-index: 50;
    transform: translate(-50%, -50%);
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
}

.feed-hint-bar {
    text-align: center;
    font-size: 0.9rem;
    color: #7dd3fc;
}

/* 2. MATH MODULE STYLES */
.math-playground {
    min-height: 380px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
}

#math-challenge-area {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.math-card-inner {
    text-align: center;
    width: 100%;
    max-width: 540px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.math-question-text {
    font-family: var(--font-heading);
    font-size: 2.8rem;
    color: #fef08a;
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.math-options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    width: 100%;
}

.math-opt-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 20px;
    font-family: var(--font-heading);
    font-size: 2rem;
    color: #ffffff;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    min-height: 70px;
}

.math-opt-btn:active {
    transform: scale(0.95);
}

.math-opt-btn:hover {
    background: rgba(56, 189, 248, 0.3);
    border-color: var(--primary-cyan);
}

.visual-count-row {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    font-size: 3rem;
    margin-bottom: 10px;
}

/* 3. COMBINED VIETNAMESE MODULE STYLES */
.vietnamese-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

@media (max-width: 900px) {
    .vietnamese-grid {
        grid-template-columns: 1fr;
    }
}

.section-subtitle {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    color: #fef08a;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alphabet-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.alphabet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
    gap: 10px;
}

.alpha-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    font-family: var(--font-handwriting);
    font-size: 1.9rem;
    font-weight: 700;
    color: #fff;
    height: 65px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.alpha-btn.active,
.alpha-btn:hover {
    background: linear-gradient(135deg, #ec4899, #8b5cf6);
    border-color: #ffffff;
    transform: scale(1.1);
    box-shadow: 0 6px 15px rgba(236, 72, 153, 0.4);
}

.alphabet-preview-box {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    padding: 20px 28px;
    display: flex;
    align-items: center;
    gap: 24px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.preview-letter {
    font-family: var(--font-handwriting);
    font-size: 5rem;
    font-weight: 700;
    color: var(--primary-yellow);
    text-shadow: 0 0 20px var(--primary-yellow);
    letter-spacing: 2px;
}

.preview-details h3 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    color: #38bdf8;
}

.preview-details p {
    margin: 6px 0 14px;
    color: #cbd5e1;
    font-size: 1.05rem;
}

.spelling-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
}

.spelling-emoji {
    font-size: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: normal;
}

.spelling-slots {
    display: flex;
    gap: 12px;
    min-height: 70px;
}

.spell-slot {
    width: 60px;
    height: 70px;
    border: 2px dashed var(--primary-cyan);
    border-radius: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--font-heading);
    font-size: 2rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.2);
}

.spelling-tiles {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.spell-tile {
    width: 55px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-purple), var(--primary-pink));
    border-radius: 14px;
    font-family: var(--font-heading);
    font-size: 1.8rem;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}

/* 4. WRITING MODULE STYLES */
.writing-playground {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

.letter-selector-bar {
    display: none !important;
}

.write-letter-pill {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 8px 16px;
    font-family: var(--font-heading);
    font-size: 1.3rem;
    color: #fff;
    cursor: pointer;
    min-width: 44px;
    text-align: center;
}

.write-letter-pill.active {
    background: var(--primary-purple);
    border-color: #fff;
}

.writing-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-width: 520px;
}

.canvas-wrapper {
    position: relative;
    width: 650px;
    max-width: 100%;
    height: 380px;
    margin: 0 auto;
    background: #0f172a;
    border: 3px solid var(--primary-cyan);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 0 25px rgba(56, 189, 248, 0.25), inset 0 0 20px rgba(0, 0, 0, 0.8);
    touch-action: none;
}

#writing-canvas {
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: crosshair;
    display: block;
}

.canvas-wrapper.canvas-success {
    border-color: #4ade80 !important;
    box-shadow: 0 0 35px rgba(74, 222, 128, 0.6), inset 0 0 25px rgba(74, 222, 128, 0.2) !important;
    animation: canvasPulseSuccess 0.6s ease-in-out 2;
}

.canvas-wrapper.canvas-error {
    border-color: #f87171 !important;
    box-shadow: 0 0 35px rgba(248, 113, 113, 0.6), inset 0 0 25px rgba(248, 113, 113, 0.2) !important;
    animation: canvasShakeError 0.5s ease-in-out;
}

.canvas-wrapper.canvas-warning {
    border-color: #fbbf24 !important;
    box-shadow: 0 0 35px rgba(251, 191, 36, 0.6), inset 0 0 25px rgba(251, 191, 36, 0.2) !important;
}

@keyframes canvasPulseSuccess {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.015); }
}

@keyframes canvasShakeError {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

.writing-feedback-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
}

.writing-feedback-badge.visible {
    opacity: 1;
    transform: translateY(0);
}

.writing-feedback-badge.badge-success {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.4);
    box-shadow: 0 2px 10px rgba(74, 222, 128, 0.2);
}

.writing-feedback-badge.badge-error {
    background: rgba(248, 113, 113, 0.15);
    color: #f87171;
    border: 1px solid rgba(248, 113, 113, 0.4);
    box-shadow: 0 2px 10px rgba(248, 113, 113, 0.2);
}

.writing-feedback-badge.badge-warning {
    background: rgba(251, 191, 36, 0.15);
    color: #facc15;
    border: 1px solid rgba(251, 191, 36, 0.4);
    box-shadow: 0 2px 10px rgba(251, 191, 36, 0.2);
}


.writing-actions {
    display: flex;
    gap: 14px;
    width: 100%;
    justify-content: center;
}

/* SHOP MODAL */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 20px;
}

.glass-card.shop-modal-card {
    background: rgba(15, 23, 42, 0.96);
    border: 1.5px solid var(--card-border);
    border-radius: 28px;
    padding: 24px 24px 18px;
    max-width: 720px;
    width: 95%;
    max-height: 85vh;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-close-btn {
    position: absolute;
    top: 18px;
    right: 22px;
    font-size: 2rem;
    color: #94a3b8;
    cursor: pointer;
    z-index: 10;
    line-height: 1;
    transition: color 0.2s ease;
}

.modal-close-btn:hover {
    color: #f87171;
}

.shop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding-right: 48px;
    flex-shrink: 0;
}

.shop-header h2 {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    color: #38bdf8;
}

.shop-coin-badge {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    color: #fef08a;
    white-space: nowrap;
}

.shop-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    flex-shrink: 0;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.shop-tabs .btn-sub {
    flex: 1;
    min-height: 42px;
    padding: 8px 10px;
    font-size: 0.92rem;
    font-weight: 700;
    border-radius: 16px;
    white-space: nowrap;
    text-align: center;
    justify-content: center;
    align-items: center;
    display: inline-flex;
    cursor: pointer;
    transition: all 0.2s ease;
}

.shop-tabs .btn-sub.active {
    background: linear-gradient(135deg, #0284c7, #38bdf8);
    color: #ffffff;
    border-color: #7dd3fc;
    box-shadow: 0 4px 16px rgba(56, 189, 248, 0.4);
}

.shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 4px 20px;
}

.shop-item-card {
    background: rgba(30, 41, 59, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 14px 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 175px;
    box-sizing: border-box;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.shop-item-card:hover {
    border-color: rgba(56, 189, 248, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.shop-item-icon {
    font-size: 2.6rem;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
}

.shop-item-name {
    font-family: var(--font-heading);
    font-size: 0.88rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.25;
}

.shop-item-price {
    font-family: var(--font-heading);
    color: #fef08a;
    font-size: 0.85rem;
    font-weight: 700;
}

.owned-tag {
    color: #38bdf8;
    font-weight: 700;
}

.owned-count {
    display: block;
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 2px;
}

.btn-buy {
    background: linear-gradient(135deg, var(--primary-green), #059669);
    color: #fff;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 8px 4px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 36px;
    transition: background 0.2s ease, transform 0.15s ease;
}

.btn-buy:disabled {
    background: #475569;
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-buy.btn-need-coins {
    background: linear-gradient(135deg, #475569, #334155);
    color: #fef08a;
    border: 1px dashed rgba(254, 240, 138, 0.4);
}

.btn-buy.btn-need-coins:hover {
    background: linear-gradient(135deg, #64748b, #475569);
    color: #ffffff;
}

.btn-buy.btn-apply {
    background: linear-gradient(135deg, #0284c7, #06b6d4);
    color: #ffffff;
}

.btn-buy.btn-apply:hover {
    background: linear-gradient(135deg, #0369a1, #0284c7);
}

.btn-buy.btn-active {
    background: linear-gradient(135deg, #eab308, #ca8a04);
    color: #0f172a;
    font-weight: 800;
}

/* BACKGROUND CARD SPECIAL STYLES */
.shop-bg-card {
    padding: 0 !important;
    overflow: hidden;
    gap: 0 !important;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    min-height: 190px;
}

.shop-bg-card.unlocked {
    border-color: rgba(56, 189, 248, 0.5);
}

.shop-bg-card.active-theme {
    border: 2px solid #facc15;
    box-shadow: 0 0 15px rgba(250, 204, 21, 0.4);
}

.shop-bg-preview {
    width: 100%;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}

.shop-bg-emoji {
    font-size: 2.3rem;
    filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.5));
}

.shop-bg-lock {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 0.9rem;
    background: rgba(0, 0, 0, 0.65);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shop-bg-active-tag {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    font-weight: 800;
    background: #facc15;
    color: #0f172a;
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.shop-bg-info {
    padding: 10px 8px 12px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    gap: 6px;
    box-sizing: border-box;
    background: rgba(15, 23, 42, 0.9);
}

/* ANIMATIONS */
.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {
    0% {
        transform: translateY(0);
    }

    100% {
        transform: translateY(-8px);
    }
}

/* NON-BLOCKING FLOATING TOAST NOTIFICATIONS */
.toast-container {
    position: fixed;
    top: 75px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.toast-box {
    background: rgba(15, 23, 42, 0.92);
    border: 2px solid var(--primary-cyan);
    color: #fff;
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    padding: 10px 22px;
    border-radius: 50px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), 0 0 15px rgba(6, 182, 212, 0.4);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toastSlideDown 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    pointer-events: auto;
}

.toast-box.warning {
    border-color: #f59e0b;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), 0 0 18px rgba(245, 158, 11, 0.5);
    background: rgba(45, 26, 3, 0.95);
    color: #fef08a;
}

.toast-box.error {
    border-color: #ef4444;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), 0 0 18px rgba(239, 68, 68, 0.5);
    background: rgba(45, 10, 10, 0.95);
    color: #fca5a5;
}

.toast-box.success {
    border-color: #10b981;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), 0 0 18px rgba(16, 185, 129, 0.5);
    background: rgba(6, 37, 24, 0.95);
    color: #a7f3d0;
}

.toast-box.fade-out {
    animation: toastFadeOut 0.3s forwards;
}

@keyframes toastSlideDown {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastFadeOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(-15px) scale(0.9);
    }
}

/* RESPONSIVE IPAD FIT */
@media (max-width: 768px) {
    .nav-tab {
        padding: 8px 14px;
        font-size: 0.95rem;
    }

    .canvas-wrapper {
        width: 100%;
        height: 260px;
    }

    .math-opt-btn {
        font-size: 1.6rem;
        padding: 14px;
    }

    .spelling-emoji {
        font-size: 3.5rem;
    }

    .aquarium-toolbar {
        flex-direction: column;
        gap: 10px;
    }

    .aquarium-main-row {
        flex-direction: column;
    }

    .aquarium-sidebar-panel {
        width: 100%;
        max-height: 200px;
    }
}

/* GAMIFICATION STYLES */
.badge-pill {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.3), rgba(245, 158, 11, 0.3));
    border: 2px solid #fef08a;
    color: #fef08a;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 20px;
}

.gamification-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: rgba(0, 0, 0, 0.35);
    padding: 10px 18px;
    border-radius: 16px;
    margin-bottom: 14px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.progress-bar-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.progress-bar-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: #fef08a;
    font-family: var(--font-heading);
}

.progress-track {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #38bdf8, #22c55e);
    border-radius: 10px;
    transition: width 0.3s ease;
}

.streak-badge {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 0.9rem;
    padding: 6px 14px;
    border-radius: 20px;
    background: rgba(56, 189, 248, 0.2);
    border: 1px solid #38bdf8;
    color: #38bdf8;
}

.combo-streak {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.4), rgba(234, 179, 8, 0.4));
    border-color: #fef08a;
    color: #fef08a;
    box-shadow: 0 0 12px rgba(254, 240, 138, 0.4);
}

.super-streak {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.5), rgba(245, 158, 11, 0.5));
    border-color: #ef4444;
    color: #ffffff;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.6);
}

/* MYSTERY GIFT MODAL & PRESENT BOX STYLES */
.gift-modal-card {
    text-align: center;
    width: 90%;
    max-width: 480px;
    padding: 30px 24px;
    border-radius: 32px;
    background: rgba(15, 23, 42, 0.96) !important;
    border: 2.5px solid rgba(255, 255, 255, 0.22) !important;
    box-shadow: 0 25px 65px rgba(0, 0, 0, 0.92), 0 0 50px rgba(56, 189, 248, 0.35) !important;
    position: relative;
    overflow: hidden;
}

.gift-box-header h2 {
    font-size: 1.65rem;
    font-weight: 800;
    color: #ffffff;
    text-shadow: 0 0 14px rgba(255, 255, 255, 0.45);
}

.gift-box-header p {
    color: #cbd5e1;
    font-size: 0.98rem;
    margin-top: 6px;
}

/* Interactive Present Box Container (Scaled Down to Sleek 220x220) */
.gift-box-container {
    position: relative;
    width: 220px;
    height: 220px;
    margin: 16px auto 14px auto;
    cursor: pointer;
    user-select: none;
    perspective: 1000px;
}

/* 3D Present Box Main Card (Box Body) */
.gift-box-card {
    position: relative;
    width: 190px;
    height: 170px;
    margin: 28px auto 0 auto;
    border-radius: 20px;
    background: linear-gradient(140deg, #e11d48 0%, #be123c 50%, #881337 100%);
    border: 3px solid rgba(255, 255, 255, 0.45);
    box-shadow: inset 0 8px 18px rgba(255, 255, 255, 0.55), inset -6px -6px 20px rgba(0, 0, 0, 0.6), 0 20px 48px rgba(0, 0, 0, 0.8), 0 0 30px rgba(253, 224, 71, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transform-style: preserve-3d;
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
    animation: bounceGift 1.5s infinite alternate ease-in-out;
}

.gift-box-container:hover .gift-box-card {
    transform: scale(1.05) translateY(-3px) rotate(2deg);
    box-shadow: inset 0 10px 22px rgba(255, 255, 255, 0.75), inset -6px -6px 20px rgba(0, 0, 0, 0.5), 0 26px 58px rgba(0, 0, 0, 0.9);
}

.gift-box-container:active .gift-box-card {
    transform: scale(0.93) translateY(3px);
}

/* Continuous Glossy Light Shimmer Glint */
.gift-shimmer-light {
    position: absolute;
    top: -60%;
    left: -60%;
    width: 220%;
    height: 220%;
    background: linear-gradient(
        115deg,
        rgba(255, 255, 255, 0) 35%,
        rgba(255, 255, 255, 0.4) 48%,
        rgba(255, 255, 255, 0.75) 50%,
        rgba(255, 255, 255, 0.4) 52%,
        rgba(255, 255, 255, 0) 65%
    );
    pointer-events: none;
    z-index: 12;
    animation: giftShimmer 3.8s infinite ease-in-out;
}

@keyframes giftShimmer {
    0% { transform: translate(-85%, -85%); }
    22% { transform: translate(85%, 85%); }
    100% { transform: translate(85%, 85%); }
}

/* ==========================================================================
   DYNAMIC 3D GIFT ARCHETYPES (Chest, Orb, Cyber, Egg, Sweet, Royal)
   ========================================================================== */

/* 1. TREASURE CHEST ARCHETYPE */
.gift-shape-chest {
    border-radius: 14px 14px 22px 22px !important;
    border: 4px solid #facc15 !important;
    box-shadow: inset 0 8px 16px rgba(255, 255, 255, 0.4), inset 0 -12px 24px rgba(0, 0, 0, 0.7), 0 20px 48px rgba(0, 0, 0, 0.9) !important;
}
.gift-shape-chest .gift-ribbon-v,
.gift-shape-chest .gift-ribbon-h {
    display: none !important;
}
.gift-shape-chest .gift-box-lid {
    border-radius: 36px 36px 8px 8px !important;
    height: 50px !important;
    top: -24px !important;
    border: 3.5px solid #facc15 !important;
}
.gift-shape-chest .gift-bow-3d {
    display: none !important;
}
.gift-chest-band {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 22px;
    background: linear-gradient(180deg, #facc15 0%, #ca8a04 50%, #713f12 100%);
    border: 1.5px solid #fef08a;
    box-shadow: inset 0 2px 4px rgba(255,255,255,0.8), 0 0 10px rgba(0,0,0,0.5);
    z-index: 6;
}
.gift-chest-band.band-left { left: 24px; }
.gift-chest-band.band-right { right: 24px; }
.gift-chest-lock {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    width: 38px;
    height: 48px;
    background: radial-gradient(circle at 35% 35%, #fef08a 0%, #eab308 60%, #854d0e 100%);
    border: 2.5px solid #ffffff;
    border-radius: 8px 8px 16px 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.7), inset 0 2px 4px rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    z-index: 15;
}

/* 2. COSMIC GALAXY ORB / CRYSTAL SPHERE ARCHETYPE */
.gift-shape-orb {
    width: 180px !important;
    height: 180px !important;
    border-radius: 50% !important;
    border: 3px solid rgba(255, 255, 255, 0.7) !important;
    box-shadow: inset -15px -15px 35px rgba(0, 0, 0, 0.75), inset 12px 12px 25px rgba(255, 255, 255, 0.6), 0 0 45px rgba(56, 189, 248, 0.8) !important;
}
.gift-shape-orb .gift-ribbon-v,
.gift-shape-orb .gift-ribbon-h {
    display: none !important;
}
.gift-shape-orb .gift-box-lid {
    width: 140px !important;
    height: 28px !important;
    top: -14px !important;
    border-radius: 50% !important;
    background: radial-gradient(ellipse at center, rgba(255,255,255,0.9) 0%, rgba(253,224,71,0.7) 50%, rgba(0,0,0,0) 100%) !important;
    border: none !important;
    box-shadow: 0 0 25px rgba(253, 224, 71, 0.9) !important;
}
.gift-shape-orb .gift-bow-3d {
    display: none !important;
}
.gift-orb-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 230px;
    height: 60px;
    margin-top: -30px;
    margin-left: -115px;
    border-radius: 50%;
    border: 5px solid rgba(253, 224, 71, 0.85);
    box-shadow: 0 0 25px rgba(253, 224, 71, 0.9), inset 0 0 15px rgba(249, 115, 22, 0.8);
    transform: rotateX(72deg) rotateY(15deg);
    pointer-events: none;
    z-index: 14;
    animation: orbRingSpin 6s infinite linear;
}
@keyframes orbRingSpin {
    0% { transform: rotateX(72deg) rotateZ(0deg); }
    100% { transform: rotateX(72deg) rotateZ(360deg); }
}

/* 3. CYBERPOD / SCI-FI CAPSULE ARCHETYPE */
.gift-shape-cyber {
    border-radius: 55px !important;
    border: 3.5px solid #22d3ee !important;
    box-shadow: inset 0 0 25px rgba(34, 211, 238, 0.4), inset -8px -8px 25px rgba(0, 0, 0, 0.8), 0 0 40px rgba(34, 211, 238, 0.6) !important;
}
.gift-shape-cyber .gift-ribbon-v,
.gift-shape-cyber .gift-ribbon-h {
    display: none !important;
}
.gift-shape-cyber .gift-box-lid {
    border-radius: 40px 40px 10px 10px !important;
    height: 46px !important;
    top: -22px !important;
    border: 3px solid #22d3ee !important;
    background: linear-gradient(140deg, #0891b2 0%, #164e63 100%) !important;
}
.gift-shape-cyber .gift-bow-3d {
    display: none !important;
}
.gift-cyber-hud {
    position: absolute;
    inset: 12px;
    border-radius: 40px;
    border: 1.5px dashed rgba(34, 211, 238, 0.7);
    pointer-events: none;
    z-index: 7;
}
.gift-cyber-scan {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: #22d3ee;
    box-shadow: 0 0 12px #22d3ee;
    z-index: 8;
    animation: cyberScanline 2.2s infinite ease-in-out;
}
@keyframes cyberScanline {
    0% { top: 10%; opacity: 0; }
    50% { opacity: 1; }
    100% { top: 90%; opacity: 0; }
}

/* 4. MYTHICAL EGG / GEODE ARCHETYPE */
.gift-shape-egg {
    width: 175px !important;
    height: 195px !important;
    border-radius: 50% 50% 45% 45% / 58% 58% 42% 42% !important;
    border: 3.5px solid rgba(255, 255, 255, 0.7) !important;
    box-shadow: inset -12px -12px 30px rgba(0, 0, 0, 0.7), inset 10px 10px 22px rgba(255, 255, 255, 0.5), 0 0 35px rgba(249, 115, 22, 0.6) !important;
}
.gift-shape-egg .gift-ribbon-v,
.gift-shape-egg .gift-ribbon-h {
    display: none !important;
}
.gift-shape-egg .gift-box-lid {
    width: 140px !important;
    height: 52px !important;
    top: -24px !important;
    border-radius: 50% 50% 20% 20% !important;
    border: 3px solid #ffffff !important;
}
.gift-shape-egg .gift-bow-3d {
    display: none !important;
}
.gift-egg-shell {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(circle at 50% 30%, rgba(255,255,255,0.3) 0%, rgba(0,0,0,0.4) 80%);
    pointer-events: none;
    z-index: 6;
}

/* 5. SWEET CAKE / DESSERT ARCHETYPE */
.gift-shape-sweet {
    border-radius: 26px !important;
    border: 3.5px solid #fbcfe8 !important;
    box-shadow: inset 0 8px 16px rgba(255, 255, 255, 0.7), inset 0 -10px 20px rgba(0, 0, 0, 0.4), 0 0 35px rgba(244, 114, 182, 0.6) !important;
}
.gift-shape-sweet .gift-box-lid {
    border-radius: 18px 18px 10px 10px !important;
    background: linear-gradient(140deg, #ffffff 0%, #fbcfe8 60%, #f472b6 100%) !important;
    border: 3px solid #ffffff !important;
}
.gift-sweet-drips {
    position: absolute;
    top: -4px;
    left: 0;
    right: 0;
    height: 18px;
    background: radial-gradient(circle at 10px 0, #ffffff 12px, transparent 13px) repeat-x;
    background-size: 24px 18px;
    z-index: 13;
    pointer-events: none;
}
.gift-sweet-cherry {
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.8rem;
    z-index: 32;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5));
}

/* ==========================================================================
   35+ INDIVIDUAL UNIQUE GIFT THEME DESIGNS (.gift-theme-1 to .gift-theme-35)
   ========================================================================== */

/* Theme 1: Gold Royal */
.gift-theme-1 { border-color: #fde047 !important; }

/* Theme 2: Dragon Egg */
.gift-theme-2 { border-radius: 50% 50% 40% 40% / 60% 60% 40% 40% !important; border-color: #f97316 !important; }
.gift-dragon-flame { position: absolute; bottom: -12px; left: 50%; transform: translateX(-50%); font-size: 2rem; z-index: 20; animation: flameFlicker 0.8s infinite alternate; }
@keyframes flameFlicker { 0% { transform: translateX(-50%) scale(0.9) rotate(-3deg); } 100% { transform: translateX(-50%) scale(1.15) rotate(3deg); } }

/* Theme 3: Diamond Crystal */
.gift-theme-3 { clip-path: polygon(25% 0%, 75% 0%, 100% 30%, 100% 70%, 75% 100%, 25% 100%, 0% 70%, 0% 30%); border-radius: 0 !important; }

/* Theme 4: Rainbow Unicorn */
.gift-theme-4 { border-radius: 35px !important; border-color: #f472b6 !important; }
.gift-unicorn-horn { position: absolute; top: -36px; left: 50%; transform: translateX(-50%); font-size: 2.2rem; z-index: 35; }

/* Theme 5: Sci-Fi Rocket */
.gift-theme-5 { border-radius: 45px 45px 12px 12px !important; }
.gift-rocket-fire { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); font-size: 1.8rem; animation: rocketPulse 0.3s infinite alternate; }
@keyframes rocketPulse { 0% { transform: translateX(-50%) scaleY(0.8); } 100% { transform: translateX(-50%) scaleY(1.3); } }

/* Theme 6: Magic Crystal Orb */
.gift-theme-6 { border-radius: 50% !important; width: 180px !important; height: 180px !important; }
.gift-magic-runes { position: absolute; inset: -15px; border-radius: 50%; border: 2px dashed #c084fc; animation: orbRingSpin 10s infinite linear; pointer-events: none; }

/* Theme 7: King Crown Pedestal */
.gift-theme-7 .gift-box-lid { border-radius: 20px 20px 4px 4px !important; }
.gift-crown-top { position: absolute; top: -32px; left: 50%; transform: translateX(-50%); font-size: 2.2rem; z-index: 35; }

/* Theme 8: Ice Glacier Cube */
.gift-theme-8 { border-radius: 8px !important; border: 3px solid #7dd3fc !important; box-shadow: 0 0 30px #38bdf8, inset 0 0 20px #ffffff !important; }
.gift-ice-drips { position: absolute; bottom: -12px; left: 0; right: 0; height: 14px; background: repeating-linear-gradient(90deg, #e0f2fe, #e0f2fe 6px, transparent 6px, transparent 18px); z-index: 15; }

/* Theme 9: Volcano Lava Rock */
.gift-theme-9 { border-radius: 35% 65% 55% 45% / 55% 45% 55% 45% !important; border: 3.5px solid #ff7d00 !important; }
.gift-lava-ember { position: absolute; inset: 0; background: radial-gradient(circle, rgba(249,115,22,0.4) 0%, transparent 70%); animation: emberPulse 1.5s infinite alternate; }
@keyframes emberPulse { 0% { opacity: 0.3; } 100% { opacity: 0.95; } }

/* Theme 10: Pirate Treasure Chest */
.gift-theme-10 { border-radius: 12px 12px 20px 20px !important; border: 4px solid #fbbf24 !important; }
.gift-pirate-badge { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); font-size: 1.6rem; z-index: 20; }

/* Theme 11: Mermaid Shell */
.gift-theme-11 { border-radius: 50% 50% 20% 20% !important; }
.gift-shell-pearl { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 32px; height: 32px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffffff, #ccfbf1, #14b8a6); box-shadow: 0 0 20px #ffffff; z-index: 15; }

/* Theme 12: Lightning Energy Cell */
.gift-theme-12 { border-radius: 35px !important; border: 3.5px solid #facc15 !important; }
.gift-lightning-bolt { position: absolute; top: -20px; right: 10px; font-size: 1.8rem; z-index: 30; animation: zapFlash 0.6s infinite alternate; }
@keyframes zapFlash { 0% { opacity: 0.2; transform: scale(0.8); } 100% { opacity: 1; transform: scale(1.2); } }

/* Theme 13: Sakura Origami */
.gift-theme-13 { border-radius: 16px !important; }
.gift-sakura-petal { position: absolute; top: -10px; left: 20%; font-size: 1.4rem; animation: floatPetal 3s infinite ease-in-out; }
@keyframes floatPetal { 0% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(15px) rotate(180deg); } 100% { transform: translateY(0) rotate(360deg); } }

/* Theme 14: Cyber Robot 2077 */
.gift-theme-14 { border-radius: 40px !important; border: 3.5px solid #22d3ee !important; }
.gift-cyber-visor { position: absolute; top: 25px; left: 15px; right: 15px; height: 24px; border-radius: 12px; background: #0891b2; box-shadow: 0 0 16px #22d3ee; z-index: 18; }

/* Theme 15: Halloween Pumpkin */
.gift-theme-15 { border-radius: 48% !important; border: 3.5px solid #fb923c !important; }
.gift-pumpkin-stem { position: absolute; top: -26px; left: 50%; transform: translateX(-50%); font-size: 1.8rem; z-index: 30; }

/* Theme 16: Xmas Gift Tree */
.gift-theme-16 { border-radius: 18px !important; border: 3.5px solid #4ade80 !important; }
.gift-xmas-holly { position: absolute; top: -22px; left: 15px; font-size: 1.5rem; z-index: 30; }

/* Theme 17: Championship Trophy */
.gift-theme-17 { border-radius: 20px 20px 35px 35px !important; border: 4px solid #fde047 !important; }
.gift-trophy-handles { position: absolute; top: 30px; left: -16px; right: -16px; height: 50px; border: 4px solid #fde047; border-radius: 25px; pointer-events: none; z-index: 5; }

/* Theme 18: Galaxy Black Hole */
.gift-theme-18 { border-radius: 50% !important; width: 180px !important; height: 180px !important; box-shadow: 0 0 50px #818cf8, inset 0 0 30px #000000 !important; }
.gift-hole-spiral { position: absolute; inset: -10px; border-radius: 50%; border: 3px solid #c026d3; border-top-color: transparent; animation: spinSpiral 1.8s infinite linear; }
@keyframes spinSpiral { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Theme 19: Artist Palette */
.gift-theme-19 { border-radius: 50% 30% 50% 40% !important; }
.gift-paint-drip { position: absolute; bottom: 8px; right: 12px; font-size: 1.5rem; z-index: 20; }

/* Theme 20: Candy Present */
.gift-theme-20 { border-radius: 28px !important; }
.gift-candy-twist { position: absolute; top: -14px; left: -14px; font-size: 1.6rem; z-index: 30; }

/* Theme 21: Dinosaur Amber Fossil */
.gift-theme-21 { border-radius: 35px !important; border: 3.5px solid #a3e635 !important; }
.gift-fossil-stamp { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 2.5rem; opacity: 0.35; z-index: 7; }

/* Theme 22: Ice Cream Sundae */
.gift-theme-22 { border-radius: 22px 22px 40px 40px !important; }
.gift-sundae-cherry { position: absolute; top: -28px; left: 50%; transform: translateX(-50%); font-size: 2rem; z-index: 35; }

/* Theme 23: Archery Target */
.gift-theme-23 { border-radius: 50% !important; width: 180px !important; height: 180px !important; border: 4px solid #ef4444 !important; }
.gift-target-ring { position: absolute; inset: 20px; border-radius: 50%; border: 3px solid #ffffff; pointer-events: none; z-index: 8; }

/* Theme 24: UFO Alien Disk */
.gift-theme-24 { border-radius: 50% / 35% !important; height: 140px !important; margin-top: 45px !important; }
.gift-ufo-beam { position: absolute; bottom: -35px; left: 50%; transform: translateX(-50%); width: 90px; height: 35px; background: linear-gradient(180deg, rgba(34,197,94,0.7) 0%, rgba(34,197,94,0) 100%); clip-path: polygon(25% 0%, 75% 0%, 100% 100%, 0% 100%); z-index: 4; }

/* Theme 25: Bamboo Trunk */
.gift-theme-25 { border-radius: 18px !important; border: 3.5px solid #84cc16 !important; }
.gift-panda-ears { position: absolute; top: -20px; left: 10px; right: 10px; display: flex; justify-content: space-between; font-size: 1.6rem; z-index: 30; }

/* Theme 26: Piñata Star */
.gift-theme-26 { border-radius: 30px !important; border: 3.5px solid #38bdf8 !important; }
.gift-pinata-tassel { position: absolute; bottom: -16px; left: 50%; transform: translateX(-50%); font-size: 1.6rem; z-index: 20; }

/* Theme 27: Retro Arcade */
.gift-theme-27 { border-radius: 20px 20px 8px 8px !important; border: 4px solid #e879f9 !important; }
.gift-arcade-screen { position: absolute; top: 18px; left: 20px; right: 20px; height: 65px; border-radius: 8px; background: #3b0764; border: 2px solid #22d3ee; z-index: 12; }

/* Theme 28: Ocean Pearl Oyster */
.gift-theme-28 { border-radius: 50% 50% 30% 30% !important; }
.gift-oyster-glow { position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 25px #ffffff; pointer-events: none; z-index: 8; }

/* Theme 29: Saturn Planet */
.gift-theme-29 { border-radius: 50% !important; width: 175px !important; height: 175px !important; }
.gift-saturn-rings { position: absolute; top: 50%; left: 50%; width: 240px; height: 50px; margin-left: -120px; margin-top: -25px; border-radius: 50%; border: 6px solid #fde047; transform: rotate(-25deg); pointer-events: none; z-index: 14; }

/* Theme 30: Papyrus Scroll Vault */
.gift-theme-30 { border-radius: 40px !important; }
.gift-scroll-seal { position: absolute; top: 50%; right: 15px; transform: translateY(-50%); font-size: 1.8rem; z-index: 20; }

/* Theme 31: Japanese Torii Gate */
.gift-theme-31 { border-radius: 12px !important; border: 4px solid #dc2626 !important; }
.gift-torii-roof { position: absolute; top: -16px; left: -12px; right: -12px; height: 12px; background: #dc2626; border-radius: 6px 6px 0 0; border: 2px solid #ffffff; z-index: 28; }

/* Theme 32: Ocean Dolphin Water */
.gift-theme-32 { border-radius: 45% !important; border: 3.5px solid #67e8f9 !important; }
.gift-water-drops { position: absolute; top: -15px; right: 15px; font-size: 1.5rem; z-index: 30; }

/* Theme 33: Lucky 3D Star */
.gift-theme-33 { clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); border-radius: 0 !important; width: 190px !important; height: 190px !important; }

/* Theme 34: Rainbow Arch */
.gift-theme-34 { border-radius: 90px 90px 18px 18px !important; border: 4px solid #f472b6 !important; }

/* Theme 35: Birthday Cake */
.gift-theme-35 { border-radius: 20px 20px 14px 14px !important; border: 3.5px solid #fda4af !important; }
.gift-cake-candle { position: absolute; top: -32px; left: 50%; transform: translateX(-50%); font-size: 2rem; z-index: 35; }

/* 3D Present Box Lid Top Cap (Attached to Box Body to Follow All Animations) */
.gift-box-lid {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 212px;
    height: 44px;
    border-radius: 12px 12px 8px 8px;
    background: linear-gradient(140deg, #fef08a 0%, #f59e0b 60%, #b45309 100%);
    border: 3px solid #ffffff;
    box-shadow: inset 0 3px 8px rgba(255, 255, 255, 0.85), inset -3px -3px 8px rgba(0, 0, 0, 0.4), 0 10px 20px rgba(0, 0, 0, 0.65);
    z-index: 25;
    pointer-events: none;
    transition: transform 0.3s ease;
}

.gift-lid-lip {
    position: absolute;
    bottom: -6px;
    left: -2px;
    right: -2px;
    height: 6px;
    background: linear-gradient(180deg, rgba(0,0,0,0.45) 0%, rgba(0,0,0,0) 100%);
    border-radius: 0 0 8px 8px;
}

.gift-lid-ribbon {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 18px;
    transform: translateY(-50%);
    background: linear-gradient(180deg, rgba(255,255,255,0.6), #ca8a04 40%, #fde047);
    box-shadow: inset 0 1px 3px rgba(255,255,255,0.8);
}

/* Lush 3D Satin Ribbon Bow */
.gift-bow-3d {
    position: absolute;
    top: -32px;
    left: 50%;
    transform: translateX(-50%);
    width: 95px;
    height: 60px;
    z-index: 30;
    pointer-events: none;
}

.gift-bow-loop {
    position: absolute;
    width: 38px;
    height: 28px;
    background: linear-gradient(135deg, #ffffff 0%, #fef08a 35%, #eab308 70%, #854d0e 100%);
    border: 1.5px solid #ffffff;
    box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.9), 0 5px 12px rgba(0, 0, 0, 0.5);
}

.gift-bow-loop.loop-top-left {
    top: 4px;
    left: 4px;
    border-radius: 50% 50% 10% 50%;
    transform: rotate(-28deg);
}

.gift-bow-loop.loop-top-right {
    top: 4px;
    right: 4px;
    border-radius: 50% 50% 50% 10%;
    transform: rotate(28deg);
}

.gift-bow-loop.loop-bottom-left {
    bottom: 10px;
    left: 10px;
    border-radius: 50% 10% 50% 50%;
    transform: rotate(-55deg) scale(0.85);
    opacity: 0.9;
}

.gift-bow-loop.loop-bottom-right {
    bottom: 10px;
    right: 10px;
    border-radius: 10% 50% 50% 50%;
    transform: rotate(55deg) scale(0.85);
    opacity: 0.9;
}

.gift-bow-tail {
    position: absolute;
    top: 28px;
    width: 18px;
    height: 32px;
    background: linear-gradient(180deg, #fde047 0%, #ca8a04 70%, #854d0e 100%);
    border: 1.2px solid #ffffff;
    z-index: 1;
}

.gift-bow-tail.tail-left {
    left: 24px;
    transform: rotate(22deg) skewX(12deg);
    border-radius: 2px 2px 8px 0;
}

.gift-bow-tail.tail-right {
    right: 24px;
    transform: rotate(-22deg) skewX(-12deg);
    border-radius: 2px 2px 0 8px;
}

.gift-bow-knot {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ffffff 0%, #fde047 45%, #ca8a04 85%);
    border: 2px solid #ffffff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.55), inset 0 2px 4px rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    z-index: 10;
}

/* Cylindrical Satin Cross Ribbons */
.gift-ribbon-v {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 36px;
    transform: translateX(-50%);
    background: linear-gradient(90deg, rgba(0,0,0,0.3) 0%, #fde047 25%, #ffffff 50%, #ca8a04 80%, rgba(0,0,0,0.3) 100%);
    box-shadow: 0 0 14px rgba(250, 204, 21, 0.65), inset 0 0 6px rgba(255, 255, 255, 0.5);
    z-index: 5;
    pointer-events: none;
}

.gift-ribbon-h {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 36px;
    transform: translateY(-50%);
    background: linear-gradient(180deg, rgba(0,0,0,0.3) 0%, #fde047 25%, #ffffff 50%, #ca8a04 80%, rgba(0,0,0,0.3) 100%);
    box-shadow: 0 0 14px rgba(250, 204, 21, 0.65), inset 0 0 6px rgba(255, 255, 255, 0.5);
    z-index: 5;
    pointer-events: none;
}

/* Center Gold Medallion Badge */
.gift-seal-center {
    position: relative;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ffffff 0%, #fde047 40%, #eab308 75%, #854d0e 100%);
    border: 3.5px solid #ffffff;
    box-shadow: inset 0 3px 6px rgba(255, 255, 255, 0.95), 0 8px 20px rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
}

.gift-emoji-icon {
    font-size: 3.5rem;
    line-height: 1;
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.55));
    pointer-events: none;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Canvas Crack & Hit Spark Overlay (Pinned over 220x220 Container) */
.gift-crack-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 220px;
    height: 220px;
    pointer-events: none;
    z-index: 35;
    mix-blend-mode: source-over;
}

/* Explosion Flash & Shockwave Overlays */
.gift-explosion-flash {
    position: absolute;
    top: -25%;
    left: -25%;
    width: 150%;
    height: 150%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 1) 0%, rgba(253, 224, 71, 0.95) 35%, rgba(249, 115, 22, 0.8) 60%, rgba(249, 115, 22, 0) 80%);
    opacity: 0;
    pointer-events: none;
    z-index: 45;
}

.gift-explosion-flash.active {
    animation: flashGlare 0.65s ease-out forwards;
}

@keyframes flashGlare {
    0% { transform: scale(0.1); opacity: 1; }
    40% { transform: scale(1.4); opacity: 1; }
    100% { transform: scale(2.2); opacity: 0; }
}

.gift-shockwave-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120px;
    height: 120px;
    margin-top: -60px;
    margin-left: -60px;
    border-radius: 50%;
    border: 10px solid #fde047;
    box-shadow: 0 0 35px #fde047, inset 0 0 25px #f97316;
    opacity: 0;
    pointer-events: none;
    z-index: 46;
}

.gift-shockwave-ring.active {
    animation: shockwaveExpand 0.7s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

.gift-shockwave-ring.delay {
    animation-delay: 0.12s;
}

@keyframes shockwaveExpand {
    0% { transform: scale(0.1); opacity: 1; border-width: 14px; }
    60% { opacity: 0.9; }
    100% { transform: scale(3.5); opacity: 0; border-width: 1px; }
}

/* 3D Shatter Explosion Fragment Layer */
.gift-explosion-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 220px;
    height: 220px;
    pointer-events: none;
    z-index: 50;
    overflow: visible;
}

.gift-shard {
    position: absolute;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.7);
    backface-visibility: visible;
    animation: shardBurst 0.85s cubic-bezier(0.12, 0.8, 0.3, 1) forwards;
}

@keyframes shardBurst {
    0% {
        transform: translate3d(0, 0, 0) rotateX(0deg) rotateY(0deg) rotateZ(0deg) scale(1);
        opacity: 1;
    }
    60% {
        transform: translate3d(calc(var(--tx) * 1px), calc(var(--ty) * 1px), 100px) rotateX(calc(var(--rx) * 1deg)) rotateY(calc(var(--ry) * 1deg)) rotateZ(calc(var(--rz) * 1deg)) scale(calc(var(--scale) * 1));
        opacity: 0.95;
    }
    100% {
        transform: translate3d(calc(var(--tx) * 1.4px), calc(var(--ty) * 1.4px + 140px), -100px) rotateX(calc(var(--rx) * 2deg)) rotateY(calc(var(--ry) * 2deg)) rotateZ(calc(var(--rz) * 2deg)) scale(0);
        opacity: 0;
    }
}

/* Lid Skyward Fly Animation */
.gift-box-lid.flying {
    animation: lidFlyUp 0.9s cubic-bezier(0.1, 0.9, 0.25, 1) forwards !important;
}

@keyframes lidFlyUp {
    0% {
        transform: translateX(-50%) translateY(0) rotate(0deg) scale(1);
        opacity: 1;
    }
    45% {
        transform: translateX(-50%) translateY(-320px) rotate(-140deg) scale(1.15);
        opacity: 0.95;
    }
    100% {
        transform: translateX(-50%) translateY(-550px) rotate(-280deg) scale(0.2);
        opacity: 0;
    }
}

/* Modal Screen Shake */
.modal-shake {
    animation: modalShake 0.45s ease-in-out !important;
}

@keyframes modalShake {
    0%, 100% { transform: translate(0, 0); }
    15% { transform: translate(-12px, 8px) rotate(-1deg); }
    35% { transform: translate(12px, -8px) rotate(1deg); }
    55% { transform: translate(-8px, -6px); }
    75% { transform: translate(8px, 6px); }
}

/* Multi-Hit Shake Animations */
.hit-shake-1 {
    animation: shakeLight 0.25s ease-in-out !important;
}

.hit-shake-2 {
    animation: shakeMedium 0.3s ease-in-out !important;
}

.hit-shake-3 {
    animation: shakeHeavy 0.35s ease-in-out !important;
}

.hit-pulse-charge {
    animation: pulseCharge 0.35s cubic-bezier(0.36, 0, 0.66, -0.56) infinite alternate !important;
}

@keyframes shakeLight {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.08) rotate(-6deg); }
    75% { transform: scale(1.08) rotate(6deg); }
}

@keyframes shakeMedium {
    0%, 100% { transform: scale(1) rotate(0deg); }
    20% { transform: scale(1.15) rotate(-12deg) translateY(-4px); }
    60% { transform: scale(1.15) rotate(12deg) translateY(4px); }
    80% { transform: scale(1.1) rotate(-6deg); }
}

@keyframes shakeHeavy {
    0%, 100% { transform: scale(1) rotate(0deg); }
    15% { transform: scale(1.24) rotate(-18deg) translateY(-8px); }
    30% { transform: scale(1.24) rotate(18deg) translateY(8px); }
    45% { transform: scale(1.28) rotate(-14deg); }
    75% { transform: scale(1.22) rotate(10deg); }
}

@keyframes pulseCharge {
    0% { transform: scale(1) rotate(-3deg); filter: brightness(1.2); }
    100% { transform: scale(1.32) rotate(4deg); filter: brightness(2.2) drop-shadow(0 0 45px #fde047); }
}

/* Reward Reveal Glow Entrance */
.gift-reward-content.revealed {
    animation: rewardBurstIn 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes rewardBurstIn {
    0% {
        transform: scale(0.1) translateY(40px);
        opacity: 0;
        filter: blur(12px);
    }
    70% {
        transform: scale(1.12) translateY(-8px);
        opacity: 1;
        filter: blur(0px);
    }
    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
        filter: blur(0px);
    }
}

.gift-hit-badge {
    display: none;
    position: absolute;
    bottom: -8px;
    background: rgba(15, 23, 42, 0.85);
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    color: #fef08a;
    font-family: var(--font-heading);
    font-size: 0.88rem;
    font-weight: 800;
    padding: 4px 14px;
    border-radius: 20px;
    backdrop-filter: blur(8px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
    z-index: 15;
}

.gift-crack-bar-wrap {
    width: 100%;
    height: 12px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    overflow: hidden;
    margin: 14px 0 18px 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.gift-crack-bar {
    height: 100%;
    background: linear-gradient(90deg, #ef4444, #f97316, #facc15, #22c55e);
    border-radius: 10px;
    transition: width 0.2s ease-out;
    box-shadow: 0 0 12px #facc15;
}

.gift-float-hit {
    position: absolute;
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 900;
    color: #fef08a;
    text-shadow: 0 0 10px #ef4444, 0 2px 4px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 25;
    animation: floatHitUp 0.8s ease-out forwards;
}

@keyframes floatHitUp {
    0% { opacity: 1; transform: translateY(0) scale(0.8); }
    50% { opacity: 1; transform: translateY(-30px) scale(1.2); }
    100% { opacity: 0; transform: translateY(-60px) scale(1); }
}

@keyframes bounceGift {
    from {
        transform: translateY(0) scale(1);
    }
    to {
        transform: translateY(-12px) scale(1.06);
    }
}

/* SUB-LESSON LEVEL STYLES */
.sub-lesson-bar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(15, 23, 42, 0.45);
    padding: 10px 14px;
    border-radius: 14px;
    margin-bottom: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sub-lesson-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #cbd5e1;
    font-family: var(--font-heading);
}

.sub-lesson-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sub-lesson-pill {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    cursor: pointer;
    transition: all 0.2s;
}

.sub-lesson-pill:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: #38bdf8;
}

.sub-lesson-pill.active {
    background: linear-gradient(135deg, #0284c7, #06b6d4);
    border-color: #fef08a;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.4);
}

/* AVATAR & RANK MODAL STYLES */
.avatar-pill {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(6, 182, 212, 0.25));
    border: 2px solid #38bdf8;
    color: #e0f2fe;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.avatar-pill:hover {
    transform: scale(1.05);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}

.clickable-badge {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.clickable-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 0 12px rgba(254, 240, 138, 0.4);
}

.avatar-modal-card {
    max-width: 480px;
    text-align: center;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 15px;
}

.avatar-card-item {
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 12px 6px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.avatar-card-item:hover {
    transform: translateY(-4px) scale(1.05);
    background: rgba(56, 189, 248, 0.2);
    border-color: #38bdf8;
}

.avatar-card-item.active {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.4), rgba(2, 132, 199, 0.4));
    border-color: #fef08a;
    box-shadow: 0 0 14px rgba(6, 182, 212, 0.5);
    transform: scale(1.06);
}

.avatar-card-emoji {
    font-size: 2.5rem;
}

.avatar-card-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: #f8fafc;
}

.rank-modal-card {
    max-width: 440px;
    text-align: center;
}

/* FRAMED AVATAR SHOWCASE CARD (Based on User Drawing) */
.avatar-modal-card {
    max-width: 680px;
    text-align: center;
}

.avatar-modal-layout {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
}

.framed-avatar-card {
    position: relative;
    width: 220px;
    height: 310px;
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.9), rgba(30, 41, 59, 0.9));
    border: 3.5px solid #38bdf8;
    border-radius: 20px;
    box-shadow: 0 12px 30px rgba(6, 182, 212, 0.35);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 16px 12px;
    overflow: visible;
}

.framed-card-corner {
    position: absolute;
    top: -14px;
    font-size: 1.1rem;
    color: #38bdf8;
    text-shadow: 0 0 8px #38bdf8;
}

.framed-card-corner.top-left {
    left: 8px;
}

.framed-card-corner.top-right {
    right: 8px;
}

.preview-badge-pill {
    background: rgba(234, 179, 8, 0.25);
    border: 1.5px solid #fef08a;
    color: #fef08a;
    font-weight: 800;
    font-size: 0.85rem;
    padding: 4px 12px;
    border-radius: 14px;
    white-space: nowrap;
}

.framed-character-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 15px 0;
}

.accessory-visual {
    font-size: 2.8rem;
    position: absolute;
    top: -26px;
    z-index: 5;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

.character-visual {
    font-size: 5.5rem;
    line-height: 1;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4));
    transform-origin: bottom center;
}

.waving-character {
    animation: waveArm 1.5s infinite ease-in-out alternate;
}

@keyframes waveArm {
    0% {
        transform: rotate(0deg) scale(1);
    }
    50% {
        transform: rotate(-6deg) scale(1.04);
    }
    100% {
        transform: rotate(6deg) scale(1.02);
    }
}

.preview-avatar-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 800;
    color: #fef08a;
}

.avatar-controls-panel {
    flex: 1;
    text-align: left;
    max-height: 340px;
    overflow-y: auto;
}

.control-section-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: #38bdf8;
    margin-bottom: 8px;
}

.accessory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.accessory-card-item {
    background: rgba(255, 255, 255, 0.08);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    padding: 8px 4px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.accessory-card-item:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: #38bdf8;
    transform: translateY(-2px);
}

.accessory-card-item.active {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.4), rgba(2, 132, 199, 0.4));
    border-color: #fef08a;
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.5);
}

.accessory-card-emoji {
    font-size: 1.8rem;
}

.accessory-card-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: #cbd5e1;
}

@media (max-width: 600px) {
    .avatar-modal-layout {
        flex-direction: column;
    }
}

/* MINIGAME HUB & ASTEROID ARCADE GAME STYLES */
.minigame-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 10px 18px;
    border-radius: 20px;
    margin-bottom: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.minigame-bar-title {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 0.95rem;
    color: #fef08a;
    white-space: nowrap;
}

.minigame-pill-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.minigame-pill {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 700;
    padding: 8px 18px;
    border-radius: 25px;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.minigame-pill:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: #38bdf8;
    transform: translateY(-2px);
}

.minigame-pill.active {
    background: linear-gradient(135deg, #0284c7, #06b6d4);
    border-color: #fef08a;
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(6, 182, 212, 0.45);
    transform: scale(1.05);
}

/* ASTEROID ARCADE GAME CONTAINER & HUD */
.asteroid-arcade-card {
    position: relative;
    padding: 20px;
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.92), rgba(30, 27, 75, 0.9), rgba(11, 19, 43, 0.95));
    border: 1.5px solid rgba(56, 189, 248, 0.5);
    border-radius: 28px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.75), 0 0 45px rgba(56, 189, 248, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.asteroid-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: 12px 22px;
    border-radius: 20px;
    margin-bottom: 16px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 8px 24px rgba(0, 0, 0, 0.4);
    font-family: var(--font-heading);
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.hud-label {
    font-weight: 600;
    color: #94a3b8;
    letter-spacing: 0.5px;
}

.hud-val {
    font-size: 1.25rem;
    font-weight: 800;
    color: #38bdf8;
    text-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
}

.hud-lives {
    font-size: 1.15rem;
    letter-spacing: 3px;
    filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.6));
}

.hud-coins {
    font-size: 1.2rem;
    font-weight: 800;
    color: #facc15;
    text-shadow: 0 0 12px rgba(250, 204, 21, 0.5);
}

.asteroid-canvas-wrapper {
    position: relative;
    width: 100%;
    max-width: 920px;
    margin: 0 auto;
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.75), 0 0 30px rgba(56, 189, 248, 0.2);
    border: 2px solid rgba(56, 189, 248, 0.35);
}

#asteroid-game-canvas {
    display: block;
    width: 100%;
    height: 520px;
    background: #090d16;
    cursor: crosshair;
}

#cakestack-game-canvas {
    display: block;
    width: 100%;
    height: 540px;
    background: #1e1b4b;
    cursor: pointer;
}

.asteroid-overlay {
    position: absolute;
    inset: 0;
    background: rgba(9, 13, 22, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.overlay-box {
    text-align: center;
    background: linear-gradient(160deg, rgba(15, 23, 42, 0.96), rgba(30, 27, 75, 0.95));
    border: 2px solid rgba(56, 189, 248, 0.6);
    padding: 36px 44px;
    border-radius: 28px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8), 0 0 45px rgba(56, 189, 248, 0.25);
    max-width: 500px;
    animation: popupZoom 0.3s ease-out;
}

@keyframes popupZoom {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.overlay-icon {
    font-size: 4.8rem;
    margin-bottom: 12px;
    filter: drop-shadow(0 0 18px rgba(56, 189, 248, 0.6));
}

.controls-hint {
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.25);
    padding: 12px 18px;
    border-radius: 14px;
    margin: 18px 0;
    font-size: 0.92rem;
    color: #e2e8f0;
    line-height: 1.5;
}

.btn-hero {
    font-size: 1.3rem;
    font-weight: 800;
    padding: 16px 40px;
    border-radius: 50px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow: 0 10px 30px rgba(34, 197, 94, 0.5), 0 0 20px rgba(34, 197, 94, 0.3);
    color: #ffffff;
    border: 2px solid #86efac;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-hero:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 14px 35px rgba(34, 197, 94, 0.6), 0 0 25px rgba(34, 197, 94, 0.4);
}

/* VIETNAMESE DAILY LESSON SELECTOR STYLES */
.vn-day-selector-card {
    margin-bottom: 20px;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    padding: 18px 22px;
}
.vn-day-pills-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}
.vn-day-pill {
    padding: 10px 16px;
    border-radius: 12px;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.vn-day-pill:hover {
    background: rgba(56, 189, 248, 0.15);
    border-color: #38bdf8;
    transform: translateY(-2px);
}
.vn-day-pill.active {
    background: linear-gradient(135deg, #0284c7, #38bdf8);
    color: #ffffff;
    border-color: #bae6fd;
    box-shadow: 0 4px 14px rgba(56, 189, 248, 0.4);
}

/* PER-LETTER LESSON CARDS GRID STYLES */
.letter-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    margin-top: 14px;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 6px;
}
.letter-cards-grid::-webkit-scrollbar {
    width: 6px;
}
.letter-cards-grid::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.4);
    border-radius: 4px;
}
.letter-lesson-card {
    margin: 0;
    text-align: left;
}

/* LUXURIOUS VIBRANT MODULE BACKGROUND THEMES */
#module-math .glass-card {
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.92), rgba(14, 116, 144, 0.35), rgba(30, 27, 75, 0.88)) !important;
    border: 1.5px solid rgba(56, 189, 248, 0.4) !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 0 35px rgba(6, 182, 212, 0.2) !important;
}

#module-vietnamese .glass-card {
    background: linear-gradient(145deg, rgba(30, 27, 75, 0.92), rgba(190, 24, 93, 0.35), rgba(15, 23, 42, 0.88)) !important;
    border: 1.5px solid rgba(244, 114, 182, 0.4) !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 0 35px rgba(236, 72, 153, 0.2) !important;
}

#game-view-puzzle .glass-card {
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.94), rgba(59, 130, 246, 0.25), rgba(16, 185, 129, 0.2)) !important;
    border: 1.5px solid rgba(56, 189, 248, 0.45) !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 0 35px rgba(56, 189, 248, 0.25) !important;
}

#game-view-animals .glass-card {
    background: linear-gradient(145deg, rgba(6, 78, 59, 0.8), rgba(15, 23, 42, 0.92), rgba(21, 128, 61, 0.35)) !important;
    border: 1.5px solid rgba(74, 222, 128, 0.4) !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 0 35px rgba(74, 222, 128, 0.2) !important;
}

#game-view-logic .glass-card {
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.92), rgba(217, 70, 239, 0.35), rgba(67, 56, 202, 0.4)) !important;
    border: 1.5px solid rgba(232, 121, 249, 0.4) !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 0 35px rgba(217, 70, 239, 0.2) !important;
}

/* ========================================================
   MAGIC PICTURE PUZZLE GAME STYLES
   ======================================================== */
.puzzle-arcade-card {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px;
}
.puzzle-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
}
.puzzle-controls-top {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}
.puzzle-btn-group {
    display: inline-flex;
    background: rgba(0, 0, 0, 0.4);
    padding: 3px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    gap: 4px;
}
.puzzle-btn-group .btn {
    border-radius: 9px;
    padding: 6px 12px;
    font-size: 0.88rem;
    font-weight: 700;
}
.puzzle-theme-carousel {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 6px 2px 14px 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
.puzzle-theme-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(30, 41, 59, 0.7);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    padding: 8px 14px;
    color: #e2e8f0;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
}
.puzzle-theme-btn:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: #38bdf8;
    transform: translateY(-2px);
}
.puzzle-theme-btn.active {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    border-color: #fef08a;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.5);
}
.puzzle-theme-btn .theme-icon {
    font-size: 1.25rem;
}
.puzzle-hud-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    background: rgba(0, 0, 0, 0.35);
    padding: 10px 16px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 18px;
}
.puzzle-hud-stats {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.puzzle-hud-item {
    font-size: 0.95rem;
    font-weight: 700;
    color: #cbd5e1;
}
.puzzle-hud-item strong {
    font-size: 1.15rem;
    font-family: inherit;
}
.puzzle-progress-bar-wrap {
    width: 140px;
    height: 10px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    overflow: hidden;
}
.puzzle-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #38bdf8, #4ade80);
    border-radius: 10px;
    transition: width 0.3s ease;
}
.puzzle-hud-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.puzzle-hud-actions .btn {
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 700;
}
.puzzle-stage {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    justify-content: center;
    flex-wrap: wrap;
}
.puzzle-board-wrapper {
    position: relative;
    width: 480px;
    height: 480px;
    max-width: 90vw;
    max-height: 90vw;
    border-radius: 20px;
    overflow: hidden;
    background: #0f172a;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), 0 0 0 3px rgba(255, 255, 255, 0.18);
    touch-action: manipulation;
}
.puzzle-ghost-overlay {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 1;
}
.puzzle-ghost-overlay.visible {
    opacity: 0.35;
}
.puzzle-board {
    position: relative;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(var(--grid-size, 3), 1fr);
    grid-template-rows: repeat(var(--grid-size, 3), 1fr);
    gap: 4px;
    padding: 4px;
    box-sizing: border-box;
    z-index: 2;
}
.puzzle-tile {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.25);
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.18s ease, border-color 0.18s ease;
    touch-action: manipulation;
    user-select: none;
    background-repeat: no-repeat;
}
.puzzle-tile:hover {
    transform: scale(1.03);
    z-index: 5;
    border-color: #38bdf8;
    box-shadow: 0 8px 18px rgba(56, 189, 248, 0.4);
}
.puzzle-tile.selected {
    transform: scale(1.06);
    border: 3px solid #fef08a !important;
    box-shadow: 0 0 20px #facc15, inset 0 0 12px rgba(254, 240, 138, 0.5) !important;
    z-index: 10;
    animation: puzzlePulse 1s infinite alternate;
}
@keyframes puzzlePulse {
    from { box-shadow: 0 0 14px #facc15; }
    to { box-shadow: 0 0 25px #facc15, 0 0 40px rgba(250, 204, 21, 0.6); }
}
.puzzle-tile.correct {
    border-color: rgba(74, 222, 128, 0.55);
}
.puzzle-tile.correct::after {
    content: '✓';
    position: absolute;
    bottom: 4px;
    right: 4px;
    font-size: 0.75rem;
    font-weight: 900;
    color: #4ade80;
    background: rgba(0, 0, 0, 0.6);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.puzzle-tile.empty {
    background: transparent !important;
    border: 2px dashed rgba(255, 255, 255, 0.2) !important;
    box-shadow: none !important;
    cursor: default;
}
.puzzle-tile.empty::after {
    display: none;
}
.puzzle-tile-num {
    position: absolute;
    top: 4px;
    left: 4px;
    background: rgba(15, 23, 42, 0.75);
    color: #ffffff;
    font-weight: 800;
    font-size: 0.8rem;
    padding: 2px 6px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    pointer-events: none;
    display: none;
}
.puzzle-board.show-numbers .puzzle-tile-num {
    display: block;
}
.puzzle-side-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 180px;
}
.puzzle-preview-card {
    padding: 14px;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.35);
    text-align: center;
}
.puzzle-preview-thumb {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.puzzle-preview-thumb:hover {
    transform: scale(1.04);
    border-color: #38bdf8;
}
.puzzle-preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.puzzle-win-card {
    max-width: 440px;
    width: 90vw;
    text-align: center;
    padding: 32px 24px;
    border-radius: 24px;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(20px);
    border: 2.5px solid #4ade80;
    box-shadow: 0 0 35px rgba(74, 222, 128, 0.4), 0 20px 50px rgba(0, 0, 0, 0.8);
    animation: modalPopIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.puzzle-win-stats {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin: 16px 0;
}
.puzzle-stat-item {
    background: rgba(255, 255, 255, 0.06);
    padding: 10px 18px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.puzzle-stat-label {
    font-size: 0.8rem;
    color: #94a3b8;
    text-transform: uppercase;
}
.puzzle-stat-val {
    font-size: 1.35rem;
    font-weight: 800;
}
.puzzle-win-reward-badge {
    display: inline-block;
    padding: 8px 18px;
    border-radius: 9999px;
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.25), rgba(74, 222, 128, 0.25));
    border: 1.5px solid #facc15;
    font-size: 1.15rem;
    font-weight: 800;
    color: #fef08a;
    margin: 8px 0;
}
.puzzle-preview-modal-card {
    max-width: 480px;
    width: 92vw;
    text-align: center;
    padding: 24px;
    border-radius: 20px;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(56, 189, 248, 0.5);
    box-shadow: 0 0 30px rgba(56, 189, 248, 0.3), 0 20px 50px rgba(0, 0, 0, 0.8);
    position: relative;
    animation: modalPopIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ANIMALS MODULE STYLES */
.animal-flashcards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
.animal-card {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 18px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
}
.animal-card:hover {
    transform: translateY(-4px);
    border-color: #a855f7;
    box-shadow: 0 8px 20px rgba(168, 85, 247, 0.3);
}
.animal-emoji {
    font-size: 3rem;
    margin-bottom: 8px;
}
.animal-name {
    font-weight: 800;
    font-size: 1.1rem;
    color: #fef08a;
    margin-bottom: 6px;
}
.animal-fact {
    font-size: 0.82rem;
    color: #cbd5e1;
    line-height: 1.4;
    margin-bottom: 10px;
}
.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    max-width: 500px;
    margin: 0 auto;
}
.mem-card {
    aspect-ratio: 1;
    background: rgba(30, 41, 59, 0.75);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 2.4rem;
    cursor: pointer;
    user-select: none;
    transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}
.mem-card:hover {
    transform: translateY(-3px) scale(1.03);
    border-color: #38bdf8;
}
.mem-card.flipped {
    background: rgba(168, 85, 247, 0.35);
    border-color: #c084fc;
    transform: scale(1.06);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.45);
}
.mem-card.matched {
    background: rgba(34, 197, 94, 0.32);
    border-color: #4ade80;
    transform: scale(1);
    box-shadow: 0 0 18px rgba(74, 222, 128, 0.4);
    cursor: default;
}

/* LOGIC MODULE STYLES */
.logic-workspace {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}
@media (max-width: 768px) {
    .logic-workspace {
        grid-template-columns: 1fr;
    }
}
.logic-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 360px;
    aspect-ratio: 1;
    background: rgba(15, 23, 42, 0.75);
    padding: 12px;
    border-radius: 18px;
    border: 2px solid rgba(56, 189, 248, 0.25);
    box-shadow: inset 0 4px 16px rgba(0, 0, 0, 0.5);
}
.grid-cell {
    background: rgba(255, 255, 255, 0.06);
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    transition: all 0.2s ease;
    user-select: none;
}
.cell-cat {
    background: rgba(56, 189, 248, 0.28);
    border-color: #38bdf8;
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.45);
    transform: scale(1.04);
}
.cell-star {
    background: rgba(250, 204, 21, 0.24);
    border-color: #facc15;
    box-shadow: 0 0 14px rgba(250, 204, 21, 0.35);
}
.cell-fish {
    background: rgba(16, 185, 129, 0.22);
    border-color: #34d399;
}
.cell-rock {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.4);
}
.cell-crash {
    background: rgba(239, 68, 68, 0.55) !important;
    border-color: #ef4444 !important;
    animation: shakeCrash 0.35s ease;
}
@keyframes shakeCrash {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}
.sequence-queue {
    min-height: 68px;
    background: rgba(0, 0, 0, 0.35);
    border: 1.5px dashed rgba(255, 255, 255, 0.25);
    border-radius: 14px;
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.cmd-badge {
    background: rgba(168, 85, 247, 0.32);
    border: 1.5px solid #a855f7;
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 700;
    color: #f3e8ff;
    cursor: pointer;
    transition: all 0.15s ease;
}
.cmd-badge:hover {
    background: rgba(239, 68, 68, 0.35);
    border-color: #f87171;
    transform: scale(1.05);
}
.cmd-badge.executing {
    background: rgba(250, 204, 21, 0.45);
    border-color: #fde047;
    color: #fef08a;
    transform: scale(1.1);
    box-shadow: 0 0 12px rgba(250, 204, 21, 0.6);
}
.empty-hint {
    color: #64748b;
    font-size: 0.85rem;
}

/* COLORING MODULE STYLES */
.coloring-tpl-btn {
    padding: 8px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.coloring-tpl-btn:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: #38bdf8;
    transform: translateY(-2px);
}
.coloring-tpl-btn.active {
    background: linear-gradient(135deg, #38bdf8, #818cf8);
    border-color: #ffffff;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.4);
}

.coloring-swatch {
    width: 44px;
    height: 44px;
    min-width: 44px !important;
    min-height: 44px !important;
    flex-shrink: 0;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease;
}
.coloring-swatch:hover {
    transform: scale(1.2);
    border-color: #ffffff;
}
.coloring-swatch.active {
    transform: scale(1.25);
    border-color: #ffffff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

@keyframes modalPopIn {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}





/* ==========================================================================
   FULL IPAD OS & TOUCH SCREEN OPTIMIZATIONS
   ========================================================================== */

/* 1. Eliminate Tap Highlight & Callout on iPad Safari */
*,
*:before,
*:after {
    -webkit-tap-highlight-color: transparent !important;
}

/* 2. Prevent Touch Page Scrolling/Zoom Interference on All Drawing & Game Canvases */
canvas,
#writing-canvas,
#user-writing-canvas,
#coloring-canvas,
#aquarium-canvas,
#cakestack-canvas,
#asteroid-canvas,
#space-canvas {
    touch-action: none !important;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
}

/* 3. Smooth iPad Momentum Scrolling for Lists & Carousels */
.coloring-templates-bar,
.sidebar-scroll-list,
.vocab-cards-grid,
.g2-vn-grid,
.spelling-tiles,
.sub-lesson-pills,
.grade-pill-group,
.minigame-pills-row {
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-x pan-y !important;
}

/* 4. Apple Human Interface Guidelines Touch Target Sizes (Min 44px) */
.btn,
.grade-pill,
.sub-lesson-pill,
.alpha-btn,
.coloring-swatch,
.coloring-tpl-btn,
.spell-tile,
.vocab-category-pill,
.math-opt-btn,
.nav-btn,
.stat-pill {
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    touch-action: manipulation !important;
    cursor: pointer !important;
}

/* 5. Responsive Active Touch Feedback for iPad */
.btn:active,
.sub-lesson-pill:active,
.grade-pill:active,
.math-opt-btn:active,
.spell-tile:active,
.coloring-tpl-btn:active {
    transform: scale(0.95) !important;
    transition: transform 0.1s ease !important;
}

/* 6. iPad Safe Area Insets for Notch / Home Bar */
body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* ==========================================================================
   TABLET & PHONE COMPREHENSIVE RESPONSIVE STYLES
   Optimized for iPad (portrait/landscape), iPhone, Android phones & tablets
   ========================================================================== */

/* Universal Canvas Sizing & Tile Rendering */
.puzzle-tile canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    object-fit: cover;
}

.puzzle-tile.empty-tile,
.puzzle-tile.empty {
    background: rgba(0, 0, 0, 0.4) !important;
    border: 2px dashed rgba(255, 255, 255, 0.25) !important;
    box-shadow: none !important;
    cursor: default;
}
.puzzle-tile.empty-tile::after,
.puzzle-tile.empty::after {
    display: none !important;
}

.coloring-canvas-container > div {
    max-width: 100% !important;
    width: 100% !important;
}

#coloring-canvas {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    aspect-ratio: 800 / 540;
}

/* --------------------------------------------------------------------------
   TABLET RESPONSIVENESS (max-width: 1024px - iPad Portrait & Landscape)
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
    .module-view {
        max-width: 100%;
    }
    
    .puzzle-stage {
        gap: 16px;
    }
    
    .aquarium-canvas-container {
        min-height: 380px;
    }
}

/* --------------------------------------------------------------------------
   PHONE & SMALL TABLET RESPONSIVENESS (max-width: 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    /* Header & Top Bar Optimization */
    .app-header {
        height: auto;
        min-height: 58px;
        padding: 8px 12px;
        padding-top: max(8px, env(safe-area-inset-top));
        flex-wrap: wrap;
        gap: 8px;
        justify-content: space-between;
    }

    .logo-area {
        gap: 8px;
    }

    .logo-icon {
        font-size: 1.6rem;
    }

    .logo-title {
        font-size: 1.15rem;
    }

    .logo-subtitle {
        display: none;
    }

    .user-status {
        order: 2;
    }

    .user-info {
        padding: 4px 10px;
        border-radius: 20px;
        gap: 8px;
    }

    .user-avatar-circle {
        width: 32px;
        height: 32px;
        font-size: 1.25rem;
    }

    .user-name {
        font-size: 0.88rem;
    }

    .user-badge-text {
        font-size: 0.72rem;
    }

    .hud-stats {
        order: 3;
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 6px;
        overflow-x: auto;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .hud-stats::-webkit-scrollbar {
        display: none;
    }

    .stat-pill {
        padding: 4px 10px;
        font-size: 0.88rem;
        min-height: 36px !important;
        gap: 4px;
        flex-shrink: 0;
    }

    .btn-shop-badge,
    .btn-secret-badge {
        padding: 4px 10px;
        font-size: 0.82rem;
        min-height: 36px !important;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .btn-icon.btn-sound {
        min-width: 36px;
        min-height: 36px !important;
        padding: 4px 8px;
        flex-shrink: 0;
    }

    /* Swipeable Horizontal Navigation Tabs */
    .nav-tabs {
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 8px 12px;
        gap: 8px;
    }
    .nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .nav-tab {
        flex-shrink: 0;
        padding: 8px 14px;
        font-size: 0.9rem;
        min-height: 40px !important;
        border-radius: 18px;
        white-space: nowrap;
    }

    /* Swipeable Grade Selection Bar */
    .grade-selector-bar {
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 6px 12px;
        gap: 8px;
    }
    .grade-selector-bar::-webkit-scrollbar {
        display: none;
    }

    .grade-label {
        font-size: 0.88rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .grade-pill-group {
        gap: 6px;
        flex-shrink: 0;
    }

    .grade-pill {
        padding: 6px 14px;
        font-size: 0.85rem;
        min-height: 36px !important;
        flex-shrink: 0;
    }

    /* Main Scrollable Viewport */
    .main-content {
        padding: 10px 10px 40px;
        padding-bottom: max(40px, env(safe-area-inset-bottom));
    }

    .module-header h2 {
        font-size: 1.55rem;
    }

    .module-header p {
        font-size: 0.88rem;
    }

    .glass-card {
        padding: 14px 12px !important;
        border-radius: 20px !important;
    }

    /* Task Menu & Tasks Grid */
    .task-menu-container {
        padding: 14px 14px;
        border-radius: 20px;
    }

    .task-cards-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .task-card-item {
        padding: 12px 14px;
        border-radius: 16px;
        gap: 10px;
    }

    .task-card-icon {
        font-size: 1.6rem;
    }

    .task-card-name {
        font-size: 0.95rem;
    }

    .task-card-desc {
        font-size: 0.8rem;
    }

    /* Aquarium Responsiveness */
    .aquarium-main-row {
        flex-direction: column;
        gap: 12px;
    }

    .aquarium-canvas-container {
        width: 100%;
        height: min(340px, 48vh);
    }

    .aquarium-sidebar-panel {
        width: 100%;
        max-height: 180px;
        padding: 10px;
    }

    .aquarium-toolbar {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
    }

    /* Math Module Options */
    .math-options-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .math-opt-btn {
        font-size: 1.5rem;
        padding: 12px;
        min-height: 60px;
    }

    .math-question-box {
        font-size: 1.8rem;
        padding: 16px 12px;
    }

    /* Minigame Dock Bar */
    .minigame-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 8px 12px;
        border-radius: 18px;
    }

    .minigame-bar-title {
        font-size: 0.85rem;
    }

    .minigame-pill-group {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        gap: 6px;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .minigame-pill-group::-webkit-scrollbar {
        display: none;
    }

    .minigame-pill {
        flex-shrink: 0;
        padding: 7px 12px;
        font-size: 0.82rem;
        min-height: 38px;
    }

    /* Arcade Game Canvases */
    #asteroid-game-canvas {
        height: min(420px, 55vh);
    }

    #cakestack-game-canvas {
        height: min(420px, 55vh);
    }

    .asteroid-hud {
        padding: 8px 12px;
        gap: 8px;
    }

    .overlay-box {
        padding: 24px 18px;
        border-radius: 20px;
        max-width: 92vw;
    }

    .overlay-icon {
        font-size: 3.2rem;
    }

    /* Animal Encyclopedia & Memory Cards */
    .animal-flashcards-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 10px;
    }

    .animal-card {
        padding: 10px;
        border-radius: 14px;
    }

    .animal-emoji {
        font-size: 2.2rem;
    }

    .animal-name {
        font-size: 0.95rem;
    }

    .memory-grid {
        gap: 8px;
        max-width: 340px;
    }

    /* Logic Grid on Phone */
    .logic-grid {
        max-width: 320px;
        gap: 6px;
        padding: 8px;
    }

    .grid-cell {
        font-size: 1.4rem;
        border-radius: 8px;
    }

    /* Magic Puzzle Game */
    .puzzle-stage {
        flex-direction: column;
        align-items: center;
        gap: 14px;
    }

    .puzzle-board-wrapper {
        width: min(340px, 92vw);
        height: min(340px, 92vw);
    }

    .puzzle-side-panel {
        width: 100%;
        max-width: 340px;
        flex-direction: row;
        justify-content: center;
    }

    .puzzle-preview-card {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 10px 14px;
    }

    .puzzle-preview-thumb {
        width: 72px;
        height: 72px;
        flex-shrink: 0;
    }

    .puzzle-hud-bar {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .puzzle-hud-stats {
        justify-content: space-between;
        gap: 8px;
    }

    .puzzle-hud-actions {
        justify-content: center;
    }

    .puzzle-theme-carousel {
        padding: 4px 2px 10px;
        gap: 8px;
    }

    .puzzle-theme-btn {
        padding: 6px 10px;
        font-size: 0.82rem;
        border-radius: 12px;
    }

    /* Shop Modal on Phone */
    .glass-card.shop-modal-card {
        padding: 16px 12px;
        width: 96%;
        max-height: 90vh;
        border-radius: 20px;
    }

    .shop-header {
        padding-right: 36px;
        margin-bottom: 10px;
    }

    .shop-tabs {
        gap: 6px;
        margin-bottom: 12px;
    }

    .shop-tabs .btn-sub {
        font-size: 0.82rem;
        padding: 6px 8px;
        min-height: 38px;
    }

    .shop-grid {
        grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
        gap: 8px;
    }

    .shop-item-card {
        padding: 8px 6px;
        border-radius: 14px;
    }

    .shop-item-card .shop-item-emoji {
        font-size: 2.2rem;
    }

    .shop-item-card .shop-item-name {
        font-size: 0.82rem;
    }

    .shop-item-card .shop-item-price {
        font-size: 0.82rem;
    }
}

/* --------------------------------------------------------------------------
   EXTRA COMPACT PHONE RESPONSIVENESS (max-width: 420px - iPhone SE / Mini)
   -------------------------------------------------------------------------- */
@media (max-width: 420px) {
    .app-header {
        padding: 6px 8px;
    }

    .logo-title {
        font-size: 1.05rem;
    }

    .hud-stats {
        gap: 4px;
    }

    .stat-pill {
        padding: 3px 8px;
        font-size: 0.82rem;
    }

    .btn-shop-badge,
    .btn-secret-badge {
        padding: 3px 8px;
        font-size: 0.78rem;
    }

    .math-opt-btn {
        font-size: 1.35rem;
        padding: 10px;
        min-height: 52px;
    }

    .puzzle-board-wrapper {
        width: min(300px, 92vw);
        height: min(300px, 92vw);
    }

    .logic-grid {
        max-width: 280px;
        gap: 4px;
        padding: 6px;
    }

    .grid-cell {
        font-size: 1.25rem;
    }
}
