/* GeoGuess — общие стили. Темы задаются переменными на html[data-theme]. */
* { box-sizing: border-box; }
/* Атрибут hidden должен побеждать любые display-правила (например, у .lightbox). */
[hidden] { display: none !important; }

:root,
html[data-theme="light"] {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --success-dark: #15803d;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --bg: #f9fafb;
    --bg-card: #ffffff;
    --bg-soft: #f3f4f6;
    --row-me: #eff6ff;
    --hint-bg: #fffbeb;
    --hint-border: #fcd34d;
    --flash-ok-bg: #f0fdf4;
    --flash-ok-border: #86efac;
    --flash-ok-text: #166534;
    --flash-err-bg: #fef2f2;
    --flash-err-border: #fca5a5;
    --flash-err-text: #b91c1c;
    --topbar-h: 56px;
}
html[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --success: #22c55e;
    --success-dark: #16a34a;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --border: #374151;
    --bg: #111827;
    --bg-card: #1f2937;
    --bg-soft: #273244;
    --row-me: #1e3a5f;
    --hint-bg: #3a3320;
    --hint-border: #a16207;
    --flash-ok-bg: #14351f;
    --flash-ok-border: #166534;
    --flash-ok-text: #86efac;
    --flash-err-bg: #3a1a1a;
    --flash-err-border: #b91c1c;
    --flash-err-text: #fca5a5;
}

html, body { margin: 0; padding: 0; }
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
    font-size: 15px;
    line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; margin: 18px 0 10px; }
h2 { font-size: 20px; margin: 22px 0 10px; }
h3 { font-size: 16px; margin: 0 0 8px; }

/* Шапка (тёмная в обеих темах) */
.topbar {
    background: #111827;
    color: #fff;
    min-height: var(--topbar-h);
    position: sticky;
    top: 0;
    z-index: 1100;
    border-bottom: 1px solid #1f2937;
}
.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    min-height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}
.brand { font-size: 19px; font-weight: 700; color: #fff; }
.brand span { color: #60a5fa; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 14px; flex-wrap: wrap; }
.nav a, .nav-user a { color: #d1d5db; }
.nav a:hover, .nav-user a:hover { color: #fff; text-decoration: none; }
.nav-user { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.nav-username { font-weight: 600; }
.inline-form { display: inline; }
.link-btn {
    background: none; border: 0; padding: 0; cursor: pointer;
    color: #d1d5db; font-size: 15px; font-family: inherit;
}
.link-btn:hover { color: #fff; }
.icon-btn {
    background: none; border: 0; padding: 0; cursor: pointer;
    font-size: 17px; line-height: 1;
}
.lang-btn {
    font-size: 12px; font-weight: 700; letter-spacing: 0.05em;
    border: 1px solid #4b5563; border-radius: 6px; padding: 2px 7px;
}
.lang-btn:hover { border-color: #9ca3af; }
.nav-score {
    font-size: 13px; font-weight: 700;
    background: #1f2937; border: 1px solid #4b5563;
    border-radius: 999px; padding: 2px 10px;
    color: #93c5fd !important;
}
.nav-score:hover { border-color: #9ca3af; text-decoration: none; }

/* Контейнеры */
.container { max-width: 1200px; margin: 0 auto; padding: 8px 16px 40px; }
.main-full { padding: 0; }
.footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; padding: 14px 0; background: var(--bg-card); }

/* Flash-сообщения */
.flash { padding: 10px 14px; border-radius: 8px; margin: 10px 0; }
.flash-ok { background: var(--flash-ok-bg); border: 1px solid var(--flash-ok-border); color: var(--flash-ok-text); }
.flash-error { background: var(--flash-err-bg); border: 1px solid var(--flash-err-border); color: var(--flash-err-text); }
.main-full .flash { margin: 10px 16px; }

/* Кнопки и формы */
.btn {
    display: inline-block;
    padding: 9px 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--bg-soft); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dark); }
.btn-danger.btn-outline { background: var(--bg-card); color: var(--danger); }
.btn-danger.btn-outline:hover { background: var(--flash-err-bg); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-lg { padding: 12px 26px; font-size: 17px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.form { max-width: 420px; }
.form-wide { max-width: 720px; }
.form label, .form-wide label { display: block; margin: 14px 0 4px; font-weight: 600; }
.form input, .form-wide input[type="text"], .form-wide input[type="file"], .form-wide textarea, select {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 15px;
    font-family: inherit;
    background: var(--bg-card);
    color: var(--text);
}
select { width: auto; }
.form button, .form-wide > button { margin-top: 18px; }
.checkbox-label {
    display: flex !important;
    gap: 9px;
    align-items: flex-start;
    font-weight: normal !important;
}
.checkbox-label input[type="checkbox"] { width: auto; margin-top: 4px; }
/* Страница политики */
.policy { max-width: 760px; }
.policy h2 { font-size: 17px; margin: 20px 0 6px; }
.policy ul { margin: 6px 0; padding-left: 22px; }
fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 16px 0; padding: 4px 14px 14px; }
legend { font-weight: 600; padding: 0 6px; }
.form-page { max-width: 440px; margin: 30px auto; }

.muted { color: var(--muted); font-weight: normal; }
.small { font-size: 13px; }
.text-error { color: var(--danger); }

/* Карточки */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    margin: 10px 0;
}
.cards-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 20px 0; }
.stats-cards { grid-template-columns: repeat(5, 1fr); }
.stat { text-align: center; }
.stat-num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--muted); font-size: 13px; }

/* Герой на главной */
.hero { text-align: center; padding: 50px 16px 20px; }
.hero h1 { font-size: 34px; }
.hero-sub { max-width: 560px; margin: 0 auto 24px; color: var(--muted); font-size: 17px; }

/* Бейджи */
.badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 999px;
}
.badge-pending { background: var(--hint-bg); color: var(--hint-border); border: 1px solid var(--hint-border); }
.badge-ok { background: var(--flash-ok-bg); color: var(--flash-ok-text); border: 1px solid var(--flash-ok-border); }
.badge-error { background: var(--flash-err-bg); color: var(--flash-err-text); border: 1px solid var(--flash-err-border); }
.badge-count { background: var(--danger); color: #fff; padding: 1px 7px; border: 0; }

/* Списки изображений (мои фото, модерация) */
.image-card { display: flex; gap: 16px; }
.image-card-thumb { flex: 0 0 220px; }
.image-card-thumb img { width: 100%; border-radius: 8px; display: block; }
.thumb-placeholder {
    width: 100%; aspect-ratio: 4 / 3;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-soft); color: var(--muted);
    border-radius: 8px; font-size: 13px;
}
.image-card-body { flex: 1; min-width: 0; }
.image-card-body p { margin: 4px 0; overflow-wrap: break-word; }
.mod-actions { margin-top: 10px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.mod-reject { display: inline-flex; gap: 6px; align-items: center; }

/* Таблицы */
.table { width: 100%; border-collapse: collapse; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.table th, .table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: var(--bg-soft); font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }
.row-me { background: var(--row-me); }
.row-banned { opacity: 0.6; }
.row-sep td { text-align: center; color: var(--muted); }
.history-thumb { width: 90px; border-radius: 6px; display: block; }

/* Игровой экран */
.game-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    height: calc(100vh - var(--topbar-h));
}
.game-photo { padding: 14px 18px; overflow-y: auto; background: var(--bg-card); }
.game-map { position: relative; }
#map { position: absolute; inset: 0; }
/* Карта, растянутая на всю секцию (загрузка/редактирование) */
.map-fill { position: absolute; inset: 0; }
/* Кнопка подтверждения — прямо на карте, снизу по центру */
.map-actions {
    position: absolute;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
}
.map-actions .btn {
    min-width: 220px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}
/* Плашка-предупреждение поверх карты */
.map-note {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
    max-width: min(560px, 92%);
    margin: 0;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    font-size: 13px;
}
#photoBox img {
    max-width: 100%;
    max-height: 55vh;
    display: block;
    margin: 0 auto;
    border-radius: 8px;
    cursor: zoom-in;
}
.game-controls { margin-top: 12px; }
.points-line { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.points-max { font-weight: 700; font-size: 17px; color: var(--primary); }
.btn-row { display: flex; gap: 10px; margin: 10px 0; flex-wrap: wrap; align-items: center; }
.hints { list-style: none; padding: 0; margin: 8px 0; }
.hints li {
    background: var(--hint-bg);
    border: 1px solid var(--hint-border);
    border-radius: 8px;
    padding: 7px 12px;
    margin: 6px 0;
}
.result-panel { margin-top: 14px; border-top: 2px solid var(--border); padding-top: 12px; }
.points-big { font-size: 22px; color: var(--success); }
.empty-box { text-align: center; padding: 60px 20px; }

/* Жалоба на изображение */
.report-box {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin: 10px 0;
    background: var(--bg-soft);
}
.report-box .btn-row { margin-bottom: 0; }
.report-link {
    background: none; border: 0; padding: 0; cursor: pointer;
    color: var(--muted); font-size: 13px; font-family: inherit;
}
.report-link:hover { color: var(--danger); }

/* Карта выбора точки при загрузке/редактировании */
.pick-map { height: 380px; border: 1px solid var(--border); border-radius: 8px; margin: 8px 0 4px; }

/* Зона перетаскивания файла */
.drop-zone {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    padding: 26px 16px;
    text-align: center;
    margin: 8px 0 4px;
    transition: border-color 0.15s, background-color 0.15s;
}
.drop-zone.dragover { border-color: var(--primary); background: var(--row-me); }
.drop-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.drop-zone-idle p { margin: 0; }
.drop-zone-preview img { max-width: 100%; max-height: 260px; border-radius: 8px; }
.drop-zone-preview p { margin: 6px 0 0; }

/* Предупреждение о точности локации */
.attention {
    background: var(--hint-bg);
    border: 1px solid var(--hint-border);
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
    padding: 10px 14px;
    margin: 10px 0;
    font-weight: 600;
}

/* Оверлей «идёт загрузка» */
.busy-overlay {
    position: fixed; inset: 0;
    background: rgba(17, 24, 39, 0.55);
    display: flex; align-items: center; justify-content: center;
    z-index: 1500;
}
.busy-box {
    background: var(--bg-card);
    color: var(--text);
    border-radius: 12px;
    padding: 22px 30px;
    text-align: center;
    max-width: 320px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
.busy-box p { margin: 0; }
.spinner {
    width: 36px; height: 36px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: gg-spin 0.8s linear infinite;
}
@keyframes gg-spin { to { transform: rotate(360deg); } }

/* Лайтбокс */
.lightbox {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.92);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000; cursor: zoom-out;
}
.lightbox img { max-width: 96%; max-height: 96%; }

/* Тёмная тема для карты: инвертируем только тайлы, маркеры не трогаем */
html[data-theme="dark"] .leaflet-layer .leaflet-tile {
    filter: invert(1) hue-rotate(180deg) brightness(0.8) contrast(0.9) saturate(0.5);
}
html[data-theme="dark"] .leaflet-container { background: #0f172a; }
html[data-theme="dark"] .leaflet-control-attribution {
    background: rgba(17, 24, 39, 0.8); color: #9ca3af;
}
html[data-theme="dark"] .leaflet-control-attribution a { color: #93c5fd; }
html[data-theme="dark"] .leaflet-bar a {
    background: #1f2937; color: #e5e7eb; border-color: #374151;
}
html[data-theme="dark"] .leaflet-bar a:hover { background: #273244; }
html[data-theme="dark"] .leaflet-popup-content-wrapper,
html[data-theme="dark"] .leaflet-popup-tip {
    background: #1f2937; color: #e5e7eb;
}

/* Адаптив */
@media (max-width: 900px) {
    .game-wrap { grid-template-columns: 1fr; height: auto; }
    .game-map { height: 48vh; min-height: 320px; }
    .cards-3, .stats-cards { grid-template-columns: 1fr; }
    .image-card { flex-direction: column; }
    .image-card-thumb { flex-basis: auto; }
    .topbar { position: static; }
    .topbar-inner { padding: 8px 16px; }
}
