/* ==========================================================================
   Doom (app/commands/doom.js)
   Library on the Orbit UI kit; the player (.dm-play) is black with the game in
   the middle. Portrait: buttons under the game. Sideways: the game fills the
   screen and the buttons float on top. Motion lives in the "Doom" section at
   the end of css/motion.css.
   ========================================================================== */

.dm-app { container-type: inline-size; container-name: dmwin; }

/* ---------- Library ---------- */
.dm-app .dm-hero {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 132px;
    padding: 18px;
    border-radius: 28px;
    color: #ffffff;
    cursor: pointer;
    overflow: hidden;
    isolation: isolate;
    background: radial-gradient(120% 140% at 0% 100%, #f97316 0%, #b91c1c 38%, #3b0a0a 75%, #120404 100%);
    -webkit-tap-highlight-color: transparent;
}
.dm-app .dm-hero-fire { position: absolute; left: 0; right: 0; bottom: 0; height: 60%; display: flex; align-items: flex-end; gap: 6%; padding: 0 4%; z-index: -1; opacity: 0.55; pointer-events: none; }
.dm-app .dm-hero-fire i { flex: 1; height: 60%; border-radius: 50% 50% 0 0; background: linear-gradient(to top, #fbbf24, #f97316 45%, transparent); filter: blur(6px); transform-origin: 50% 100%; }
.dm-app .dm-hero-fire i:nth-child(2) { height: 85%; }
.dm-app .dm-hero-fire i:nth-child(3) { height: 70%; }
.dm-app .dm-hero-fire i:nth-child(4) { height: 95%; }
.dm-app .dm-hero-skull { display: inline-flex; flex-shrink: 0; width: 72px; height: 72px; align-items: center; justify-content: center; border-radius: 22px; background: rgba(0, 0, 0, 0.35); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12); }
.dm-app .dm-hero-skull svg { width: 46px; height: 46px; stroke: #ffffff; }
.dm-app .dm-hero-text { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.dm-app .dm-hero-text .ok-hero-label { color: #fde68a; }
.dm-app .dm-hero-text strong { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-app .dm-hero-text > span:last-child { font-size: 0.82rem; opacity: 0.88; line-height: 1.35; }
.dm-app .dm-hero-play { display: inline-flex; align-items: center; justify-content: center; width: 54px; height: 54px; border-radius: 50%; background: #ffffff; color: #7f1d1d; flex-shrink: 0; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35); }
.dm-app .dm-hero-play svg { margin-left: 3px; }

/* A game box: dark, hot colors, the skull mark and the title */
.dm-box {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 14px;
    overflow: hidden;
    isolation: isolate;
    background: linear-gradient(170deg, color-mix(in srgb, var(--h, #b91c1c) 35%, #0a0a0a) 0%, #0a0606 75%);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.dm-box.is-big { width: 96px; flex-shrink: 0; }
.dm-box-glow { position: absolute; left: -20%; right: -20%; bottom: -40%; height: 80%; z-index: -1; background: radial-gradient(closest-side, color-mix(in srgb, var(--h, #b91c1c) 85%, #f97316), transparent); opacity: 0.7; }
.dm-box-mark { position: absolute; top: 18%; left: 50%; translate: -50% 0; color: #fde68a; opacity: 0.92; }
.dm-box-mark svg { stroke: currentColor; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6)); }
.dm-box-title { position: relative; width: 100%; padding: 6px 8px; font: 900 0.7rem/1.1 var(--font-main); letter-spacing: 0.06em; text-transform: uppercase; color: #ffffff; text-align: center; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-box.is-big .dm-box-title { font-size: 0.62rem; }
.dm-box-mod { position: absolute; top: 6px; right: 6px; display: inline-flex; align-items: center; gap: 3px; padding: 2px 6px; border-radius: 999px; font: 800 0.55rem var(--font-main); letter-spacing: 0.08em; color: #ffffff; background: #7c3aed; }
.dm-box-mod svg { stroke: currentColor; }

.dm-app .dm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.dm-app .dm-game {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
    padding: 10px;
    border-radius: 20px;
    border: 1px solid var(--ok-line);
    background: var(--ok-card);
    color: var(--on-surface);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}
.dm-app .dm-game-name { margin-top: 4px; font-size: 0.9rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 26px; }
.dm-app .dm-game-meta { font-size: 0.74rem; color: var(--ok-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 26px; }
.dm-app .dm-more { position: absolute; right: 6px; bottom: 10px; width: 28px; height: 28px; }

.dm-app .dm-own { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 22px; border: 1px dashed var(--ok-line-strong); background: transparent; color: var(--on-surface); font-family: var(--font-main); text-align: left; cursor: pointer; }
.dm-app .dm-own-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.dm-app .dm-own-text strong { font-size: 0.95rem; }
.dm-app .dm-own-text span { font-size: 0.8rem; color: var(--ok-muted); line-height: 1.4; }

.dm-app .dm-tips { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
@container dmwin (min-width: 620px) { .dm-app .dm-tips { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.dm-app .dm-tip { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-radius: 18px; background: var(--ok-card); border: 1px solid var(--ok-line); }
.dm-app .dm-tip > span:last-child { display: flex; flex-direction: column; gap: 2px; font-size: 0.8rem; line-height: 1.4; color: var(--ok-muted); }
.dm-app .dm-tip b { font-size: 0.9rem; color: var(--on-surface); }

/* ---------- Sheets ---------- */
.dm-app .dm-sheet .xa-sheet-card { gap: 12px; max-height: 88%; overflow-y: auto; overscroll-behavior: contain; }
.dm-app .dm-grab { align-self: center; width: 38px; height: 4px; border-radius: 2px; background: var(--ok-line-strong); flex-shrink: 0; }
.dm-app .dm-sheet-head { display: flex; align-items: center; gap: 14px; }
.dm-app .dm-sheet-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dm-app .dm-sheet-title strong { font-size: 1.15rem; }
.dm-app .dm-sheet-title span { font-size: 0.82rem; color: var(--ok-muted); }
.dm-app .dm-sheet-text { margin: 0; font-size: 0.88rem; line-height: 1.5; color: var(--ok-muted); }
.dm-app .dm-sheet-actions { display: flex; gap: 10px; }
.dm-app .dm-sheet-actions .ok-btn { flex: 1; height: 48px; gap: 8px; font-size: 0.92rem; }
@container dmwin (min-width: 700px) {
    .dm-app .dm-sheet { align-items: center; padding: 24px; }
    .dm-app .dm-sheet .xa-sheet-card { max-width: 480px; border-radius: 26px; border-bottom: 1px solid var(--ok-line); padding-bottom: 20px; }
    .dm-app .dm-grab { display: none; }
    .dm-app .ok-column { max-width: 1100px; }
}
@media (hover: hover) and (pointer: fine) {
    .dm-app :is(.dm-game, .dm-own, .dm-mod):hover { border-color: var(--ok-line-strong); background: color-mix(in srgb, var(--on-surface) 4%, var(--ok-card)); }
    .dm-play :is(.dm-top-btn, .dm-chip):hover { background: rgba(255, 255, 255, 0.16); }
}
html.kbd-nav .dm-app :is(.dm-game, .dm-own, .dm-hero):focus-visible { outline: 2px solid #f97316; outline-offset: 2px; }

/* ---------- Player ---------- */
.dm-play {
    --dm-ink: #f5ede6;
    --pad-alpha: 0.7;
    --u: 1;
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    background: #000000;
    color: var(--dm-ink);
    overflow: hidden;
    font-family: var(--font-main);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
}
.dm-play.dm-portal { position: fixed; z-index: 10000; }
.dm-play.is-away { visibility: hidden; }
.dm-app.dm-under > .ok-body { visibility: hidden; }
.dm-play[data-size="s"] { --u: 0.84; }
.dm-play[data-size="l"] { --u: 1.18; }

.dm-play .dm-top { position: relative; z-index: 6; display: flex; align-items: center; gap: 6px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top, 0px)); flex-shrink: 0; }
.dm-play .dm-top-btn { width: 40px; height: 40px; border-color: transparent; background: rgba(255, 255, 255, 0.08); color: var(--dm-ink); }
.dm-play .dm-top-btn svg { stroke: currentColor; }
.dm-play .dm-top-text { display: flex; flex-direction: column; flex: 1; min-width: 0; padding: 0 4px; }
.dm-play .dm-top-text strong { font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-play .dm-status { font-style: normal; font-size: 0.74rem; color: rgba(245, 237, 230, 0.6); }

.dm-play .dm-stage { flex: 1 1 auto; min-height: 120px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.dm-play .dm-screen { position: relative; width: 320px; height: 240px; background: #000000; flex-shrink: 0; }
.dm-play .dm-screen canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; }
.dm-play.dm-smooth .dm-screen canvas { image-rendering: auto; }
.dm-play .dm-crt { position: absolute; inset: 0; display: none; pointer-events: none; background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.28) 0, rgba(0, 0, 0, 0.28) 1px, transparent 1px, transparent 3px); }
.dm-play.dm-crt-on .dm-crt { display: block; }
.dm-play .dm-hurt { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(closest-side, transparent 55%, rgba(220, 20, 20, 0.55)); }

.dm-play .dm-overlay, .dm-play .dm-paused { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center; font-size: 0.86rem; color: rgba(245, 237, 230, 0.8); }
.dm-play .dm-overlay { background: radial-gradient(90% 60% at 50% 100%, #3b0a0a 0%, #000000 70%); }
.dm-play .dm-overlay strong { font-size: 1.1rem; color: var(--dm-ink); }
.dm-play .dm-load-skull { display: inline-flex; align-items: center; justify-content: center; width: 78px; height: 78px; border-radius: 26px; background: #b91c1c; box-shadow: 0 0 40px rgba(249, 115, 22, 0.45); }
.dm-play .dm-load-skull svg { stroke: #ffffff; }
.dm-play .dm-progress { width: min(240px, 70%); height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.dm-play .dm-progress[hidden] { display: none; }
.dm-play .dm-progress i { display: block; width: 0; height: 100%; border-radius: 3px; background: #f97316; }
.dm-play .dm-err { display: inline-flex; align-items: center; justify-content: center; width: 60px; height: 60px; border-radius: 20px; background: #b91c1c; }
.dm-play .dm-err svg { stroke: #ffffff; }
.dm-play .dm-paused { background: rgba(0, 0, 0, 0.55); }
.dm-play .dm-paused[hidden], .dm-play .dm-hint[hidden] { display: none; }
.dm-play .dm-paused-btn { display: inline-flex; align-items: center; justify-content: center; width: 72px; height: 72px; border: none; border-radius: 50%; background: #ffffff; color: #111111; cursor: pointer; }
.dm-play .dm-paused-btn svg { margin-left: 4px; }
.dm-play .dm-hint { position: absolute; top: calc(max(8px, env(safe-area-inset-top, 0px)) + 54px); left: 50%; translate: -50% 0; z-index: 7; max-width: calc(100% - 32px); padding: 8px 14px; border-radius: 999px; background: rgba(20, 16, 14, 0.92); font-size: 0.8rem; font-weight: 600; text-align: center; pointer-events: none; opacity: 0; transition: opacity 0.2s ease; }
.dm-play .dm-hint.is-on { opacity: 1; }
.dm-play .dm-flash { position: absolute; inset: 0; z-index: 8; background: #ffffff; opacity: 0; pointer-events: none; }

/* Touch: left half moves, right half turns. Buttons sit above. */
.dm-play .dm-touch { position: absolute; inset: 0; z-index: 2; display: flex; }
.dm-play.pad-hidden .dm-touch, .dm-play.pad-hidden .dm-pad { display: none; }
.dm-play .dm-zone { position: relative; flex: 1; touch-action: none; }
.dm-play .dm-stick { position: absolute; width: calc(120px * var(--u)); height: calc(120px * var(--u)); margin: calc(-60px * var(--u)) 0 0 calc(-60px * var(--u)); border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.28); background: rgba(255, 255, 255, 0.06); opacity: 0; pointer-events: none; }
.dm-play .dm-stick.is-on { opacity: var(--pad-alpha); }
.dm-play .dm-stick i { position: absolute; left: 50%; top: 50%; width: calc(52px * var(--u)); height: calc(52px * var(--u)); margin: calc(-26px * var(--u)) 0 0 calc(-26px * var(--u)); border-radius: 50%; background: rgba(255, 255, 255, 0.55); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4); }

.dm-play .dm-pad { position: relative; z-index: 3; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; padding: 8px 16px max(16px, env(safe-area-inset-bottom, 0px)); pointer-events: none; opacity: var(--pad-alpha); }
.dm-play .dm-pad button { pointer-events: auto; touch-action: none; -webkit-tap-highlight-color: transparent; }
.dm-play .dm-pad-row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.dm-play .dm-chip { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: calc(44px * var(--u)); height: calc(36px * var(--u)); padding: 0 12px; border: none; border-radius: 999px; background: rgba(255, 255, 255, 0.12); color: var(--dm-ink); font: 800 calc(0.74rem * var(--u)) var(--font-main); letter-spacing: 0.04em; cursor: pointer; }
.dm-play .dm-chip svg { stroke: currentColor; flex-shrink: 0; }
.dm-play .dm-chip.is-down { background: rgba(255, 255, 255, 0.28); }
.dm-play .dm-wname { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-play .dm-menu-only { display: none; }
.dm-play.in-menu .dm-menu-only { display: inline-flex; }
.dm-play.in-menu [data-k="map"], .dm-play.in-menu [data-k="weapon"], .dm-play:not(.in-level) [data-k="map"], .dm-play:not(.in-level) [data-k="weapon"] { display: none; }
.dm-play .dm-pad-main { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; min-height: calc(132px * var(--u)); }
.dm-play .dm-pad-hint { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0 0 6px 6px; font-size: 0.72rem; font-weight: 700; color: rgba(245, 237, 230, 0.55); pointer-events: none; }
.dm-play .dm-stick-ghost { width: calc(84px * var(--u)); height: calc(84px * var(--u)); border-radius: 50%; border: 2px dashed rgba(255, 255, 255, 0.25); }
.dm-play.dm-moved .dm-pad-hint { opacity: 0; }
.dm-play .dm-actions { position: relative; display: flex; align-items: flex-end; gap: calc(14px * var(--u)); }
.dm-play .dm-btn { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: none; border-radius: 50%; color: #ffffff; cursor: pointer; font-family: var(--font-main); }
.dm-play .dm-btn small { font: 900 calc(0.6rem * var(--u)) var(--font-main); letter-spacing: 0.12em; }
.dm-play .dm-btn svg { stroke: currentColor; }
.dm-play .dm-fire { width: calc(104px * var(--u)); height: calc(104px * var(--u)); background: radial-gradient(circle at 50% 35%, #ef4444, #991b1b 75%); box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.3), 0 0 26px rgba(239, 68, 68, 0.45); }
.dm-play .dm-use { width: calc(70px * var(--u)); height: calc(70px * var(--u)); margin-bottom: calc(40px * var(--u)); background: rgba(255, 255, 255, 0.16); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.3); }
.dm-play .dm-fire.is-down { background: radial-gradient(circle at 50% 40%, #f87171, #7f1d1d 80%); box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.35), 0 0 34px rgba(249, 115, 22, 0.7); }
.dm-play .dm-use.is-down { background: rgba(255, 255, 255, 0.3); }

/* Sideways phone: the game fills the screen, everything floats on top. */
@media (orientation: landscape) and (max-height: 600px) {
    .dm-play .dm-top { position: absolute; left: 0; right: 0; top: 0; padding: max(6px, env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px)) 6px max(10px, env(safe-area-inset-left, 0px)); background: linear-gradient(rgba(0, 0, 0, 0.55), transparent); }
    .dm-play .dm-top-btn { width: 36px; height: 36px; background: rgba(0, 0, 0, 0.35); }
    .dm-play .dm-top-text { opacity: 0.85; }
    .dm-play .dm-stage { height: 100%; }
    .dm-play .dm-pad { position: absolute; inset: 0; padding: 52px max(18px, env(safe-area-inset-right, 0px)) max(14px, env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px)); display: block; }
    .dm-play .dm-pad-sys { position: absolute; top: 52px; right: max(18px, env(safe-area-inset-right, 0px)); flex-direction: column; align-items: flex-end; }
    .dm-play .dm-pad-main { position: absolute; left: max(18px, env(safe-area-inset-left, 0px)); right: max(18px, env(safe-area-inset-right, 0px)); bottom: max(14px, env(safe-area-inset-bottom, 0px)); min-height: 0; }
    .dm-play .dm-chip { background: rgba(0, 0, 0, 0.4); }
    .dm-play .dm-use { background: rgba(0, 0, 0, 0.4); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25); }
    .dm-play .dm-pad-hint .dm-stick-ghost { border-color: rgba(255, 255, 255, 0.2); }
    .dm-play .dm-hint { top: 50px; }
}
/* Light themes: the player stays dark. */
html.theme-solar-flare .dm-play, html.theme-arctic .dm-play, html.theme-paper .dm-play, html.theme-blossom .dm-play, html.theme-sage .dm-play, html.ts-light .dm-play { color: var(--dm-ink); }
.dm-play .dm-spin { display: inline-block; width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.25); border-top-color: #ffffff; }
