:root {
    --grid-size: 10cm; /* Standard Amsler grid size */
}

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

body {
    background-color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    overflow: hidden;
}

/* Sponsor Banner */
.sponsor-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: #000;
    color: white;
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    animation: bannerSlideIn 0.4s ease-out;
}

@keyframes bannerSlideIn {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

.sponsor-banner.dismissed {
    transform: translateY(-100%);
    transition: transform 0.3s ease-in;
}

.sponsor-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: white;
}

.sponsor-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
}

.sponsor-text {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.sponsor-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.6;
}

.sponsor-name {
    font-size: 14px;
    font-weight: 700;
}

.sponsor-tagline {
    font-size: 11px;
    opacity: 0.7;
}

.sponsor-qr-link {
    margin-left: 16px;
    flex-shrink: 0;
}

.sponsor-qr {
    width: 40px;
    height: 40px;
    border-radius: 4px;
}

.sponsor-dismiss {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sponsor-dismiss:hover {
    color: white;
}

.sponsor-dismiss svg {
    width: 16px;
    height: 16px;
}

@media (max-width: 768px) {
    .sponsor-logo {
        width: 28px;
        height: 28px;
    }

    .sponsor-name {
        font-size: 13px;
    }

    .sponsor-tagline {
        display: none;
    }

    .sponsor-qr-link {
        display: none;
    }
}

@media print {
    .sponsor-banner {
        display: none !important;
    }
}

/* Mobile Warning */
.mobile-warning {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.95);
    display: none;
    z-index: 3000;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-warning-card {
    background-color: white;
    padding: 40px 30px;
    border-radius: 16px;
    max-width: 340px;
    width: calc(100% - 40px);
    text-align: center;
    margin: 0 auto;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.mobile-warning-icon {
    color: #333;
    margin-bottom: 16px;
}

.mobile-warning-card h2 {
    margin-bottom: 12px;
    color: #333;
    font-size: 22px;
}

.mobile-warning-card p {
    margin-bottom: 12px;
    color: #666;
    font-size: 14px;
    line-height: 1.5;
}

.mobile-app-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: #000;
    color: white;
    text-decoration: none;
    padding: 14px 24px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    margin: 16px 0 12px;
    transition: background-color 0.2s;
}

.mobile-app-button:hover {
    background-color: #333;
}

.mobile-continue-button {
    display: block;
    width: 100%;
    background: none;
    border: none;
    color: #999;
    font-size: 13px;
    cursor: pointer;
    padding: 8px;
    text-decoration: underline;
}

.mobile-continue-button:hover {
    color: #666;
}

@media print {
    .mobile-warning {
        display: none !important;
    }
}

body.inverted {
    background-color: black;
}

body.inverted svg line {
    stroke: white !important;
}

body.inverted svg circle {
    fill: white !important;
}

body.inverted .controls {
    background-color: rgba(255, 255, 255, 0.9);
    color: black;
}

.container {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Grid Container - uses CSS physical units */
.grid-container {
    width: var(--grid-size);
    height: var(--grid-size);
    display: flex;
    justify-content: center;
    align-items: center;
}

#amslerGrid {
    width: 100%;
    height: 100%;
}

/* Calibration Overlay */
.calibration-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.calibration-card {
    background-color: white;
    padding: 40px;
    border-radius: 16px;
    max-width: 600px;
    text-align: center;
}

.calibration-card h2 {
    margin-bottom: 20px;
    color: #333;
}

.calibration-card p {
    margin-bottom: 15px;
    color: #666;
    line-height: 1.6;
}

.calibration-method-selector {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
}

.method-button {
    background-color: #f5f5f5;
    color: #333;
    border: 2px solid #ddd;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

.method-button:hover {
    background-color: #e8e8e8;
}

.method-button.active {
    background-color: #000;
    color: white;
    border-color: #000;
}

.calibration-ruler {
    margin: 30px 0;
    padding: 20px;
    background-color: #f5f5f5;
    border-radius: 8px;
}

.ruler-line {
    width: calc(var(--grid-size) / 2);
    height: 0;
    border-top: 3px solid #000;
    margin: 0 0 10px;
}

.card-outline {
    width: calc(var(--grid-size) * 0.856);
    height: calc(var(--grid-size) * 0.54);
    border: 3px solid #000;
    margin: 0 auto 10px;
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.card-label {
    font-size: 14px;
    color: #999;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ruler-label {
    font-size: 14px;
    color: #666;
    margin: 0;
}

.calibration-controls {
    margin: 20px 0;
}

.button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 15px 0;
}

.button-group button {
    background-color: #000;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: background-color 0.2s;
}

.button-group button:hover {
    background-color: #333;
}

.size-display {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    margin: 10px 0;
}

.calibration-tips {
    background-color: #FFF8E1;
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
    text-align: left;
}

.calibration-tips ul {
    margin-left: 20px;
    margin-top: 10px;
}

.calibration-tips li {
    margin: 5px 0;
    color: #666;
}

.confirm-button {
    background-color: #000;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    margin: 10px 5px;
    transition: background-color 0.2s;
}

.confirm-button:hover {
    background-color: #333;
}

.skip-button {
    background-color: #555;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    margin: 10px 5px;
    transition: background-color 0.2s;
}

.skip-button:hover {
    background-color: #333;
}

/* Size Indicator */
.size-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 999;
}

/* Controls */
.controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #000;
    color: white;
    padding: 15px 25px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 1000;
    transition: opacity 0.3s;
}

.button-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.controls button {
    background-color: white;
    color: black;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.controls button svg {
    width: 16px;
    height: 16px;
}

.controls button:hover {
    background-color: #e0e0e0;
}

.controls button:active {
    background-color: #d0d0d0;
}

.info {
    text-align: center;
    margin-top: 5px;
}

.info p {
    margin: 2px 0;
    font-size: 14px;
}

.info .small {
    font-size: 11px;
    opacity: 0.8;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .calibration-card {
        padding: 20px;
        margin: 20px;
    }

    .controls {
        padding: 10px 15px;
        font-size: 12px;
    }

    .controls button {
        font-size: 12px;
        padding: 6px 12px;
    }

    .size-indicator {
        font-size: 12px;
        padding: 6px 12px;
    }
}

/* Fullscreen mode adjustments */
:fullscreen .grid-container,
:-webkit-full-screen .grid-container,
:-moz-full-screen .grid-container,
:-ms-fullscreen .grid-container {
    width: var(--grid-size);
    height: var(--grid-size);
}

/* Instructions Modal */
.instructions-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.instructions-card {
    background-color: white;
    padding: 40px;
    border-radius: 16px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    text-align: left;
}

.instructions-card h2 {
    margin-bottom: 20px;
    color: #333;
    text-align: center;
}

.instructions-content ol {
    margin-left: 20px;
    line-height: 1.8;
    color: #333;
}

.instructions-content li {
    margin: 15px 0;
}

.instructions-content ul {
    margin-left: 20px;
    margin-top: 10px;
}

.instructions-content ul li {
    margin: 8px 0;
    color: #666;
}

.warning-box {
    background-color: #FFF8E1;
    border-left: 4px solid #FF9800;
    padding: 15px;
    margin: 20px 0;
    border-radius: 4px;
}

.warning-box p {
    margin: 5px 0;
    color: #333;
}

.instructions-content .note {
    font-size: 14px;
    color: #666;
    margin-top: 20px;
    text-align: center;
}

.close-button {
    background-color: #000;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    display: block;
    margin: 20px auto 0;
    transition: background-color 0.2s;
}

.close-button:hover {
    background-color: #333;
}

/* Print Calibration and Instructions (hidden on screen, visible when printed) */
.print-calibration,
.print-instructions {
    display: none;
}

/* Print styles */
@media print {
    body {
        background-color: white;
        margin: 0;
        padding: 0;
    }

    .controls,
    .size-indicator,
    .calibration-overlay,
    .instructions-modal {
        display: none !important;
    }

    .container {
        width: 10cm;
        height: 10cm;
        display: block;
        margin: 0;
        padding: 0;
    }

    .grid-container {
        width: 10cm !important;
        height: 10cm !important;
        margin: 0;
        padding: 0;
    }

    /* Ensure SVG prints at correct size */
    #amslerGrid {
        width: 10cm !important;
        height: 10cm !important;
    }

    /* Show print calibration and instructions */
    .print-calibration {
        display: block;
        page-break-before: always;
        padding: 10px 0;
        max-width: 100%;
    }

    .print-calibration h2 {
        color: #333;
        margin-bottom: 6px;
        font-size: 16px;
    }

    .print-calibration > p {
        margin-bottom: 8px;
        font-size: 10px;
    }

    .print-verification-box {
        margin: 8px 0;
        padding: 10px;
        background-color: #f9f9f9;
        border: 1px solid #ddd;
        border-radius: 3px;
        display: inline-block;
        width: 48%;
        vertical-align: top;
    }

    .print-verification-box:first-of-type {
        margin-right: 3%;
    }

    .print-verification-box h3 {
        margin-bottom: 6px;
        color: #333;
        font-size: 12px;
    }

    .print-verification-box p {
        margin-top: 5px;
        font-size: 9px;
        color: #666;
        text-align: center;
        line-height: 1.2;
    }

    .print-ruler-line {
        width: 10cm;
        height: 0;
        border-top: 3px solid #000;
        margin: 8px auto;
    }

    .print-card-outline {
        width: 8.56cm;
        height: 5.4cm;
        border: 3px solid #000;
        margin: 8px auto;
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: white;
        border-radius: 3px;
    }

    .print-card-outline p {
        font-size: 10px;
        color: #999;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 1px;
    }

    .verification-note {
        background-color: #FFF8E1;
        padding: 8px;
        margin-top: 8px;
        border-left: 3px solid #FF9800;
        font-weight: 600;
        font-size: 9px;
        clear: both;
    }

    .print-instructions {
        display: block;
        padding: 10px 0 15px;
        page-break-inside: avoid;
    }

    .print-instructions h2 {
        color: #333;
        margin-bottom: 8px;
        font-size: 14px;
    }

    .print-instructions ol {
        margin-left: 16px;
        line-height: 1.4;
        font-size: 10px;
    }

    .print-instructions li {
        margin: 6px 0;
    }

    .print-instructions ul {
        margin-left: 16px;
        margin-top: 4px;
        font-size: 9px;
    }

    .print-instructions ul li {
        margin: 3px 0;
    }

    .print-instructions .warning-note {
        background-color: #f5f5f5;
        padding: 8px;
        margin-top: 8px;
        border-left: 3px solid #FF9800;
        font-size: 9px;
    }

    /* Page setup for printing */
    @page {
        size: letter portrait;
        margin: 1in;
    }
}
