/* ============================================================
   ECHOES OF A FRACTURED MIND
   Palette, type and screens for the prototype.
   ============================================================ */

:root {
    --black: #05070A;
    --charcoal: #12161C;
    --white: #E8EDF2;
    --cyan: #7FD8FF;
    --red: #FF3B3B;

    --line: rgba(232, 237, 242, .12);
    --line-strong: rgba(232, 237, 242, .24);
    --muted: rgba(232, 237, 242, .55);
    --faint: rgba(232, 237, 242, .38);

    --serif: Georgia, "Times New Roman", Times, serif;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='150'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='150' height='150' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    background-color: var(--black);
    color: var(--white);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* atmosphere: vignette + light grain over every screen */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 40;
    pointer-events: none;
    background: radial-gradient(ellipse 125% 95% at 50% 46%,
            rgba(5, 7, 10, 0) 38%,
            rgba(5, 7, 10, .5) 78%,
            rgba(5, 7, 10, .88) 100%);
}

body::after {
    content: "";
    position: fixed;
    inset: -25%;
    z-index: 41;
    pointer-events: none;
    opacity: .05;
    background-image: var(--grain);
    background-repeat: repeat;
    animation: grain-shift 1.1s steps(3) infinite;
}

@keyframes grain-shift {
    0% {
        transform: translate3d(0, 0, 0);
    }

    33% {
        transform: translate3d(-2%, 1.6%, 0);
    }

    66% {
        transform: translate3d(1.6%, -2%, 0);
    }

    100% {
        transform: translate3d(0, 0, 0);
    }
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}

/* ------------------------------------------------------------
   Shared controls
   ------------------------------------------------------------ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    padding: 0 26px;
    border: 1px solid rgba(232, 237, 242, .42);
    border-radius: 2px;
    background-color: #12161C;
    color: var(--white);
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .26em;
    text-transform: uppercase;
    text-align: center;
    cursor: pointer;
    transition: border-color .28s ease, color .28s ease, background-color .28s ease, box-shadow .28s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover,
.btn:focus-visible {
    outline: none;
    border-color: rgba(127, 216, 255, .6);
    color: var(--cyan);
    background-color: #182029;
}

.btn-primary {
    border-color: rgba(127, 216, 255, .72);
    background-color: #132029;
    color: var(--cyan);
    box-shadow: 0 0 40px -20px rgba(127, 216, 255, .95), inset 0 0 18px -10px rgba(127, 216, 255, .8);
}

.btn-primary:hover,
.btn-primary:focus-visible {
    border-color: rgba(127, 216, 255, .9);
    background-color: #16262f;
    box-shadow: 0 0 46px -16px rgba(127, 216, 255, .95), inset 0 0 22px -8px rgba(127, 216, 255, .9);
}

/* ------------------------------------------------------------
   Title screen
   ------------------------------------------------------------ */

.title-screen {
    position: relative;
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 96px 24px 92px;
    overflow: hidden;
    text-align: center;
    background:
        radial-gradient(ellipse 68% 42% at 50% 54%, rgba(127, 216, 255, .11), rgba(5, 7, 10, 0) 72%),
        radial-gradient(ellipse 130% 70% at 50% 112%, rgba(28, 42, 56, .6), rgba(5, 7, 10, 0) 74%),
        linear-gradient(180deg, #05070A 0%, #070B11 44%, #0A1119 74%, #04060A 100%);
}

.title-fog {
    position: absolute;
    inset: -12% -22%;
    pointer-events: none;
    opacity: .85;
    background:
        radial-gradient(ellipse 58% 26% at 28% 62%, rgba(158, 194, 224, .11), transparent 70%),
        radial-gradient(ellipse 46% 22% at 74% 71%, rgba(138, 178, 214, .09), transparent 72%),
        radial-gradient(ellipse 92% 30% at 50% 88%, rgba(118, 158, 198, .09), transparent 76%);
    animation: fog-drift 48s ease-in-out infinite alternate;
}

@keyframes fog-drift {
    from {
        transform: translate3d(-2%, 1%, 0) scale(1);
    }

    to {
        transform: translate3d(3%, -1.6%, 0) scale(1.07);
    }
}

.title-horizon {
    position: absolute;
    left: -20%;
    right: -20%;
    top: 32%;
    height: 48%;
    pointer-events: none;
    background: radial-gradient(ellipse 58% 44% at 50% 58%,
            rgba(127, 216, 255, .10),
            rgba(127, 216, 255, .035) 44%,
            rgba(127, 216, 255, 0) 72%);
}

.title-inner {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.title-logo {
    margin: 0;
    font-family: var(--serif);
    font-weight: 400;
    font-size: clamp(54px, 14.5vw, 168px);
    line-height: .94;
    letter-spacing: .2em;
    text-indent: .2em;
    color: var(--white);
    text-shadow: 0 0 46px rgba(127, 216, 255, .22), 0 0 2px rgba(232, 237, 242, .45);
}

.title-sub {
    margin: 20px 0 0;
    font-family: var(--sans);
    font-size: clamp(9px, 2.2vw, 12px);
    font-weight: 400;
    letter-spacing: .5em;
    text-indent: .5em;
    text-transform: uppercase;
    color: rgba(232, 237, 242, .6);
}

.title-line {
    margin: 32px auto 0;
    max-width: 34ch;
    font-family: var(--serif);
    font-style: italic;
    font-size: clamp(14px, 2.1vw, 18px);
    line-height: 1.75;
    color: rgba(232, 237, 242, .58);
}

.title-actions {
    margin-top: 46px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: min(440px, 100%);
}

.title-actions .btn-primary {
    grid-column: 1 / -1;
}

.title-foot {
    position: absolute;
    left: 0;
    right: 0;
    bottom: max(22px, env(safe-area-inset-bottom));
    margin: 0;
    z-index: 2;
    font-size: 9px;
    letter-spacing: .38em;
    text-indent: .38em;
    text-transform: uppercase;
    color: rgba(232, 237, 242, .58);
}

/* ------------------------------------------------------------
   Text pages (controls, archive)
   ------------------------------------------------------------ */

.page {
    position: relative;
    z-index: 1;
    max-width: 960px;
    margin: 0 auto;
    padding: clamp(30px, 6vw, 84px) clamp(20px, 5vw, 40px) 88px;
}

.back {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin-bottom: clamp(24px, 4vw, 40px);
    padding: 6px 2px 6px 0;
    font-size: 9px;
    font-weight: 500;
    letter-spacing: .32em;
    text-transform: uppercase;
    color: rgba(232, 237, 242, .66);
    transition: color .24s ease;
    -webkit-tap-highlight-color: transparent;
}

.back-ico {
    display: block;
    width: 11px;
    height: 11px;
    flex: none;
    transition: transform .24s ease;
}

.back:hover,
.back:focus-visible {
    outline: none;
    color: var(--cyan);
}

.back:hover .back-ico,
.back:focus-visible .back-ico {
    transform: translateX(-2px);
}

.eyebrow {
    margin: 0 0 16px;
    font-size: 9px;
    letter-spacing: .42em;
    text-transform: uppercase;
    color: rgba(127, 216, 255, .75);
}

.page-title {
    margin: 0;
    font-family: var(--serif);
    font-weight: 400;
    font-size: clamp(30px, 6vw, 52px);
    letter-spacing: .06em;
    line-height: 1.06;
}

.page-note {
    margin: 16px 0 0;
    font-family: var(--serif);
    font-style: italic;
    font-size: clamp(14px, 2vw, 16px);
    color: rgba(232, 237, 242, .48);
}

.page-head {
    margin-bottom: clamp(26px, 5vw, 46px);
}

.spec {
    list-style: none;
    margin: 0 0 46px;
    padding: 0;
    border-top: 1px solid var(--line);
}

.spec li {
    display: grid;
    grid-template-columns: minmax(92px, 168px) 1fr;
    gap: 6px 24px;
    align-items: baseline;
    padding: 18px 0;
    border-bottom: 1px solid var(--line);
}

.spec-key {
    font-size: 9px;
    letter-spacing: .32em;
    text-transform: uppercase;
    color: rgba(232, 237, 242, .42);
}

.spec-line {
    margin: 0;
    font-family: var(--serif);
    font-size: clamp(15px, 2.3vw, 18px);
    color: rgba(232, 237, 242, .92);
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.page-actions .btn {
    min-width: 190px;
}

/* ------------------------------------------------------------
   Archive
   ------------------------------------------------------------ */

.arch-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(14px, 2.4vw, 26px);
}

.arch-card {
    margin: 0;
    padding: 9px;
    border: 1px solid var(--line);
    border-radius: 2px;
    background: linear-gradient(180deg, #12161C, #0B0F14);
    cursor: pointer;
    transition: border-color .3s ease, box-shadow .3s ease, transform .3s ease;
    -webkit-tap-highlight-color: transparent;
}

.arch-card:hover,
.arch-card:focus-visible {
    outline: none;
    border-color: rgba(127, 216, 255, .42);
    box-shadow: 0 30px 70px -52px rgba(127, 216, 255, .9);
}

.arch-card:focus-visible {
    border-color: rgba(127, 216, 255, .7);
}

.arch-shot {
    position: relative;
    overflow: hidden;
    aspect-ratio: 2 / 1;
    min-height: 140px;
    background: #000;
}

.arch-shot img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 50%;
    transform: translateY(8%) scale(1.35);
    transform-origin: 50% 50%;
    filter: saturate(.9) contrast(1.03);
}

/* file 05 — lowest-resolution sheet: framed smaller on a dark matte
   instead of being blown up to full card size */
.arch-shot-inset {
    background: #080B10;
}

.arch-shot-inner {
    position: absolute;
    left: 9%;
    right: 9%;
    top: 9%;
    bottom: 9%;
    overflow: hidden;
    background: #000;
    box-shadow: 0 0 0 1px rgba(232, 237, 242, .07);
}

.arch-plate {
    display: block;
    padding: 13px 5px 5px;
}

.arch-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.arch-no {
    font-size: 9px;
    letter-spacing: .3em;
    color: rgba(127, 216, 255, .7);
}

.arch-name {
    font-size: 10px;
    letter-spacing: .26em;
    text-transform: uppercase;
    color: var(--white);
}

.arch-line {
    margin: 6px 0 0;
    font-family: var(--serif);
    font-style: italic;
    font-size: 13px;
    line-height: 1.5;
    color: rgba(232, 237, 242, .48);
}

/* lightbox */
.lb {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(12px, 3vw, 44px);
    background: #000;
}

.lb[hidden] {
    display: none;
}

.lb-frame {
    position: relative;
    width: min(100%, calc(92vh * 2));
    max-height: 92vh;
    min-height: 160px;
    aspect-ratio: 2 / 1;
    overflow: hidden;
    background: #000;
}

.lb-frame img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 50%;
    transform: translateY(8%) scale(1.35);
    transform-origin: 50% 50%;
}

.lb-close,
.lb-nav {
    position: fixed;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border: 1px solid rgba(232, 237, 242, .22);
    border-radius: 50%;
    background: rgba(5, 7, 10, .6);
    color: rgba(232, 237, 242, .8);
    font-size: 17px;
    line-height: 1;
    transition: border-color .24s ease, color .24s ease, background-color .24s ease;
    -webkit-tap-highlight-color: transparent;
}

.lb-close:hover,
.lb-nav:hover,
.lb-close:focus-visible,
.lb-nav:focus-visible {
    outline: none;
    border-color: rgba(127, 216, 255, .6);
    color: var(--cyan);
    background: rgba(5, 7, 10, .9);
}

.lb-close {
    top: max(14px, env(safe-area-inset-top));
    right: max(14px, env(safe-area-inset-right));
    font-size: 21px;
}

.lb-prev {
    left: max(10px, env(safe-area-inset-left));
    top: 50%;
    margin-top: -23px;
}

.lb-next {
    right: max(10px, env(safe-area-inset-right));
    top: 50%;
    margin-top: -23px;
}

.lb-cap {
    position: fixed;
    left: 0;
    right: 0;
    bottom: max(16px, env(safe-area-inset-bottom));
    margin: 0;
    text-align: center;
    font-size: 9px;
    letter-spacing: .3em;
    text-transform: uppercase;
    color: rgba(232, 237, 242, .55);
}

/* ------------------------------------------------------------
   Game screen
   ------------------------------------------------------------ */

.game-root {
    position: fixed;
    inset: 0;
    z-index: 30;
    overflow: hidden;
    background: var(--black);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.game-canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.game-hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 3;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: calc(12px + env(safe-area-inset-top)) clamp(12px, 3vw, 26px) 0;
    pointer-events: none;
}

.hud-left {
    display: flex;
    align-items: flex-start;
    gap: clamp(12px, 3.2vw, 32px);
    min-width: 0;
}

.hud-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.hud-lab {
    font-size: 8px;
    letter-spacing: .3em;
    text-transform: uppercase;
    color: rgba(232, 237, 242, .42);
}

.hud-val {
    font-family: var(--sans);
    font-size: clamp(13px, 2.4vw, 16px);
    letter-spacing: .1em;
    color: var(--white);
    font-variant-numeric: tabular-nums;
}

.hud-ward {
    font-size: clamp(9px, 1.9vw, 11px);
    letter-spacing: .2em;
    color: rgba(127, 216, 255, .85);
    white-space: nowrap;
}

.hud-right {
    display: flex;
    align-items: center;
    gap: clamp(8px, 2vw, 14px);
    pointer-events: auto;
}

.pips {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-right: 4px;
}

.pips span {
    display: block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 10px rgba(127, 216, 255, .8);
    transition: background-color .25s ease, box-shadow .25s ease;
}

.pips span.off {
    background: rgba(232, 237, 242, .13);
    box-shadow: none;
}

.hud-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(232, 237, 242, .18);
    border-radius: 2px;
    background: rgba(5, 7, 10, .42);
    color: rgba(232, 237, 242, .72);
    -webkit-tap-highlight-color: transparent;
    transition: border-color .24s ease, color .24s ease;
}

.hud-btn:hover,
.hud-btn:focus-visible {
    outline: none;
    border-color: rgba(127, 216, 255, .55);
    color: var(--cyan);
}

.i-pause {
    display: inline-block;
    width: 10px;
    height: 12px;
    border-left: 3px solid currentColor;
    border-right: 3px solid currentColor;
}

.i-snd {
    font-size: 14px;
    line-height: 1;
}

.hud-btn.is-muted .i-snd {
    opacity: .35;
}

.hud-btn.is-muted::after {
    content: "";
    position: absolute;
    left: 7px;
    right: 7px;
    top: 50%;
    height: 1px;
    background: currentColor;
    transform: rotate(-34deg);
}

.ward-card {
    position: absolute;
    left: 0;
    right: 0;
    top: 30%;
    z-index: 2;
    text-align: center;
    pointer-events: none;
    opacity: 0;
}

.ward-card span {
    font-family: var(--serif);
    font-size: clamp(20px, 5vw, 40px);
    letter-spacing: .4em;
    text-indent: .4em;
    color: rgba(232, 237, 242, .94);
    text-shadow: 0 0 34px rgba(127, 216, 255, .35);
}

.ward-card.show {
    animation: ward-flash 2.4s ease-out forwards;
}

@keyframes ward-flash {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }

    18% {
        opacity: 1;
        transform: translateY(0);
    }

    70% {
        opacity: 1;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateY(-8px);
    }
}

.touch-zones {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    display: none;
    gap: 8px;
    height: 40%;
    padding: 0 10px calc(10px + env(safe-area-inset-bottom));
    pointer-events: none;
}

.tz {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    padding-bottom: 16px;
    border: 1px solid rgba(127, 216, 255, .34);
    border-radius: 3px;
    background: rgba(127, 216, 255, .07);
    color: rgba(232, 237, 242, .68);
    font-size: 10px;
    letter-spacing: .3em;
}

.tz-arrow {
    display: block;
    font-size: 15px;
    line-height: 1;
    color: rgba(232, 237, 242, .8);
}

.tz-hint {
    display: block;
    font-size: 9px;
    letter-spacing: .24em;
    text-transform: uppercase;
    color: rgba(232, 237, 242, .58);
    opacity: 0;
    transition: opacity .9s ease;
}

.touch-zones.is-hinted .tz-hint {
    opacity: 1;
}

.tz-c {
    flex: 1.15;
}

@media (hover: none) and (pointer: coarse) {
    .touch-zones {
        display: flex;
    }
}

.ov {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(20px, 5vw, 40px);
    background: rgba(5, 7, 10, .87);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

.ov[hidden] {
    display: none;
}

.ov-box {
    width: min(560px, 100%);
    text-align: center;
}

.ov-eyebrow {
    margin: 0 0 16px;
    font-size: 9px;
    letter-spacing: .42em;
    text-transform: uppercase;
    color: rgba(232, 237, 242, .4);
}

.ov-title {
    margin: 0 0 34px;
    font-family: var(--serif);
    font-weight: 400;
    font-size: clamp(26px, 7vw, 44px);
    letter-spacing: .3em;
    text-indent: .3em;
    color: var(--white);
}

.ov-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.ov-actions .btn {
    min-width: 152px;
}

.over-line {
    margin: 0 0 22px;
    font-family: var(--serif);
    font-size: clamp(18px, 4.4vw, 30px);
    letter-spacing: .09em;
    line-height: 1.4;
    color: var(--white);
}

.over-label {
    margin: 0 0 32px;
    font-size: 9px;
    letter-spacing: .5em;
    text-indent: .5em;
    text-transform: uppercase;
    color: var(--red);
}

.over-stats {
    display: flex;
    justify-content: center;
    gap: clamp(16px, 6vw, 54px);
    margin: 0 0 34px;
}

.over-stat {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* ------------------------------------------------------------
   Narrow screens
   ------------------------------------------------------------ */

@media (max-width: 760px) {
    .arch-grid {
        grid-template-columns: 1fr;
    }

    .lb-prev {
        left: 6px;
    }

    .lb-next {
        right: 6px;
    }

    .lb-close,
    .lb-nav {
        width: 42px;
        height: 42px;
    }
}

@media (max-width: 560px) {
    .spec li {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .title-actions {
        grid-template-columns: 1fr;
    }

    .title-actions .btn-primary {
        grid-column: auto;
    }

    .ov-actions .btn {
        min-width: 132px;
        flex: 1;
    }

    .hud-left {
        gap: 10px;
        flex-wrap: wrap;
    }

    .hud-lab {
        font-size: 7px;
        letter-spacing: .22em;
    }

    .hud-val {
        font-size: 12px;
        letter-spacing: .06em;
    }

    .hud-ward {
        font-size: 8.5px;
        letter-spacing: .1em;
    }

    .hud-btn {
        width: 34px;
        height: 34px;
    }

    .pips {
        gap: 5px;
    }

    .pips span {
        width: 7px;
        height: 7px;
    }
}

/* short viewports (landscape phones) */
@media (max-height: 560px) {
    .title-screen {
        padding: 54px 20px 70px;
    }

    .title-logo {
        font-size: clamp(38px, 12vh, 84px);
    }

    .title-sub {
        margin-top: 12px;
        letter-spacing: .4em;
        text-indent: .4em;
    }

    .title-line {
        margin-top: 16px;
        font-size: 14px;
        line-height: 1.5;
    }

    .title-actions {
        margin-top: 22px;
    }

    .btn {
        min-height: 44px;
    }

    .title-foot {
        bottom: 12px;
    }
}

/* ------------------------------------------------------------
   Reduced motion
   ------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }

    .title-fog {
        animation: none;
    }

    body::after {
        animation: none;
    }

    .ward-card.show {
        animation: none;
        opacity: 1;
    }
}
