html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
}

#sketch {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 0;
    background: #020617;
}

#quasicrystals-canvas {
    display: block;
    width: 100vw;
    height: 100vh;
}

.xr-panel {
    position: fixed;
    left: max(1.25rem, env(safe-area-inset-left));
    top: max(1.25rem, env(safe-area-inset-top));
    z-index: 1000;
    display: grid;
    gap: 0.45rem;
    max-width: min(18rem, calc(100vw - 2.5rem));
}

.xr-panel[hidden] {
    display: none;
}

.xr-panel__actions {
    display: flex;
    align-items: stretch;
    gap: 0.4rem;
}

.xr-button {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(12, 74, 110, 0.9);
    color: #ffffff;
    cursor: pointer;
    flex: 1;
    font: inherit;
    font-weight: 700;
    min-height: 2.75rem;
    padding: 0.7rem 1rem;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.28);
    backdrop-filter: blur(14px);
}

.xr-close {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.72);
    color: #ffffff;
    cursor: pointer;
    font: inherit;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1;
    min-width: 2.75rem;
    padding: 0 0.75rem;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.28);
    backdrop-filter: blur(14px);
}

.xr-close:hover,
.xr-close:focus-visible {
    background: rgba(30, 41, 59, 0.86);
}

.xr-button:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.xr-status {
    margin: 0;
    color: #e5e7eb;
    font-size: 0.85rem;
    line-height: 1.3;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.references-panel {
    display: none;
}

.references-panel.is-mounted {
    display: block;
    margin: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-trigger {
    appearance: none;
    display: block;
    width: 100%;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 14px;
    background: rgba(17, 24, 39, 0.9);
    color: #f8fafc;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.8rem 1rem;
    text-align: left;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.28);
    backdrop-filter: blur(14px);
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.modal-trigger:hover,
.modal-trigger:focus-visible {
    transform: translateY(-1px);
    border-color: rgba(96, 165, 250, 0.45);
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.32);
}

body {
    position: relative;
    min-height: 100vh;
}

.center {
    position: relative;
    z-index: 2;
    padding-top: 1.5rem;
}

.links-modal {
    width: min(42rem, calc(100vw - 2rem));
    border: 0;
    border-radius: 22px;
    padding: 0;
    background: #ffffff;
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.28);
}

.links-modal::backdrop {
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(8px);
}

.links-modal__content {
    padding: 1.5rem 1.5rem 1.25rem;
}

.links-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.links-modal__title {
    margin: 0;
    font-size: 1.1rem;
}

.links-modal__close {
    appearance: none;
    border: 0;
    background: transparent;
    color: #334155;
    cursor: pointer;
    font-size: 1.75rem;
    line-height: 1;
    padding: 0.2rem 0.35rem;
}

.links-modal ul {
    margin: 0;
    padding-left: 1.2rem;
}

.links-modal li + li {
    margin-top: 0.5rem;
}

.lil-gui.root {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 1000;
    --width: 280px;
    --background-color: rgba(17, 24, 39, 0.9);
    --text-color: #f3f4f6;
    --title-background-color: rgba(255, 255, 255, 0.08);
    --title-text-color: #ffffff;
    --widget-color: rgba(255, 255, 255, 0.16);
    --hover-color: rgba(255, 255, 255, 0.24);
    --focus-color: #60a5fa;
    backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.28);
}

@media (max-width: 768px) {
    .lil-gui.root {
        top: 0.75rem;
        right: 0.75rem;
        --width: min(280px, calc(100vw - 1.5rem));
    }

    .xr-panel {
        left: max(0.75rem, env(safe-area-inset-left));
        top: max(0.75rem, env(safe-area-inset-top));
        max-width: min(14rem, calc(100vw - 1.5rem));
    }
}

@supports (height: 100dvh) {
    html,
    body {
        min-height: 100dvh;
    }

    #quasicrystals-canvas {
        width: 100dvw;
        height: 100dvh;
    }
}
