@font-face { font-family: 'Rubik'; src: url('fonts/Rubik.ttf') format('truetype'); font-weight: 300 900; font-display: swap; }

:root {
  --ink: #16222e;          /* контур и основной текст */
  --sky-top: #6cc0f5;
  --sky-bottom: #c4e9ff;
  --mandarin: #ff8a1f;     /* главный акцент */
  --mandarin-deep: #c45a00;
  --grass: #5fcf3a;
  --grass-deep: #2f8a1a;
  --soil: #7a4a24;
  --paper: #ffffff;
  --paper-2: #eef7ff;
  --muted: #4d6273;
  --gold: #ffcc33;
  --radius: 22px;
  --press: 160ms cubic-bezier(.3, .7, .4, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--sky-bottom); color: var(--ink);
  font-family: 'Rubik', system-ui, sans-serif; -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
img, video { -webkit-user-drag: none; }

/* ---------- фон-мир: небо, облака, холмы ---------- */
#world { position: fixed; inset: 0; overflow: hidden;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 70%); }
.cloud { position: absolute; width: 140px; height: 46px; background: var(--cloud, #fff); border-radius: 40px; opacity: .9;
  animation: drift linear infinite; }
.cloud::before, .cloud::after { content: ''; position: absolute; background: var(--cloud, #fff); border-radius: 50%; }
.cloud::before { width: 64px; height: 64px; left: 22px; top: -30px; }
.cloud::after { width: 46px; height: 46px; left: 72px; top: -20px; }
@keyframes drift { from { transform: translateX(-180px); } to { transform: translateX(calc(100vw + 40px)); } }
.hill { position: absolute; left: -10%; right: -10%; bottom: -60px; height: 190px; border-radius: 50% 50% 0 0;
  background: var(--hill, var(--grass)); border-top: 4px solid rgba(0,0,0,.18); }
.hill.back { bottom: -30px; height: 230px; left: 30%; right: -40%; background: var(--hill-back, #4fb92e); }

/* ---------- экраны ---------- */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center;
  padding: calc(18px + env(safe-area-inset-top)) 18px calc(18px + env(safe-area-inset-bottom));
  opacity: 0; pointer-events: none; transform: translateY(18px) scale(.98);
  transition: opacity 220ms ease-out, transform 280ms cubic-bezier(.2, .9, .3, 1.2); }
.screen.on { opacity: 1; pointer-events: auto; transform: none; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ---------- заголовки ---------- */
.title { font-weight: 900; font-size: clamp(38px, 11vw, 56px); line-height: .95; margin: 0; text-align: center;
  color: #fff; -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; letter-spacing: .5px;
  text-shadow: 0 6px 0 var(--ink); transform: rotate(-3deg); }
.title span { display: block; color: var(--title-sub, var(--mandarin)); font-size: 1.12em; transform: rotate(2deg) translateX(14px); }
.h2 { font-weight: 900; font-size: 30px; margin: 4px 0 14px; color: #fff; -webkit-text-stroke: 6px var(--ink);
  paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); }

/* ---------- кнопки: объёмные, продавливаются ---------- */
.btn { display: flex; align-items: center; gap: 12px; width: min(330px, 86vw); min-height: 64px; padding: 8px 20px 8px 10px;
  font: 800 22px 'Rubik', sans-serif; color: var(--ink); background: var(--paper); border: 3px solid var(--ink);
  border-radius: var(--radius); box-shadow: 0 7px 0 var(--ink); cursor: pointer;
  transition: transform var(--press), box-shadow var(--press); position: relative; }
.btn img { width: 46px; height: 46px; flex: none; }
.btn:active, .btn.down { transform: translateY(6px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: var(--mandarin); min-height: 78px; font-size: 28px; }
.btn.primary img { width: 58px; height: 58px; }
.btn.small { width: auto; min-height: 52px; font-size: 18px; padding: 6px 16px 6px 8px; }
.btn.small img { width: 36px; height: 36px; }
.btn.icon { width: 60px; min-height: 60px; padding: 0; justify-content: center; }
.btn.icon img { width: 40px; height: 40px; }
.btn .sub { font-size: 13px; font-weight: 500; color: var(--muted); display: block; margin-top: 2px; }
.menu-list { display: flex; flex-direction: column; gap: 16px; align-items: center; margin-top: auto; margin-bottom: 8px; }

/* ---------- главное меню ---------- */
#menu .hero { position: relative; width: min(300px, 74vw); aspect-ratio: 1; margin: 6px 0 -10px; }
#menu .hero video, #menu .hero img { width: 100%; height: 100%; object-fit: contain; }
#menu .side { position: absolute; width: 34vw; max-width: 150px; }
#menu .side.l { left: -2vw; bottom: 150px; transform: rotate(-8deg); }
#menu .side.r { right: -4vw; top: 30%; }
.best-chip { margin-top: 6px; font-weight: 700; font-size: 16px; background: rgba(255,255,255,.85); border: 3px solid var(--ink);
  border-radius: 14px; padding: 6px 12px; display: flex; align-items: center; gap: 6px; }
.best-chip img { width: 26px; height: 26px; }

/* ---------- панель-карточка ---------- */
.panel { width: min(400px, 92vw); background: var(--paper); border: 3px solid var(--ink); border-radius: var(--radius);
  box-shadow: 0 7px 0 var(--ink); padding: 16px 18px; }
.panel + .panel { margin-top: 18px; }
.panel h3 { margin: 0 0 8px; font-size: 19px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.panel h3 img { width: 30px; height: 30px; }
.panel p { margin: 0 0 8px; font-size: 16px; line-height: 1.5; color: var(--ink); }
.panel .muted { color: var(--muted); font-size: 14px; }
.topbar { width: min(400px, 92vw); display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }

/* ---------- рекорды ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 2px dashed #d5e6f3; font-size: 17px; font-weight: 600; }
.rows li:last-child { border-bottom: 0; }
.rows .n { width: 34px; text-align: center; font-weight: 800; color: var(--muted); flex: none; }
.rows .n img { width: 30px; height: 30px; display: block; margin: auto; }
.rows .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .pts { font-weight: 900; font-variant-numeric: tabular-nums; }
.rows li.me { background: #fff3e2; border-radius: 12px; }

/* ---------- об игре ---------- */
.credit { display: flex; gap: 12px; align-items: flex-start; margin: 12px 0; }
.credit img.av { width: 54px; height: 54px; flex: none; }
.credit b { display: block; font-size: 18px; }
.credit span { font-size: 15px; color: var(--muted); }
.made { display: grid; grid-template-columns: 40px 1fr; gap: 10px 10px; align-items: center; font-size: 15px; }
.made img { width: 40px; height: 40px; }
.stack-logo { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 24px; }
.stack-logo img { width: 48px; height: 48px; }
.stack-logo > span { font-weight: 700; font-size: 28px; color: #16171C; letter-spacing: -.3px; }
.stack-logo .w { color: #FF4A1C; }

/* ---------- настройки ---------- */
.switch { display: flex; align-items: center; gap: 12px; padding: 10px 0; font-size: 18px; font-weight: 600; }
.switch img { width: 40px; height: 40px; }
.switch .grow { flex: 1; }
.toggle { width: 66px; height: 38px; border-radius: 20px; border: 3px solid var(--ink); background: #cfdce6; position: relative;
  transition: background 200ms; flex: none; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; border: 3px solid var(--ink); transition: transform 220ms cubic-bezier(.3, 1.4, .5, 1); }
.toggle.on { background: var(--grass); }
.toggle.on::after { transform: translateX(28px); }
input.name { font: 600 19px 'Rubik', sans-serif; width: 100%; padding: 12px 14px; border: 3px solid var(--ink); border-radius: 14px;
  background: var(--paper-2); color: var(--ink); -webkit-user-select: text; user-select: text; }
label.lab { display: block; font-weight: 700; font-size: 15px; margin-bottom: 6px; }

/* ---------- игра ---------- */
#game { padding: 0; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 0; pointer-events: none; }
.hud .score { font-weight: 900; font-size: 38px; color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill;
  font-variant-numeric: tabular-nums; }
.hud .grow { flex: 1; }
.hud .mand { display: flex; align-items: center; gap: 4px; font-weight: 900; font-size: 26px; color: #fff;
  -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; }
.hud .mand img { width: 34px; height: 34px; }
.hud .btn { pointer-events: auto; }
.pad { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; gap: 14px;
  padding: 0 14px calc(14px + env(safe-area-inset-bottom)); }
.arrow { flex: 1; height: 96px; border-radius: 26px; border: 3px solid var(--ink); background: rgba(255, 255, 255, .55);
  box-shadow: 0 7px 0 var(--ink); display: flex; align-items: center; justify-content: center; touch-action: none;
  transition: transform 90ms, box-shadow 90ms, background 90ms; }
.arrow svg { width: 52px; height: 52px; }
.arrow.on { transform: translateY(6px); box-shadow: 0 1px 0 var(--ink); background: rgba(255, 138, 31, .9); }
.pad.hidden { display: none; }

/* ---------- окна поверх игры ---------- */
.modal { position: fixed; inset: 0; background: rgba(10, 18, 28, .55); display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 180ms; padding: 18px; }
.modal.on { opacity: 1; pointer-events: auto; }
.modal .panel { text-align: center; transform: scale(.85) rotate(-2deg); transition: transform 300ms cubic-bezier(.2, 1.4, .4, 1); }
.modal.on .panel { transform: none; }
.modal .big { font-weight: 900; font-size: 74px; line-height: 1; margin: 6px 0; font-variant-numeric: tabular-nums; }
.modal .row { display: flex; gap: 12px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.newrec { display: inline-flex; align-items: center; gap: 6px; background: var(--gold); border: 3px solid var(--ink); border-radius: 12px;
  padding: 4px 12px; font-weight: 900; animation: wob 900ms ease-in-out infinite; }
.newrec img { width: 28px; height: 28px; }
@keyframes wob { 0%, 100% { transform: rotate(-4deg) scale(1); } 50% { transform: rotate(4deg) scale(1.08); } }

@media (prefers-reduced-motion: reduce) {
  .cloud, .newrec { animation: none; }
  .screen, .modal .panel { transition: none; }
}

/* активные бонусы в HUD */
.fxs { display: flex; gap: 6px; }
.fx { position: relative; width: 40px; height: 44px; background: rgba(255,255,255,.85); border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; }
.fx img { width: 30px; height: 30px; display: block; margin: 2px auto 0; }
.fx i { position: absolute; left: 0; bottom: 0; height: 5px; background: var(--mandarin); }
#menu .side { z-index: 0; }
#menu .side.l { left: -8vw; top: 19%; bottom: auto; width: 34vw; max-width: 160px; transform: rotate(-8deg); }
#menu .side.r { right: -2vw; top: 6%; width: 26vw; max-width: 120px; }
#menu .title, #menu .hero, #menu .menu-list, #menu .best-chip { position: relative; z-index: 1; }
.deco { width: 120px; height: 120px; margin: -10px 0 -18px; position: relative; z-index: 1; }

.btn:disabled { opacity: .5; transform: none; box-shadow: 0 7px 0 var(--ink); }
#hello .hero { width: min(230px, 56vw); aspect-ratio: 1; margin: 6px 0; }
#hello .hero video { width: 100%; height: 100%; object-fit: contain; }

/* ---------- темы ---------- */
#fxbg { position: absolute; inset: 0; width: 100%; height: 100%; }
#decor img { position: absolute; width: 15vw; max-width: 74px; transform: rotate(var(--r)); animation: floaty 4.5s ease-in-out infinite; opacity: .95; }
#decor img.moon { width: 30vw; max-width: 140px; left: auto; right: 6%; top: 3%; animation: none; filter: drop-shadow(0 0 18px rgba(255,240,180,.6)); }
@keyframes floaty { 0%, 100% { transform: translateY(0) rotate(var(--r)); } 50% { transform: translateY(-10px) rotate(calc(var(--r) * -1)); } }
.greet { position: relative; z-index: 1; margin-top: 10px; font-weight: 800; font-size: 17px; color: #fff; background: var(--ink);
  border-radius: 12px; padding: 5px 12px; transform: rotate(-2deg); }
.themes { display: flex; flex-wrap: wrap; gap: 8px; }
.themes button { font: 700 15px 'Rubik', sans-serif; display: flex; align-items: center; gap: 6px; padding: 6px 10px 6px 6px;
  border: 3px solid var(--ink); border-radius: 14px; background: var(--paper); color: var(--ink); box-shadow: 0 4px 0 var(--ink); min-height: 44px; }
.themes button img { width: 28px; height: 28px; }
.themes button.on { background: var(--grass); }
.themes button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
[data-theme="halloween"] .cloud, [data-theme="halloween"] .cloud::before, [data-theme="halloween"] .cloud::after { filter: blur(1px); }
@media (prefers-reduced-motion: reduce) { #decor img { animation: none; } }

/* ---------- меню под любую высоту экрана ---------- */
#menu, #hello { overflow-y: auto; -webkit-overflow-scrolling: touch; height: 100dvh; }
#menu .title, #hello .title { font-size: clamp(30px, min(11vw, 6.2dvh), 56px); }
#menu .hero { flex: 1 1 0; min-height: 110px; max-height: 300px; width: auto; aspect-ratio: 1; margin: 4px 0 -6px; }
#hello .hero { flex: 1 1 0; min-height: 90px; max-height: 230px; width: auto; aspect-ratio: 1; }
#menu .greet { margin-top: clamp(4px, 1dvh, 10px); font-size: clamp(14px, 2dvh, 17px); }
#menu .best-chip { margin-top: 4px; }
#menu .menu-list { gap: clamp(9px, 1.6dvh, 16px); margin-top: clamp(10px, 2dvh, 20px); }
#menu .btn { min-height: clamp(50px, 7dvh, 64px); font-size: clamp(18px, 2.6dvh, 22px); }
#menu .btn img { width: clamp(34px, 5dvh, 46px); height: clamp(34px, 5dvh, 46px); }
#menu .btn.primary { min-height: clamp(58px, 8.6dvh, 78px); font-size: clamp(22px, 3.2dvh, 28px); }
#menu .btn.primary img { width: clamp(42px, 6.4dvh, 58px); height: clamp(42px, 6.4dvh, 58px); }
#menu .menu-list { padding-bottom: 8px; }

/* касания по экрану вместо кнопок */
.tapzone { position: absolute; inset: 0; touch-action: none; z-index: 1; }
.hud { z-index: 2; }
.taphint { position: absolute; left: 0; right: 0; bottom: calc(40px + env(safe-area-inset-bottom)); display: flex; justify-content: space-between;
  padding: 0 20px; pointer-events: none; z-index: 2; transition: opacity 400ms; }
.taphint span { font-weight: 800; font-size: 17px; color: #fff; background: rgba(22,34,46,.6); border-radius: 12px; padding: 6px 12px; }
.taphint.gone { opacity: 0; }

/* ---------- меню 2x2, кошелёк, магазин ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(9px, 1.6dvh, 14px); width: min(330px, 86vw); }
.grid2 .btn { width: 100%; padding: 6px 8px; gap: 6px; font-size: clamp(15px, 2.2dvh, 18px) !important; min-height: clamp(50px, 7dvh, 62px) !important; }
.grid2 .btn img { width: clamp(30px, 4.4dvh, 38px) !important; height: clamp(30px, 4.4dvh, 38px) !important; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; position: relative; z-index: 1; }
.chips .best-chip { font-size: 14px; padding: 4px 10px; }
.wallet { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; background: var(--paper); border: 3px solid var(--ink);
  border-radius: 16px; padding: 8px 14px; box-shadow: 0 5px 0 var(--ink); margin-bottom: 14px; }
.wallet img { width: 34px; height: 34px; }
.tabs { display: flex; gap: 10px; margin-bottom: 14px; }
.tab { display: flex; align-items: center; gap: 6px; font: 800 17px 'Rubik', sans-serif; padding: 8px 16px 8px 10px; border: 3px solid var(--ink);
  border-radius: 14px; background: var(--paper); color: var(--ink); box-shadow: 0 4px 0 var(--ink); min-height: 48px; }
.tab img { width: 28px; height: 28px; }
.tab.on { background: var(--mandarin); }
.cards { width: min(400px, 94vw); display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card { background: var(--paper); border: 3px solid var(--ink); border-radius: 18px; box-shadow: 0 5px 0 var(--ink); padding: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.card .pic { width: 100%; aspect-ratio: 1.25; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: var(--paper-2); overflow: hidden; }
.card .pic img { max-width: 86%; max-height: 86%; }
.card.map .pic img { width: 56%; }
.card b { font-size: 16px; line-height: 1.15; }
.card .desc { font-size: 12.5px; color: var(--muted); line-height: 1.3; min-height: 32px; }
.card .act { width: 100%; font: 800 15px 'Rubik', sans-serif; border: 3px solid var(--ink); border-radius: 12px; min-height: 44px;
  display: flex; align-items: center; justify-content: center; gap: 4px; box-shadow: 0 3px 0 var(--ink); background: var(--mandarin); color: var(--ink); }
.card .act img { width: 22px; height: 22px; }
.card .act.own { background: var(--paper-2); }
.card .act.sel { background: var(--grass); }
.card .act.no { opacity: .55; }
.card .act:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.earn { margin-top: 6px; font-weight: 800; font-size: 17px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.earn img { width: 28px; height: 28px; }

.card.life { grid-column: 1 / -1; }
.card.life .pic { aspect-ratio: 2.4; }
.card.life .pic img { height: 80%; width: auto; }
#continueBtn { background: #ff6f91; }
.tabs { flex-wrap: wrap; justify-content: center; }

.say67 { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); font-weight: 900; font-size: 54px; color: #ffd23f;
  -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; animation: say 900ms ease-out forwards; pointer-events: none; white-space: nowrap; }
@keyframes say { from { opacity: 0; transform: translate(-50%, -30%) scale(.6) rotate(-8deg); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1.15) rotate(4deg); } to { opacity: 0; transform: translate(-50%, -120%) scale(1) rotate(-3deg); } }

/* 3D-бег и переход */
#cv3 { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
#game.run3d #cv3 { display: block; }
#iris { position: fixed; inset: 0; z-index: 60; background: var(--ink); pointer-events: none; clip-path: circle(0% at 50% 45%);
  display: flex; align-items: center; justify-content: center; }
#iris.play { animation: iris 1600ms cubic-bezier(.6, 0, .4, 1) forwards; }
@keyframes iris { 0% { clip-path: circle(0% at 50% 45%); } 32%, 68% { clip-path: circle(150% at 50% 45%); } 100% { clip-path: circle(0% at 50% 45%); } }
.iris-card { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; text-align: center; padding: 0 24px; }
.iris-card img { width: 120px; height: 120px; }
.iris-card b { font-size: 40px; font-weight: 900; color: var(--mandarin); -webkit-text-stroke: 2px #000; }
.iris-card span { font-size: 17px; font-weight: 600; opacity: .9; max-width: 320px; }
#iris.play .iris-card { animation: card 1600ms ease-out forwards; }
@keyframes card { 0%, 25% { opacity: 0; transform: scale(.6) rotate(-6deg); } 40% { opacity: 1; transform: scale(1.08) rotate(2deg); } 60% { opacity: 1; transform: scale(1); } 75%, 100% { opacity: 0; transform: scale(.9); } }

.rows li.note { font-size: 13px; font-weight: 500; color: var(--muted); border-bottom: 0; }

#buyContBtn { background: #ffd23f; font-size: 20px; }
#mOver .row { flex-wrap: wrap; }
