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

html {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
    background: #fff;
}

#screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    background: #fff;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    outline: none;
    will-change: transform;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Transparent textarea that overlays the canvas on mobile.
   Captures touch events and opens the keyboard when a remote
   input field is focused. Invisible to the user. */
#mobile-input {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    font-size: 16px;
    border: none;
    padding: 0;
    background: transparent;
    color: transparent;
    caret-color: transparent;
    resize: none;
    outline: none;
    z-index: 2;
    pointer-events: none;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-appearance: none;
}

#mobile-input.enabled {
    pointer-events: auto;
}

#overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #888;
    font-size: 14px;
    z-index: 10;
    transition: opacity 0.3s;
}

#overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-top-color: #888;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
}

.spinner.error {
    border: none;
    animation: none;
    border-radius: 0;
    position: relative;
}

.spinner.error::before, .spinner.error::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 2px;
    background: #e74c3c;
    border-radius: 1px;
}

.spinner.error::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.spinner.error::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#captcha-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    z-index: 20;
}

#captcha-screen.hidden {
    display: none;
}

.captcha-box {
    background: #fff;
    border-radius: 8px;
    padding: 28px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.10);
    max-width: 340px;
    width: 100%;
}

.captcha-header {
    font-size: 20px;
    font-weight: 600;
    color: #3498db;
    text-align: center;
    margin-bottom: 16px;
}

.captcha-verify {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    color: #333;
    user-select: none;
    transition: border-color 0.2s, background 0.2s;
}

.captcha-verify:hover {
    border-color: #bbb;
    background: #fafafa;
}

.captcha-checkmark {
    width: 24px;
    height: 24px;
    border: 2px solid #ccc;
    border-radius: 4px;
    flex-shrink: 0;
    position: relative;
    transition: border-color 0.2s, background 0.2s;
}

.captcha-verify.verifying {
    pointer-events: none;
    border-color: #3498db;
}

.captcha-verify.verifying .captcha-checkmark {
    border-radius: 50%;
    border: 2px solid #ddd;
    border-top-color: #3498db;
    animation: spin 0.8s linear infinite;
}

.captcha-verify.checked {
    pointer-events: none;
    border-color: #2ecc71;
    background: #f0fdf4;
}

.captcha-verify.checked .captcha-checkmark {
    background: #2ecc71;
    border-color: #2ecc71;
}

.captcha-verify.checked .captcha-checkmark::after {
    content: "";
    position: absolute;
    left: 7px;
    top: 3px;
    width: 6px;
    height: 11px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.captcha-error {
    color: #e74c3c;
    font-size: 13px;
    text-align: center;
    margin-top: 10px;
    min-height: 18px;
}
