/* styles.css — Сортировка воды (премиум-визуал) */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { position: fixed; inset: 0; }
:root {
  --fg: #eaf1ff;
  --muted: #9fb0d4;
  --glass: rgba(255,255,255,0.07);
  --glass-strong: rgba(20,32,66,0.62);
  --glass-bd: rgba(255,255,255,0.16);
  --accent: #5ad7e6;
  --accent2: #2a8fff;
  --reward: #ffb12e;
  --shadow: rgba(0,0,0,0.5);
  --font-disp: 'Baloo 2', 'Nunito', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
body.light {
  --fg: #15243f;
  --muted: #5b6b89;
  --glass: rgba(255,255,255,0.45);
  --glass-strong: rgba(255,255,255,0.82);
  --glass-bd: rgba(40,70,120,0.16);
  --shadow: rgba(40,70,120,0.28);
}
body {
  font-family: var(--font-body);
  background: linear-gradient(165deg, #1b2c58, #0a1024);
  color: var(--fg);
  user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none;
  -webkit-touch-callout: none; touch-action: manipulation;
}
body.light { background: linear-gradient(165deg, #eaf4ff, #c4ddf6); }
#app { position: fixed; inset: 0; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* SVG-иконки (наследуют цвет текста) */
.ic { width: 22px; height: 22px; display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- HUD (две строки: уровень+шестерёнка, затем подписанные кнопки) ---------- */
.hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: none; flex-direction: column; gap: 8px;
  padding: max(12px, env(safe-area-inset-top)) 14px 8px;
  z-index: 5; pointer-events: none;
}
body.playing .hud { display: flex; } /* HUD только во время игры, не в меню */
.hud-top { display: flex; align-items: center; justify-content: space-between; }
.hud-level {
  font-family: var(--font-disp); font-size: 18px; font-weight: 800; letter-spacing: .3px;
  white-space: nowrap;
  padding: 7px 16px; border-radius: 14px;
  background: var(--glass); border: 1px solid var(--glass-bd);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px var(--shadow); pointer-events: auto;
}
.hud-tools { display: flex; gap: 8px; justify-content: center; pointer-events: auto; }
.tbtn {
  position: relative; flex: 1; max-width: 86px; padding: 8px 4px 7px; border-radius: 15px;
  border: 1px solid var(--glass-bd); background: var(--glass); color: var(--fg); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px var(--shadow);
  transition: transform .12s cubic-bezier(.2,.9,.3,1.4), opacity .15s;
}
.tbtn .ic { width: 22px; height: 22px; }
.icon-gear .ic { width: 21px; height: 21px; }
.tbtn-lbl { font-size: 11px; font-weight: 700; color: var(--muted); }
.tbtn:active { transform: scale(.9); }
.tbtn:disabled { opacity: .34; }
.tbtn-reward::after {
  content: "▶"; position: absolute; top: -5px; right: -5px;
  font-size: 8px; background: linear-gradient(135deg, #ffc857, var(--reward)); color: #2a1a00;
  width: 17px; height: 17px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-weight: 900;
  box-shadow: 0 2px 6px rgba(255,160,0,0.5);
}
/* шестерёнка (в игре, в правом верхнем углу) */
.icon-gear {
  width: 42px; height: 42px; border-radius: 13px; flex: none;
  border: 1px solid var(--glass-bd); background: var(--glass); color: var(--fg);
  font-size: 19px; cursor: pointer; pointer-events: auto;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px var(--shadow); transition: transform .12s;
}
.icon-gear:active { transform: scale(.9); }

/* ---------- Overlays ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 10;
  display: none; align-items: center; justify-content: center;
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 20px; background: rgba(6,11,28,0.5);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
}
/* скроллбар внутреннего скролла не показываем — модерация принимает его за браузерную прокрутку (п.1.10.2) */
.overlay { scrollbar-width: none; }
.overlay::-webkit-scrollbar { display: none; }
.overlay.active { display: flex; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
/* меню — прозрачное, чтобы был виден анимированный фон */
.screen { background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }

/* ---------- Меню (иммерсивное: бренд сверху, действия снизу, живая демка на canvas) ---------- */
#menu-overlay {
  flex-direction: column; justify-content: space-between; align-items: center;
  padding: max(30px, env(safe-area-inset-top)) 22px max(28px, env(safe-area-inset-bottom));
}
.brand { text-align: center; margin-top: 8vh; display: flex; flex-direction: column; align-items: center; }
.logo {
  font-family: var(--font-disp); font-size: 38px; font-weight: 800; line-height: 1.02; letter-spacing: .5px;
  background: linear-gradient(135deg, #9ff0ff, #4db5ff 55%, #b89bff);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 14px rgba(40,140,255,0.4));
}
body.light .logo { background: linear-gradient(135deg, #0f6fd6, #2a8fff 55%, #7b5be0); -webkit-background-clip: text; background-clip: text; }
.tagline { color: var(--muted); font-size: 14px; font-weight: 600; margin-top: 12px; max-width: 300px; line-height: 1.45; }

.menu-actions { width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 13px; }
.chips { display: flex; gap: 12px; }
.chip {
  display: flex; flex-direction: column; align-items: center; padding: 9px 24px; border-radius: 16px;
  background: var(--glass); border: 1px solid var(--glass-bd);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.chip-num { font-family: var(--font-disp); font-size: 22px; font-weight: 800; color: var(--accent); }
body.light .chip-num { color: var(--accent2); }
.chip-lbl { font-size: 11px; color: var(--muted); font-weight: 700; }
.btn-play { width: 100%; padding: 18px; font-size: 19px; box-shadow: 0 10px 30px rgba(42,143,255,0.5), inset 0 1px 0 rgba(255,255,255,0.3); }
/* заметная кнопка «без рекламы» */
.btn-noads {
  width: 100%; padding: 13px; font-size: 15px; color: var(--fg);
  background: var(--glass); border: 1.5px solid rgba(255,179,46,0.55);
  box-shadow: 0 6px 18px rgba(255,160,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12);
}
.btn-noads::before { display: none; }
.btn-noads.vip { border-color: var(--glass-bd); color: var(--accent); box-shadow: none; }
.menu-links { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.link-btn {
  background: none; border: none; color: var(--muted);
  font-family: var(--font-body); font-size: 14px; font-weight: 700; cursor: pointer; padding: 6px; transition: transform .1s, color .15s;
}
.link-btn:active { transform: scale(.96); }
.link-dot { color: var(--muted); opacity: .6; }

/* ---------- Dialog ---------- */
.dialog {
  width: 100%; max-width: 340px; margin: auto;
  background: var(--glass-strong); border: 1px solid var(--glass-bd); border-radius: 26px;
  padding: 28px 24px; text-align: center;
  backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: 0 24px 70px var(--shadow), inset 0 1px 0 rgba(255,255,255,0.18);
  animation: pop .32s cubic-bezier(.2,.9,.3,1.3);
}
@keyframes pop { from { transform: scale(.85) translateY(10px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
.dialog h2 { font-family: var(--font-disp); font-size: 24px; margin-bottom: 12px; font-weight: 800; }
.dialog-msg { color: var(--muted); font-size: 14px; line-height: 1.5; margin-bottom: 18px; font-weight: 600; }
.win-illus { width: 88px; height: 88px; display: block; margin: 0 auto 6px; filter: drop-shadow(0 6px 14px rgba(245,166,35,0.4)); animation: burst .6s cubic-bezier(.2,.9,.3,1.4); }
@keyframes burst { 0% { transform: scale(0) rotate(-40deg); } 65% { transform: scale(1.3) rotate(10deg); } 100% { transform: scale(1); } }
.win-level { font-size: 16px; color: var(--muted); margin-bottom: 20px; font-weight: 700; }
.win-level span:last-child { color: var(--accent); font-weight: 800; font-size: 22px; }
.stuck-illus { width: 50px; height: 50px; display: block; margin: 0 auto 8px; stroke: #ffb12e; }

/* ---------- Buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px 18px; margin-top: 11px;
  border: none; border-radius: 17px; cursor: pointer;
  font-family: var(--font-disp); font-size: 17px; font-weight: 700; color: #fff;
  transition: transform .12s cubic-bezier(.2,.9,.3,1.4), filter .15s, box-shadow .15s; position: relative; overflow: hidden;
}
.btn::before {
  content: ""; position: absolute; top: 0; left: -60%; width: 50%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,0.35), transparent);
  transform: skewX(-20deg);
}
.btn-primary::before { animation: shine 3.4s ease-in-out infinite; }
@keyframes shine { 0%, 60% { left: -60%; } 80%, 100% { left: 130%; } }
.btn:active { transform: scale(.96); }
.btn-primary { background: linear-gradient(135deg, #2a8fff, #5ad7e6); box-shadow: 0 8px 22px rgba(42,143,255,0.45), inset 0 1px 0 rgba(255,255,255,0.3); }
.btn-secondary { background: var(--glass); border: 1px solid var(--glass-bd); color: var(--fg); }
.btn-secondary::before { display: none; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost::before { display: none; }
.btn-small { padding: 11px; font-size: 14px; margin-top: 8px; }
.btn-reward { background: linear-gradient(135deg, #ff9d2e, #ffc857); color: #2a1a00; box-shadow: 0 8px 22px rgba(255,160,0,0.4), inset 0 1px 0 rgba(255,255,255,0.4); }
.btn.vip { background: var(--glass); border: 1px solid var(--glass-bd); color: var(--accent); }
.btn.vip::before { display: none; }
.rw-ic { width: 20px; height: 20px; }
.rw-tag { font-size: 11px; background: rgba(0,0,0,0.16); padding: 3px 9px; border-radius: 9px; font-weight: 800; }

/* ---------- Settings ---------- */
.dialog-settings { text-align: left; }
.dialog-settings h2 { text-align: center; }
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 2px; border-bottom: 1px solid var(--glass-bd); font-size: 15px; font-weight: 700;
}
.toggle-btn {
  background: var(--glass); border: 1px solid var(--glass-bd); color: var(--fg);
  border-radius: 12px; padding: 8px 15px; font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: var(--font-body); min-width: 82px;
  transition: transform .1s;
}
.toggle-btn:active { transform: scale(.93); }
.dialog-settings .btn { margin-top: 12px; }
.credit { text-align: center; color: var(--muted); font-size: 11px; opacity: .6; margin: 12px 0 2px; }
.credit { text-align: center; color: var(--muted); font-size: 11px; opacity: .6; margin-top: 12px; }

/* ---------- Компакт: диалоги должны влезать без прокрутки (п.1.10.2) ---------- */
@media (max-height: 760px) {
  .dialog { padding: 18px 20px; border-radius: 20px; }
  .dialog h2 { font-size: 20px; margin-bottom: 8px; }
  .dialog-msg { font-size: 13px; margin-bottom: 12px; }
  .setting-row { padding: 8px 2px; font-size: 14px; }
  .toggle-btn { padding: 6px 12px; font-size: 13px; min-width: 74px; }
  .btn { padding: 12px 16px; margin-top: 8px; font-size: 15px; }
  .dialog-settings .btn { margin-top: 8px; }
  .btn-small { padding: 9px; }
  .credit { margin: 8px 0 0; }
  .win-illus { width: 64px; height: 64px; }
}
/* ---------- Компакт-HUD: короткий ландшафт, чтобы поле не сжималось (п.1.10.1) ---------- */
@media (max-height: 460px) {
  .hud { gap: 5px; padding-top: max(6px, env(safe-area-inset-top)); }
  .hud-level { font-size: 15px; padding: 5px 12px; border-radius: 11px; }
  .icon-gear { width: 34px; height: 34px; border-radius: 10px; }
  .tbtn { padding: 7px 4px; border-radius: 12px; }
  .tbtn-lbl { display: none; }
}

/* ---------- Toast ---------- */
.toast {
  position: absolute; bottom: 92px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--glass-strong); color: var(--fg); border: 1px solid var(--glass-bd);
  padding: 12px 22px; border-radius: 15px; font-size: 14px; font-weight: 700;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 20;
  box-shadow: 0 10px 30px var(--shadow); white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
