/* style.css — The Mist Compass */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700;900&family=Share+Tech+Mono&display=swap');

:root {
    --stone: #6b6560;
    --stone-dark: #4a4540;
    --mist: #9a9490;
    --amber: #d4a84b;
    --amber-dim: #8a6a2b;
    --text: #c8c0b0;
    --text-dim: #706860;
    --bg: #1a1815;
    --panel: rgba(18, 16, 14, 0.92);
    --border: rgba(180, 160, 130, 0.15);
}

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

html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    background: #000;
    font-family: 'Share Tech Mono', monospace;
    color: var(--text);
    cursor: crosshair;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

#gameCanvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: block;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* ---- VHS Overlay (CSS scanlines on top of canvas) ---- */
#vhsOverlay {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 5;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        rgba(0,0,0,0.06) 1px,
        transparent 2px,
        transparent 4px
    );
    mix-blend-mode: multiply;
}

/* ---- HUD ---- */
#hud {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.5s;
}
#hud.hidden { opacity: 0; pointer-events: none; }

/* Crosshair */
#crosshair {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 12px; height: 12px;
    border: 1.5px solid var(--amber);
    opacity: 0.5;
    border-radius: 1px;
}
#crosshair::before, #crosshair::after {
    content: ''; position: absolute;
    background: var(--amber); opacity: 0.6;
}
#crosshair::before { width: 1px; height: 4px; top: -6px; left: 50%; transform: translateX(-50%); }
#crosshair::after { width: 4px; height: 1px; top: 50%; left: -6px; transform: translateY(-50%); }

/* Compass */
#compass {
    position: absolute;
    bottom: 30px; left: 50%;
    transform: translateX(-50%);
    text-align: center;
}
#compassRing {
    width: 64px; height: 64px;
    border-radius: 50%;
    border: 2px solid var(--amber-dim);
    background: rgba(0,0,0,0.5);
    position: relative;
    margin: 0 auto;
    box-shadow: 0 0 15px rgba(212,168,75,0.15);
}
#compassNeedle {
    position: absolute;
    bottom: 50%; left: 50%;
    width: 2px; height: 24px;
    margin-left: -1px;
    background: linear-gradient(to top, var(--amber), rgba(212,168,75,0.3));
    transform-origin: center bottom;
    transition: transform 0.15s ease-out;
    box-shadow: 0 0 6px var(--amber);
}
#compassNeedle::after {
    content: '';
    position: absolute;
    top: -3px; left: -2px;
    width: 0; height: 0;
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-bottom: 5px solid var(--amber);
}
#compassLabel {
    margin-top: 6px;
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-dim);
    text-shadow: 0 0 8px rgba(212,168,75,0.3);
}

/* Lexicon */
#lexicon {
    position: absolute;
    top: 20px; left: 20px;
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 12px 16px;
    border-radius: 2px;
    min-width: 140px;
}
#lexiconTitle {
    font-family: 'Cinzel', serif;
    font-size: 11px;
    letter-spacing: 3px;
    color: var(--amber-dim);
    margin-bottom: 8px;
    text-transform: uppercase;
}
.lexiconEntry {
    margin: 4px 0;
    opacity: 0.3;
    transition: opacity 0.6s;
    font-size: 12px;
}
.lexiconEntry.collected {
    opacity: 1;
    color: var(--amber);
}
.lexiconMeaning {
    font-size: 10px;
    color: var(--text-dim);
    margin-left: 12px;
}

/* Interact prompt */
#interactPrompt {
    position: absolute;
    top: 60%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s;
}
#interactPrompt.visible { opacity: 1; }
#interactPrompt .prompt-key {
    font-size: 14px;
    color: var(--amber);
    letter-spacing: 2px;
    text-shadow: 0 0 10px var(--amber);
}
#interactPrompt .prompt-word {
    font-family: 'Cinzel', serif;
    font-size: 18px;
    color: var(--text);
    margin-top: 4px;
    letter-spacing: 4px;
}

/* ---- Word Recovery Overlay ---- */
#wordOverlay {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0);
    pointer-events: none;
    transition: background 1s;
}
#wordOverlay.active {
    background: rgba(0,0,0,0.6);
}
#wordOverlay .word-text {
    font-family: 'Cinzel', serif;
    font-size: 72px;
    font-weight: 900;
    color: var(--amber);
    letter-spacing: 16px;
    text-shadow: 0 0 40px var(--amber), 0 0 80px rgba(212,168,75,0.3);
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 1s, transform 1.5s cubic-bezier(0.16, 1, 0.3, 1);
}
#wordOverlay.active .word-text {
    opacity: 1;
    transform: scale(1);
}
#wordOverlay .word-meaning {
    font-size: 18px;
    color: var(--text);
    letter-spacing: 6px;
    text-transform: uppercase;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 1s 0.5s;
}
#wordOverlay.active .word-meaning { opacity: 0.8; }
#wordOverlay .word-narration {
    max-width: 500px;
    text-align: center;
    font-family: 'Cinzel', serif;
    font-size: 14px;
    color: var(--text-dim);
    line-height: 1.8;
    margin-top: 30px;
    opacity: 0;
    transition: opacity 1.5s 1s;
    font-style: italic;
}
#wordOverlay.active .word-narration { opacity: 1; }

/* ---- Title Screen ---- */
#titleScreen {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10, 8, 6, 0.75);
}
#titleScreen.hidden { display: none; }

.title-text {
    font-family: 'Cinzel', serif;
    font-size: 48px;
    font-weight: 900;
    letter-spacing: 10px;
    color: var(--amber);
    text-shadow: 0 0 30px rgba(212,168,75,0.4), 0 2px 4px rgba(0,0,0,0.8);
    animation: titleGlow 4s ease-in-out infinite alternate;
    text-align: center;
}
.title-sub {
    font-size: 14px;
    letter-spacing: 6px;
    color: var(--text-dim);
    margin-top: 8px;
    text-transform: uppercase;
}

@keyframes titleGlow {
    from { text-shadow: 0 0 30px rgba(212,168,75,0.3), 0 2px 4px rgba(0,0,0,0.8); }
    to { text-shadow: 0 0 50px rgba(212,168,75,0.6), 0 0 80px rgba(212,168,75,0.2), 0 2px 4px rgba(0,0,0,0.8); }
}

.menu-items {
    margin-top: 50px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}
.menu-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    font-family: 'Share Tech Mono', monospace;
    font-size: 15px;
    letter-spacing: 3px;
    padding: 10px 40px;
    cursor: pointer;
    transition: all 0.25s;
    text-transform: uppercase;
    min-width: 220px;
}
.menu-btn:hover, .menu-btn:focus {
    color: var(--amber);
    border-color: var(--amber-dim);
    background: rgba(212,168,75,0.05);
    text-shadow: 0 0 10px var(--amber);
    outline: none;
}
.menu-btn.primary {
    border-color: var(--amber-dim);
    color: var(--amber);
    font-size: 17px;
}

.title-meta {
    position: absolute;
    bottom: 20px;
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 2px;
}
.demo-hint {
    position: absolute;
    bottom: 60px;
    font-size: 12px;
    color: var(--text-dim);
    letter-spacing: 3px;
    animation: demoHintPulse 2s ease-in-out infinite;
    opacity: 0;
    transition: opacity 1s;
}
.demo-hint.visible { opacity: 1; }
@keyframes demoHintPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* ---- Tutorial ---- */
#tutorial {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10,8,6,0.85);
}
#tutorial.hidden { display: none; }

.tutorial-box {
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 36px 44px;
    max-width: 460px;
    width: 90%;
}
.tutorial-box h2 {
    font-family: 'Cinzel', serif;
    font-size: 20px;
    letter-spacing: 4px;
    color: var(--amber);
    margin-bottom: 24px;
    text-align: center;
}
.tutorial-row {
    display: flex;
    align-items: center;
    margin: 12px 0;
    font-size: 13px;
    line-height: 1.6;
}
.tutorial-key {
    min-width: 100px;
    color: var(--amber);
    letter-spacing: 1px;
    font-size: 12px;
    text-align: right;
    padding-right: 16px;
    flex-shrink: 0;
}
.tutorial-desc {
    color: var(--text-dim);
}
.tutorial-flavor {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-family: 'Cinzel', serif;
    font-size: 13px;
    color: var(--text-dim);
    font-style: italic;
    text-align: center;
    line-height: 1.8;
}
.tutorial-start {
    display: block;
    margin: 28px auto 0;
    background: transparent;
    border: 1px solid var(--amber-dim);
    color: var(--amber);
    font-family: 'Share Tech Mono', monospace;
    font-size: 14px;
    letter-spacing: 3px;
    padding: 10px 36px;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.25s;
}
.tutorial-start:hover {
    background: rgba(212,168,75,0.08);
    text-shadow: 0 0 8px var(--amber);
}

/* ---- Pause Menu ---- */
#pauseMenu {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 80;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10,8,6,0.8);
}
#pauseMenu.hidden { display: none; }
.pause-title {
    font-family: 'Cinzel', serif;
    font-size: 28px;
    letter-spacing: 8px;
    color: var(--text-dim);
    margin-bottom: 30px;
}

/* ---- Win Screen ---- */
#winScreen {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10,8,6,0.9);
}
#winScreen.hidden { display: none; }
.win-title {
    font-family: 'Cinzel', serif;
    font-size: 32px;
    letter-spacing: 8px;
    color: var(--amber);
    text-shadow: 0 0 40px var(--amber);
    margin-bottom: 12px;
}
.win-subtitle {
    font-family: 'Cinzel', serif;
    font-style: italic;
    font-size: 14px;
    color: var(--text-dim);
    margin-bottom: 40px;
    letter-spacing: 3px;
}
.win-stats {
    text-align: center;
    margin-bottom: 30px;
}
.win-stat-line {
    font-size: 14px;
    letter-spacing: 2px;
    margin: 6px 0;
    color: var(--text-dim);
}
.win-stat-line span { color: var(--amber); }
.win-name-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
}
.win-name-entry label {
    font-size: 13px;
    color: var(--text-dim);
    letter-spacing: 2px;
}
.win-name-input {
    width: 60px;
    text-align: center;
    background: rgba(0,0,0,0.4);
    border: 1px solid var(--amber-dim);
    color: var(--amber);
    font-family: 'Share Tech Mono', monospace;
    font-size: 18px;
    letter-spacing: 6px;
    padding: 6px 8px;
    text-transform: uppercase;
}
.win-name-input:focus { outline: 1px solid var(--amber); }

/* ---- Leaderboard ---- */
#leaderboard {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10,8,6,0.9);
}
#leaderboard.hidden { display: none; }
.lb-title {
    font-family: 'Cinzel', serif;
    font-size: 22px;
    letter-spacing: 6px;
    color: var(--amber);
    margin-bottom: 24px;
}
.lb-table {
    min-width: 340px;
}
.lb-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border);
}
.lb-row.header {
    color: var(--text-dim);
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
}
.lb-row .rank { width: 40px; color: var(--text-dim); }
.lb-row .name { width: 60px; color: var(--amber); letter-spacing: 2px; }
.lb-row .time { width: 80px; text-align: right; }
.lb-row .date { width: 100px; text-align: right; color: var(--text-dim); }
.lb-row.highlight { background: rgba(212,168,75,0.08); }

/* ---- Mobile Controls ---- */
#mobileControls {
    position: fixed; bottom: 0; left: 0;
    width: 100%; height: 200px;
    z-index: 20;
    pointer-events: none;
    display: none;
}
#joystickZone {
    position: absolute;
    bottom: 20px; left: 20px;
    width: 120px; height: 120px;
    pointer-events: auto;
    touch-action: none;
}
#joystickBase {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 100px; height: 100px;
    border-radius: 50%;
    border: 2px solid rgba(212,168,75,0.2);
    background: rgba(0,0,0,0.2);
}
#joystickThumb {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(212,168,75,0.25);
    border: 1px solid rgba(212,168,75,0.4);
}
.mobile-interact-btn {
    position: absolute;
    bottom: 40px; right: 30px;
    width: 60px; height: 60px;
    border-radius: 50%;
    border: 2px solid rgba(212,168,75,0.3);
    background: rgba(0,0,0,0.3);
    color: var(--amber);
    font-size: 11px;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    touch-action: none;
    font-family: 'Share Tech Mono', monospace;
}

/* ---- Buttons ---- */
#fullscreenBtn, #muteBtn {
    position: fixed;
    z-index: 200;
    background: rgba(0,0,0,0.4);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 16px;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
    font-family: 'Share Tech Mono', monospace;
}
#fullscreenBtn { top: 10px; right: 10px; }
#muteBtn { top: 10px; right: 50px; }
#fullscreenBtn:hover, #muteBtn:hover {
    color: var(--amber);
    border-color: var(--amber-dim);
}

/* ---- Utility ---- */
.hidden { display: none !important; }

/* Responsive */
@media (max-width: 600px) {
    .title-text { font-size: 28px; letter-spacing: 5px; }
    .title-sub { font-size: 10px; }
    .menu-btn { font-size: 13px; padding: 8px 24px; min-width: 180px; }
    .tutorial-box { padding: 24px; }
    .tutorial-box h2 { font-size: 16px; }
    .tutorial-key { min-width: 80px; font-size: 11px; }
    .tutorial-desc { font-size: 12px; }
    #wordOverlay .word-text { font-size: 42px; letter-spacing: 8px; }
    #wordOverlay .word-meaning { font-size: 14px; }
    .win-title { font-size: 24px; }
    #compassRing { width: 50px; height: 50px; }
    #compassNeedle { height: 18px; }
}
