@font-face {
    font-family: 'Moqla';
    src: url('Fonts/Moqla-Regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'VTC Du Bois';
    src: url('Fonts/VTCDuBoisTrial-Regular.otf');
    font-weight: normal;
    font-style: normal;
}

#count {
    font-family: 'VTC Du Bois';
}

:root {
    --u: calc(100vw / 1920);
    --bg: #1b1b1b;
    --grid-line: rgba(255, 255, 255, 0.06);
    --tile-fill: #2b2b38;
    --tile-border: #4a4a4a;
    --ink: #ffffff;
}

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

html,
body {
    background: var(--bg);
}

.stage {
    position: relative;
    width: 100vw;
    height: calc(var(--u) * 1080);
    min-height: 100vh;
    overflow: hidden;
    color: var(--ink);
    background-color: var(--bg);
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: calc(var(--u) * 20) calc(var(--u) * 20);
}

.tagline {
    position: absolute;
    left: calc(var(--u) * 74);
    top: calc(var(--u) * 175);
    font-family: 'VTC Du Bois';
    font-weight: 400;
    font-size: calc(var(--u) * 24);
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.logo {
    position: absolute;
    right: calc(var(--u) * 70);
    top: calc(var(--u) * 40);
    width: calc(var(--u) * 172);
    text-align: center;
    line-height: 1;
}

.letters {
    position: absolute;
    left: calc(var(--u) * 147);
    top: calc(var(--u) * 286);
    width: calc(var(--u) * 1292);
    display: grid;
    grid-template-columns: repeat(8, calc(var(--u) * 144));
    grid-auto-rows: calc(var(--u) * 135);
    column-gap: calc(var(--u) * 20);
    row-gap: calc(var(--u) * 18);
    direction: rtl;
    list-style: none;
}

.letters button {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    background: var(--tile-fill);
    color: var(--ink);
    border: calc(var(--u) * 5) solid var(--tile-border);
    border-radius: 0;
    cursor: pointer;
    font-family: 'Moqla';
    font-size: 45px;
    line-height: 1;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.letters button:hover {
    background: #3a3a4d;
    border-color: #7a7a7a;
}

.letters button:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}

.viewer {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--ink);
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    margin: 0;
}

.viewer:not([open]) {
    display: none;
}

.viewer::backdrop {
    background: rgba(10, 10, 14, 0.82);
    backdrop-filter: blur(4px);
}

.viewer-inner {
    position: relative;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: clamp(8px, 2vw, 32px);
    padding: clamp(56px, 8vh, 96px) clamp(12px, 3vw, 48px);
}

.frame {
    justify-self: center;
    width: min(100%, 1100px);
    background: var(--tile-fill);
    border: 5px solid var(--tile-border);
}

.frame-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 5px solid var(--tile-border);
    font-family: 'Moqla';
    font-size: 18px;
}

.frame-head .meta {
    display: flex;
    align-items: baseline;
    gap: 12px;
    min-width: 0;
}

.frame-head .sep {
    color: var(--tile-border);
}

.frame-head .title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: 'Moqla';
}

.frame-head .glyph {
    font-family: 'Moqla';
    font-size: 34px;
    line-height: 1;
}

.screen {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #000;
}

.screen video {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.screen canvas {
    display: none;
}

.ascii {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
    cursor: pointer;
}

.ascii pre {
    margin: 0;
    color: #fff;
    font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace;
    font-size: 6px;
    line-height: 1.09;
    white-space: pre;
    direction: ltr;
    unicode-bidi: bidi-override;
    font-variant-ligatures: none;
    user-select: none;
}

.screen .missing {
    position: absolute;
    inset: 0;
    display: none;
    place-items: center;
    text-align: center;
    padding: 24px;
    font-family: "Chakra Petch", sans-serif;
    font-size: 20px;
    color: #bdbdc8;
}

.screen.is-missing .missing {
    display: grid;
}

.screen.is-missing .ascii {
    visibility: hidden;
}

.nav,
.close {
    background: var(--tile-fill);
    color: var(--ink);
    border: 5px solid var(--tile-border);
    border-radius: 0;
    cursor: pointer;
    font-family: "Chakra Petch", sans-serif;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.nav:hover,
.close:hover {
    background: #3a3a4d;
    border-color: #7a7a7a;
}

.nav:focus-visible,
.close:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}

.nav {
    width: clamp(44px, 5vw, 72px);
    height: clamp(64px, 8vw, 110px);
    display: grid;
    place-items: center;
}

.nav svg,
.close svg {
    width: 50%;
    height: auto;
    stroke: currentColor;
    fill: none;
    stroke-width: 3;
    stroke-linecap: square;
}

.close {
    position: absolute;
    top: clamp(12px, 3vh, 32px);
    right: clamp(12px, 3vw, 48px);
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
}

.close svg {
    width: 45%;
}

@media (max-width: 820px) {
    .stage {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto 1fr;
        align-content: start;
        align-items: start;
        gap: 24px 16px;
        padding: max(20px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
        background-size: 20px 20px;
    }

    .tagline {
        position: static;
        grid-column: 1;
        grid-row: 1;
        font-size: clamp(16px, 4.6vw, 24px);
        align-self: center;
    }

    .logo {
        position: static;
        grid-column: 2;
        grid-row: 1;
        width: auto;
    }

    .logo img {
        height: clamp(40px, 11vw, 64px);
        width: auto;
        display: block;
    }

    .letters {
        position: static;
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        grid-auto-rows: auto;
        gap: 10px;
    }

    .letters li {
        aspect-ratio: 1 / 1;
    }

    .letters button {
        border-width: 3px;
        font-size: clamp(30px, 10vw, 45px);
        -webkit-tap-highlight-color: transparent;
    }
}

@media (max-width: 700px) {
    .viewer {
        height: 100vh;
        height: 100dvh;
    }

    .viewer-inner {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
        align-content: center;
        gap: 12px;
        padding: max(72px, calc(env(safe-area-inset-top) + 64px)) 12px max(20px, env(safe-area-inset-bottom));
    }

    .frame {
        grid-column: 1 / -1;
        grid-row: 1;
        width: 100%;
        border-width: 3px;
        touch-action: pan-y;
    }

    .frame-head {
        padding: 8px 12px;
        border-bottom-width: 3px;
        font-size: 14px;
    }

    .frame-head .glyph {
        font-size: 26px;
    }

    .nav {
        width: 100%;
        height: 56px;
        grid-row: 2;
        border-width: 3px;
    }

    .nav svg {
        height: 60%;
        width: auto;
    }

    .close {
        top: max(12px, env(safe-area-inset-top));
        right: 12px;
        width: 48px;
        height: 48px;
        border-width: 3px;
    }
}

@media (max-height: 480px) and (orientation: landscape) {
    .viewer-inner {
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-rows: auto;
        padding: 12px 64px;
    }

    .frame {
        grid-column: 2;
        grid-row: 1;
        width: auto;
        max-height: calc(100dvh - 24px);
    }

    .screen {
        max-height: calc(100dvh - 100px);
    }

    .nav {
        grid-row: 1;
        width: 44px;
        height: 72px;
    }

    .close {
        top: 8px;
        right: 8px;
        width: 40px;
        height: 40px;
    }
}
