* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 50%, #ffecd2 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

#app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px;
}

header {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%);
    padding: 15px 20px;
    border-radius: 20px;
    text-align: center;
    margin-bottom: 15px;
    box-shadow: 0 4px 15px rgba(255, 154, 158, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

header h1 {
    font-size: 1.8rem;
    color: #5a3d5c;
    text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.5);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #5a3d5c;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ccc;
}

.status-dot.loading {
    background: #ffa726;
    animation: pulse-dot 1s infinite;
}

.status-dot.ready {
    background: #4caf50;
    box-shadow: 0 0 8px #4caf50;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    position: relative;
}

#camera-container {
    position: relative;
    background: #000;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    aspect-ratio: 4/3;
    max-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

#video {
    display: none;
}

#canvas {
    max-width: 100%;
    max-height: 100%;
    transform: scaleX(-1);
    border-radius: 15px;
}

#frame-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    border-radius: 15px;
}

.frame-polaroid {
    border: 15px solid white;
    border-bottom-width: 50px;
}

.frame-rainbow {
    border: 10px solid transparent;
    background: linear-gradient(white, white) padding-box,
                linear-gradient(90deg, red, orange, yellow, green, blue, indigo, violet) border-box;
}

.frame-hearts {
    box-shadow: inset 0 0 0 15px rgba(255, 105, 180, 0.5);
}

.frame-stars {
    box-shadow: inset 0 0 0 15px rgba(255, 215, 0, 0.5);
}

.frame-floral {
    box-shadow: inset 0 0 0 15px rgba(255, 182, 193, 0.6);
}

.frame-holiday {
    box-shadow: inset 0 0 0 15px rgba(34, 139, 34, 0.5);
}

.frame-birthday {
    box-shadow: inset 0 0 0 15px rgba(255, 20, 147, 0.4);
}

#props-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.placed-prop {
    position: absolute;
    cursor: grab;
    pointer-events: auto;
    transition: transform 0.2s ease;
    user-select: none;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
    z-index: 10;
}

.placed-prop:hover {
    transform: translate(-50%, -50%) scale(1.1);
}

#countdown-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 120px;
    color: white;
    text-shadow: 4px 4px 8px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 100;
}

#countdown-display.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    animation: pulse 0.5s ease-in-out;
}

@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.2); }
}

#controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

#timer-options {
    display: flex;
    gap: 10px;
}

.timer-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    background: #f0f0f0;
    color: #666;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.timer-btn.active {
    background: linear-gradient(135deg, #ff9a9e 0%, #fad0c4 100%);
    color: white;
    transform: scale(1.05);
}

.timer-btn:hover {
    transform: scale(1.05);
}

#capture-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 4px solid white;
    background: linear-gradient(135deg, #ff6b9d 0%, #ff8e53 100%);
    cursor: pointer;
    font-size: 32px;
    box-shadow: 0 6px 20px rgba(255, 107, 157, 0.4);
    transition: all 0.3s ease;
    animation: pulse-glow 2s infinite;
}

#capture-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    animation: none;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 6px 20px rgba(255, 107, 157, 0.4); }
    50% { box-shadow: 0 6px 30px rgba(255, 107, 157, 0.7); }
}

#capture-btn:hover:not(:disabled) {
    transform: scale(1.1);
}

#capture-btn:active:not(:disabled) {
    transform: scale(0.95);
}

#control-buttons {
    display: flex;
    gap: 15px;
}

#control-buttons button {
    width: 50px;
    height: 50px;
    border-radius: 15px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#control-buttons button:hover {
    transform: translateY(-3px) scale(1.05);
}

.side-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.side-panel h3 {
    margin-bottom: 15px;
    color: #5a3d5c;
    text-align: center;
}

.hint-text {
    font-size: 12px;
    color: #888;
    text-align: center;
    margin-top: 10px;
}

.hidden {
    display: none !important;
}

#props-grid, #frames-grid, #filters-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.prop-item {
    font-size: 32px;
    text-align: center;
    padding: 10px;
    background: #f8f8f8;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.prop-item:hover {
    background: #fff0f5;
    transform: scale(1.1);
}

.frame-item, .filter-item {
    padding: 12px 8px;
    text-align: center;
    background: #f8f8f8;
    border-radius: 12px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.frame-item.active, .filter-item.active {
    background: linear-gradient(135deg, #ff9a9e 0%, #fad0c4 100%);
    color: white;
}

.frame-item:hover, .filter-item:hover {
    transform: scale(1.05);
}

.action-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f0f0f0;
    color: #666;
}

.action-btn.success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.action-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.action-btn.danger {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    color: white;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

#gallery-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 20px;
}

#gallery-panel h3 {
    margin-bottom: 15px;
    color: #5a3d5c;
    text-align: center;
}

#gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
    max-height: 300px;
    overflow-y: auto;
}

.gallery-item {
    position: relative;
    aspect-ratio: 4/3;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-item:hover img {
    transform: scale(1.1);
}

.delete-photo {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-item:hover .delete-photo {
    opacity: 1;
}

.empty-gallery {
    text-align: center;
    color: #999;
    padding: 20px;
}

#pose-suggestion {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 40px;
    border-radius: 25px;
    font-size: 1.5rem;
    font-weight: bold;
    color: #ff6b9d;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    animation: bounce-in 0.5s ease;
}

@keyframes bounce-in {
    0% { transform: translate(-50%, -50%) scale(0); }
    50% { transform: translate(-50%, -50%) scale(1.1); }
    100% { transform: translate(-50%, -50%) scale(1); }
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 25px;
    padding: 20px;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.error-content {
    text-align: center;
    padding: 30px;
}

.error-content h2 {
    margin-bottom: 15px;
    color: #5a3d5c;
}

.error-content p {
    margin-bottom: 20px;
    color: #666;
}

#modal-image {
    max-width: 100%;
    max-height: 60vh;
    border-radius: 15px;
    object-fit: contain;
}

.modal-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.modal-actions button {
    flex: 1;
    min-width: 100px;
}

#confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3000;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -20px;
    animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

footer {
    text-align: center;
    padding: 15px;
    color: #888;
    font-size: 14px;
}

footer a {
    color: #ff6b9d;
    text-decoration: none;
}

.camera-error {
    color: white;
    text-align: center;
    padding: 40px;
}

.camera-error h2 {
    margin-bottom: 15px;
}

.camera-error .error-detail {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 10px;
}

.camera-error button {
    padding: 15px 30px;
    border: none;
    border-radius: 25px;
    background: linear-gradient(135deg, #ff9a9e 0%, #fad0c4 100%);
    color: white;
    font-size: 16px;
    cursor: pointer;
    margin-top: 20px;
}

/* Mobile optimizations */
@media (max-width: 600px) {
    header h1 {
        font-size: 1.4rem;
    }
    
    #camera-container {
        aspect-ratio: 3/4;
        max-height: 55vh;
    }
    
    #capture-btn {
        width: 70px;
        height: 70px;
        font-size: 28px;
    }
    
    #control-buttons button {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
    
    .prop-item {
        font-size: 24px;
        padding: 8px;
    }
    
    #props-grid, #frames-grid, #filters-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
    
    .frame-item, .filter-item {
        font-size: 11px;
        padding: 10px 6px;
    }
    
    #pose-suggestion {
        font-size: 1.2rem;
        padding: 15px 25px;
    }
}

/* Tablet and larger */
@media (min-width: 768px) {
    #app-container {
        padding: 20px;
    }
    
    #main-content {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    #camera-container {
        flex: 2;
        min-width: 60%;
        max-height: 70vh;
    }
    
    #controls {
        flex: 1;
        min-width: 200px;
        height: fit-content;
    }
    
    .side-panel {
        width: 100%;
    }
}