/* ============ Watcher of Realms — тёмное фэнтези с золотом ============
   Фон: положите assets/bg.jpg (арт игры) — подхватится автоматически.
   Логотип: assets/logo.png (экран выбора языка + шапка).                */
:root {
  --bg2: #0b0e15;                 /* фон приложения — глубокая ночь */
  --bg: #161b27;                  /* карточки */
  --bg-raised: #1c2333;           /* приподнятые элементы */
  --text: #e9e2d0;                /* тёплый пергамент */
  --hint: #8d8873;
  --gold: #c9a45c;                /* основной акцент — латунь/золото */
  --gold-bright: #e8c987;
  --link: #e0b96f;
  --accent-text: #14100a;
  --up: #5fae7d;
  --down: #c75b55;
  --line: rgba(201, 164, 92, .22); /* золотые окантовки */
  --radius: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(201,164,92,.14), transparent 60%),
    radial-gradient(80% 50% at 50% 110%, rgba(60,40,90,.25), transparent 60%),
    var(--bg2);
}
/* арт-подложка, если загружен assets/bg.jpg */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: url("assets/bg.jpg") center top / cover no-repeat;
  opacity: .18; pointer-events: none;
}

h1, h2, h3, .stat b, .lang-btn {
  font-family: "Philosopher", Georgia, serif;
  letter-spacing: .3px;
}

.hidden { display: none !important; }
.muted { color: var(--hint); font-size: .85em; font-weight: 400; }

/* ---------- выбор языка ---------- */
#lang-screen {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(201,164,92,.18), transparent 60%),
    var(--bg2);
}
.lang-box { text-align: center; padding: 24px; width: 100%; max-width: 340px; }
.lang-logo { font-size: 56px; margin-bottom: 16px; }
.lang-logo-img { max-width: 220px; max-height: 110px; margin-bottom: 20px; filter: drop-shadow(0 4px 18px rgba(201,164,92,.35)); }
.lang-box h1 { font-size: 24px; line-height: 1.4; margin-bottom: 28px; color: var(--gold-bright); }
.lang-btn {
  display: block; width: 100%; margin-bottom: 12px; padding: 14px;
  font-size: 17px; font-weight: 700; border: 1px solid var(--line);
  border-radius: var(--radius); cursor: pointer;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: var(--accent-text);
  box-shadow: 0 2px 14px rgba(201,164,92,.25);
}
.lang-btn:active { filter: brightness(.9); }

/* ---------- каркас ---------- */
#header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 10px;
  background: linear-gradient(180deg, rgba(11,14,21,.97), rgba(11,14,21,.88));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
#header-logo { height: 26px; }
#page-title { font-size: 21px; font-weight: 700; color: var(--gold-bright); }

#content { padding: 10px 12px 88px; }

#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: rgba(11,14,21,.97);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  backdrop-filter: blur(6px);
}
.tab {
  flex: 1; padding: 8px 0 6px; border: none; background: none;
  color: var(--hint); font-size: 19px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab small { font-size: 9.5px; font-family: inherit; }
.tab.active { color: var(--gold-bright); }
.tab.active span { filter: drop-shadow(0 0 6px rgba(232,201,135,.6)); }

/* ---------- карточки ---------- */
.card {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px;
  animation: rise .18s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .card { animation: none; } }

.card h3 { font-size: 16px; margin-bottom: 6px; color: var(--gold-bright); }
.card .dates { color: var(--hint); font-size: 13px; }
.card a { color: var(--link); text-decoration: none; font-size: 14px; }
.card p { font-size: 15px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }

/* прогресс периода события */
.progress { height: 4px; border-radius: 2px; background: rgba(201,164,92,.15); margin-top: 10px; overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright)); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 8px;
  font-size: 11px; font-weight: 600; margin-left: 6px; vertical-align: middle;
}
.badge.ok { background: rgba(95,174,125,.16); color: var(--up); }
.badge.wait { background: rgba(141,136,115,.16); color: var(--hint); }

/* ---------- сегментированный переключатель ---------- */
.seg {
  display: flex; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 3px; margin: 8px 0 12px;
}
.seg button {
  flex: 1; padding: 8px 4px; border: none; border-radius: 11px;
  background: none; color: var(--hint); font-size: 13px; font-weight: 600; cursor: pointer;
}
.seg button.active {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: var(--accent-text);
}

/* ---------- формы ---------- */
textarea, input[type=text] {
  width: 100%; padding: 12px; border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg); color: var(--text); font-size: 15px;
  font-family: inherit; resize: vertical; margin-bottom: 10px;
}
textarea { min-height: 90px; }
textarea:focus, input:focus { outline: none; border-color: var(--gold); }
::placeholder { color: var(--hint); }

.btn {
  display: block; width: 100%; padding: 13px; border: none;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: var(--accent-text); font-size: 16px; font-weight: 700; cursor: pointer;
  font-family: "Philosopher", Georgia, serif;
  box-shadow: 0 2px 12px rgba(201,164,92,.2);
}
.btn:disabled { opacity: .5; }
.btn:active { filter: brightness(.9); }

.section-label {
  color: var(--gold); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.2px; margin: 18px 4px 8px;
}

/* ---------- голосование ---------- */
.vote-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.vote-btn {
  border: 1px solid var(--line); border-radius: 10px; padding: 6px 14px;
  font-size: 14px; background: var(--bg-raised); color: var(--text); cursor: pointer;
}
.vote-btn.up.on { background: rgba(95,174,125,.22); color: var(--up); border-color: rgba(95,174,125,.4); }
.vote-btn.down.on { background: rgba(199,91,85,.22); color: var(--down); border-color: rgba(199,91,85,.4); }
.score { margin-left: auto; font-weight: 700; font-size: 15px; }
.score.pos { color: var(--up); }
.score.neg { color: var(--down); }

/* ---------- кабинет ---------- */
.profile { display: flex; align-items: center; gap: 14px; padding: 6px 4px 14px; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: var(--accent-text);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; flex-shrink: 0;
  font-family: "Philosopher", Georgia, serif;
  box-shadow: 0 0 0 2px var(--bg2), 0 0 0 3px var(--line);
}
.stats { display: flex; gap: 10px; }
.stat { flex: 1; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; text-align: center; }
.stat b { display: block; font-size: 22px; color: var(--gold-bright); }
.stat small { color: var(--hint); font-size: 12px; }

.empty { text-align: center; color: var(--hint); padding: 36px 16px; font-size: 15px; }

/* ---------- гайды ---------- */
.back-row {
  display: flex; align-items: center; gap: 6px;
  color: var(--link); padding: 2px 4px 12px; cursor: pointer; font-size: 15px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.fac-card {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 8px 12px;
  text-align: center; cursor: pointer; animation: rise .18s ease-out;
}
.fac-card:active { background: var(--bg-raised); }
.fac-card h3 { font-size: 14.5px; margin: 8px 0 2px; }
.fac-icon {
  height: 52px; display: flex; align-items: center; justify-content: center;
  font-size: 38px;
}
.fac-icon img { width: 52px; height: 52px; object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(201,164,92,.35)); }

.hero-card { text-align: center; cursor: pointer; animation: rise .18s ease-out; }
.hero-card small {
  display: block; margin-top: 6px; font-size: 12px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.portrait {
  position: relative; width: 100%; aspect-ratio: 1;
  border-radius: 12px; border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg-raised), var(--bg));
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; color: var(--gold);
  font-family: "Philosopher", Georgia, serif; overflow: hidden;
}
.portrait img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.hero-head { display: flex; gap: 14px; align-items: center; margin-bottom: 4px; }
.hero-head .portrait { width: 88px; flex-shrink: 0; font-size: 34px; }
.hero-head h3 { font-size: 20px; color: var(--gold-bright); }

/* ---------- наследуемая иконка фракции ---------- */
.fac-label { display: flex; align-items: center; gap: 6px; }
.fac-inline-icon {
  width: 20px; height: 20px; object-fit: contain; vertical-align: middle;
  filter: drop-shadow(0 1px 4px rgba(201,164,92,.4));
}

/* ---------- награды (CDK) ---------- */
.reward-card {
  position: relative; display: flex; align-items: center; gap: 12px;
  background:
    linear-gradient(135deg, rgba(201,164,92,.10), rgba(60,40,90,.12)),
    var(--bg);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px;
  box-shadow: 0 0 14px rgba(201,164,92,.15), inset 0 0 24px rgba(201,164,92,.05);
  animation: rise .18s ease-out;
}
.reward-card.claimed {
  border-color: var(--line);
  box-shadow: none;
  background: var(--bg);
}
.reward-gem {
  font-size: 30px; flex-shrink: 0;
  filter: drop-shadow(0 0 8px rgba(232,201,135,.55));
}
.reward-card.claimed .reward-gem { filter: none; opacity: .8; }
.reward-body { flex: 1; min-width: 0; }
.reward-body h3 { font-size: 15.5px; color: var(--gold-bright); margin-bottom: 2px; }
.reward-body .muted { margin-top: 2px; }
.claim-btn {
  flex-shrink: 0; padding: 9px 16px; border: none; border-radius: 11px;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: var(--accent-text); font-weight: 700; font-size: 14px; cursor: pointer;
  font-family: "Philosopher", Georgia, serif;
  box-shadow: 0 2px 10px rgba(201,164,92,.35);
}
.claim-btn:active { filter: brightness(.9); }
.claim-btn:disabled { opacity: .5; }
.reward-badge { flex-shrink: 0; margin-left: 0; }
.reward-side {
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  flex-shrink: 0;
}
.hide-btn {
  padding: 3px 10px; font-size: 11.5px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 8px;
  background: transparent; color: var(--muted);
}
.hide-btn:active { filter: brightness(1.3); }
.rw-seg { margin-bottom: 10px; }
.reward-code {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 8px; padding: 8px 10px;
  background: rgba(11,14,21,.6); border: 1px dashed var(--line);
  border-radius: 10px;
}
.reward-code code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px; font-weight: 700; color: var(--gold-bright);
  letter-spacing: 1px; word-break: break-all;
}
.copy-btn {
  margin-left: auto; padding: 4px 10px; font-size: 12px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg-raised); color: var(--link);
}

/* ---------- XP и уровень ---------- */
.level-badge {
  flex-shrink: 0; padding: 5px 12px; border-radius: 10px;
  border: 1px solid var(--gold); color: var(--gold-bright);
  font-family: "Philosopher", Georgia, serif; font-weight: 700; font-size: 13px;
  background: rgba(201,164,92,.1);
}
.xp-bar {
  position: relative; height: 22px; margin: 10px 0 14px;
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: 11px; overflow: hidden;
}
.xp-fill {
  height: 100%; border-radius: 11px; transition: width .4s ease;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
  box-shadow: 0 0 10px rgba(232,201,135,.4);
}
.xp-text {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; font-size: 11.5px; font-weight: 700;
  color: var(--text); text-shadow: 0 1px 3px rgba(0,0,0,.7);
}

/* ---------- задания ---------- */
.card.quest { display: flex; align-items: center; gap: 12px; }
.quest-info { flex: 1; min-width: 0; }
.quest-info h3 { margin-bottom: 2px; }
.streak-dots { display: flex; gap: 5px; margin-top: 7px; }
.streak-dots .dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg-raised);
}
.streak-dots .dot.on {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  border-color: var(--gold); box-shadow: 0 0 6px rgba(232,201,135,.5);
}

/* ---------- рейтинг ---------- */
.top-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 6px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.top-row.me {
  border-color: var(--gold);
  background: linear-gradient(135deg, rgba(201,164,92,.12), var(--bg));
  box-shadow: 0 0 10px rgba(201,164,92,.15);
}
.top-rank { min-width: 30px; text-align: center; font-weight: 700; font-size: 15px; }
.top-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-weight: 600;
}
.top-lvl { flex-shrink: 0; font-size: 12px; color: var(--gold-bright); }
.top-xp { flex-shrink: 0; font-size: 12.5px; color: var(--muted); min-width: 58px; text-align: right; }
.top-dots { text-align: center; color: var(--muted); letter-spacing: 4px; margin: 2px 0 8px; }

/* ---------- прогресс задания ---------- */
.quest-bar {
  position: relative; height: 16px; margin-top: 7px;
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden;
}
.quest-fill {
  height: 100%; transition: width .3s ease;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
}
.quest-bar span {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; font-size: 10.5px; font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,.7);
}

/* ---------- форма фан-гайда ---------- */
#fg-form input {
  width: 100%; box-sizing: border-box; margin-bottom: 8px;
  padding: 10px 12px; background: var(--bg-raised);
  border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); font-size: 14.5px;
}
#fg-form input:focus { outline: none; border-color: var(--gold); }

/* ---------- игровой аккаунт ---------- */
.ga-row { display: flex; gap: 8px; align-items: center; }
.ga-row input {
  flex: 1; min-width: 0; padding: 10px 12px;
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); font-size: 15px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.ga-row input:focus { outline: none; border-color: var(--gold); }
/* форма привязки: два поля + кнопка, кнопка переносится на новую строку */
.ga-form { flex-wrap: wrap; }
.ga-form .ga-uid { flex: 1.4; }
.ga-form .ga-sid { flex: 1; }
.ga-form .claim-btn { flex: 1 1 100%; }
.ga-bound { flex: 1; font-size: 14.5px; }
.ga-privacy { margin-top: 8px; font-size: 11.5px; }

/* ---------- напоминание о событии ---------- */
.remind-btn {
  margin-top: 10px; padding: 7px 14px; font-size: 13px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg-raised); color: var(--link);
}
.remind-btn.on {
  border-color: var(--gold); color: var(--gold-bright);
  background: rgba(201,164,92,.14);
}
.remind-btn:disabled { opacity: .5; }

/* ---------- фишки фракций героя ---------- */
.fac-label { flex-wrap: wrap; }
.fac-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px 2px 4px; margin: 2px 4px 2px 0;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg-raised); font-size: 12px;
}

/* ---------- подписка на героя ---------- */
.follow-btn {
  margin-top: 8px; padding: 6px 14px; font-size: 13px; cursor: pointer;
  border: 1px solid var(--gold); border-radius: 10px;
  background: transparent; color: var(--gold-bright);
  font-family: "Philosopher", Georgia, serif; font-weight: 700;
}
.follow-btn.on {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: var(--accent-text);
  box-shadow: 0 2px 10px rgba(201,164,92,.3);
}
.follow-btn:disabled { opacity: .5; }
.follow-btn:active { filter: brightness(.9); }

.badge.personal {
  background: rgba(201,164,92,.18); color: var(--gold-bright);
  border: 1px solid var(--line); font-size: 10px;
}

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  background: rgba(20, 16, 10, .92); color: var(--gold-bright);
  border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 12px; font-size: 14px;
  z-index: 100; max-width: 86%; text-align: center;
}
