body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f0f0f0;
    color: #333;
    text-align: center;
    margin: 0;
    padding: 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

#calculator-container {
    display: block;
    margin: 0 auto;
    position: relative;
    width: 100%;
    max-width: 372px;
    height: auto;
    min-height: 780px;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

#calculator-container svg {
    display: block; /* Removes any extra space below the SVG */
    width: 100%;
    height: auto;
    min-height: 780px;
    max-height: none;
}

    #calculator-screen-canvas {
        position: absolute;
        /* Calculations based on SVG viewBox="0 0 372 780" and screen rect */
        /* top = 67.5 / 780 = 8.65% */
        top: 8.65%;
        /* left = 38.5 / 372 = 10.35% */
        left: 10.35%;
        /* width = 295 / 372 = 79.30% */
        width: 79.30%;
        /* height = 215 / 780 = 27.56% */
        height: 27.56%;
        border-radius: 7.5px; /* Match SVG screen radius */
        background: transparent; /* Make canvas transparent */
        z-index: 10;
    }

    /* D-Pad button hover effects for better visibility */
    #calculator-container path[id*="key-"]:hover {
        fill: rgba(255, 255, 0, 0.2) !important;
        stroke: rgba(255, 255, 0, 0.6) !important;
        stroke-width: 2px !important;
    }

    #calculator-container path[id*="key-"]:active {
        fill: rgba(255, 255, 0, 0.3) !important;
        stroke: rgba(255, 255, 0, 0.8) !important;
        stroke-width: 3px !important;
    }

/* Mobile Responsive Design */
@media (max-width: 768px) {
    * {
        box-sizing: border-box;
    }
    
    html {
        overflow-x: hidden;
        margin: 0;
        padding: 0;
    }
    
    body {
        padding: 0 0 20px 0; /* Add bottom padding to show full calculator */
        margin: 0;
        min-height: 100vh;
        overflow-x: hidden;
        overflow-y: auto; /* Allow vertical scroll if needed */
        display: block;
    }
    
    h1 {
        font-size: 1.5rem;
        margin: 0.5rem auto;
        text-align: center;
        max-width: 100%;
    }
    
    p {
        font-size: 0.9rem;
        margin: 0.5rem auto 1rem auto;
        text-align: center;
        max-width: 100%;
    }
    
    #calculator-container {
        width: 100%;
        max-width: 372px;
        margin: 0 auto;
        display: block;
        padding: 0;
        position: relative;
        box-sizing: border-box;
        min-height: auto; /* Remove 780px min-height on mobile */
        max-height: none; /* Remove height restrictions */
    }
    
    #calculator-container svg {
        width: 100%;
        height: auto;
        display: block;
        margin: 0 auto;
        min-height: auto; /* Override base min-height for mobile */
        max-height: none; /* Allow full height on mobile */
    }
    
    .calculator-svg {
        max-height: none !important; /* Override desktop max-height on mobile */
    }
    
    #calculator-screen-canvas {
        position: absolute;
        /* Align with light bluish screen: 67.5 / 780 = 8.65% */
        top: 8.65%;
        left: 10.35%;
        width: 79.30%;
        height: 27.56%;
        border-radius: 7.5px;
        background: transparent;
        z-index: 10;
    }
}

/* Small phones (iPhone SE, etc.) */
@media (max-width: 480px) {
    body {
        padding: 0;
        padding-top: max(0.5rem, env(safe-area-inset-top, 0.5rem));
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
    }
}

/* Medium-large phones (Samsung Galaxy A52s, Pixel, etc.) - Portrait mode */
@media (min-width: 390px) and (max-width: 430px) and (orientation: portrait) {
    #calculator-screen-canvas {
        /* Fine-tuned for Galaxy A52s (412px) and similar devices */
        top: 8.7%;
    }
}

/* Small phones - Portrait mode fix */
@media (max-width: 480px) and (orientation: portrait) {
    #calculator-container {
        width: 100%;
        max-width: 350px;
        margin: 0 auto;
        padding: 0;
    }
    
    h1 {
        font-size: 1.25rem;
        margin: 0.25rem auto;
        text-align: center;
    }
    
    p {
        font-size: 0.8rem;
        margin: 0.25rem auto 0.5rem auto;
        text-align: center;
    }
    
    #calculator-container svg {
        width: 100%;
        max-width: 350px;
        aspect-ratio: 350/735;
    }
    
    #calculator-screen-canvas {
        /* Fine-tuned for 350px max-width */
        top: 9.0%;
    }
}

/* Very small phones (iPhone 12 mini, etc.) */
@media (max-width: 375px) {
    body {
        padding-top: max(0.5rem, env(safe-area-inset-top, 0.5rem));
    }
    
    #calculator-container {
        width: 100%;
        max-width: 320px;
        margin: 15px auto;
    }
}

/* Very small phones - Portrait mode fix */
@media (max-width: 375px) and (orientation: portrait) {
    #calculator-container {
        width: 100%;
        max-width: 320px;
        margin: 0 auto;
        padding: 0;
    }
    
    #calculator-container svg {
        width: 100%;
        max-width: 320px;
        aspect-ratio: 320/672;
    }
    
    #calculator-screen-canvas {
        /* Fine-tuned for 320px max-width */
        top: 9.5%;
    }
}

/* Extra small phones */
@media (max-width: 320px) {
    body {
        padding-top: max(0.5rem, env(safe-area-inset-top, 0.5rem));
    }
    
    #calculator-container {
        width: 100%;
        max-width: 300px;
        margin: 15px auto;
    }
}

/* Extra small phones - Portrait mode fix */
@media (max-width: 320px) and (orientation: portrait) {
    #calculator-container {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
        padding: 0;
    }
    
    #calculator-container svg {
        width: 100%;
        max-width: 300px;
        aspect-ratio: 300/630;
    }
    
    #calculator-screen-canvas {
        /* Fine-tuned for 300px max-width */
        top: 10.0%;
    }
}

/* Touch optimization */
@media (hover: none) and (pointer: coarse) {
    #calculator-container path[id*="key-"]:hover {
        fill: rgba(255, 255, 0, 0.2) !important;
        stroke: rgba(255, 255, 0, 0.6) !important;
        stroke-width: 2px !important;
    }
    
    #calculator-container path[id*="key-"]:active {
        fill: rgba(255, 255, 0, 0.4) !important;
        stroke: rgba(255, 255, 0, 0.8) !important;
        stroke-width: 3px !important;
    }
}

/* Portrait orientation for mobile - Zero padding */
@media (max-width: 768px) and (orientation: portrait) {
    #calculator-container {
        margin: 0 auto;
        padding: 0;
    }
    
    #calculator-screen-canvas {
        /* Fine-tuned position for perfect border visibility */
        top: 8.7%;
    }
}

/* Landscape orientation for mobile */
@media (max-width: 768px) and (orientation: landscape) {
    body {
        padding: 0;
    }
    
    h1 {
        font-size: 1.2rem;
        margin: 0.25rem 0;
        text-align: center;
    }
    
    p {
        font-size: 0.8rem;
        margin: 0.25rem 0 0.5rem 0;
        text-align: center;
    }
    
    #calculator-container {
        width: 50vw;
        max-width: 300px;
        margin: 0 auto;
        padding: 0;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    #calculator-screen-canvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
    
    #calculator-container svg {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* iOS specific calculator optimizations */
@supports (-webkit-touch-callout: none) {
    #calculator-container {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
    
    #calculator-container svg {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
    }
    
    /* iOS safe area for calculator */
    @media (max-width: 768px) {
        body {
            padding-top: env(safe-area-inset-top, 0px);
        }
        
        .calculator-section {
            padding-top: max(15px, env(safe-area-inset-top, 15px)) !important;
        }
    }
}

/* Android specific calculator optimizations */
@media screen and (-webkit-min-device-pixel-ratio: 1) {
    #calculator-container {
        /* Better touch targets for Android */
        touch-action: manipulation;
    }
    
    #calculator-container path[id*="key-"] {
        /* Larger touch targets on Android */
        min-width: 44px;
        min-height: 44px;
    }
}

/* Landscape orientation optimizations */
@media (max-width: 768px) and (orientation: landscape) {
    #calculator-container {
        width: 50vw;
        max-width: 300px;
        margin: 0 auto;
        min-height: 80vh;
    }
    
    #calculator-container svg {
        width: 100%;
        max-width: 300px;
        aspect-ratio: 300/630;
    }
}

/* Very wide screens (tablets in landscape) */
@media (min-width: 1024px) and (max-height: 768px) {
    #calculator-container {
        max-width: 400px;
        width: 400px;
    }
    
    #calculator-container svg {
        max-width: 400px;
        aspect-ratio: 400/840;
    }
}

/* ===== DESKTOP RESPONSIVE SIZING ===== */
/* Calculator container - responsive sizing */
.calculator-container {
    max-width: 100% !important;
    margin: 0 auto !important;
    padding: 20px !important;
    text-align: center !important;
}

/* Calculator SVG - responsive sizing */
.calculator-svg {
    max-width: 100% !important;
    height: auto !important;
    max-height: 80vh !important;
    width: auto !important;
}

/* Desktop-specific sizing */
@media (min-width: 768px) {
    .calculator-svg {
        max-width: 600px !important;
        max-height: 70vh !important;
    }
}

@media (min-width: 1200px) {
    .calculator-svg {
        max-width: 700px !important;
        max-height: 65vh !important;
    }
}

@media (min-width: 1600px) {
    .calculator-svg {
        max-width: 800px !important;
        max-height: 60vh !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }
    
    h1, p {
        color: #e0e0e0;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Legal Disclaimer Styles */
.legal-disclaimer {
    background-color: #f8f9fa;
    border-top: 1px solid #e9ecef;
    padding: 15px 0;
    margin-top: 20px;
}

.legal-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    text-align: center;
}

.legal-content p {
    font-size: 12px;
    color: #495057;
    margin: 0;
    line-height: 1.4;
}

.legal-content a {
    color: #0056b3;
    text-decoration: underline;
    font-weight: 500;
}

.legal-content a:hover {
    text-decoration: underline;
}

.legal-content a:focus {
    outline: 2px solid #0056b3;
    outline-offset: 2px;
    text-decoration: underline;
}

/* Dark mode for legal disclaimer */
@media (prefers-color-scheme: dark) {
    .legal-disclaimer {
        background-color: #2d3748;
        border-top-color: #4a5568;
    }
    
    .legal-content p {
        color: #cbd5e0;
    }
    
    .legal-content a {
        color: #63b3ed;
    }
}

/* ========================================
   START BUTTON & LOADING STATES
   ======================================== */

/* Calculator Placeholder */
.calculator-placeholder {
    position: relative;
    width: 100%;
    max-width: 372px;
    height: auto;
    margin: 0 auto;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

/* Ensure calculator stays below header on mobile */
@media (max-width: 768px) {
    .calculator-placeholder {
        margin-top: 10px;
    }
}

.placeholder-content {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Calculator Preview Image (color but blurred) */
.calculator-preview-image {
    width: 100%;
    height: auto;
    display: block;
    filter: blur(4px) brightness(0.7);
    /* Prevent layout shift */
    aspect-ratio: 372/780;
    object-fit: cover;
}

/* START Button Overlay */
.start-button-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 150px;
    background: rgba(0, 0, 0, 0.4);
}

/* Clean and Professional START Button - High Visibility */
.start-calculator-button {
    padding: 20px 50px;
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    background: linear-gradient(135deg, #00C853 0%, #00E676 100%);
    border: none;
    border-radius: 60px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 10px 30px rgba(0, 200, 83, 0.5), 0 0 0 0 rgba(255, 255, 255, 0.5);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

/* Shine effect on button */
.start-calculator-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.start-calculator-button:hover::before {
    left: 100%;
}

.start-calculator-button:hover {
    background: linear-gradient(135deg, #00E676 0%, #69F0AE 100%);
    transform: translateY(-4px) scale(1.08);
    box-shadow: 0 15px 40px rgba(0, 230, 118, 0.7), 0 0 20px rgba(105, 240, 174, 0.4);
}

.start-calculator-button:active {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 8px 25px rgba(0, 200, 83, 0.6);
}

.play-icon {
    width: 32px;
    height: 32px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.start-text {
    font-size: 1.3rem;
    letter-spacing: 0.5px;
    font-weight: 700;
}

/* Loading Progress - Desktop Overlay */
.loading-progress {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 9999 !important;
    background: rgba(0, 0, 0, 0.9) !important;
    padding: 30px !important;
    border-radius: 15px !important;
    text-align: center !important;
    color: white !important;
    font-size: 18px !important;
    font-weight: bold !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
    min-width: 300px !important;
    width: auto;
    max-width: 400px;
}

.loading-spinner {
    width: 50px !important;
    height: 50px !important;
    border: 5px solid #f3f3f3 !important;
    border-top: 5px solid #4CAF50 !important;
    border-radius: 50% !important;
    animation: spin 1s linear infinite !important;
    margin: 0 auto 20px !important;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.progress-bar-container {
    width: 100%;
    margin: 20px 0;
}

.progress-bar {
    width: 100% !important;
    height: 8px !important;
    background: #333 !important;
    border-radius: 4px !important;
    overflow: hidden !important;
    margin-top: 15px !important;
}

.progress-fill {
    height: 100% !important;
    background: linear-gradient(90deg, #4CAF50, #8BC34A) !important;
    border-radius: 4px !important;
    transition: width 0.3s ease !important;
    width: 0%;
}

.loading-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin: 15px 0 5px 0;
}

.loading-subtext {
    font-size: 0.9rem;
    color: #666;
    margin: 5px 0 0 0;
}

#progress-percent {
    font-weight: 700;
    color: #4CAF50;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .calculator-placeholder {
        max-width: 100%;
        border-radius: 10px;
    }
    
    .start-button-overlay {
        padding-top: 120px;
    }
    
    .start-calculator-button {
        padding: 16px 36px;
        font-size: 1.1rem;
    }
    
    .play-icon {
        width: 24px;
        height: 24px;
    }
    
    .start-text {
        font-size: 1.1rem;
    }
    
    .loading-progress {
        position: absolute;
        top: 120px;
        left: 50%;
        transform: translateX(-50%);
        max-width: 90%;
        padding: 25px 20px;
        background: rgba(255, 255, 255, 0.95);
        color: #333;
        font-size: 1rem;
        font-weight: 600;
    }
    
    .loading-spinner {
        width: 50px;
        height: 50px;
    }
    
    .progress-bar {
        height: 25px;
    }
    
    .loading-text {
        font-size: 1rem;
    }
    
    .loading-subtext {
        font-size: 0.85rem;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .start-button-overlay {
        padding-top: 80px;
    }
    
    .start-calculator-button {
        padding: 14px 32px;
        font-size: 1rem;
    }
    
    .play-icon {
        width: 22px;
        height: 22px;
    }
    
    .start-text {
        font-size: 1rem;
    }
    
    .loading-progress {
        top: 80px;
    }
}