/* ========================================================
   QUEST APP — STYLES
   Тёмная детективная эстетика
   ======================================================== */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --gold:        #E8C97A;
    --gold-dim:    rgba(232,201,122,0.35);
    --gold-glow:   rgba(232,201,122,0.12);
    --bg:          #080B11;
    --surface:     #0E1320;
    --surface2:    #141926;
    --border:      rgba(232,201,122,0.12);
    --border2:     rgba(255,255,255,0.06);
    --text:        rgba(255,255,255,0.92);
    --muted:       rgba(255,255,255,0.38);
    --red:         #FF453A;
    --green:       #30D158;
    --radius:      16px;
    --answer-h:    64px;  /* высота полоски с инпутом */
}

html, body {
    width: 100%; height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: 'Mulish', sans-serif;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

/* ========================================================
   SCREENS
   ======================================================== */
.screen {
    position: fixed;
    inset: 0;
    display: none;
    flex-direction: column;
}
.screen.active { display: flex; }

/* ========================================================
   PASSWORD SCREEN
   ======================================================== */
#passwordScreen {
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.pw-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
}
.pw-noise {
    position: absolute; inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    opacity: 0.5;
}
.pw-glow {
    position: absolute;
    top: -30%;
    left: 50%;
    transform: translateX(-50%);
    width: 120%;
    height: 70%;
    background: radial-gradient(ellipse, rgba(232,201,122,0.07) 0%, transparent 70%);
    pointer-events: none;
}

.pw-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 32px 28px;
    width: 100%;
    max-width: 380px;
}

.pw-logo {
    margin-bottom: 12px;
    animation: pwLogoSpin 20s linear infinite;
}
@keyframes pwLogoSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.pw-title {
    font-family: 'Unbounded', sans-serif;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--gold);
    line-height: 1;
}
.pw-city {
    font-family: 'Unbounded', sans-serif;
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.22em;
    color: var(--muted);
    margin-bottom: 16px;
}
.pw-subtitle {
    font-size: 14px;
    color: var(--muted);
    letter-spacing: 0.04em;
    margin-bottom: 24px;
}

.pw-input-wrap {
    position: relative;
    width: 100%;
    max-width: 280px;
    margin-bottom: 8px;
}
.pw-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    font-family: 'Unbounded', sans-serif;
    font-size: 26px;
    font-weight: 600;
    letter-spacing: 0.25em;
    color: var(--text);
    text-align: center;
    padding: 12px 0 14px;
    caret-color: var(--gold);
}
.pw-input::placeholder {
    color: rgba(255,255,255,0.15);
    letter-spacing: 0.2em;
}
.pw-input-line {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 1px;
    background: var(--border);
    transition: background 0.2s;
}
.pw-input-wrap:focus-within .pw-input-line {
    background: var(--gold-dim);
    box-shadow: 0 0 8px var(--gold-glow);
}

.pw-btn {
    margin-top: 16px;
    width: 100%;
    max-width: 280px;
    height: 54px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--gold) 0%, #B8932A 100%);
    color: #080B11;
    font-family: 'Unbounded', sans-serif;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.08em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 28px rgba(232,201,122,0.25);
    transition: transform 0.1s, box-shadow 0.15s;
}
.pw-btn::before {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, transparent 55%);
}
.pw-btn:active { transform: scale(0.97); box-shadow: 0 4px 14px rgba(232,201,122,0.15); }

.pw-error {
    font-size: 13px;
    color: var(--red);
    text-align: center;
    margin-top: 8px;
    min-height: 20px;
    opacity: 0;
    transition: opacity 0.25s;
}
.pw-error.show { opacity: 1; }

.pw-hint {
    font-size: 12px;
    color: rgba(255,255,255,0.2);
    text-align: center;
    margin-top: 24px;
    line-height: 1.6;
    max-width: 240px;
}

/* ========================================================
   QUEST SCREEN
   ======================================================== */
#questScreen {
    display: none;
    flex-direction: column;
    height: 100%;
}
#questScreen.active { display: flex; }

/* ── ВЕРХНЯЯ ПАНЕЛЬ: загадка ── */
.riddle-panel {
    flex: 1;
    position: relative;
    background: var(--surface);
    overflow: hidden;
    border-bottom: 1px solid var(--border);
    min-height: 0;
}

.riddle-waiting {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}
.riddle-waiting.hidden { display: none; }

.waiting-icon {
    font-size: 36px;
    animation: waitBounce 2s ease-in-out infinite;
}
@keyframes waitBounce {
    0%,100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}
.waiting-text {
    font-size: 15px;
    color: var(--muted);
    letter-spacing: 0.02em;
}
.waiting-dots {
    display: flex; gap: 6px;
}
.waiting-dots span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--gold-dim);
    animation: dotPulse 1.4s ease-in-out infinite;
}
.waiting-dots span:nth-child(2) { animation-delay: 0.2s; }
.waiting-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse {
    0%,100% { opacity: 0.3; transform: scale(0.8); }
    50%      { opacity: 1;   transform: scale(1); }
}

.riddle-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 12px;
    animation: fadeIn 0.35s ease;
}

.riddle-number {
    position: absolute;
    top: 12px;
    left: 14px;
    font-family: 'Unbounded', sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    color: var(--gold);
    background: rgba(8,11,17,0.7);
    backdrop-filter: blur(8px);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

/* ── СРЕДНЯЯ ПОЛОСА: ответ ── */
.answer-bar {
    flex-shrink: 0;
    background: var(--surface2);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 0 14px;
}
.answer-bar-inner {
    height: var(--answer-h);
    display: flex;
    align-items: center;
    gap: 10px;
}
.answer-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-family: 'Mulish', sans-serif;
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    caret-color: var(--gold);
    padding: 0;
    letter-spacing: 0.02em;
}
.answer-input::placeholder { color: var(--muted); font-weight: 400; }
.answer-btn {
    width: 44px; height: 44px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, var(--gold) 0%, #B8932A 100%);
    color: #080B11;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.1s;
    box-shadow: 0 4px 14px rgba(232,201,122,0.2);
}
.answer-btn:active { transform: scale(0.94); }

.answer-feedback {
    height: 20px;
    font-size: 13px;
    padding-bottom: 8px;
    transition: all 0.25s;
}
.answer-feedback.wrong { color: var(--red); }
.answer-feedback.right { color: var(--green); }

/* ── НИЖНЯЯ ПАНЕЛЬ: дешифровщики ── */
.cipher-panel {
    flex-shrink: 0;
    height: calc(100% - 50% - var(--answer-h) - 2px);
    /* высота = всё что осталось под загадкой и инпутом */
    /* пересчитывается в JS под реальный экран */
    background: var(--bg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 12px 14px 14px;
    gap: 10px;
}

.cipher-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: rgba(255,255,255,0.18);
    text-align: center;
    line-height: 1.6;
}
.cipher-empty.hidden { display: none; }

.cipher-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
}
.cipher-buttons::-webkit-scrollbar { display: none; }

.cipher-btn {
    height: 38px;
    padding: 0 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: 'Mulish', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    letter-spacing: 0.02em;
}
.cipher-btn:active, .cipher-btn.active {
    background: var(--gold-glow);
    border-color: var(--gold-dim);
    color: var(--gold);
}

.cipher-preview {
    flex: 1;
    min-height: 0;
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border2);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.cipher-preview.empty { background: transparent; border-color: transparent; }

.cipher-preview-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    animation: fadeIn 0.2s ease;
    cursor: zoom-in;
}

.cipher-preview-placeholder {
    font-size: 13px;
    color: rgba(255,255,255,0.18);
}

/* ========================================================
   MAP SCREEN
   ======================================================== */
#mapScreen { display: none; }
#mapScreen.active { display: flex; position: fixed; inset: 0; }

#map {
    width: 100%; height: 100%;
    position: absolute; inset: 0;
}

.map-back-btn {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 1000;
    height: 42px;
    padding: 0 16px;
    border-radius: 12px;
    border: none;
    background: rgba(8,11,17,0.85);
    backdrop-filter: blur(10px);
    color: var(--text);
    font-family: 'Mulish', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    border: 1px solid var(--border2);
    transition: background 0.15s;
}
.map-back-btn:active { background: rgba(14,19,32,0.95); }

.map-hint {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(8,11,17,0.9);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 20px;
    font-size: 15px;
    color: var(--text);
    text-align: center;
    max-width: calc(100% - 40px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    white-space: pre-line;
    line-height: 1.55;
}
.map-hint:empty { display: none; }

.map-progress {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 1000;
    background: rgba(8,11,17,0.85);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 14px;
    font-family: 'Unbounded', sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: var(--gold);
    letter-spacing: 0.06em;
}

/* ── Навигационная стрелка (DOM-элемент) ── */
#navArrow {
    position: absolute;
    pointer-events: none;
    z-index: 9999;
    transform-origin: center center;
    color: #00ff88;
}

/* ========================================================
   SUCCESS OVERLAY
   ======================================================== */
.success-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(8,11,17,0.92);
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}
.success-overlay.hidden { display: none; }

.success-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px;
    text-align: center;
}
.success-icon {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--green), #00A83A);
    font-size: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 40px rgba(48,209,88,0.35);
    animation: successPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes successPop {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}
.success-title {
    font-family: 'Unbounded', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.05em;
}
.success-text {
    font-size: 15px;
    color: var(--muted);
    line-height: 1.55;
}

/* ========================================================
   CIPHER OVERLAY (fullscreen картинка дешифровщика)
   ======================================================== */
.cipher-overlay {
    position: fixed;
    inset: 0;
    z-index: 500000;
    background: rgba(0,0,0,0.92);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}
.cipher-overlay.hidden { display: none; }

.cipher-overlay-inner {
    position: relative;
    max-width: 95vw;
    max-height: 90vh;
}
.cipher-overlay-inner img {
    max-width: 95vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 12px;
    display: block;
}
.cipher-overlay-close {
    position: absolute;
    top: -14px; right: -14px;
    width: 32px; height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.12);
    color: var(--text);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================================
   УТИЛИТЫ
   ======================================================== */
.hidden { display: none !important; }

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes shake {
    0%,100% { transform: translateX(0); }
    20%     { transform: translateX(-8px); }
    40%     { transform: translateX(8px); }
    60%     { transform: translateX(-5px); }
    80%     { transform: translateX(5px); }
}
.shake { animation: shake 0.35s ease; }

/* MapLibre — убираем логотип если хочется */
.maplibregl-ctrl-logo { opacity: 0.3 !important; }
