/* ============================================================
   MazeTON Styles — v2026052201
   Dark dreamcore/liminal aesthetic, mobile-first, 32-lang safe
   ============================================================ */

:root {
    --bg-0: #04060e;
    --bg-1: #0a0e1a;
    --bg-2: #131a2e;
    --surface: rgba(20, 26, 46, 0.85);
    --surface-2: rgba(28, 36, 60, 0.92);
    --border: rgba(120, 140, 200, 0.18);
    --border-strong: rgba(140, 160, 230, 0.34);
    --text: #e6ecff;
    --text-muted: #98a3c9;
    --text-dim: #5a6890;
    --accent: #5b8def;
    --accent-2: #9b6cf7;
    --accent-glow: rgba(91, 141, 239, 0.45);
    --danger: #ff5a6e;
    --success: #4dd4a8;
    --warning: #ffbd5a;
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
    --radius: 16px;
    --radius-sm: 10px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-0);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    user-select: none;
    -webkit-user-select: none;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: manual;
    -webkit-hyphens: manual;
    text-wrap: pretty;
    overscroll-behavior: none;
}

body {
    background: radial-gradient(ellipse at top, var(--bg-2) 0%, var(--bg-1) 50%, var(--bg-0) 100%);
}

/* ============== SCREEN SYSTEM ============== */
.screen {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: none;
    overflow: hidden;
}
.screen.active {
    display: block;
}
.screen.active.flex {
    display: flex;
}

/* ============== BOOT SCREEN ============== */
#screen-boot {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #1a2244 0%, var(--bg-0) 80%);
}
#screen-boot.active { display: flex; }
.boot-content {
    text-align: center;
    padding: 24px;
}
.boot-logo {
    margin: 0 auto 18px;
    filter: drop-shadow(0 8px 30px var(--accent-glow));
}
.boot-title {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 1.5px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 24px;
}
.boot-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 12px auto;
    animation: spin 0.9s linear infinite;
}
.boot-status {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============== ERROR SCREEN ============== */
#screen-error.active { display: flex; align-items: center; justify-content: center; }
.error-content { text-align: center; padding: 24px; max-width: 360px; }
.error-icon { font-size: 56px; margin-bottom: 12px; }
.error-title { font-size: 20px; margin-bottom: 8px; }
.error-message { color: var(--text-muted); font-size: 14px; margin-bottom: 20px; }

/* ============== INTRO SCREEN ============== */
#screen-intro {
    background: #0a0e1a;
    overflow: hidden;
}
#intro-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    background: linear-gradient(to bottom, #87b9e8 0%, #c8d8e8 50%, #e8e0d0 100%);
}
.intro-overlay {
    display: none !important;       /* eliminat — sageata 3D indica drumul */
    position: absolute;
    top: calc(76px + var(--safe-top));
    left: 0;
    right: 0;
    padding: 0 20px;
    text-align: center;
    pointer-events: none;
    z-index: 10;
    /* Auto-fade dupa 5 secunde ca sa nu ocupe ecranul */
    animation: introOverlayFade 8s ease-in-out forwards;
}
.intro-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
    text-shadow: 0 2px 14px rgba(0, 0, 0, 0.85), 0 0 30px rgba(0,0,0,0.5);
    letter-spacing: 0.3px;
    animation: fadeUp 1.2s ease-out;
    color: #ffffff;
}
.intro-subtitle {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.92);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.85);
    animation: fadeUp 1.6s ease-out;
    max-width: 360px;
    margin: 0 auto;
}
@keyframes introOverlayFade {
    0%   { opacity: 0; transform: translateY(-12px); }
    8%   { opacity: 1; transform: translateY(0); }
    70%  { opacity: 1; }
    100% { opacity: 0; pointer-events: none; }
}
.intro-skip {
    position: absolute;
    top: calc(16px + var(--safe-top));
    right: calc(16px + var(--safe-right));
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    z-index: 20;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.intro-hint {
    /* Joystick deja indica controlul — ascundem hint-ul de tap */
    display: none !important;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* ============== MENU SCREEN ============== */
#screen-menu.active {
    display: flex;
    flex-direction: column;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
}
.menu-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at top, rgba(91, 141, 239, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at bottom, rgba(155, 108, 247, 0.12) 0%, transparent 50%);
    z-index: 0;
}
.menu-header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    z-index: 2;
}
.logo-small {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.icon-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 16px;
    color: var(--text);
    cursor: pointer;
}
.menu-main {
    position: relative;
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    z-index: 2;
}
.hero-card {
    text-align: center;
    padding: 24px 20px 12px;
}
.hero-eye {
    font-size: 48px;
    filter: drop-shadow(0 4px 20px var(--accent-glow));
    margin-bottom: 8px;
    animation: eyeBlink 5s ease-in-out infinite;
}
@keyframes eyeBlink {
    0%, 95%, 100% { transform: scaleY(1); }
    97% { transform: scaleY(0.1); }
}
.hero-title {
    font-size: 28px;
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}
.hero-sub {
    color: var(--text-muted);
    font-size: 15px;
}
.hero-sub b {
    color: var(--warning);
    font-weight: 700;
}

.progress-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
.progress-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}
.progress-numbers {
    display: flex;
    align-items: center;
    gap: 12px;
}
.progress-current {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.progress-current .num {
    font-size: 32px;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
}
.progress-current .lbl {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.progress-bar-wrap {
    flex: 1;
    height: 8px;
    background: var(--bg-1);
    border-radius: 999px;
    overflow: hidden;
    min-width: 0;
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    border-radius: 999px;
    transition: width 0.6s ease-out;
}
.progress-target {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 600;
}

.btn-play {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border: none;
    border-radius: var(--radius);
    padding: 18px;
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 30px var(--accent-glow);
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 8px;
    align-items: center;
    transition: transform 0.15s ease;
}
.btn-play:active { transform: scale(0.98); }
.btn-play .play-icon {
    font-size: 14px;
    background: rgba(255, 255, 255, 0.22);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-play .play-text {
    text-align: left;
    line-height: 1.2;
}
.btn-play .play-sub {
    font-size: 12px;
    opacity: 0.85;
    font-weight: 500;
}
.btn-play .play-level {
    font-size: 20px;
    font-weight: 800;
    background: rgba(255, 255, 255, 0.18);
    padding: 4px 12px;
    border-radius: 8px;
}

.menu-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
}
.action-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 6px;
    color: var(--text);
    font-size: 11px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 0;
    line-height: 1.2;
    white-space: normal;
    text-align: center;
}
.action-btn:active { background: var(--surface-2); }
.action-icon { font-size: 22px; }
.action-label {
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: manual;
}

.menu-footer {
    text-align: center;
    color: var(--text-dim);
    font-size: 11px;
    margin-top: auto;
    padding-top: 20px;
}
.menu-footer b { color: var(--warning); }

/* ============== GAME SCREEN ============== */
#screen-game.active { display: block; background: #000; }
#game-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}
.hud-top {
    position: absolute;
    top: calc(64px + var(--safe-top));
    left: calc(12px + var(--safe-left));
    right: calc(12px + var(--safe-right));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    z-index: 10;
    pointer-events: none;
}
.hud-btn {
    pointer-events: auto;
    background: rgba(10, 14, 26, 0.7);
    border: 1px solid var(--border);
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    font-size: 20px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer;
}
.hud-level {
    background: rgba(10, 14, 26, 0.7);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 14px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    text-align: center;
    pointer-events: auto;
}
.hud-level-label {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
}
.hud-level-num {
    display: block;
    font-size: 18px;
    font-weight: 800;
    color: var(--accent);
    line-height: 1.1;
}

.hud-controls {
    position: absolute;
    bottom: calc(20px + var(--safe-bottom));
    left: 0;
    right: 0;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    z-index: 10;
    pointer-events: none;
}
.control-pad, .look-pad { pointer-events: auto; }
.control-pad {
    display: grid;
    grid-template-rows: auto auto auto;
    gap: 6px;
    justify-items: center;
}
.ctrl-row {
    display: grid;
    grid-template-columns: auto auto auto;
    gap: 6px;
}
.ctrl-btn {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: rgba(20, 26, 46, 0.75);
    border: 1px solid var(--border-strong);
    color: #fff;
    font-size: 18px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    cursor: pointer;
}
.ctrl-action {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border: none;
    color: #fff;
    font-size: 22px;
    box-shadow: 0 4px 20px var(--accent-glow);
}
.look-pad {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(91, 141, 239, 0.15), rgba(20, 26, 46, 0.4));
    border: 1px solid var(--border);
    position: relative;
    touch-action: none;
}
.look-pad::before {
    content: '';
    position: absolute;
    inset: 50%;
    width: 32px;
    height: 32px;
    margin: -16px;
    border-radius: 50%;
    background: rgba(91, 141, 239, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.4);
}

/* ============== MODALS ============== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(4, 6, 14, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.modal.active { display: flex; }
.modal-content {
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 28px 20px 20px;
    max-width: 380px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s cubic-bezier(0.34, 1.4, 0.64, 1);
}
.modal-large { max-width: 480px; }
@keyframes modalIn {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
}
.modal h2 {
    font-size: 22px;
    margin-bottom: 12px;
    font-weight: 700;
}
.modal p {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 12px;
}
.modal .muted {
    color: var(--text-dim);
    font-size: 12px;
}

.btn-primary, .btn-secondary {
    width: 100%;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    margin-top: 10px;
    line-height: 1.2;
    white-space: normal;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    box-shadow: 0 6px 20px var(--accent-glow);
}
.btn-primary:active { transform: scale(0.98); }
.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.quest-type-badge {
    display: inline-block;
    background: var(--accent-glow);
    color: var(--accent);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    font-weight: 600;
}
.quest-prompt {
    font-size: 17px;
    margin-bottom: 14px;
    line-height: 1.4;
    font-weight: 600;
}
.quest-body { margin-bottom: 14px; }
.quest-body input[type="text"],
.quest-body input[type="number"] {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 17px;
    text-align: center;
    letter-spacing: 2px;
}
.quest-body input:focus {
    outline: none;
    border-color: var(--accent);
}
.quest-attempts {
    color: var(--text-dim);
    font-size: 12px;
    margin-bottom: 10px;
}

.hint-icon, .complete-icon {
    font-size: 56px;
    margin-bottom: 8px;
}
.hint-text {
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg-1);
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border-strong);
    margin-bottom: 12px;
}
.complete-stats {
    background: var(--bg-1);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin: 14px 0;
    font-size: 14px;
    color: var(--text-muted);
}
.complete-stats div { margin: 4px 0; }
.complete-stats b { color: var(--text); }

/* ============== LEADERBOARD ============== */
.lb-list {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 55vh;
    overflow-y: auto;
}
.lb-row {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-1);
    border-radius: var(--radius-sm);
}
.lb-row.top { background: linear-gradient(90deg, rgba(255, 189, 90, 0.18), rgba(255, 189, 90, 0.05)); }
.lb-rank { font-weight: 700; color: var(--text-muted); text-align: center; }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.lb-level { font-weight: 700; color: var(--accent); }

.wallet-current {
    background: var(--bg-1);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: ui-monospace, monospace;
    font-size: 12px;
    color: var(--text-muted);
    word-break: break-all;
    margin: 12px 0;
    display: none;
}
.wallet-current.has-value { display: block; }

/* ============== QUEST SPECIFIC ============== */
.quest-num-grid {
    display: flex;
    justify-content: center;
    margin: 10px 0;
}
.quest-helper {
    color: var(--text-dim);
    font-size: 12px;
    margin-top: 8px;
}
.quest-seq {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
}
.seq-display {
    min-height: 36px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    width: 100%;
    align-items: center;
    justify-content: center;
}
.seq-pill {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-block;
    border: 2px solid rgba(255,255,255,0.2);
}
.seq-red { background: #ff5070; }
.seq-green { background: #50d090; }
.seq-blue { background: #5090ff; }
.seq-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
}
.seq-btn {
    padding: 14px;
    border-radius: 10px;
    border: none;
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
}
.seq-btn:active { transform: scale(0.96); }
.seq-clear {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

/* ============== INTRO VIRTUAL JOYSTICK (visible on mobile) ============== */
.intro-joystick {
    position: absolute;
    bottom: calc(80px + var(--safe-bottom));
    left: calc(24px + var(--safe-left));
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 50%,
        rgba(91, 141, 239, 0.32) 0%,
        rgba(20, 26, 46, 0.55) 70%,
        rgba(20, 26, 46, 0.7) 100%);
    border: 2px solid rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 25;
    touch-action: none;
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.4),
                inset 0 0 20px rgba(255, 255, 255, 0.08);
    user-select: none;
    -webkit-user-select: none;
}
.intro-joystick-thumb {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 56px;
    height: 56px;
    margin: -28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6a9af0, #9b6cf7);
    border: 3px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 4px 16px rgba(91, 141, 239, 0.6);
    transition: transform 0.05s linear;
    pointer-events: none;
}
.intro-joystick-label {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.85);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    white-space: nowrap;
}

/* ============== RESPONSIVE BREAKPOINTS ============== */
@media (max-width: 420px) {
    .intro-joystick { width: 110px; height: 110px; bottom: calc(70px + var(--safe-bottom)); }
    .intro-joystick-thumb { width: 48px; height: 48px; margin: -24px; }
    .hero-title { font-size: 24px; }
    .menu-actions { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .ctrl-btn { width: 48px; height: 48px; font-size: 16px; }
    .look-pad { width: 110px; height: 110px; }
}
@media (max-width: 380px) {
    .hero-title { font-size: 22px; }
    .btn-play { padding: 14px; font-size: 15px; }
    .btn-play .play-level { font-size: 18px; }
    .action-btn { font-size: 10px; padding: 10px 4px; }
    .modal-content { padding: 24px 16px 16px; }
}
@media (max-width: 340px) {
    .hero-title { font-size: 20px; }
    .ctrl-btn { width: 44px; height: 44px; }
    .look-pad { width: 96px; height: 96px; }
}

@media (orientation: landscape) and (max-height: 500px) {
    .hud-controls { padding: 0 20px; }
    .control-pad, .look-pad { transform: scale(0.85); }
}

/* ============================================================
   3RD PERSON CONTROLS — joystick mobil vizibil (jos-stanga)
   Player controller foloseste joystick + swipe; ascundem
   vechiul ctrl-pad ca nu mai e necesar.
   ============================================================ */
body.screen-game .hud-controls {
    display: none !important;
}

.maze-joystick {
    position: fixed;
    left: calc(24px + var(--safe-left));
    bottom: calc(28px + var(--safe-bottom));
    width: 144px;
    height: 144px;
    border-radius: 50%;
    background: radial-gradient(circle at center,
        rgba(91, 141, 239, 0.32) 0%,
        rgba(91, 141, 239, 0.18) 45%,
        rgba(10, 14, 26, 0.55) 100%);
    border: 2px solid rgba(140, 160, 230, 0.45);
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.45),
        inset 0 0 24px rgba(91, 141, 239, 0.18);
    touch-action: none;
    z-index: 50;
    user-select: none;
    -webkit-user-select: none;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.maze-joystick-thumb {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%,
        rgba(230, 236, 255, 0.95) 0%,
        rgba(155, 108, 247, 0.85) 60%,
        rgba(91, 141, 239, 0.9) 100%);
    border: 2px solid rgba(255, 255, 255, 0.55);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.45),
        inset 0 -3px 8px rgba(0, 0, 0, 0.3),
        inset 0 3px 6px rgba(255, 255, 255, 0.35);
    transform: translate(-50%, -50%);
    transition: transform 0.05s linear;
    pointer-events: none;
}

/* Responsive: telefon mic 340 */
@media (max-width: 340px) {
    .maze-joystick { width: 116px; height: 116px; left: 16px; bottom: 22px; }
    .maze-joystick-thumb { width: 48px; height: 48px; }
}

/* Tablet+ */
@media (min-width: 768px) {
    .maze-joystick { width: 168px; height: 168px; }
    .maze-joystick-thumb { width: 68px; height: 68px; }
}

/* Landscape phone: muta joystickul mai aproape de margine */
@media (orientation: landscape) and (max-height: 500px) {
    .maze-joystick { width: 120px; height: 120px; left: 18px; bottom: 18px; }
    .maze-joystick-thumb { width: 50px; height: 50px; }
}

/* Desktop: ascundem joystick (player.js verifica touch oricum, dar e backup) */
@media (hover: hover) and (pointer: fine) {
    .maze-joystick { display: none !important; }
}

/* ============================================================
   LEVEL 1 VIRAL FEATURES (2026-05-22)
   Hearts HUD, Timer, Minimap, Photo button, Toasts, Intro overlay,
   Photo modal, Future hint banner, Multiple-choice quiz, etc.
   ============================================================ */

/* ===== HUD hearts ===== */
.hud-hearts {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 6px 10px;
    background: rgba(10, 14, 26, 0.55);
    border: 1px solid rgba(91, 141, 239, 0.25);
    border-radius: 999px;
    color: #ff5b7a;
    font-size: 18px;
    line-height: 1;
    font-weight: 700;
    text-shadow: 0 0 6px rgba(255, 80, 120, 0.6);
    pointer-events: none;
}
.hud-hearts .heart { transition: transform 0.2s, opacity 0.3s; }
.hud-hearts .heart.empty { color: #444; opacity: 0.5; text-shadow: none; }
.hud-hearts .heart.lost { animation: heartLost 0.5s ease-out; }
@keyframes heartLost {
    0% { transform: scale(1.4); color: #fff; }
    100% { transform: scale(1); color: #444; opacity: 0.5; }
}

/* ===== HUD timer ===== */
.hud-timer {
    padding: 6px 10px;
    background: rgba(10, 14, 26, 0.55);
    border: 1px solid rgba(91, 141, 239, 0.25);
    border-radius: 999px;
    color: #c9d8ff;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    letter-spacing: 0.5px;
    pointer-events: none;
}

/* ===== HUD minimap ===== */
#hud-minimap {
    position: fixed;
    top: calc(124px + var(--safe-top));
    right: calc(12px + var(--safe-right));
    width: 96px;
    height: 96px;
    background: rgba(10, 14, 26, 0.65);
    border: 1px solid rgba(91, 141, 239, 0.35);
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    z-index: 30;
    pointer-events: none;
    display: none;
}
body.screen-game #hud-minimap { display: block; }

/* ===== Photo button ===== */
.btn-photo {
    position: fixed;
    right: 14px;
    bottom: 180px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 2px solid rgba(255, 215, 0, 0.7);
    background: linear-gradient(135deg, rgba(91, 141, 239, 0.85), rgba(155, 108, 247, 0.85));
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    z-index: 30;
    box-shadow: 0 4px 16px rgba(155, 108, 247, 0.45);
    display: none;
    transition: transform 0.15s, box-shadow 0.2s;
}
.btn-photo:active { transform: scale(0.94); }
.btn-photo:hover { box-shadow: 0 6px 22px rgba(255, 215, 0, 0.55); }
body.screen-game .btn-photo { display: block; }
@media (max-width: 420px) {
    .btn-photo { width: 46px; height: 46px; font-size: 19px; bottom: 168px; }
}

/* ===== Floating ACTION button (interact / open quest) ===== */
.btn-action-float {
    position: fixed;
    right: calc(14px + var(--safe-right));
    bottom: calc(248px + var(--safe-bottom));
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 3px solid rgba(255, 215, 0, 0.85);
    background: radial-gradient(circle at 35% 30%,
        rgba(255, 255, 255, 0.35) 0%,
        rgba(155, 108, 247, 0.95) 45%,
        rgba(91, 141, 239, 1) 100%);
    color: #fff;
    font-size: 28px;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
    z-index: 31;
    box-shadow:
        0 6px 22px rgba(155, 108, 247, 0.65),
        0 0 0 4px rgba(255, 215, 0, 0.18),
        inset 0 -4px 10px rgba(0, 0, 0, 0.35),
        inset 0 4px 8px rgba(255, 255, 255, 0.35);
    display: none;
    transition: transform 0.12s, box-shadow 0.2s;
    animation: actFloatPulse 2.2s ease-in-out infinite;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.btn-action-float:active { transform: scale(0.92); animation: none; }
body.screen-game .btn-action-float { display: flex; align-items: center; justify-content: center; }
.btn-action-float .act-label {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 700;
    color: #ffd966;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
    letter-spacing: 1.5px;
    pointer-events: none;
    white-space: nowrap;
}
@keyframes actFloatPulse {
    0%, 100% { box-shadow: 0 6px 22px rgba(155, 108, 247, 0.55), 0 0 0 4px rgba(255, 215, 0, 0.18), inset 0 -4px 10px rgba(0,0,0,0.35), inset 0 4px 8px rgba(255,255,255,0.35); }
    50%      { box-shadow: 0 6px 32px rgba(255, 215, 0, 0.75), 0 0 0 8px rgba(255, 215, 0, 0.25), inset 0 -4px 10px rgba(0,0,0,0.35), inset 0 4px 8px rgba(255,255,255,0.45); }
}
@media (max-width: 420px) {
    .btn-action-float { width: 64px; height: 64px; font-size: 24px; bottom: calc(232px + var(--safe-bottom)); }
}
@media (max-width: 340px) {
    .btn-action-float { width: 56px; height: 56px; font-size: 22px; bottom: calc(218px + var(--safe-bottom)); }
    .btn-action-float .act-label { font-size: 9px; bottom: -18px; }
}

/* ===== Level intro overlay (per-level cinematic) ===== */
.level-intro-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(10, 14, 26, 0.92), rgba(0, 0, 0, 0.98));
    display: none;
    z-index: 90;
    align-items: center;
    justify-content: center;
    padding: 24px;
    cursor: pointer;
    animation: fadeIn 0.35s ease-out;
}
.level-intro-overlay.active { display: flex; }
.level-intro-content {
    max-width: 480px;
    text-align: center;
    color: #f1f5ff;
}
.level-intro-eye {
    font-size: 64px;
    line-height: 1;
    margin-bottom: 12px;
    animation: eyePulse 2.5s ease-in-out infinite;
    text-shadow: 0 0 26px rgba(91, 141, 239, 0.8);
}
@keyframes eyePulse {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.08); opacity: 1; }
}
.level-intro-title {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 1.5px;
    color: #ffd860;
    margin: 12px 0;
    text-shadow: 0 0 18px rgba(255, 216, 96, 0.5);
}
.level-intro-text {
    font-size: 16px;
    line-height: 1.55;
    color: #c9d8ff;
    margin: 8px 0 24px;
}
.level-intro-skip {
    margin-top: 18px;
    font-size: 13px;
    color: rgba(201, 216, 255, 0.6);
    letter-spacing: 1px;
    text-transform: uppercase;
    animation: blink 1.6s ease-in-out infinite;
}
@keyframes blink { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 420px) {
    .level-intro-title { font-size: 21px; letter-spacing: 1px; }
    .level-intro-text { font-size: 14px; }
    .level-intro-eye { font-size: 48px; }
}

/* ===== Center toast (transient status messages) ===== */
.center-toast {
    position: fixed;
    top: 38%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.85);
    background: rgba(10, 14, 26, 0.92);
    color: #fff;
    padding: 14px 22px;
    border-radius: 14px;
    border: 1px solid rgba(91, 141, 239, 0.4);
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
    z-index: 80;
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    max-width: 86%;
}
.center-toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* ===== Achievement toast ===== */
.achievement-toast {
    position: fixed;
    top: -120px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, rgba(91, 141, 239, 0.95), rgba(155, 108, 247, 0.95));
    color: #fff;
    padding: 12px 18px;
    border-radius: 14px;
    border: 2px solid rgba(255, 215, 0, 0.7);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    z-index: 90;
    transition: top 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 90%;
}
.achievement-toast.show { top: 18px; }
.achievement-toast .ach-icon { font-size: 28px; line-height: 1; }
.achievement-toast .ach-title { font-size: 14px; font-weight: 700; }
.achievement-toast .ach-desc { font-size: 12px; opacity: 0.85; }

/* ===== Future hint banner ===== */
.fh-banner {
    position: fixed;
    top: -130px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, rgba(60, 40, 10, 0.96), rgba(40, 25, 5, 0.96));
    color: #ffd860;
    padding: 12px 16px 12px 18px;
    border-radius: 14px;
    border: 2px solid rgba(255, 216, 96, 0.65);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
    z-index: 90;
    transition: top 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 92%;
    width: 380px;
}
.fh-banner.show { top: 18px; }
.fh-banner-icon { font-size: 26px; line-height: 1; }
.fh-banner-body { flex: 1; min-width: 0; }
.fh-banner-title { font-size: 11px; opacity: 0.75; letter-spacing: 0.5px; text-transform: uppercase; }
.fh-banner-text { font-size: 14px; font-weight: 600; line-height: 1.35; margin-top: 2px; color: #fff5d6; }
.fh-banner-close {
    background: none; border: none; color: rgba(255, 216, 96, 0.7);
    font-size: 16px; cursor: pointer; padding: 4px 8px;
}

/* ===== Multiple-choice quiz ===== */
.quest-mc {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 12px 0;
}
.mc-question {
    font-size: 15px;
    font-weight: 600;
    color: #f1f5ff;
    text-align: center;
    padding: 10px;
    background: rgba(91, 141, 239, 0.1);
    border-radius: 10px;
    border-left: 3px solid #5b8def;
}
.mc-choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.mc-choice {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(91, 141, 239, 0.15), rgba(155, 108, 247, 0.15));
    border: 2px solid rgba(91, 141, 239, 0.35);
    border-radius: 12px;
    color: #f1f5ff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.12s, background 0.2s, border-color 0.2s;
    text-align: left;
    min-height: 52px;
}
.mc-choice:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(91, 141, 239, 0.25), rgba(155, 108, 247, 0.25));
    border-color: rgba(91, 141, 239, 0.65);
    transform: translateY(-1px);
}
.mc-choice:active:not(:disabled) { transform: scale(0.98); }
.mc-choice:disabled { opacity: 0.5; cursor: not-allowed; }
.mc-choice.mc-picked {
    background: linear-gradient(135deg, rgba(255, 216, 96, 0.3), rgba(255, 175, 50, 0.25));
    border-color: rgba(255, 216, 96, 0.8);
    opacity: 1;
}
.mc-letter {
    flex-shrink: 0;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(91, 141, 239, 0.4);
    color: #fff;
    font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
}
.mc-label { flex: 1; min-width: 0; }

/* ===== Light sequence / hidden door helper boxes ===== */
.quest-lights-hint, .quest-hidden-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: rgba(91, 141, 239, 0.1);
    border-radius: 12px;
    border: 1px dashed rgba(91, 141, 239, 0.4);
}
.ls-icon {
    font-size: 28px;
    font-weight: 800;
    color: #ffd860;
    text-shadow: 0 0 10px rgba(255, 216, 96, 0.6);
}
.ls-text {
    text-align: center;
    color: #c9d8ff;
    font-size: 14px;
    line-height: 1.5;
}

/* ===== Photo modal ===== */
.modal-photo-content {
    max-width: 480px;
    text-align: center;
}
.photo-preview-wrap {
    background: #000;
    border: 1px solid rgba(91, 141, 239, 0.3);
    border-radius: 10px;
    overflow: hidden;
    margin: 14px 0;
    min-height: 180px;
    display: flex; align-items: center; justify-content: center;
}
.photo-preview-wrap img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}
.photo-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

/* ===== Complete splits (per-room split times) ===== */
.complete-splits {
    margin: 12px 0;
    padding: 10px;
    background: rgba(91, 141, 239, 0.08);
    border-radius: 8px;
    font-size: 12px;
    color: #c9d8ff;
    max-height: 120px;
    overflow-y: auto;
}
.complete-splits .split-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 6px;
    border-bottom: 1px dashed rgba(91, 141, 239, 0.15);
}
.complete-splits .split-row:last-child { border-bottom: none; }
.complete-splits .split-room { opacity: 0.8; }
.complete-splits .split-time { font-variant-numeric: tabular-nums; font-weight: 600; color: #ffd860; }

/* ===== Small screens adjustments ===== */
@media (max-width: 420px) {
    .hud-hearts { font-size: 16px; padding: 5px 8px; }
    .hud-timer { font-size: 12px; padding: 5px 8px; }
    #hud-minimap { width: 78px; height: 78px; top: calc(118px + var(--safe-top)); right: calc(10px + var(--safe-right)); }
    .mc-choice { font-size: 14px; padding: 12px 14px; min-height: 48px; }
    .mc-letter { width: 28px; height: 28px; font-size: 13px; }
    .fh-banner { width: auto; padding: 10px 12px; }
    .fh-banner-text { font-size: 13px; }
}
@media (max-width: 340px) {
    .hud-hearts { font-size: 14px; padding: 4px 6px; gap: 2px; }
    .hud-timer { font-size: 11px; padding: 4px 6px; }
    #hud-minimap { width: 68px; height: 68px; top: calc(110px + var(--safe-top)); right: calc(8px + var(--safe-right)); }
    .mc-choice { font-size: 13px; padding: 10px 12px; min-height: 44px; }
}
