/* Казуальный стиль в духе матч-3: кремовые панели с золотым кантом, пухлые кнопки с бортиком снизу,
   крупный жирный текст, чистые насыщенные цвета. Поле — на размытой фреске (рисует app.js). */
:root {
  --cream: #fff6e2;
  --cream-2: #ffeccc;
  --gold: #e9a93a;
  --brown: #5a3416;
  --brown-2: #8a5a2b;
  --muted: #9a6b3c;
  --line: #e7b35a;
  --orange: #ff9f1c;
  --orange-lo: #d9780b;
  --green: #5cc93a;
  --green-lo: #2f8f1f;
  --r: 18px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #3b2a1c; color: var(--brown);
  font: 15px/1.35 Nunito, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
b, strong { font-weight: 800; }

#field { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: pointer; }

/* --- общая «пухлая» панель */
.top, .dock, .sheet, .card, .chip, .me, .round {
  background: linear-gradient(var(--cream), var(--cream-2));
  border: 3px solid var(--line);
  box-shadow: 0 4px 0 #b9792a, 0 10px 24px rgba(0, 0, 0, .35);
}

/* --- шапка */
.top { position: fixed; top: 8px; left: 8px; right: 8px; display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: 22px; z-index: 5; margin-top: env(safe-area-inset-top); }
.brand { display: flex; align-items: center; gap: 6px; font-weight: 900; font-size: 20px; color: #c2541a; text-shadow: 0 1px 0 #fff; }
.brand img { width: 32px; height: 32px; }
.prog { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.prog .bar { height: 12px; border-radius: 7px; background: #e9d2a6; box-shadow: inset 0 2px 3px rgba(120, 70, 20, .3); overflow: hidden; }
.prog .bar i { display: block; height: 100%; width: 0; border-radius: 7px; transition: width .4s;
  background: linear-gradient(#8de065, var(--green)); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12), inset 0 2px 0 rgba(255, 255, 255, .5); }
.prog span { font-size: 12px; font-weight: 700; color: var(--brown-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip, .me { display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border-radius: 20px; border-width: 2px; box-shadow: 0 3px 0 #c98a3c; }
.chip svg { width: 20px; height: 20px; fill: var(--brown-2); stroke: var(--brown-2); stroke-width: .6; }
.chip b { font-size: 17px; }
.me img { width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 2px solid #fff; }
.me span { max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 800; }
.me b { color: var(--orange-lo); font-size: 17px; min-width: 1.5em; text-align: right; }
@media (max-width: 640px) {
  .brand span, .me span { display: none; }
  .top { gap: 8px; left: 6px; right: 6px; }
}

/* --- нижняя панель */
.dock { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(12px, env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 26px; z-index: 5; }
.tools { display: flex; gap: 4px; background: #ecd3a3; border-radius: 18px; padding: 4px; box-shadow: inset 0 2px 4px rgba(120, 70, 20, .3); }
.tools button { display: flex; align-items: center; gap: 6px; height: 48px; padding: 0 14px 0 8px; border: 0;
  border-radius: 14px; background: transparent; color: var(--brown-2); font-weight: 800; }
.tools button img { width: 34px; height: 34px; }
.tools button.on { background: linear-gradient(#ffd25e, var(--orange)); color: #5a2a06; box-shadow: 0 3px 0 var(--orange-lo); }
.round { width: 54px; height: 54px; border-radius: 50%; border-width: 2px; box-shadow: 0 3px 0 #c98a3c; display: grid; place-items: center; padding: 0; }
.round img { width: 34px; height: 34px; }
.round svg { width: 28px; height: 28px; fill: none; stroke: #c2541a; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.round b { font-size: 24px; font-weight: 900; color: #c2541a; }
.round.on { background: linear-gradient(#ffd25e, var(--orange)); }
.round:active, .tools button:active, .go:active, .ghost:active { transform: translateY(2px); }
@media (max-width: 420px) {
  .tools button span { display: none; }
  .tools button { padding: 0 8px; }
  .round { width: 48px; height: 48px; }
}

/* --- всплывающее */
.banner, .freeze, .toast { position: fixed; left: 50%; transform: translateX(-50%); z-index: 6; border-radius: 999px;
  padding: 8px 18px; font-weight: 800; text-align: center; max-width: calc(100% - 32px); }
.banner { top: 72px; background: linear-gradient(#ffd25e, var(--orange)); color: #5a2a06; border: 2px solid #fff3d0;
  box-shadow: 0 3px 0 var(--orange-lo), 0 8px 18px rgba(0, 0, 0, .3); font-size: 13px; }
.freeze { top: 46%; display: flex; align-items: center; gap: 10px; background: linear-gradient(#a8784a, #6e4a28); color: #fff;
  border: 3px solid #fff6e2; box-shadow: 0 4px 0 #4a2f18, 0 12px 30px rgba(0, 0, 0, .4); font-size: 18px; padding: 10px 22px 10px 12px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .2); }
.freeze img { width: 46px; height: 46px; filter: drop-shadow(0 0 3px #fff); }
.freeze b { font-size: 22px; }
.toast { bottom: 108px; background: rgba(60, 34, 14, .92); color: #fff6e2; font-size: 14px; box-shadow: 0 6px 18px rgba(0, 0, 0, .35); animation: pop .2s ease-out; }
@keyframes pop { from { transform: translate(-50%, 8px); opacity: 0; } }

.sheet { position: fixed; left: 50%; transform: translateX(-50%); bottom: 100px; z-index: 7; width: min(420px, calc(100% - 24px));
  border-radius: var(--r); padding: 14px; }
.sheet.wide { width: min(460px, calc(100% - 24px)); max-height: calc(100% - 190px); overflow: auto; }
.sheet h2 { font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: .6px; color: #c2541a; margin: 8px 0; }
.hint { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--brown-2); }
.emo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.emo-grid button { height: 74px; border-radius: 14px; border: 2px solid var(--line); background: #fff;
  box-shadow: 0 3px 0 #d9a24c; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 700; color: var(--brown-2); }
.emo-grid button:active { transform: translateY(2px); box-shadow: 0 1px 0 #d9a24c; }
.emo-grid img, .emo-grid canvas { width: 40px; height: 40px; }
.x { position: absolute; top: 6px; right: 8px; width: 34px; height: 34px; border: 0; background: none; font-size: 28px; font-weight: 800; color: var(--muted); }

.people { display: flex; flex-wrap: wrap; gap: 6px; }
.people button { display: flex; align-items: center; gap: 6px; border: 2px solid var(--line); background: #fff;
  border-radius: 999px; padding: 3px 10px 3px 3px; font-size: 13px; font-weight: 700; }
.people img, .leaders img { width: 28px; height: 28px; border-radius: 50%; border: 2px solid; background: #fff; }
.people .empty { color: var(--brown-2); font-size: 13px; }
ol.leaders { margin: 0; padding: 0; list-style: none; counter-reset: n; }
ol.leaders li { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 2px dashed #f0d3a0; counter-increment: n; font-weight: 700; }
ol.leaders li::before { content: counter(n); width: 22px; color: var(--muted); text-align: right; font-size: 13px; font-weight: 900; }
ol.leaders li span { flex: 1; }
ol.leaders li b { color: var(--orange-lo); font-size: 16px; }
ol.leaders li.me-row { background: #fff3c4; border-radius: 10px; }
ol.leaders li.empty::before { content: none; }
.mine { margin: 8px 0 0; color: var(--brown-2); font-size: 13px; font-weight: 600; }
ul.finds { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
ul.finds li { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--brown-2); }
ul.finds img { width: 66px; height: 46px; object-fit: cover; border-radius: 8px; border: 2px solid #fff; box-shadow: 0 2px 0 #d9a24c; }
ul.finds b { color: var(--brown); }

.modal { position: fixed; inset: 0; z-index: 9; background: rgba(30, 18, 8, .6); display: grid; place-items: center; padding: 16px; }
.card { position: relative; width: min(460px, 100%); max-height: 100%; overflow: auto; border-radius: 24px; padding: 22px; }
.card.center { text-align: center; }
.card h1 { margin: 0 0 14px; font-size: 24px; font-weight: 900; color: #c2541a; text-shadow: 0 1px 0 #fff; }
.rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.rules li { display: flex; gap: 12px; align-items: flex-start; }
.rules img { width: 46px; height: 46px; flex: none; }
.rules img.sq { border-radius: 10px; object-fit: cover; border: 2px solid #fff; }
.note { color: var(--brown-2); font-size: 13px; }
.go { width: 100%; height: 56px; border: 0; border-radius: 18px; margin-top: 8px; font-weight: 900; font-size: 20px; color: #fff;
  background: linear-gradient(#8de065, var(--green)); box-shadow: 0 5px 0 var(--green-lo), 0 10px 20px rgba(0, 0, 0, .25);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.ghost { width: 100%; height: 48px; border-radius: 16px; border: 0; font-weight: 800; color: #5a2a06;
  background: linear-gradient(#ffd25e, var(--orange)); box-shadow: 0 4px 0 var(--orange-lo); }
.ghost:disabled { opacity: .5; cursor: default; }
.me-big { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.me-big img { width: 68px; height: 68px; border-radius: 50%; border: 4px solid; background: #fff; }
.me-big b { display: block; font-size: 21px; }
.me-big span { color: var(--brown-2); font-size: 13px; }
.opt { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-weight: 700; }
.opt input { width: 22px; height: 22px; accent-color: var(--orange); }
.fresco { width: 100%; border-radius: 14px; border: 4px solid #fff; box-shadow: 0 0 0 3px var(--gold), 0 10px 30px rgba(0, 0, 0, .35); }
#done .card h1 { margin-top: 16px; }

/* --- мини-карта всего раскопа */
#map { position: fixed; right: 14px; bottom: 104px; width: 180px; z-index: 4; border-radius: 10px; cursor: pointer;
  border: 3px solid #fff6e2; box-shadow: 0 0 0 2px #b8aa90, 0 8px 20px rgba(0, 0, 0, .4); touch-action: none; }
@media (max-width: 640px) { #map { width: 112px; right: 8px; bottom: auto; top: 76px; } }

/* --- реклама РСЯ (только если сервер настроен: RASKOP_RSYA) */
.ad-side { position: fixed; left: 14px; bottom: 104px; width: 300px; z-index: 4; padding: 6px; border-radius: 12px;
  background: #fff6e2; border: 2px solid #e7b35a; box-shadow: 0 8px 20px rgba(0, 0, 0, .35); }
.ad-wrap { margin-top: 12px; }
.ad-slot { min-height: 50px; }
.ad-note { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); text-align: right; }

/* --- текстовые страницы (privacy.html) */
body.page { overflow: auto; padding: 16px; background: #3b2f24; }
.card.doc { margin: 24px auto; max-height: none; }
.card.doc h2 { font-size: 16px; color: #c2541a; margin: 16px 0 6px; }
.card.doc li { margin-bottom: 6px; }
.card.doc a { color: #c2541a; }

/* --- фон под полем: та же фреска, размытая браузером один раз (не перерисовывается каждый кадр) */
html, body { background: linear-gradient(#4a3a2a, #2b2118); }
#bg { position: fixed; inset: -80px; z-index: 0; background: center / cover no-repeat; opacity: 0;
  filter: blur(32px) brightness(.55) saturate(1.1); transition: opacity .6s; pointer-events: none; }
#bg.on { opacity: 1; }
#field { z-index: 1; }

/* --- ползунок яркости фрески в настройках */
.opt.range { gap: 12px; }
.opt.range input[type=range] { flex: 1; width: auto; height: 22px; accent-color: var(--orange); }
.opt.range input[type=range]:disabled { opacity: .4; }
.opt.range b { min-width: 3.2em; text-align: right; color: var(--orange-lo); }

/* --- шестерёнка на кнопке с ником: видно, что там настройки */
.me .gear { width: 22px; height: 22px; flex: none; fill: none; stroke: #c2541a; stroke-width: 1.8; stroke-linejoin: round;
  margin-left: 2px; transition: transform .4s; }
.me:hover .gear { transform: rotate(60deg); }

/* --- обучение */
.modal.tut .card { width: min(420px, 100%); text-align: center; }
.modal.tut #tut-text { min-height: 4.2em; margin: 0 0 12px; font-weight: 600; color: var(--brown-2); }
#tut-cv { display: block; width: 100%; border-radius: 10px; border: 3px solid #b8aa90; touch-action: none; cursor: pointer; background: #5a4630; }
.dots { margin: 10px 0 4px; letter-spacing: 3px; color: var(--orange-lo); font-size: 12px; }
button.link { margin-top: 8px; border: 0; background: none; color: var(--muted); font-weight: 700; text-decoration: underline; padding: 6px; }
.ghost + .ghost, .go + .ghost { margin-top: 10px; }
.tut-again { margin: 4px 0 8px; }

/* кнопки окна правил всегда видны внизу карточки, даже когда правила длиннее экрана */
.card .actions { position: sticky; bottom: -22px; margin: 12px -22px -22px; padding: 12px 22px 18px;
  background: linear-gradient(rgba(255, 236, 204, 0), var(--cream-2) 18%); }
