/* Pixel fonts hosted with the app (OFL, @fontsource 5.3.0) instead of Google Fonts, so the anonymous
   page sends no visitor address to a third party and needs no cross-origin request. */

@font-face {
    font-family: 'Press Start 2P';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../../vendor/press-start-2p/press-start-2p-latin-400-normal.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Press Start 2P';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../../vendor/press-start-2p/press-start-2p-latin-ext-400-normal.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'VT323';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../../vendor/vt323/vt323-latin-400-normal.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'VT323';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../../vendor/vt323/vt323-latin-ext-400-normal.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

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

:root {
    /* Light pixel RPG palette (GBA / SNES town vibe) */
    --ink:        #2C2137;
    --ink-soft:   #4A3B5C;
    --muted:      #6B5A7A;
    --paper:      #FFF8E7;
    --paper-alt:  #F5E6C8;
    --panel:      #FFFDF5;
    --sky:        #A8D4F0;
    --sky-deep:   #7BB8E0;
    --grass:      #7BC67E;
    --hp:         #E85D5D;
    --mp:         #5B8DEF;
    --xp:         #F0C040;
    --gold:       #E8A838;
    --teal:       #3CB8A0;
    --teal-deep:  #2A8A78;
    --purple:     #8B6BC4;
    --border:     #2C2137;
    --border-mid: #8B7A9A;
    --white:      #FFFFFF;
    --pixel:      4px;
    --font-pixel: 'Press Start 2P', monospace;
    --font-body:  'VT323', monospace;
}

body {
    background: var(--sky);
    font-family: var(--font-body);
    color: var(--ink);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    font-size: 20px;
}

/* ── Canvas ───────────────────────────────────────── */
#vrCanvas {
    display: block;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    position: fixed;
    top: 0; left: 0;
    z-index: 1;
    image-rendering: pixelated;
}

/* CRT-lite scanlines over light scene */
.vr-vignette {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(44, 33, 55, .03) 2px,
            rgba(44, 33, 55, .03) 4px
        ),
        radial-gradient(ellipse at 50% 40%, transparent 50%, rgba(123, 184, 224, .25) 100%);
}

/* Pixel sky tiles decoration */
.sky-deco {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
}
.sky-deco span {
    position: absolute;
    background: var(--white);
    opacity: .55;
    box-shadow:
        8px 0 0 var(--white),
        16px 0 0 var(--white),
        4px 4px 0 var(--white),
        12px 4px 0 var(--white),
        20px 4px 0 var(--white);
    width: 8px;
    height: 8px;
    animation: pixelFloat 12s steps(8) infinite;
}
.sky-deco span:nth-child(1) { top: 10%; left: 14%; }
.sky-deco span:nth-child(2) { top: 16%; right: 20%; animation-delay: -3s; opacity: .4; }
.sky-deco span:nth-child(3) { bottom: 28%; left: 8%; animation-delay: -6s; opacity: .3; }

/* ── Shared pixel panel ──────────────────────────── */
.px-panel {
    background: var(--panel);
    border: 4px solid var(--border);
    box-shadow:
        inset 0 0 0 2px var(--paper-alt),
        4px 4px 0 rgba(44, 33, 55, .25);
    border-radius: 0;
}

/* ── HUD ─────────────────────────────────────────── */
.hud {
    position: fixed;
    z-index: 100;
    pointer-events: none;
}

.hud-top {
    top: 0; left: 0; right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    background: linear-gradient(180deg, rgba(168, 212, 240, .85) 0%, rgba(168, 212, 240, .35) 70%, transparent 100%);
}

.hud-brand-block {
    display: flex;
    align-items: stretch;
    gap: 0;
    pointer-events: auto;
}

/* Classic RPG status window */
.status-window {
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    min-width: 0;
}

.player-face {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    background:
        linear-gradient(90deg, #F5C8A0 0 50%, #E8B088 50% 100%),
        #F5C8A0;
    border: 3px solid var(--border);
    box-shadow: inset -3px -3px 0 rgba(0,0,0,.12);
    position: relative;
    image-rendering: pixelated;
}
/* simple pixel eyes */
.player-face::before,
.player-face::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    background: var(--ink);
    top: 16px;
}
.player-face::before { left: 10px; }
.player-face::after { right: 10px; }
.player-face .mouth {
    position: absolute;
    bottom: 10px;
    left: 14px;
    width: 16px;
    height: 4px;
    background: var(--ink);
}

.hud-brand-meta {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
    justify-content: center;
}

.hud-brand {
    font-family: var(--font-pixel);
    font-size: 11px;
    color: var(--ink);
    line-height: 1.4;
    letter-spacing: 0;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.stat-label {
    font-family: var(--font-pixel);
    font-size: 7px;
    color: var(--ink-soft);
    width: 22px;
    flex-shrink: 0;
}
.stat-track {
    width: 100px;
    height: 10px;
    background: var(--ink);
    border: 2px solid var(--border);
    box-shadow: inset 0 0 0 1px #5A4A6A;
    position: relative;
    overflow: hidden;
}
.stat-fill {
    height: 100%;
    image-rendering: pixelated;
}
.stat-fill.hp { width: 86%; background: repeating-linear-gradient(90deg, var(--hp) 0 6px, #F08080 6px 8px); }
.stat-fill.mp { width: 64%; background: repeating-linear-gradient(90deg, var(--mp) 0 6px, #7AA8F5 6px 8px); }
.stat-fill.xp { width: 42%; background: repeating-linear-gradient(90deg, var(--xp) 0 6px, #F8D870 6px 8px); }

.level-chip {
    font-family: var(--font-pixel);
    font-size: 7px;
    color: var(--paper);
    background: var(--purple);
    border: 2px solid var(--border);
    padding: 4px 6px;
    box-shadow: 2px 2px 0 rgba(44,33,55,.3);
    white-space: nowrap;
}

.hud-breadcrumb {
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--muted);
    line-height: 1;
}
.hud-breadcrumb span { color: var(--border-mid); margin: 0 3px; }

.hud-nav {
    display: flex;
    gap: 8px;
    pointer-events: auto;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.hud-nav a {
    font-family: var(--font-pixel);
    font-size: 8px;
    text-decoration: none;
    color: var(--ink);
    padding: 12px 14px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    background: var(--paper);
    border: 3px solid var(--border);
    box-shadow: 3px 3px 0 var(--border);
    transition: none;
    cursor: pointer;
    image-rendering: pixelated;
}
.hud-nav a:hover {
    background: var(--paper-alt);
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 var(--border);
}
.hud-nav a:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 var(--border);
}
.hud-nav a:focus-visible {
    outline: 3px solid var(--teal);
    outline-offset: 2px;
}

/* Objective window (classic dialogue corner) */
.obj-hint {
    position: fixed;
    top: 100px;
    left: 14px;
    z-index: 100;
    pointer-events: none;
    max-width: 280px;
    padding: 10px 12px;
}
.obj-hint-label {
    font-family: var(--font-pixel);
    font-size: 7px;
    color: var(--gold);
    margin-bottom: 6px;
    text-shadow: 1px 1px 0 var(--border);
}
.obj-hint-text {
    font-family: var(--font-body);
    font-size: 18px;
    color: var(--ink);
    line-height: 1.2;
}
.obj-hint-text::after {
    content: '▼';
    display: inline-block;
    margin-left: 6px;
    font-size: 12px;
    color: var(--teal);
    animation: blink 1s steps(1) infinite;
}

/* Bottom dialogue / quest input */
.hud-bottom {
    bottom: 0; left: 0; right: 0;
    display: flex;
    justify-content: center;
    padding: 0 12px 16px;
}

.search-card {
    pointer-events: auto;
    width: 100%;
    max-width: 580px;
    padding: 14px 16px 12px;
    position: relative;
}
/* Pixel corner ticks */
.search-card::before,
.search-card::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--gold);
    border: 2px solid var(--border);
}
.search-card::before { top: -4px; left: 16px; }
.search-card::after { top: -4px; right: 16px; }

.search-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-pixel);
    font-size: 8px;
    color: var(--ink);
    margin-bottom: 12px;
    line-height: 1.5;
}
.quest-icon {
    width: 24px;
    height: 24px;
    background: var(--gold);
    border: 3px solid var(--border);
    box-shadow: 2px 2px 0 rgba(44,33,55,.3);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: var(--font-pixel);
    font-size: 10px;
    color: var(--ink);
    line-height: 1;
}

.status-dot {
    width: 12px;
    height: 12px;
    background: var(--border-mid);
    border: 2px solid var(--border);
    margin-left: auto;
    flex-shrink: 0;
    image-rendering: pixelated;
}
.status-dot.busy {
    background: var(--xp);
    animation: blink 0.6s steps(1) infinite;
}
.status-dot.ok { background: var(--teal); }
.status-dot.error { background: var(--hp); }

.search-row {
    display: flex;
    gap: 8px;
}
.search-input {
    flex: 1;
    min-height: 48px;
    padding: 10px 12px;
    background: var(--paper-alt);
    border: 3px solid var(--border);
    box-shadow: inset 2px 2px 0 rgba(44,33,55,.12);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 22px;
    outline: none;
    border-radius: 0;
    image-rendering: pixelated;
}
.search-input::placeholder {
    color: var(--muted);
    font-family: var(--font-body);
}
.search-input:focus, .search-input:focus-visible {
    background: var(--white);
    box-shadow: inset 2px 2px 0 rgba(44,33,55,.12), 0 0 0 3px var(--teal);
}

.search-btn {
    min-height: 48px;
    min-width: 120px;
    padding: 10px 14px;
    border: 3px solid var(--border);
    background: var(--teal);
    color: var(--white);
    font-family: var(--font-pixel);
    font-size: 10px;
    cursor: pointer;
    box-shadow: 3px 3px 0 var(--border);
    border-radius: 0;
    text-shadow: 1px 1px 0 var(--teal-deep);
    transition: none;
}
.search-btn:hover {
    background: #4CC8B0;
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 var(--border);
}
.search-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 var(--border);
}
.search-btn:focus-visible {
    outline: 3px solid var(--purple);
    outline-offset: 2px;
}
.search-btn:disabled {
    opacity: .55;
    cursor: default;
    transform: none;
}

.search-status {
    font-family: var(--font-body);
    font-size: 18px;
    color: var(--muted);
    margin-top: 10px;
    min-height: 22px;
    line-height: 1.2;
}
.search-status.error { color: #C04040; }
.search-status.ok { color: var(--teal-deep); }
.search-status.ok::before { content: '★ '; color: var(--gold); }
.search-status.error::before { content: '✕ '; }

/* Side controls */
.hud-side {
    bottom: 20px;
    right: 14px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.control-panel {
    padding: 10px 12px;
}
.hud-controls {
    text-align: right;
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--ink-soft);
    line-height: 1.7;
}
.hud-controls kbd {
    display: inline-block;
    min-width: 28px;
    padding: 2px 6px;
    border: 2px solid var(--border);
    background: var(--paper-alt);
    color: var(--ink);
    font-size: 14px;
    font-family: var(--font-pixel);
    font-size: 8px;
    box-shadow: 2px 2px 0 var(--border);
    margin: 0 2px;
    vertical-align: middle;
}

.reset-view-btn {
    pointer-events: auto;
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    background: var(--purple);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 3px 3px 0 var(--border);
    border-radius: 0;
    font-family: var(--font-pixel);
    font-size: 14px;
    transition: none;
}
.reset-view-btn:hover {
    background: #9B7BD4;
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 var(--border);
}
.reset-view-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 var(--border);
}
.reset-view-btn:focus-visible {
    outline: 3px solid var(--teal);
    outline-offset: 2px;
}
.reset-view-btn svg { width: 18px; height: 18px; display: none; }
.reset-view-btn .px-icon { display: block; line-height: 1; }

/* Loading — title screen style */
.vr-loading {
    position: fixed;
    inset: 0;
    z-index: 200;
    background:
        repeating-linear-gradient(0deg, #8EC8E8 0 8px, #A8D4F0 8px 16px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity .4s steps(4);
}
.vr-loading.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.vr-loading-mark {
    width: 64px;
    height: 64px;
    background: var(--teal);
    border: 4px solid var(--border);
    box-shadow: 4px 4px 0 var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-family: var(--font-pixel);
    font-size: 14px;
    margin-bottom: 20px;
    animation: pixelBounce 0.8s steps(2) infinite;
    text-shadow: 2px 2px 0 var(--teal-deep);
}
.vr-loading-text {
    font-family: var(--font-pixel);
    font-size: 14px;
    color: var(--ink);
    margin-bottom: 8px;
    text-align: center;
    line-height: 1.6;
    text-shadow: 2px 2px 0 rgba(255,255,255,.6);
}
.vr-loading-sub {
    font-family: var(--font-body);
    font-size: 20px;
    color: var(--ink-soft);
    margin-bottom: 20px;
}
.vr-loading-sub::after {
    content: '█';
    margin-left: 4px;
    animation: blink 0.8s steps(1) infinite;
    color: var(--ink);
}
.vr-loading-bar {
    width: 240px;
    height: 16px;
    background: var(--ink);
    border: 3px solid var(--border);
    box-shadow: 3px 3px 0 rgba(44,33,55,.35);
    overflow: hidden;
    padding: 2px;
}
.vr-loading-bar > div {
    width: 0%;
    max-width: 100%;
    height: 100%;
    background: repeating-linear-gradient(90deg, var(--xp) 0 8px, #F8D870 8px 10px, var(--teal) 10px 18px, #6AD0B8 18px 20px);
    transition: width .1s steps(4);
}
.vr-loading-pct {
    margin-top: 12px;
    font-family: var(--font-pixel);
    font-size: 9px;
    color: var(--ink-soft);
}

/* Mini map frame (decorative) */
.mini-map {
    position: fixed;
    top: 100px;
    right: 14px;
    z-index: 100;
    width: 88px;
    height: 88px;
    pointer-events: none;
    padding: 4px;
}
.mini-map-inner {
    width: 100%;
    height: 100%;
    background:
        repeating-linear-gradient(0deg, #C8E8A8 0 8px, #B8D898 8px 16px),
        var(--grass);
    border: 2px solid var(--border);
    position: relative;
    image-rendering: pixelated;
}
.mini-map-inner::before {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--hp);
    border: 1px solid var(--border);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 2px var(--white);
    animation: blink 1.2s steps(1) infinite;
}
.mini-map-label {
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    text-align: center;
    font-family: var(--font-pixel);
    font-size: 6px;
    color: var(--ink);
    background: var(--paper);
    border-top: 2px solid var(--border);
    padding: 3px 0;
    transform: translateY(100%);
}

@media (max-width: 720px) {
    .hud-top { padding: 8px; flex-wrap: wrap; }
    .hud-brand { font-size: 9px; }
    .stat-track { width: 72px; }
    .obj-hint, .mini-map { display: none; }
    .hud-side { bottom: auto; top: 110px; right: 8px; }
    .control-panel { display: none; }
    .hud-bottom { padding: 0 8px 10px; }
    .search-card { padding: 12px; }
    .search-row { flex-direction: column; }
    .search-btn { width: 100%; }
    .search-card-title { font-size: 7px; }
    .vr-loading-text { font-size: 11px; padding: 0 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .status-dot.busy,
    .vr-loading-mark,
    .sky-deco span,
    .obj-hint-text::after,
    .vr-loading-sub::after,
    .mini-map-inner::before { animation: none; }
}

@keyframes blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}
@keyframes pixelBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}
@keyframes pixelFloat {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(16px, 4px); }
}
