html, body {
    margin: 0;
    padding: 0;
    background: #050202;
    color: #e8dcc8;
    font-family: Impact, Haettenschweiler, "Arial Black", Arial, sans-serif;
}

body.gate {
    min-height: 100%;
    background:
        radial-gradient(ellipse at top, #3a0505 0%, #050202 55%),
        repeating-linear-gradient(0deg, rgba(255,255,255,0.03) 0, rgba(255,255,255,0.03) 1px, transparent 1px, transparent 3px);
}

a {
    color: #ffb347;
}

.wrap {
    width: 92%;
    max-width: 820px;
    margin: 0 auto;
    padding: 28px 0 48px;
    text-align: center;
}

.brand {
    font-size: 18px;
    letter-spacing: 0.45em;
    color: #9a1f1f;
    text-transform: uppercase;
}

h1.logo {
    margin: 8px 0 6px;
    font-size: 42px;
    line-height: 0.9;
    letter-spacing: 0.04em;
    color: #d61f1f;
    text-shadow:
        0 0 18px #ff2a2a,
        0 4px 0 #4a0000,
        0 8px 0 #220000;
    text-transform: uppercase;
}

@media (min-width: 700px) {
    h1.logo { font-size: 64px; }
}

.tag {
    margin: 0 0 28px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 16px;
    color: #cbb79a;
}

.choices {
    width: 100%;
    border-collapse: collapse;
}

.choices td {
    padding: 8px;
}

.choice {
    display: block;
    padding: 18px 12px;
    background: #140707;
    border: 3px solid #7a1515;
    color: #ffe7c8;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.choice:hover,
.choice:focus {
    border-color: #ff3030;
    background: #2a0a0a;
    color: #fff;
}

.choice b {
    display: block;
    font-size: 28px;
    margin-bottom: 6px;
}

.choice span {
    display: block;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 14px;
    letter-spacing: 0;
    text-transform: none;
    color: #d7c3a5;
}

.wad-box {
    margin-top: 28px;
    padding: 14px 12px 10px;
    border: 1px solid #4a2020;
    font-family: "Courier New", Courier, monospace;
    font-size: 13px;
    color: #c9a07a;
    text-align: left;
}

.wad-box label {
    display: block;
    margin-bottom: 8px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #d61f1f;
}

.wad-box select {
    width: 100%;
    padding: 10px 8px;
    background: #140707;
    color: #ffe7c8;
    border: 2px solid #7a1515;
    font-family: inherit;
    font-size: 14px;
}

.wad-import {
    margin-top: 12px;
    color: #ffb347;
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
}

.wad-import input {
    display: block;
    margin-top: 8px;
    width: 100%;
    color: #c9a07a;
}

.wad-status {
    min-height: 1.2em;
    margin: 8px 0 0;
    color: #e8dcc8;
}

.fs-root {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    background: #000;
}

.fs-root.is-on {
    display: block;
}

.fs-root iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: #000;
}

.play-gate {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 500;
    background: #050202;
    color: #ffe7c8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.play-gate.is-off {
    display: none;
}

.play-gate button {
    padding: 18px 28px;
    background: #140707;
    border: 3px solid #d61f1f;
    color: #ffe7c8;
    font-family: Impact, Arial, sans-serif;
    font-size: 28px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.play-gate span {
    display: block;
    margin-top: 12px;
    font-family: Georgia, serif;
    color: #cbb79a;
}

html.play-html,
html.play-html body {
    background: #000;
    overflow: hidden;
    height: 100%;
    height: 100dvh;
    width: 100%;
    position: fixed;
    left: 0;
    top: 0;
    touch-action: none;
    -ms-touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.play-shell, .play-shell body {
    overflow: hidden;
}

.stage {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background: #000;
}

.stage canvas,
#doom-canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background: #000;
}

.quit-btn {
    position: absolute;
    top: calc(8px + env(safe-area-inset-top, 0px));
    right: calc(8px + env(safe-area-inset-right, 0px));
    z-index: 400;
    padding: 12px 18px;
    min-width: 64px;
    min-height: 44px;
    background: rgba(140, 12, 12, 0.82);
    border: 2px solid rgba(255, 90, 90, 0.85);
    color: #fff;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 16px;
    font-family: Impact, Arial, sans-serif;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(255, 0, 0, 0.35);
    border-radius: 6px;
    cursor: pointer;
}

.quit-btn:active,
.quit-btn:hover {
    background: rgba(180, 20, 20, 0.7);
}

.hud-bar {
    display: none;
}

.status {
    position: absolute;
    left: 8%;
    right: 8%;
    top: 42%;
    z-index: 30;
    text-align: center;
    color: #ff4d4d;
    font-size: 22px;
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    text-shadow: 0 0 12px #ff1a1a;
    pointer-events: none;
}

/* Diagnostics are sentences, not two words: make them readable and clickable. */
.status.is-error {
    top: 34%;
    font-size: 15px;
    line-height: 1.5;
    text-transform: none;
    letter-spacing: 0.02em;
    color: #ffcf9e;
    text-shadow: 0 0 10px rgba(255, 26, 26, 0.7);
}

.status a {
    pointer-events: auto;
    color: #ff8f8f;
}

.touch-layer {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 6;
    pointer-events: none;
}

.pad, .actions, .tbtn, .analog, .util-bar {
    pointer-events: auto;
}

.analog {
    position: absolute;
    left: calc(18px + env(safe-area-inset-left, 0px));
    bottom: calc(22px + env(safe-area-inset-bottom, 0px));
    width: 148px;
    height: 148px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.07);
    border: 2px solid rgba(255, 255, 255, 0.22);
    touch-action: none;
}

.analog-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 64px;
    height: 64px;
    margin: -32px 0 0 -32px;
    border-radius: 50%;
    background: rgba(220, 50, 50, 0.32);
    border: 2px solid rgba(255, 210, 210, 0.4);
    box-shadow: none;
}

body.is-mobile .analog {
    width: 160px;
    height: 160px;
}

@media (orientation: landscape) {
    body.is-mobile .analog {
        width: 132px;
        height: 132px;
        left: calc(14px + env(safe-area-inset-left, 0px));
        bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    }
}

.pad {
    position: absolute;
    left: 10px;
    bottom: 10px;
    width: 132px;
    height: 132px;
}

.tbtn {
    position: absolute;
    width: 52px;
    height: 52px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(0, 0, 0, 0.22);
    color: rgba(255, 230, 210, 0.8);
    font-family: Impact, Arial, sans-serif;
    font-size: 13px;
    text-transform: uppercase;
    border-radius: 50%;
}

.tbtn:active, .tbtn.is-down {
    background: rgba(200, 30, 30, 0.4);
}

.pad .tbtn.up { left: 42px; top: 0; }
.pad .tbtn.down { left: 42px; bottom: 0; }
.pad .tbtn.left { left: 0; top: 42px; }
.pad .tbtn.right { right: 0; top: 42px; }

.util-bar {
    position: absolute;
    left: calc(8px + env(safe-area-inset-left, 0px));
    top: calc(8px + env(safe-area-inset-top, 0px));
    width: 210px;
    height: 48px;
    pointer-events: auto;
}

.util-bar .tbtn {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 40px;
    margin-right: 4px;
    border-radius: 8px;
    font-size: 11px;
    vertical-align: top;
}

.actions {
    position: absolute;
    right: calc(10px + env(safe-area-inset-right, 0px));
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    width: 168px;
    height: 168px;
}

.actions .fire {
    right: 0;
    bottom: 52px;
    width: 78px;
    height: 78px;
    background: rgba(160, 0, 0, 0.32);
    font-size: 16px;
}
.actions .run {
    right: 0;
    bottom: 0;
    width: 78px;
    height: 44px;
    border-radius: 8px;
    background: rgba(180, 140, 0, 0.32);
    font-size: 14px;
    display: block;
}
.actions .use {
    right: 86px;
    bottom: 18px;
    width: 56px;
    height: 56px;
}
.actions .menu {
    right: 86px;
    bottom: 84px;
    width: 56px;
    height: 40px;
    border-radius: 8px;
    font-size: 11px;
}
.actions .enter { display: none; }
.actions .start { display: none; }

.weapons {
    position: absolute;
    left: 50%;
    bottom: 8px;
    margin-left: -140px;
    width: 280px;
    text-align: center;
    pointer-events: auto;
}

.weapons .tbtn {
    position: relative;
    display: inline-block;
    width: 28px;
    height: 28px;
    font-size: 13px;
    margin: 0 2px;
}

.help {
    position: absolute;
    left: 10px;
    right: 110px;
    top: 14px;
    z-index: 5;
    font-family: "Courier New", Courier, monospace;
    font-size: 12px;
    color: #c9a07a;
    text-align: left;
    pointer-events: none;
}

.legacy-list a {
    display: block;
    margin: 10px auto;
    width: 90%;
    max-width: 420px;
    padding: 14px 10px;
    background: #180808;
    border: 2px solid #8a1c1c;
    color: #ffe6c4;
    text-decoration: none;
    text-transform: uppercase;
}

.nokia-frame {
    text-align: center;
    background: #000;
    color: #9cff9c;
    font-family: "Courier New", Courier, monospace;
}

.nokia-frame img {
    border: 2px solid #2a4a2a;
    background: #000;
}

.keygrid a {
    display: inline-block;
    width: 28%;
    margin: 4px 1%;
    padding: 10px 0;
    background: #102010;
    color: #b6ffb6;
    text-decoration: none;
    border: 1px solid #3a6a3a;
}

.dt-mix {
    position: absolute;
    left: -9999px;
    top: 0;
    width: 2px;
    height: 2px;
    opacity: 0;
    pointer-events: none;
}

.dt-rec-fab {
    position: absolute;
    z-index: 420;
    top: calc(8px + env(safe-area-inset-top, 0px));
    left: calc(8px + env(safe-area-inset-left, 0px));
    padding: 8px 14px;
    min-height: 40px;
    border: 1px solid rgba(255, 90, 90, 0.85);
    border-radius: 8px;
    background: rgba(160, 16, 16, 0.82);
    color: #fff;
    font: 600 13px/1 Impact, Arial, sans-serif;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    pointer-events: auto;
    touch-action: manipulation;
    cursor: pointer;
}

.dt-recbar {
    position: absolute;
    z-index: 420;
    top: calc(8px + env(safe-area-inset-top, 0px));
    left: calc(8px + env(safe-area-inset-left, 0px));
    display: none;
    flex-direction: column;
    gap: 6px;
    max-width: min(440px, calc(100vw - 110px));
    padding: 8px;
    background: rgba(0, 0, 0, 0.62);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 10px;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.dt-recbar.is-on {
    display: flex;
}

.dt-recbar:not(.is-live) #dt-rec-pause,
.dt-recbar:not(.is-live) #dt-rec-stop {
    display: none;
}

.dt-recbar.is-live #dt-rec-start {
    display: none;
}

.dt-recbar.is-paused .dt-rec-dot {
    animation: none;
    opacity: 0.35;
}

.dt-rec-main,
.dt-rec-tools,
.dt-rec-corners {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.dt-rec-time {
    min-width: 42px;
    color: #fff;
    font: 600 13px/1 ui-monospace, Menlo, monospace;
    font-variant-numeric: tabular-nums;
}

.dt-rec-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #666;
}

.dt-rec-dot.is-on {
    background: #ff2f3d;
    animation: dt-rec-pulse 1.1s infinite ease-in-out;
}

@keyframes dt-rec-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.25; }
}

.dt-recbar button {
    padding: 6px 9px;
    min-height: 32px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font: 600 11px/1 Impact, Arial, sans-serif;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
}

.dt-recbar button.is-on,
.dt-rec-corners button.is-on {
    background: rgba(200, 30, 30, 0.72);
    border-color: rgba(255, 90, 90, 0.85);
}

.dt-recbar button.is-stop {
    background: rgba(180, 16, 16, 0.85);
    border-color: rgba(255, 90, 90, 0.9);
}

.dt-rec-note {
    margin: 0;
    color: #ffd8d8;
    font: 12px/1.3 Georgia, serif;
}

.dt-pip {
    position: absolute;
    z-index: 350;
    width: 22vw;
    max-width: 180px;
    min-width: 96px;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.38);
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
    pointer-events: none;
    background: #111;
}

.dt-pip.is-off {
    display: none;
}

.dt-pip video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transform: scaleX(-1);
}

.dt-pip-tl {
    top: calc(8px + env(safe-area-inset-top, 0px));
    left: calc(8px + env(safe-area-inset-left, 0px));
}

.dt-pip-tr {
    top: calc(8px + env(safe-area-inset-top, 0px));
    right: calc(8px + env(safe-area-inset-right, 0px));
}

.dt-pip-bl {
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    left: calc(8px + env(safe-area-inset-left, 0px));
}

.dt-pip-br {
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    right: calc(8px + env(safe-area-inset-right, 0px));
}

body.is-mobile .dt-recbar,
body.is-mobile .dt-rec-fab {
    top: calc(58px + env(safe-area-inset-top, 0px));
}

body.is-mobile .dt-pip-tl {
    top: calc(58px + env(safe-area-inset-top, 0px));
}

.dt-cheat-fab {
    position: absolute;
    z-index: 430;
    top: calc(8px + env(safe-area-inset-top, 0px));
    right: calc(86px + env(safe-area-inset-right, 0px));
    padding: 8px 14px;
    min-height: 40px;
    border: 1px solid rgba(255, 196, 96, 0.8);
    border-radius: 8px;
    background: rgba(90, 40, 0, 0.88);
    color: #ffe7c2;
    font: 600 13px/1 Impact, Arial, sans-serif;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    pointer-events: auto;
    touch-action: manipulation;
    cursor: pointer;
}

.dt-cheat-fab.is-on {
    background: rgba(160, 70, 0, 0.95);
    color: #fff;
}

.dt-cheats {
    display: none;
    position: absolute;
    z-index: 430;
    top: calc(56px + env(safe-area-inset-top, 0px));
    right: calc(8px + env(safe-area-inset-right, 0px));
    width: min(320px, calc(100vw - 16px));
    max-height: calc(100% - 80px);
    overflow: auto;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.78);
    border: 1px solid rgba(255, 196, 96, 0.45);
    border-radius: 10px;
    pointer-events: auto;
    touch-action: manipulation;
}

.dt-cheats.is-on {
    display: flex;
}

.dt-cheats-bar,
.dt-cheats-warp {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: #ffe7c2;
    font: 600 14px/1 Impact, Arial, sans-serif;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.dt-cheats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.dt-cheats button,
.dt-cheats-warp input {
    min-height: 36px;
    border-radius: 7px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(40, 16, 0, 0.9);
    color: #fff;
    font: 600 12px/1.2 Arial, sans-serif;
    cursor: pointer;
}

.dt-cheats-warp input {
    width: 64px;
    padding: 0 8px;
    cursor: text;
}

.dt-cheats button:active {
    background: #8a3a00;
}

#dt-cheat-note {
    margin: 0;
    min-height: 1.2em;
    color: #ffd59a;
    font: 13px/1.3 Arial, sans-serif;
}

.dt-pad-note {
    position: absolute;
    z-index: 360;
    left: 50%;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    margin: 0;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    color: #d7ffd0;
    font: 12px/1.3 Arial, sans-serif;
    pointer-events: none;
}

.dt-pad-note:empty {
    display: none;
}

body.is-pad .touch-layer {
    display: none;
}
