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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #000;
    color: #fff;
    overflow: hidden;
    height: 100dvh;
    width: 100vw;
    position: fixed;
}

.container {
    width: 100%;
    height: 100%;
    position: relative;
}

.view {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.view.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Camera View */
#camera-view {
    background: #000;
}

#video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Default is mirrored for user camera */
}

#canvas {
    display: none;
}

.camera-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 120px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: linear-gradient(transparent, rgba(0,0,0,0.6));
    padding-bottom: env(safe-area-inset-bottom, 20px);
    z-index: 10;
}

.control-button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s;
}

.control-button:active {
    transform: scale(0.9);
}

.control-spacer {
    width: 50px; /* Same width as control-button to balance flex layout */
}

.capture-button {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #fff;
    border: 6px solid #000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    transition: transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.capture-button:active {
    transform: scale(0.9);
}

.button-icon {
    font-size: 32px;
}

/* Loading View */
#loading-view {
    background: #1a1a1a;
}

.loading-content {
    text-align: center;
}

/* Pond Ripple Loader */
.pond-ripples {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ripple {
    position: absolute;
    width: 100px;
    height: 100px;
    border: 4px solid #4CAF50; /* Frog green */
    border-radius: 50%;
    opacity: 0;
    animation: ripple-out 2s cubic-bezier(0.21, 0.53, 0.56, 0.8) infinite;
}

.ripple-1 { animation-delay: 0s; }
.ripple-2 { animation-delay: 0.6s; }
.ripple-3 { animation-delay: 1.2s; }

.pulsing-text {
    font-size: 20px !important;
    font-weight: 600;
    color: #4CAF50; /* Matching green text */
    animation: text-pulse 1.5s ease-in-out infinite;
}

@keyframes ripple-out {
    0% {
        transform: scale(0.1);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

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

/* Result View */
#result-view {
    background: #000;
}

#result-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.result-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 20px));
    display: flex;
    gap: 15px;
    justify-content: center;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    z-index: 10;
}

.retry-button, .save-button {
    padding: 14px 20px;
    background: #fff;
    color: #000;
    border: none;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s;
    flex: 1;
    max-width: 180px;
}

.save-button {
    background: #4CAF50;
    color: white;
}

.retry-button:active, .save-button:active {
    transform: scale(0.95);
}

/* Error View */
#error-view {
    background: #1a1a1a;
}

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

.error-content p {
    font-size: 18px;
    margin-bottom: 30px;
    color: #ff6b6b;
}

/* Mobile optimizations */
@media (max-width: 480px) {
    .capture-button {
        width: 70px;
        height: 70px;
    }
    
    .button-icon {
        font-size: 28px;
    }
    
    .retry-button, .save-button {
        padding: 12px 16px;
        font-size: 15px;
    }
    
    .camera-controls {
        height: 140px; /* Give more space for bottom URL bar on mobile */
        padding-bottom: 40px;
    }
    
    .result-controls {
        padding-bottom: 40px; /* Give more space for bottom URL bar on mobile */
    }
}

/* Landscape orientation */
@media (orientation: landscape) {
    .camera-controls, .result-controls {
        padding-bottom: 10px;
        height: 100px;
    }
}
