/* =========================================================
   RusGuessr — main.css
   Премиальный интерфейс, тёмная тема, все страницы
   ========================================================= */

/* ---------------------------------------------------------
   1. ПЕРЕМЕННЫЕ ТЕМ
   --------------------------------------------------------- */
:root {
    /* Фоны */
    --bg:             #f4f6f8;
    --bg-elevated:    #ffffff;
    --bg-soft:        #eef2f7;
    --bg-hover:       #f9fafc;

    /* Границы */
    --border:         #eef1f5;
    --border-strong:  #d8dee6;

    /* Текст */
    --text:           #1f2d3d;
    --text-soft:      #556070;
    --text-muted:     #8a94a3;

    /* Акценты */
    --primary:        #1f2d3d;
    --primary-hover:  #2c3e50;
    --accent:         #4CAF50;
    --accent-hover:   #43A047;

    /* Цвета состояний */
    --success:        #4CAF50;
    --success-dark:   #388E3C;
    --warning:        #FF9800;
    --danger:         #F44336;
    --danger-dark:    #C62828;
    --info:           #2196F3;
    --purple:         #9C27B0;

    /* Карта */
    --map-fill:        #dfe5ec;
    --map-fill-hover:  #cfd8e3;
    --map-fill-press:  #c2cddb;
    --map-stroke:      #ffffff;

    /* Тени */
    --shadow-sm: 0 1px 0 rgba(0,0,0,0.03), 0 2px 10px rgba(31,45,61,0.04);
    --shadow-md: 0 1px 0 rgba(0,0,0,0.04), 0 6px 20px rgba(31,45,61,0.06);
    --shadow-lg: 0 8px 28px rgba(31,45,61,0.10);
    --shadow-xl: 0 20px 50px rgba(31,45,61,0.15);

    /* Радиусы */
    --radius-sm: 8px;
    --radius:    14px;
    --radius-lg: 20px;
    --radius-xl: 24px;
}

[data-theme="dark"] {
    --bg:             #0f1419;
    --bg-elevated:    #1a2029;
    --bg-soft:        #141a22;
    --bg-hover:       #232b36;

    --border:         #232b36;
    --border-strong:  #2f3a48;

    --text:           #e8ecf1;
    --text-soft:      #a5b0bf;
    --text-muted:     #7a8698;

    --primary:        #4CAF50;
    --primary-hover:  #5CBF60;
    --accent:         #4CAF50;
    --accent-hover:   #5CBF60;

    --map-fill:        #2a3340;
    --map-fill-hover:  #37424f;
    --map-fill-press:  #435061;
    --map-stroke:      #1a2029;

    --shadow-sm: 0 1px 0 rgba(0,0,0,0.3), 0 2px 10px rgba(0,0,0,0.3);
    --shadow-md: 0 1px 0 rgba(0,0,0,0.4), 0 6px 20px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 28px rgba(0,0,0,0.5);
    --shadow-xl: 0 20px 50px rgba(0,0,0,0.6);
}

/* ---------------------------------------------------------
   2. БАЗОВЫЕ СТИЛИ
   --------------------------------------------------------- */
* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color .25s ease, color .25s ease;
}

a { color: inherit; }

/* Кастомный скроллбар */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-soft); }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 10px;
    border: 2px solid var(--bg-soft);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---------------------------------------------------------
   3. ШАПКА ПРИЛОЖЕНИЯ
   --------------------------------------------------------- */
.app-header {
    height: 64px;
    padding: 0 28px;
    background: var(--bg-elevated);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
    z-index: 10;
    position: relative;
    border-bottom: 1px solid var(--border);
    transition: background-color .25s ease, border-color .25s ease;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 19px;
    letter-spacing: .2px;
    transition: transform .2s ease;
}
.logo:hover { transform: scale(1.02); }
.logo-icon { font-size: 22px; }
.logo-text { font-weight: 800; }

.header-nav {
    display: flex;
    gap: 18px;
    align-items: center;
}
.nav-link {
    color: var(--text-soft);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: color .2s;
}
.nav-link:hover { color: var(--text); }

.header-btn {
    background: transparent;
    color: var(--text-soft);
    border: 1px solid var(--border-strong);
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    transition: all .2s ease;
}
.header-btn:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
    color: var(--text);
}

/* ---------------------------------------------------------
   4. ОСНОВНОЙ КОНТЕЙНЕР
   --------------------------------------------------------- */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 22px;
    gap: 16px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* ---------------------------------------------------------
   5. ГЛАВНАЯ СТРАНИЦА
   --------------------------------------------------------- */
.page-home {
    max-width: 1240px;
    margin: 0 auto;
    width: 100%;
}

.hero {
    text-align: center;
    margin: 24px 0 44px;
    position: relative;
}
.hero::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 200px;
    background: radial-gradient(ellipse,
        rgba(76, 175, 80, 0.08) 0%,
        transparent 70%);
    pointer-events: none;
    z-index: 0;
}
.hero h1 {
    font-size: 40px;
    color: var(--text);
    margin: 0 0 14px;
    font-weight: 800;
    letter-spacing: -0.5px;
    position: relative;
    z-index: 1;
    background: linear-gradient(135deg, var(--text) 0%, var(--text-soft) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero-sub {
    font-size: 16px;
    color: var(--text-muted);
    margin: 0 auto;
    max-width: 620px;
    line-height: 1.6;
    position: relative;
    z-index: 1;
}

/* Блок категории */
.cat-block { margin-bottom: 46px; }
.cat-head { margin-bottom: 20px; }
.cat-head h2 {
    font-size: 24px;
    color: var(--text);
    margin: 0 0 6px;
    font-weight: 800;
    letter-spacing: -0.2px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.cat-head h2::before {
    content: '';
    width: 4px;
    height: 22px;
    border-radius: 2px;
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-hover) 100%);
}
.cat-desc {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.5;
}

/* Сетка карточек */
.maps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.map-card {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
    border: 1px solid var(--border);
    position: relative;
}
.map-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg,
        rgba(76, 175, 80, 0.06) 0%,
        transparent 60%);
    opacity: 0;
    transition: opacity .3s ease;
    pointer-events: none;
}
.map-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-strong);
}
.map-card:hover::before { opacity: 1; }

.map-card-thumb {
    height: 130px;
    background:
        radial-gradient(circle at 30% 30%, rgba(76, 175, 80, 0.08) 0%, transparent 60%),
        linear-gradient(135deg, var(--bg-soft) 0%, var(--bg-hover) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.map-card-thumb::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(140, 160, 190, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(140, 160, 190, 0.08) 1px, transparent 1px);
    background-size: 22px 22px;
    mask-image: radial-gradient(ellipse at center, black 30%, transparent 85%);
    -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 85%);
}
.thumb-icon {
    font-size: 44px;
    opacity: 0.85;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.12));
    transition: transform .3s ease;
}
.map-card:hover .thumb-icon { transform: scale(1.1) rotate(-4deg); }

.map-card-body {
    padding: 18px 20px 8px;
    flex: 1;
}
.map-title {
    margin: 0 0 4px;
    font-size: 17px;
    color: var(--text);
    font-weight: 700;
    letter-spacing: -0.1px;
}
.map-sub {
    margin: 0 0 10px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}
.map-meta { margin: 0; }
.meta-badge {
    display: inline-block;
    background: var(--bg-soft);
    color: var(--text-soft);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border);
}

.map-actions {
    padding: 14px 20px 20px;
    display: flex;
    gap: 10px;
}

/* ---------------------------------------------------------
   6. УНИВЕРСАЛЬНЫЕ КНОПКИ
   --------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    padding: 11px 22px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .2px;
    cursor: pointer;
    text-decoration: none;
    transition: all .18s ease;
    font-family: inherit;
    white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(31, 45, 61, 0.18);
    flex: 1;
}
[data-theme="dark"] .btn-primary { color: #0f1419; }
.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(31, 45, 61, 0.24);
}

.btn-ghost {
    background: transparent;
    color: var(--text-soft);
    border: 1px solid var(--border-strong);
}
.btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--text-muted);
    color: var(--text);
}

/* ---------------------------------------------------------
   7. СТРАНИЦА ИГРЫ — КОНТЕЙНЕР
   --------------------------------------------------------- */
.page-game {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px 22px 22px;
    min-height: 0;
}

/* ---------------------------------------------------------
   8. ВЕРХНЯЯ ПАНЕЛЬ ИГРЫ
   --------------------------------------------------------- */
.game-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: var(--bg-elevated);
    padding: 10px 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    flex-shrink: 0;
    transition: background-color .25s ease, border-color .25s ease;
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 200px;
}
.topbar-right { justify-content: flex-end; }
.topbar-center { flex: 1; display: flex; justify-content: center; }

.back-link,
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-soft);
    cursor: pointer;
    text-decoration: none;
    transition: all .18s ease;
    padding: 0;
    font-family: inherit;
    flex-shrink: 0;
}
.back-link:hover,
.icon-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    color: var(--text);
    transform: translateY(-1px);
}
.back-link:active,
.icon-btn:active { transform: scale(.94); }

.game-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}
.game-progress {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .6px;
    font-weight: 700;
}
.game-map-name {
    font-size: 14px;
    color: var(--text);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------------------------------------------------------
   9. ТАЙМЕР
   --------------------------------------------------------- */
.timer {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 24px;
    background: var(--bg-soft);
    border-radius: 12px;
    border: 1px solid var(--border);
    min-width: 150px;
    transition: all .3s ease;
    position: relative;
    overflow: hidden;
}
.timer::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(76, 175, 80, 0.10) 50%,
        transparent 100%);
    transform: translateX(-100%);
    animation: timer-shine 3.5s infinite;
}
@keyframes timer-shine {
    0%   { transform: translateX(-100%); }
    60%  { transform: translateX(100%); }
    100% { transform: translateX(100%); }
}
.timer-value {
    font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 1px;
    font-variant-numeric: tabular-nums;
    transition: color .3s ease;
    position: relative;
    z-index: 1;
    line-height: 1.15;
}
.timer-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 700;
    position: relative;
    z-index: 1;
}

.timer.timer-danger .timer-value { color: var(--danger); }
.timer.timer-danger {
    border-color: var(--danger);
    animation: timer-pulse 1s infinite;
}
@keyframes timer-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.4); }
    50%      { box-shadow: 0 0 0 8px rgba(244, 67, 54, 0); }
}

/* ---------------------------------------------------------
   10. ЧИП МОНЕТ
   --------------------------------------------------------- */
.coins-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #FFF8E1 0%, #FFECB3 100%);
    color: #8B6F00;
    border-radius: 10px;
    font-weight: 800;
    font-size: 14px;
    border: 1px solid #FFE082;
    transition: transform .3s ease;
    font-variant-numeric: tabular-nums;
    cursor: default;
    user-select: none;
}
[data-theme="dark"] .coins-chip {
    background: linear-gradient(135deg, #3d3218 0%, #4a3f1e 100%);
    color: #FFD54F;
    border-color: #5a4d28;
}
.coins-chip.coins-pulse { animation: coins-pulse .6s ease; }
@keyframes coins-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.14); box-shadow: 0 0 20px rgba(255, 193, 7, 0.5); }
}
.coin-icon { font-size: 15px; }

/* ---------------------------------------------------------
   11. ПЕРЕКЛЮЧАТЕЛЬ ТЕМЫ
   --------------------------------------------------------- */
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------------------------------------------------------
   12. ПОЛОСА ЗАДАНИЯ
   --------------------------------------------------------- */
.task-bar {
    background: var(--bg-elevated);
    padding: 16px 26px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
    flex-wrap: wrap;
    transition: background-color .25s ease, border-color .25s ease;
}
.task-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    flex-shrink: 0;
}
.task-name {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    flex: 1;
    letter-spacing: -0.2px;
    min-width: 0;
}
.task-hint-zone {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}
#letter-hint {
    font-size: 14px;
    color: var(--warning);
    font-weight: 800;
    padding: 5px 14px;
    background: rgba(255, 152, 0, .12);
    border: 1px dashed rgba(255, 152, 0, .35);
    border-radius: var(--radius-sm);
    animation: hint-appear .4s ease;
}
@keyframes hint-appear {
    from { opacity: 0; transform: translateY(-4px) scale(.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.task-status {
    font-size: 13px;
    color: var(--danger);
    font-weight: 700;
    min-height: 20px;
    transition: opacity .25s ease;
}

/* ---------------------------------------------------------
   13. КАРТА
   --------------------------------------------------------- */
.map-container {
    flex: 1;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background:
        radial-gradient(ellipse at 50% 40%, rgba(255,255,255,0.85) 0%, rgba(255,255,255,0) 65%),
        radial-gradient(circle at 15% 85%, rgba(180, 195, 215, 0.18) 0%, transparent 55%),
        radial-gradient(circle at 85% 15%, rgba(180, 195, 215, 0.15) 0%, transparent 55%),
        linear-gradient(180deg, #fbfcfd 0%, #eef2f7 100%);
    min-height: 420px;
    transition: background .3s ease;
}
[data-theme="dark"] .map-container {
    background:
        radial-gradient(ellipse at 50% 40%, rgba(40, 55, 75, 0.5) 0%, rgba(0,0,0,0) 65%),
        radial-gradient(circle at 15% 85%, rgba(60, 100, 160, 0.15) 0%, transparent 55%),
        radial-gradient(circle at 85% 15%, rgba(60, 100, 160, 0.12) 0%, transparent 55%),
        linear-gradient(180deg, #131a22 0%, #0d1218 100%);
}

.map-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(140, 160, 190, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(140, 160, 190, 0.06) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    mask-image: radial-gradient(ellipse at center, black 40%, transparent 95%);
    -webkit-mask-image: radial-gradient(ellipse at center, black 40%, transparent 95%);
}
[data-theme="dark"] .map-container::before {
    background-image:
        linear-gradient(rgba(90, 120, 160, 0.10) 1px, transparent 1px),
        linear-gradient(90deg, rgba(90, 120, 160, 0.10) 1px, transparent 1px);
}

/* Тряска при ошибке */
.map-container.shake { animation: shake .4s ease; }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-6px); }
    40%      { transform: translateX(6px); }
    60%      { transform: translateX(-4px); }
    80%      { transform: translateX(4px); }
}

#map-svg {
    width: 100%;
    height: 100%;
    display: block;
    max-width: 100%;
    max-height: 100%;
    position: relative;
    z-index: 1;
    filter:
        drop-shadow(0 10px 24px rgba(31, 45, 61, 0.16))
        drop-shadow(0 2px 4px rgba(31, 45, 61, 0.08));
}
[data-theme="dark"] #map-svg {
    filter:
        drop-shadow(0 10px 24px rgba(0, 0, 0, 0.6))
        drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

/* ---------------------------------------------------------
   14. ПУТИ КАРТЫ
   --------------------------------------------------------- */
#map-svg path {
    fill: var(--map-fill);
    stroke: var(--map-stroke);
    stroke-width: 2.5;
    stroke-linejoin: round;
    stroke-linecap: round;
    cursor: pointer;
    paint-order: stroke fill;
    transition: fill .25s ease, stroke-width .2s ease, opacity .3s ease;
}

#map-svg path:hover:not(.answered):not(.dimmed) {
    fill: var(--map-fill-hover);
    stroke-width: 3;
}
#map-svg path:active:not(.answered):not(.dimmed) {
    fill: var(--map-fill-press);
}
#map-svg path.dimmed {
    opacity: 0.15;
    pointer-events: none;
}

/* Правильные ответы */
#map-svg path.correct-1 {
    fill: #4CAF50 !important;
    stroke: var(--map-stroke);
    stroke-width: 3;
    animation: correct-pop .5s ease;
}
#map-svg path.correct-2 {
    fill: #FFEB3B !important;
    stroke: #FBC02D;
    stroke-width: 3;
    animation: correct-pop .5s ease;
}
#map-svg path.correct-3 {
    fill: #FF9800 !important;
    stroke: var(--map-stroke);
    stroke-width: 3;
    animation: correct-pop .5s ease;
}
@keyframes correct-pop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.015); }
    100% { transform: scale(1); }
}

/* Раскрытый ответ */
#map-svg path.revealed {
    fill: #9C27B0 !important;
    stroke: var(--map-stroke);
    stroke-width: 3;
    animation: revealed-pulse 1.4s ease;
}
@keyframes revealed-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.65; }
}

/* Подсветка от подсказки */
#map-svg path.highlighted {
    fill: #FFC107 !important;
    stroke: #FF6F00;
    stroke-width: 4;
    animation: highlight-flash .5s ease infinite;
}
@keyframes highlight-flash {
    0%, 100% { filter: brightness(1); }
    50%      { filter: brightness(1.5); }
}

#map-svg path.answered { pointer-events: none; }

/* Красная вспышка при ошибке */
@keyframes flashRed {
    0%, 100% { fill: var(--map-fill); }
    50%      { fill: #F44336; }
}
#map-svg path.wrong-flash {
    animation: flashRed .42s ease;
    stroke: #E53935;
    stroke-width: 3;
}

/* Плавающие очки */
.floating-score text {
    font-family: 'Inter', sans-serif;
    pointer-events: none;
    paint-order: stroke;
    stroke: rgba(255,255,255,0.9);
    stroke-width: 3;
    stroke-linejoin: round;
}
[data-theme="dark"] .floating-score text {
    stroke: rgba(0,0,0,0.7);
}

/* ---------------------------------------------------------
   15. ИНДИКАТОР ПОПЫТОК
   --------------------------------------------------------- */
.attempts-indicator {
    position: absolute;
    top: 18px;
    left: 18px;
    display: flex;
    gap: 8px;
    z-index: 3;
    padding: 8px 12px;
    background: rgba(255,255,255,0.75);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    border: 1px solid var(--border);
}
[data-theme="dark"] .attempts-indicator {
    background: rgba(26, 32, 41, 0.75);
}
.attempt-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border-strong);
    transition: all .3s ease;
}
.attempt-dot.active {
    background: var(--danger);
    box-shadow: 0 0 8px rgba(244, 67, 54, 0.6);
    transform: scale(1.15);
}

/* ---------------------------------------------------------
   16. ПАНЕЛЬ ПОДСКАЗОК
   --------------------------------------------------------- */
.hints-panel {
    position: absolute;
    right: 18px;
    bottom: 18px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.hints-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #FFC107 0%, #FF9800 100%);
    color: #fff;
    border: none;
    border-radius: 24px;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.35);
    transition: all .2s ease;
    font-family: inherit;
}
.hints-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(255, 152, 0, 0.5);
}
.hints-toggle:active { transform: scale(.96); }
.hints-toggle-icon { font-size: 17px; }

.hints-list {
    display: none;
    flex-direction: column;
    gap: 8px;
    width: 340px;
    padding: 12px;
    background: var(--bg-elevated);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
}
.hints-panel.open .hints-list {
    display: flex;
    animation: hints-open .28s cubic-bezier(.34,1.56,.64,1);
}
@keyframes hints-open {
    from { opacity: 0; transform: translateY(12px) scale(.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.hint-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: all .18s ease;
    position: relative;
    width: 100%;
    color: var(--text);
}
.hint-item:hover:not(.hint-disabled) {
    background: var(--bg-hover);
    border-color: var(--warning);
    transform: translateX(3px);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.15);
}
.hint-item.hint-disabled {
    opacity: 0.42;
    cursor: not-allowed;
    filter: grayscale(0.4);
}
.hint-icon {
    font-size: 22px;
    flex-shrink: 0;
    width: 32px;
    text-align: center;
    line-height: 1;
}
.hint-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.hint-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}
.hint-desc {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.35;
}
.hint-price {
    font-size: 12px;
    font-weight: 800;
    color: var(--warning);
    background: rgba(255, 152, 0, .12);
    padding: 4px 10px;
    border-radius: 8px;
    flex-shrink: 0;
    white-space: nowrap;
}
.hint-used {
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 12px;
    color: var(--success);
    font-weight: 900;
}

/* ---------------------------------------------------------
   17. ТОСТЫ
   --------------------------------------------------------- */
.toast {
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translate(-50%, -20px);
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    background: var(--primary);
    opacity: 0;
    pointer-events: none;
    transition: all .3s ease;
    z-index: 30;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    white-space: nowrap;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
}
.toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}
.toast-success {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-dark) 100%);
}
.toast-error {
    background: linear-gradient(135deg, var(--danger) 0%, var(--danger-dark) 100%);
}
.toast-info {
    background: linear-gradient(135deg, var(--info) 0%, #1565C0 100%);
}

/* ---------------------------------------------------------
   18. ЛОАДЕР
   --------------------------------------------------------- */
.loader {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(3px);
    z-index: 8;
    gap: 16px;
}
[data-theme="dark"] .loader { background: rgba(15, 20, 25, 0.7); }
.loader p {
    margin: 0;
    color: var(--text-soft);
    font-size: 14px;
    font-weight: 600;
}
.spinner {
    width: 42px;
    height: 42px;
    border: 3px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------
   19. ЭКРАН ПОБЕДЫ
   --------------------------------------------------------- */
.win-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 20;
    padding: 20px;
}
[data-theme="dark"] .win-overlay { background: rgba(10, 15, 20, 0.94); }
.win-overlay.active {
    display: flex;
    animation: win-in .4s ease;
}
@keyframes win-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.win-inner {
    background: var(--bg-elevated);
    padding: 40px 50px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    text-align: center;
    max-width: 480px;
    width: 100%;
    animation: win-pop .5s cubic-bezier(.34,1.56,.64,1);
}
@keyframes win-pop {
    from { transform: scale(.85); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

.win-emoji {
    font-size: 64px;
    margin-bottom: 8px;
    display: inline-block;
    animation: win-emoji .8s ease infinite alternate;
}
@keyframes win-emoji {
    from { transform: rotate(-5deg) scale(1); }
    to   { transform: rotate(5deg) scale(1.1); }
}

.win-title {
    font-size: 26px;
    margin: 0 0 24px;
    color: var(--text);
    font-weight: 800;
    letter-spacing: -0.3px;
}

.win-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 28px;
}
.stat {
    padding: 16px 10px;
    background: var(--bg-soft);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: transform .2s ease;
}
.stat:hover { transform: translateY(-2px); }
.stat-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .8px;
    font-weight: 700;
    margin-bottom: 6px;
}
.stat-value {
    display: block;
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}
#win-coins { color: var(--warning); }

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

/* Старое сообщение для совместимости */
.win-message {
    font-size: 28px;
    color: var(--text);
    font-weight: 700;
    text-align: center;
    line-height: 1.4;
    margin-bottom: 20px;
}

/* ---------------------------------------------------------
   20. СТРАНИЦА РЕЗУЛЬТАТОВ
   --------------------------------------------------------- */
.page-result {
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    background: var(--bg-elevated);
    padding: 34px 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}
.page-result h1 {
    margin: 0 0 8px;
    font-size: 26px;
    color: var(--text);
    font-weight: 800;
    letter-spacing: -0.3px;
}
.result-meta {
    margin: 0 0 26px;
    color: var(--text-muted);
    font-size: 14px;
}
.result-meta b { color: var(--text-soft); font-weight: 700; }

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.results-table th,
.results-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.results-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--text-muted);
    font-weight: 800;
    background: var(--bg-soft);
}
.results-table th:first-child { border-top-left-radius: var(--radius-sm); }
.results-table th:last-child  { border-top-right-radius: var(--radius-sm); }

.results-table td { color: var(--text-soft); font-weight: 500; }
.results-table td b { color: var(--text); font-weight: 800; }
.results-table tr:hover td { background: var(--bg-hover); }
.results-table tr:last-child td { border-bottom: none; }

.result-actions {
    display: flex;
    gap: 12px;
    margin-top: 30px;
    flex-wrap: wrap;
}

/* ---------------------------------------------------------
   21. СТРАНИЦА 404
   --------------------------------------------------------- */
.page-404 {
    text-align: center;
    padding: 80px 20px;
    max-width: 480px;
    margin: 0 auto;
}
.page-404 h1 {
    font-size: 96px;
    color: var(--text);
    margin: 0 0 8px;
    font-weight: 800;
    letter-spacing: -2px;
    background: linear-gradient(135deg, var(--text) 0%, var(--text-muted) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}
.page-404 p {
    color: var(--text-muted);
    margin: 0 0 28px;
    font-size: 15px;
}

/* ---------------------------------------------------------
   22. АДАПТИВ
   --------------------------------------------------------- */
@media (max-width: 900px) {
    .topbar-left,
    .topbar-right { min-width: auto; }
    .game-map-name { display: none; }
}

@media (max-width: 768px) {
    .app-header { padding: 0 16px; height: 58px; }
    .logo { font-size: 17px; }
    .logo-icon { font-size: 20px; }

    .app-main { padding: 12px; gap: 12px; }

    .hero { margin: 12px 0 28px; }
    .hero h1 { font-size: 28px; }
    .hero-sub { font-size: 14px; }
    .hero::before { width: 100%; }

    .cat-head h2 { font-size: 20px; }
    .maps-grid { gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
    .map-card-thumb { height: 110px; }
    .thumb-icon { font-size: 36px; }

    .page-game { padding: 10px; gap: 10px; }

    .game-topbar { padding: 8px 12px; gap: 8px; }
    .topbar-left, .topbar-right { gap: 8px; }
    .topbar-center { padding: 0 4px; }
    .timer { padding: 5px 16px; min-width: 120px; }
    .timer-value { font-size: 18px; }
    .coins-chip { padding: 7px 10px; font-size: 13px; }
    .back-link, .icon-btn { width: 34px; height: 34px; }

    .task-bar { padding: 12px 16px; gap: 8px; }
    .task-label { font-size: 10px; }
    .task-name { font-size: 18px; }
    .task-hint-zone { gap: 8px; }

    .map-container { min-height: 340px; }

    .attempts-indicator { top: 10px; left: 10px; padding: 6px 10px; gap: 6px; }
    .attempt-dot { width: 8px; height: 8px; }

    .hints-panel { right: 10px; bottom: 10px; }
    .hints-toggle { padding: 10px 14px; }
    .hints-toggle-label { display: none; }
    .hints-list { width: min(300px, calc(100vw - 24px)); padding: 10px; }
    .hint-item { padding: 10px; gap: 10px; }
    .hint-icon { font-size: 18px; width: 26px; }
    .hint-title { font-size: 13px; }
    .hint-desc { font-size: 10px; }
    .hint-price { font-size: 11px; padding: 3px 8px; }

    .toast { font-size: 13px; padding: 10px 18px; }

    .win-inner { padding: 28px 22px; border-radius: var(--radius-lg); }
    .win-emoji { font-size: 52px; }
    .win-title { font-size: 20px; margin-bottom: 18px; }
    .win-stats { grid-template-columns: 1fr; gap: 8px; margin-bottom: 20px; }
    .stat { padding: 12px 10px; display: flex; align-items: center; justify-content: space-between; }
    .stat-label { margin-bottom: 0; font-size: 12px; }
    .stat-value { font-size: 20px; }

    .page-result { padding: 22px 18px; border-radius: var(--radius); }
    .page-result h1 { font-size: 20px; }
    .results-table th, .results-table td { padding: 8px 8px; font-size: 12px; }
    .result-actions { flex-direction: column; }
    .result-actions .btn { width: 100%; }

    .page-404 h1 { font-size: 72px; }
}

@media (max-width: 420px) {
    .maps-grid { grid-template-columns: 1fr; }
    .map-actions { flex-direction: column; }
    .map-actions .btn { width: 100%; }

    .task-bar { flex-direction: column; align-items: flex-start; }
    .task-name { font-size: 17px; }
    .task-hint-zone { width: 100%; justify-content: space-between; }
}

/* ---------------------------------------------------------
   23. АНИМАЦИИ ПРЕДПОЧТЕНИЙ
   --------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------------------------------------------------------
   24. PRINT (на всякий случай)
   --------------------------------------------------------- */
@media print {
    .app-header,
    .hints-panel,
    .attempts-indicator,
    .theme-toggle,
    .back-link,
    .icon-btn { display: none !important; }
    .map-container { box-shadow: none; }
    body { background: #fff; color: #000; }
}
/* ---------- Зум карты ---------- */

.map-container {
    position: relative; /* уже есть, но на всякий */
    overflow: hidden;
    cursor: pointer;
}

#map-svg {
    transform-origin: center center;
    will-change: transform;
    transition: transform 0.08s ease-out;
}

.zoom-controls {
    position: absolute;
    right: 14px;
    bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 6;
}

.zoom-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid #d8dee6;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(6px);
    color: #1f2d3d;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(31, 45, 61, 0.08);
    transition: background 0.15s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}

.zoom-btn:hover {
    background: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(31, 45, 61, 0.12);
}

.zoom-btn:active {
    transform: scale(0.95);
}

/* Плавное появление лоадера/оверлея над зумом */
.loader,
.win-overlay {
    z-index: 10;
}