:root {
    --ink: #1a1a1a;
    --paper: #fbfdfb;
    --accent: #d97706;
    /* Matching Day 17 amber accent for consistency */
    --muted: #5b615c;
    --glass: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    overflow: hidden;
    background-color: #000;
    font-family: 'JetBrains Mono', monospace;
    color: var(--ink);
    padding: 0;
}

#ui-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 16px 20px;
    /* Compact padding */
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    pointer-events: auto;
    width: 280px;
    /* Slightly smaller width */
    max-width: calc(100vw - 40px);
    transition: all 0.3s ease;
}

.back-link {
    display: block;
    font-size: 0.65rem;
    color: var(--muted);
    text-decoration: none;
    margin-bottom: 12px;
    font-family: 'JetBrains Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--accent);
}

h1 {
    margin: 0 0 8px 0;
    font-family: 'Instrument Serif', serif;
    font-size: 1.6rem;
    /* Slightly smaller */
    font-weight: 400;
    letter-spacing: -0.01em;
    color: var(--ink);
    line-height: 1.1;
}

p {
    margin: 0 0 16px 0;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--muted);
}

p a {
    color: var(--ink);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s;
}

p a:hover {
    color: var(--accent);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* Tighter gap */
}

select {
    background: rgba(255, 255, 255, 0.8);
    color: var(--ink);
    border: 1px solid var(--glass-border);
    padding: 6px 10px;
    /* Compact padding */
    border-radius: 6px;
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    outline: none;
    transition: all 0.2s;
    width: 100%;
}

select:hover,
select:focus {
    border-color: var(--accent);
    background: #fff;
}

/* Target the dynamically created Three.js ARButton */
#ar-button-container {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    pointer-events: none;
    /* Let clicks pass through container */
    z-index: 1000;
}

#ARButton {
    /* Reset positioning since container handles it */
    position: relative !important;
    bottom: auto !important;
    left: auto !important;

    padding: 6px 16px;
    /* Compact padding */
    background: var(--ink) !important;
    color: #fff !important;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace !important;
    font-weight: 400;
    font-size: 0.75rem;
    /* transition: background 0.2s; */
    text-transform: uppercase;
    letter-spacing: 0.05em;
    pointer-events: auto !important;
    /* Re-enable for button */
    width: auto !important;
    /* Override inline width */
}

#ARButton:hover {
    background: var(--accent) !important;
}

.status-hidden {
    display: none;
}

#status-text {
    margin: 0;
    font-size: 0.7rem;
    font-style: italic;
    color: var(--accent);
}

#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    overflow: hidden;
    z-index: 1;
}

body.xr-active #canvas-container {
    width: 100vw;
    height: 100vh;
    border: none;
    border-radius: 0;
}

/* Mobile adjustments */
@media (max-width: 600px) {
    #ui-overlay {
        top: 20px;
        bottom: auto;
        left: 50%;
        transform: translateX(-50%);
        width: calc(100% - 40px);
        /* Almost full width */
        max-width: none;
        padding: 16px;
        border-radius: 12px;
    }

    .back-link {
        margin-bottom: 8px;
    }

    h1 {
        font-size: 1.4rem;
        margin-bottom: 4px;
    }

    p {
        font-size: 0.7rem;
        margin-bottom: 12px;
        display: -webkit-box;
        -webkit-line-clamp: 5;
        /* Increased to fit text */
        line-clamp: 5;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* Force hide AR button container on mobile */
    #ar-button-container {
        display: none !important;
    }

    /* Legacy fallback */
    #ARButton {
        display: none !important;
    }
}

/* Extended mobile/tablet range */
@media (max-width: 900px) {
    #ar-button-container {
        display: none !important;
    }
}