/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* Full-screen iPad app foundation */
html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: fixed;
    overscroll-behavior: none;
    touch-action: manipulation;
    font-family: -apple-system, sans-serif;
    background: #e8f4f8;
}

/* Main app container */
#app {
    width: 100%;
    height: calc(100% - 80px);
    overflow: hidden;
}

/* Navigation bar - bottom for child thumb reach */
#nav-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    padding: 10px;
    height: 80px;
    background: rgba(255, 255, 255, 0.8);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
}

/* Navigation icons - FOUN-01: 60pt minimum tap targets */
.nav-icon {
    width: 60px;
    height: 60px;
    min-width: 60px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    text-decoration: none;
    touch-action: manipulation;
    transition: background 0.15s ease;
}

.nav-icon.active {
    background: rgba(100, 200, 255, 0.3);
}

/* SVG interaction regions */
[data-region] {
    cursor: pointer;
    touch-action: manipulation;
}

[data-region]:active {
    opacity: 0.8;
}

/* Sparkle animation */
.sparkle {
    animation: sparkle-fade 0.6s ease-out forwards;
    pointer-events: none;
}

@keyframes sparkle-fade {
    0% {
        opacity: 1;
        transform: scale(0);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
    100% {
        opacity: 0;
        transform: scale(0.5) translateY(-10px);
    }
}

/* Home screen activity buttons */
.home-grid {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    height: 100%;
}

.activity-btn {
    min-width: 120px;
    min-height: 120px;
    width: 160px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 24px;
    text-decoration: none;
    touch-action: manipulation;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

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

.activity-btn--dressup {
    background: #f5e6fa;
    box-shadow: 0 4px 12px rgba(196, 126, 208, 0.25);
}

.activity-btn--coloring {
    background: #fce8d8;
    box-shadow: 0 4px 12px rgba(232, 151, 107, 0.25);
}

/* Dress-up view */
.dressup-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.mermaid-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
}

.mermaid-container svg {
    max-width: 100%;
    max-height: 100%;
}

/* Selection panel */
.selection-panel {
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.9);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.category-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 4px 8px;
}

.cat-tab,
.undo-btn {
    width: 60px;
    height: 60px;
    min-width: 60px;
    min-height: 60px;
    border: 2px solid transparent;
    border-radius: 14px;
    background: rgba(200, 220, 240, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    cursor: pointer;
}

.cat-tab.active {
    border-color: #5b8fa8;
    background: rgba(100, 200, 255, 0.2);
}

.undo-btn {
    margin-left: auto;
}

.undo-btn.disabled {
    opacity: 0.35;
    pointer-events: none;
}

.options-row {
    display: flex;
    gap: 8px;
    padding: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    justify-content: center;
}

.option-btn {
    width: 64px;
    height: 64px;
    min-width: 64px;
    min-height: 64px;
    border: 2px solid transparent;
    border-radius: 14px;
    background: rgba(200, 220, 240, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    cursor: pointer;
}

.option-btn.selected {
    border-color: #c47ed0;
    background: rgba(196, 126, 208, 0.15);
}

.option-btn svg {
    width: 48px;
    height: 48px;
    max-width: 48px;
    max-height: 48px;
}

/* Color swatches */
.color-swatch {
    width: 52px;
    height: 52px;
    min-width: 52px;
    min-height: 52px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    touch-action: manipulation;
}

/* Celebration sparkle animation */
.sparkle.celebration {
    animation: celebration-sparkle 1s ease-out forwards;
    pointer-events: none;
}

@keyframes celebration-sparkle {
    0% {
        opacity: 1;
        transform: scale(0);
    }
    30% {
        opacity: 1;
        transform: scale(1.5);
    }
    100% {
        opacity: 0;
        transform: scale(0.3) translateY(-30px);
    }
}

/* Coloring gallery */
.coloring-gallery {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    padding: 16px;
    height: 100%;
    align-content: center;
}

.gallery-thumb {
    aspect-ratio: 3 / 4;
    border: 3px solid #ddd;
    border-radius: 16px;
    background: white;
    padding: 8px;
    cursor: pointer;
    touch-action: manipulation;
    min-height: 120px;
}

.gallery-thumb:active {
    transform: scale(0.95);
    border-color: #5b8fa8;
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Coloring view */
.coloring-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.coloring-page-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
    position: relative;
}

#coloring-canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: calc(100% - 32px);
    max-height: calc(100% - 32px);
    touch-action: manipulation;
}

.coloring-svg-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: calc(100% - 32px);
    max-height: calc(100% - 32px);
    pointer-events: none;
    /* Without width/height attrs, SVG needs explicit sizing.
       aspect-ratio ensures it scales proportionally like the canvas. */
    aspect-ratio: 1;
    width: 100%;
    height: auto;
}

/* Coloring panel */
.coloring-panel {
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.9);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.coloring-toolbar {
    display: flex;
    gap: 8px;
    padding: 4px 8px;
    justify-content: space-between;
}

.back-btn,
.tool-btn {
    width: 60px;
    height: 60px;
    min-width: 60px;
    min-height: 60px;
    border: 2px solid transparent;
    border-radius: 14px;
    background: rgba(200, 220, 240, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    cursor: pointer;
}

.tool-btn.selected {
    border-color: #5b8fa8;
    background: rgba(100, 200, 255, 0.2);
}

/* Coloring color swatch selected state */
.color-swatch.selected {
    border-color: #5b8fa8;
    box-shadow: 0 0 0 2px #5b8fa8;
}

/* Loading state */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    font-size: 1.5rem;
    color: #7eb8c8;
}
