body,
html {
    height: 100%;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f5f5f5;
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Oxygen,
        Ubuntu,
        Cantarell,
        "Open Sans",
        "Helvetica Neue",
        sans-serif;
    user-select: none;
    position: fixed;
    width: 100%;
    overflow: hidden;
}

.captcha-container {
    border: 1px solid #ccc;
    background-color: white;
    outline: none;
    transition: box-shadow 0.3s ease;
}

.captcha-container:focus {
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.3);
}

.captcha-header {
    background-color: #4285f4;
    color: white;
    padding: 16px;
    margin: 5px;
    margin-bottom: 0;
}

.captcha-header h2 {
    margin: 0;
    font-size: 14px;
    font-weight: normal;
}

.captcha-header p {
    margin: 4px 0 0;
    font-size: 22px;
    font-weight: bold;
}

.captcha-canvas-container {
    margin: 5px;
    min-width: 320px;
    min-height: 200px;
    width: 360px;
    aspect-ratio: 16 / 10;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #999;
    font-size: 14px;
    resize: horizontal;
    overflow: auto;
}

@media (min-width: 768px) {
    .captcha-canvas-container {
        width: 480px;
    }
}

.captcha-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    pointer-events: none;
    opacity: 0.8;
    transition: opacity 0.15s ease;
}

.captcha-container:focus .captcha-canvas {
    opacity: 1;
}

.captcha-footer {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 5px;
    border-top: 1px solid #ccc;
}

.captcha-controls {
    display: flex;
    gap: 12px;
}

.captcha-button {
    border: none;
    padding: 0 16px;
    border-radius: 4px;
    font-size: 14px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.captcha-refresh-button {
    background-color: #e0e0e0;
    color: #444;
    cursor: pointer;
}

.captcha-refresh-button:hover {
    background-color: #d0d0d0;
}

.captcha-refresh-button:active {
    background-color: #c0c0c0;
}

.captcha-refresh-icon {
    width: 14px;
    height: 14px;
    fill: #444;
}

.captcha-verify-button {
    position: relative;
    background-color: #f0f0f0;
    min-width: 70px;
    color: #888;
    pointer-events: none;
    cursor: default;
    padding: 0 12px 0 24px;
    transition: background-color 0.3s ease;
    white-space: nowrap;
}

.success-message {
    color: #000;
    display: none;
    text-align: center;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
        "Liberation Mono", "Courier New", monospace;
}

.success-message h2 {
    margin: 0 0 10px 0;
    font-size: 18px;
    color: #4285f4;
}

.success-message a {
    color: #4285f4;
    text-decoration: none;
}

.success-message a:hover {
    text-decoration: underline;
}

@keyframes killFlash {
    0% {
        background-color: #4285f4;
    }

    100% {
        background-color: var(--end-color, #f0f0f0);
    }
}

@keyframes iconFlash {
    0% {
        fill: white;
    }

    100% {
        fill: var(--end-icon-color, #888888);
    }
}

.captcha-verify-icon {
    width: 18px;
    height: 18px;
    position: absolute;
    left: 8px;
}

.captcha-verify-button span {
    font-weight: 600;
}

.status-message {
    position: absolute;
    left: 0;
    right: 0;
    text-align: center;
    color: #888;
    font-size: 14px;
    display: none;
}

.status-message.focus {
    display: none;
}

.status-message.death {
    color: #ff4444;
    display: none;
}

.status-message.instructions {
    color: #666;
    display: none;
}

/* Show "Tap to play" when not focused, regardless of death state */
.captcha-container:not(:focus) .status-message.focus {
    display: block;
}

/* Show instructions when focused and not dead */
.captcha-container:focus .status-message.instructions {
    display: block;
}

/* Only show death message when focused */
.captcha-container:focus .status-message.death.visible {
    display: block;
}

/* Hide instructions when death message is visible */
.captcha-container:focus .status-message.death.visible~.status-message.instructions {
    display: none;
}

#debug-toggle {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 100;
    font-size: 12px;
    display: flex;
    align-items: center;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 3px 5px;
    cursor: pointer;
}

#debug-toggle input {
    margin-right: 5px;
}

#debug-container {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    width: 50%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 999;
}

#debug-log {
    width: 100%;
    height: 100%;
    background-color: #1e1e1e;
    color: #d4d4d4;
    border: none;
    padding: 10px;
    font-family: monospace;
    font-size: 14px;
    resize: none;
}

body.debug-active {
    margin-right: 50%;
}

body.debug-active .captcha-container {
    transform: translateX(-25%);
}

@media (max-width: 768px) {
    #debug-toggle {
        top: 5px;
        right: 5px;
        padding: 3px 6px;
        font-size: 12px;
    }

    #debug-container {
        width: 100%;
        height: 50%;
        top: auto;
        bottom: 0;
    }

    body.debug-active {
        margin-right: 0;
        margin-bottom: 50%;
    }

    body.debug-active .captcha-container {
        transform: translateY(-25%);
    }
}

.site-footer {
    position: fixed;
    bottom: 20px;
    left: 0;
    right: 0;
    text-align: center;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
        "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    color: #666;
}

.site-footer a {
    color: inherit;
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}

/* Mobile controls */
.mobile-controls {
    display: none;
    position: absolute;
    bottom: 30px;
    left: 0;
    right: 0;
    padding: 10px;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

@media (hover: none) and (pointer: coarse) {
    .captcha-container:focus .mobile-controls {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    /* Hide keyboard instructions when showing touch controls */
    .captcha-container:focus .status-message.instructions {
        display: none;
    }
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 40px);
    grid-template-rows: repeat(3, 40px);
    gap: 5px;
    pointer-events: auto;
}

.fire-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    pointer-events: auto;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.d-pad button {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.d-pad button:active,
.fire-button:active {
    background: rgba(255, 255, 255, 0.3);
}

.d-pad .up {
    grid-column: 2;
    grid-row: 1;
}

.d-pad .left {
    grid-column: 1;
    grid-row: 2;
}

.d-pad .right {
    grid-column: 3;
    grid-row: 2;
}

.d-pad .down {
    grid-column: 2;
    grid-row: 3;
}

.site-footer span {
    margin: 0 4px;
    opacity: 0.5;
}

.modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 1000;
}

.modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 4px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 1001;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
        "Liberation Mono", "Courier New", monospace;
    font-size: 14px;
    line-height: 1.5;
    user-select: text;
}

.modal code {
    background: #f5f5f5;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 13px;
    color: #666;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
        "Liberation Mono", "Courier New", monospace;
}

.modal h2 {
    margin-top: 0;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 20px;
    color: #666;
    padding: 5px;
}

.modal-close:hover {
    color: #000;
}