:root {
  --accent: #2f6fdb;
  --accent-2: #1f55b8;
  --gold: #ffc83d;
  --gold-d: #e09a0b;
  --ink: #23180f;
  --text: #1d1d1f;
  --muted: #6b6b75;
  --card: rgba(255, 255, 255, .88);
  --card-solid: #ffffff;
  --line: rgba(0, 0, 0, .08);
  --shade: rgba(255, 250, 240, .0);
  --good: #23a55a;
  --bad: #e5484d;
  --nav-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
body.dark {
  --text: #f2f2f5;
  --muted: #a3a3b0;
  --card: rgba(28, 31, 42, .9);
  --card-solid: #1c1f2a;
  --line: rgba(255, 255, 255, .1);
  --shade: rgba(10, 12, 22, .55);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: #e9dcc4;
  overflow: hidden;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}
#bg {
  position: fixed; inset: 0;
  background: url("/static/assets/auditorium.svg") center / cover no-repeat;
}
#bg::after { content: ""; position: absolute; inset: 0; background: var(--shade); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 500; }
.center { text-align: center; }

/* ---------- заставка */
.splash {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 24px; text-align: center; z-index: 50;
}
.splash-img { width: 180px; animation: breathe 2.4s ease-in-out infinite; }
.splash-text {
  font-size: 19px; font-weight: 700; line-height: 1.35; max-width: 340px;
  background: var(--card); padding: 14px 18px; border-radius: 18px; box-shadow: 0 6px 20px rgba(0,0,0,.12);
}
@keyframes breathe { 50% { transform: scale(1.04) translateY(-3px); } }

/* ---------- страницы */
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
.page { display: none; flex: 1; min-height: 0; padding: 12px 14px calc(var(--nav-h) + var(--safe-b) + 12px); }
.page.active { display: flex; flex-direction: column; }
.sheet { overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--card); backdrop-filter: blur(8px); }
.sheet h2 { margin: 6px 0 10px; font-size: 26px; }
.sheet h3 { margin: 20px 0 10px; font-size: 19px; }

/* ---------- верх главной */
.top {
  text-align: center; background: var(--card); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-radius: 22px; padding: 10px 12px 12px; box-shadow: 0 4px 14px rgba(0,0,0,.1);
}
.who { display: flex; align-items: center; gap: 10px; text-align: left; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none; background: var(--accent) center / cover;
  color: #fff; font-weight: 800; font-size: 19px; display: flex; align-items: center; justify-content: center;
  border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.who-text { min-width: 0; }
.me-name { font-size: 17px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.relation { margin-top: 1px; font-size: 13px; font-weight: 700; color: var(--muted); }
.balance-label { margin-top: 6px; font-size: 15px; font-weight: 700; color: var(--muted); }
body:not(.dark) .balance-label { color: #6b5532; }
.balance {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 44px; font-weight: 900; letter-spacing: -1px; line-height: 1.1;
}
body.dark .balance { text-shadow: 0 2px 6px rgba(0,0,0,.5); }
.coin {
  width: 38px; height: 38px; border-radius: 50%; flex: none; position: relative;
  background: radial-gradient(circle at 35% 30%, #fff3b0 0, var(--gold) 45%, var(--gold-d) 100%);
  border: 3px solid #b8780a; box-shadow: 0 2px 0 #8a5a06;
}
.coin::after { content: "Г"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 900; color: #8a5a06; }
.coin.small { width: 22px; height: 22px; border-width: 2px; }
.coin.small::after { font-size: 12px; }
.chips { display: flex; gap: 8px; justify-content: center; margin-top: 8px; }
.chip { background: rgba(47,111,219,.1); border-radius: 99px; padding: 6px 12px; font-size: 15px; font-weight: 800; }
.event {
  margin: 10px auto 0; max-width: 360px; background: linear-gradient(90deg, #ffe08a, #ffc83d); color: #3b2a05;
  border-radius: 14px; padding: 8px 12px; font-size: 15px; font-weight: 800; box-shadow: 0 3px 10px rgba(0,0,0,.12);
}
.event small { display: block; font-weight: 600; font-size: 13px; margin-top: 2px; }

/* ---------- Гришка */
.stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; padding: 6px 0; }
.tapzone {
  position: relative; height: min(100%, 340px); max-width: 84vw; aspect-ratio: 1; border-radius: 50%;
  display: flex; align-items: flex-end; justify-content: center; cursor: pointer; touch-action: none;
}
.halo {
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, rgba(255,255,255,.95), rgba(255,255,255,.55) 55%, rgba(255,255,255,0) 72%);
}
body.dark .halo { background: radial-gradient(circle at 50% 45%, rgba(120,150,255,.35), rgba(120,150,255,.12) 55%, rgba(0,0,0,0) 72%); }
.grishka {
  position: relative; width: 100%; height: 100%; object-fit: contain; pointer-events: none;
  transition: transform .08s ease-out; filter: drop-shadow(0 8px 14px rgba(0,0,0,.25));
}
.grishka.hit { transform: scale(.93) rotate(var(--rot, 0deg)); }
.grishka.shake { animation: shake .35s; }
@keyframes shake {
  20% { transform: translateX(-8px) rotate(-3deg); } 40% { transform: translateX(8px) rotate(3deg); }
  60% { transform: translateX(-6px) rotate(-2deg); } 80% { transform: translateX(5px) rotate(1deg); }
}
.floats { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.float {
  position: absolute; font-size: 30px; font-weight: 900; color: #fff;
  text-shadow: 0 2px 0 #b8780a, 0 0 8px rgba(0,0,0,.35);
  animation: rise .9s ease-out forwards; will-change: transform, opacity;
}
@keyframes rise { to { transform: translateY(-120px) scale(1.15); opacity: 0; } }
.bubble {
  position: absolute; top: 2%; left: 50%; transform: translateX(-50%); z-index: 3; width: max-content; max-width: 88%;
  background: #fff; color: #1d1d1f; font-size: 18px; font-weight: 800; padding: 10px 16px; border-radius: 18px;
  border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); text-align: center; line-height: 1.25;
  animation: pop .18s ease-out;
}
.bubble::after {
  content: ""; position: absolute; bottom: -14px; left: 50%; margin-left: -10px;
  border: 10px solid transparent; border-top: 12px solid var(--ink); border-bottom: 0;
}
@keyframes pop { from { transform: translateX(-50%) scale(.6); opacity: 0; } }

/* ---------- энергия */
.energy { background: var(--card); border-radius: 18px; padding: 10px 14px; box-shadow: 0 4px 14px rgba(0,0,0,.1); }
.energy-row { display: flex; justify-content: space-between; font-size: 17px; font-weight: 800; margin-bottom: 8px; }
.bar { height: 14px; border-radius: 99px; background: rgba(0,0,0,.1); overflow: hidden; }
body.dark .bar { background: rgba(255,255,255,.12); }
.bar-fill { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #ffb703, #ffd84d); transition: width .25s; }
.bar-fill.low { background: linear-gradient(90deg, #e5484d, #ff8a65); }

/* ---------- навигация */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex;
  padding: 6px 6px calc(6px + var(--safe-b)); background: var(--card-solid);
  border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0,0,0,.08);
}
.nav button {
  flex: 1; border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; border-radius: 12px;
  min-height: 52px;
}
.nav button span { font-size: 24px; line-height: 1.1; }
.nav button.active { color: var(--accent); background: rgba(47,111,219,.1); }

/* ---------- списки и карточки */
.list { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--card-solid); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px;
  display: flex; align-items: center; gap: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.05);
}
.card .ico { font-size: 34px; width: 46px; text-align: center; flex: none; }
.card .body { flex: 1; min-width: 0; }
.card .title { font-size: 17px; font-weight: 800; }
.card .sub { font-size: 14px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.card.owned { opacity: .6; }
.card.locked { opacity: .55; }
.btn {
  border: 0; border-radius: 14px; padding: 12px 16px; font: inherit; font-size: 16px; font-weight: 800;
  background: var(--accent); color: #fff; box-shadow: 0 3px 0 var(--accent-2); min-height: 46px; white-space: nowrap;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--accent-2); }
.btn[disabled] { background: #a9b3c4; box-shadow: none; }
.btn.gold { background: var(--gold); color: #3b2a05; box-shadow: 0 3px 0 var(--gold-d); }
.btn.small { padding: 9px 12px; font-size: 15px; min-height: 42px; }
.price { display: inline-flex; align-items: center; gap: 5px; }
.mini-balance { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 900; }
.seg { display: flex; background: rgba(0,0,0,.06); border-radius: 14px; padding: 4px; gap: 4px; margin-bottom: 12px; }
body.dark .seg { background: rgba(255,255,255,.08); }
.seg-btn { flex: 1; border: 0; border-radius: 11px; padding: 11px 6px; font: inherit; font-size: 15px; font-weight: 800;
  background: none; color: var(--muted); }
.seg-btn.active { background: var(--card-solid); color: var(--text); box-shadow: 0 2px 6px rgba(0,0,0,.1); }
.rank { font-size: 22px; font-weight: 900; width: 40px; text-align: center; flex: none; }
.row-avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; background: var(--accent) center / cover;
  color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.value { font-weight: 900; font-size: 17px; white-space: nowrap; }
.card.me { border: 2px solid var(--accent); }
.me-card { margin-bottom: 12px; justify-content: space-between; font-size: 17px; font-weight: 800; }
.progress { height: 10px; border-radius: 99px; background: rgba(0,0,0,.08); overflow: hidden; margin-top: 8px; }
body.dark .progress { background: rgba(255,255,255,.12); }
.progress > div { height: 100%; background: linear-gradient(90deg, #3ec46d, #23a55a); border-radius: 99px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card-solid); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.stat b { display: block; font-size: 21px; font-weight: 900; margin-top: 2px; }
.stat span { font-size: 13px; color: var(--muted); font-weight: 700; }
.ach-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ach { background: var(--card-solid); border: 1px solid var(--line); border-radius: 16px; padding: 12px; text-align: center; }
.ach .e { font-size: 34px; }
.ach .t { font-size: 15px; font-weight: 800; margin-top: 4px; }
.ach .d { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.ach.no { opacity: .45; filter: grayscale(1); }

/* ---------- уведомления */
.toasts { position: fixed; top: 10px; left: 10px; right: 10px; z-index: 60; display: flex; flex-direction: column;
  align-items: center; gap: 8px; pointer-events: none; }
.toast { background: #1d1d1f; color: #fff; font-size: 16px; font-weight: 800; padding: 12px 16px; border-radius: 16px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 420px; text-align: center; animation: drop .25s ease-out; }
.toast.good { background: #1c7c45; }
.toast.bad { background: #b3261e; }
.toast.ach { background: linear-gradient(90deg, #7b4dff, #2f6fdb); }
@keyframes drop { from { transform: translateY(-20px); opacity: 0; } }
.modal { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.45); display: flex; align-items: center;
  justify-content: center; padding: 24px; }
.modal-card { background: var(--card-solid); border-radius: 22px; padding: 22px; max-width: 360px; width: 100%;
  text-align: center; font-size: 19px; font-weight: 800; line-height: 1.35; display: flex; flex-direction: column; gap: 16px; }
.modal-card .big { font-size: 54px; }

@media (max-height: 720px) {
  .event small { display: none; }
}
@media (max-height: 640px) {
  .balance { font-size: 36px; }
  .chips { margin-top: 4px; }
  .chip { padding: 4px 10px; font-size: 14px; }
  .nav button { min-height: 46px; }
}
