/* стиль сайту pu4ko: чорне тло, квадратики-паттерн, Onest, текст лише білий різної яскравості;
   зеленим буває тільки кнопка. кольори будівель — тільки на іконках і плитках поля. */
:root {
  color-scheme: dark;
  --green: #93d354;
  --green-hi: #a9e56d;
  --w80: rgba(255, 255, 255, 0.8);
  --w55: rgba(255, 255, 255, 0.55);
  --w35: rgba(255, 255, 255, 0.35);
  --tile: rgba(255, 255, 255, 0.05);
  --tile-hi: rgba(255, 255, 255, 0.085);
  --silver: linear-gradient(135deg, #fff 0%, #d4d4d4 45%, #999 100%);
  --plus: rgba(147, 211, 84, 0.85);
  --red: #ff6b5b;
  --minus: rgba(255, 107, 91, 0.85);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --r: 8px;
  --cell: 80px;
}
/* кольори будівель */
.c-house { --c: #ffffff; }
.c-tower { --c: #9cc2ff; }
.c-park { --c: #93d354; }
.c-school { --c: #ffd166; }
.c-mall { --c: #c4a1ff; }
.c-factory { --c: #ff9a62; }
.c-site { --c: #d9d9d9; }
.c-forest { --c: rgba(147, 211, 84, 0.45); }
.c-metro { --c: #5fd4c4; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: #000; }
body {
  min-height: 100svh;
  font-family: Onest, system-ui, sans-serif;
  font-weight: 500;
  color: var(--w80);
  background: #000;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--w55); outline-offset: 3px; border-radius: 6px; }

.bg { display: none; }

.top {
  position: relative; z-index: 2;
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 24px 0;
  font-size: 15px;
}
.back, .txt-btn { color: var(--w55); text-decoration: none; transition: color 0.2s; }
.back:hover, .txt-btn:hover { color: #fff; }

.game {
  position: relative; z-index: 1;
  display: flex; gap: 56px; justify-content: center; align-items: center;
  min-height: calc(100svh - 60px);
  padding: 12px 24px 32px;
}
.side { width: 360px; flex: none; display: flex; flex-direction: column; gap: 24px; }

.title { font-weight: 700; font-size: 26px; line-height: 1.1; letter-spacing: -0.03em; color: #fff; text-wrap: balance; }
.sub { color: var(--w35); }

/* ---- рівні: таблетки як чіпи на сайті ---- */
.levels { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.lvl {
  position: relative; min-width: 0; height: 40px; padding: 0 4px;
  border-radius: 66px; background: var(--tile); color: var(--w55);
  font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background 0.25s, color 0.25s, transform 0.3s var(--ease-back);
}
.lvl:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); color: #fff; }
.lvl:active:not(:disabled) { transform: scale(0.95); }
.lvl:disabled { opacity: 0.35; }
.lvl.is-done { background: var(--tile-hi); color: #fff; }
.lvl.is-cur { background: var(--silver); color: #000; }
.lvl svg { width: 14px; height: 14px; flex: none; }

/* ---- панель ---- */
.panel { display: flex; flex-direction: column; gap: 20px; }
.lv__name { font-weight: 700; font-size: 26px; line-height: 1.15; letter-spacing: -0.02em; color: #fff; text-wrap: balance; }
.lv__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tools { display: flex; gap: 4px; flex: none; }
.tool { width: 40px; height: 40px; display: grid; place-items: center; border-radius: var(--r); background: var(--tile); color: var(--w80); transition: background 0.2s, color 0.2s, transform 0.25s var(--ease-back), opacity 0.2s; }
.tool svg { width: 20px; height: 20px; }
.tool:hover:not(:disabled) { background: var(--tile-hi); color: #fff; }
.tool:active:not(:disabled) { transform: scale(0.9); }
.tool:disabled { opacity: 0.3; }
.tool.is-on { background: var(--silver); color: #000; }
.how__hint { color: var(--w35); }
.taptip { padding: 12px 14px; border-radius: var(--r); background: var(--silver); color: #000; font-size: 14px; line-height: 1.4; animation: rise 0.35s var(--ease-out); }
.how-btn { flex: none; font-size: 14px; color: var(--w55); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--w35); transition: color 0.2s; }
.how-btn:hover, .how-btn.is-open { color: #fff; }
.how { display: grid; gap: 8px; margin-top: 12px; padding: 16px 18px; border-radius: var(--r); background: var(--tile); font-size: 14px; line-height: 1.5; color: var(--w55); animation: rise 0.35s var(--ease-out); }
.how b { color: var(--w80); font-weight: 500; }

/* бонус за всі рівні */
.bonus__in { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r); background: var(--tile); font-size: 14px; line-height: 1.4; color: var(--w55); text-decoration: none; }
.bonus__in svg { flex: none; width: 22px; height: 22px; color: #fff; }
.bonus__in b { color: #fff; font-weight: 700; }
.bonus__in.is-won { background: var(--green); color: rgba(0, 0, 0, 0.75); }
.bonus__in.is-won svg, .bonus__in.is-won b { color: #000; }

.hud__row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.hud__score { font-size: 15px; color: var(--w55); }
.hud__score b { display: inline-block; font-weight: 700; font-size: 28px; color: #fff; letter-spacing: -0.02em; }
.hud__score.is-pop b { animation: pop 0.45s var(--ease-back); }
@keyframes pop { 40% { transform: scale(1.25); } }
.hud__goal { font-size: 15px; color: var(--w55); text-align: right; }
.bar { position: relative; margin-top: 10px; height: 8px; border-radius: 4px; background: var(--tile-hi); }
.bar__fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; background: var(--w55); transition: width 0.5s var(--ease-out); }
.bar.is-pass .bar__fill { background: var(--silver); }
.bar__mark { position: absolute; top: -4px; bottom: -4px; width: 2px; border-radius: 1px; background: var(--w35); }
.hud__left { margin-top: 10px; font-size: 14px; color: var(--w35); }

/* монети (рейтинг рівня): пласкі срібні, з'являються по черзі */
.coins { display: inline-flex; gap: 6px; }
.coin { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 700; font-size: 15px; }
.coin.on { background: linear-gradient(135deg, #fff 0%, #d4d4d4 45%, #999 100%); color: #000; animation: coinIn 0.6s var(--ease-back) both; }
.coin.off { background: var(--tile-hi); color: var(--w35); }
@keyframes coinIn { from { transform: scale(0) rotate(-90deg); } }

/* ---- картки будівель ---- */
.hand { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.card {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  padding: 12px 10px; border-radius: var(--r);
  background: var(--tile); text-align: left; color: var(--w80);
  transition: background 0.2s, transform 0.25s var(--ease-back);
}
.card:hover { background: var(--tile-hi); }
.card:active { transform: scale(0.95); }
.card svg { width: 26px; height: 26px; color: var(--c); }
.card__name { font-size: 14px; line-height: 1; }
.card__n { position: absolute; top: 10px; right: 10px; font-size: 13px; color: var(--w35); }
.card.is-sel { background: var(--silver); color: #000; }
.card.is-sel svg { color: #000; }
.card.is-sel .card__n { color: rgba(0, 0, 0, 0.55); }

.rules { font-size: 14px; line-height: 1.55; color: var(--w55); }
.rules h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-weight: 700; font-size: 17px; color: #fff; }
.rules h3 svg { width: 20px; height: 20px; color: var(--c); }
.rules li { list-style: none; }
.rules .tip { margin-top: 10px; color: var(--w35); }

.acts { display: flex; gap: 20px; font-size: 14px; }

/* ---- кнопки як на сайті ---- */
.btn { height: 52px; padding: 0 22px; border-radius: 4px; font-weight: 700; font-size: 16px; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; transition: transform 0.3s var(--ease-back), background 0.25s; }
.btn:active { transform: scale(0.95); }
.btn--green { background: var(--green); color: rgba(0, 0, 0, 0.85); }
.btn--green:hover { background: var(--green-hi); }
.btn--tile { background: var(--tile-hi); color: #fff; }
.btn--tile:hover { background: rgba(255, 255, 255, 0.14); }
.btns { display: flex; gap: 6px; } .btns .btn { flex: 1; padding: 0 12px; }

/* результат рівня — на місці карток будівель (на телефоні закріплений унизу) */
.res { display: flex; flex-direction: column; gap: 14px; padding: 20px; border-radius: var(--r); background: var(--tile); animation: rise 0.45s var(--ease-out); }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }
.res__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.res__t { font-weight: 700; font-size: 24px; line-height: 1.15; letter-spacing: -0.02em; color: #fff; }
.res__p { font-size: 14px; line-height: 1.45; color: var(--w55); margin-top: -6px; }
.res__btns { display: flex; gap: 6px; }
.res__btns .btn--green { flex: 1; gap: 8px; text-decoration: none; }
.res__ico { display: inline-grid; width: 18px; height: 18px; }
.res__ico svg, .btn--sq svg { width: 100%; height: 100%; }
.btn--sq { width: 52px; padding: 0; flex: none; }
.btn--sq svg { width: 20px; height: 20px; }

/* фінальний заклик: дві зелені кнопки, як головна кнопка сайту */
.cta { display: flex; gap: 4px; text-decoration: none; font-weight: 700; font-size: 16px; color: rgba(0, 0, 0, 0.85); }
.cta span { display: flex; align-items: center; justify-content: center; height: 52px; padding: 0 20px; border-radius: 4px; background: var(--green); transition: background 0.3s, transform 0.45s var(--ease-out); }
.cta span + span { flex: 1; }
.cta:hover span { background: var(--green-hi); }
.cta:hover span:first-child { transform: rotate(-3deg); }

/* ---- поле ---- */
.board-wrap { flex: none; }
.board {
  display: grid; gap: max(3px, calc(var(--cell) / 28));
  grid-template-columns: repeat(var(--w), var(--cell)); grid-auto-rows: var(--cell);
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.cell {
  position: relative; display: grid; place-items: center;
  border-radius: max(4px, calc(var(--cell) / 14));
  background: var(--tile);
  transition: background 0.18s, box-shadow 0.18s;
}
.board.is-in .cell { animation: cellIn 0.7s var(--ease-out) both; animation-delay: var(--d, 0s); }
@keyframes cellIn { from { opacity: 0; transform: scale(0.92); } }
.cell .ic { width: 44%; height: 44%; color: var(--c); pointer-events: none; }
.cell .ic svg { width: 100%; height: 100%; display: block; }
.cell.can { cursor: pointer; }
.cell.is-hover { background: rgba(255, 255, 255, 0.11); }
@media (hover: hover) { .cell.can:hover { background: rgba(255, 255, 255, 0.11); } }
.cell.built { background: color-mix(in srgb, var(--c) 12%, #0b0b0b); }
.cell.t-forest { background: color-mix(in srgb, #93d354 12%, #0b0b0b); }
.cell.t-metro { background: color-mix(in srgb, var(--c) 14%, #0b0b0b); }
.cell.is-placed .ic { animation: drop 0.5s var(--ease-back); }
@keyframes drop { from { transform: translateY(-25%) scale(0.4); opacity: 0; } }

.cell .val { position: absolute; right: 7%; bottom: 5%; font-size: max(10px, calc(var(--cell) / 6.5)); line-height: 1; color: var(--w35); pointer-events: none; }
.cell .ghost { position: absolute; inset: 28%; opacity: 0.5; color: var(--c); pointer-events: none; }
.cell .ghost svg { width: 100%; height: 100%; }
.cell .big { position: absolute; left: 50%; bottom: 6%; transform: translateX(-50%); font-weight: 700; font-size: max(13px, calc(var(--cell) / 4.2)); line-height: 1; color: #fff; white-space: nowrap; pointer-events: none; text-shadow: 0 1px 8px #000; }
.neg { color: var(--red) !important; }
.cell .tag { position: absolute; top: 6%; right: 7%; font-weight: 700; font-size: max(10px, calc(var(--cell) / 5.5)); line-height: 1; color: #fff; pointer-events: none; }
.cell.is-pos { box-shadow: inset 0 0 0 2px var(--plus); }
.cell.is-neg { box-shadow: inset 0 0 0 2px var(--minus); }
.cell .badge { position: absolute; top: 7%; left: 7%; width: 28%; height: 28%; transform-style: preserve-3d; animation: spin 2.4s linear infinite; pointer-events: none; }
.cell .badge i { position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 700; font-size: max(8px, calc(var(--cell) / 6.5)); color: #000; background: linear-gradient(to right, #fff, #999); backface-visibility: hidden; }
.cell .badge i + i { transform: rotateY(180deg); background: linear-gradient(to left, #fff, #999); }

.fly { position: fixed; z-index: 20; pointer-events: none; font-weight: 700; white-space: nowrap; color: #fff; transform: translate(-50%, -50%); text-shadow: 0 2px 12px #000; }
.spark { position: fixed; z-index: 20; pointer-events: none; font-weight: 700; color: #fff; }

/* ---- телефон ---- */
@media (max-width: 899px) {
  body { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
  body.is-done { padding-bottom: calc(200px + env(safe-area-inset-bottom, 0px)); }
  .hand {
    position: fixed; z-index: 10; left: 0; right: 0; bottom: 0;
    display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
    padding: 12px max(16px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0), #000 22%);
  }
  .hand::-webkit-scrollbar { display: none; }
  .hand .card { flex: 1 0 76px; }
  .bonus__in { padding: 9px 12px; font-size: 13px; gap: 10px; }
  .bonus__in svg { width: 18px; height: 18px; }
  .hud__score b { font-size: 24px; }
  .bar { margin-top: 8px; }
  .hud__left { margin-top: 8px; font-size: 13px; }
  .tool { width: 36px; height: 36px; }
  .tool svg { width: 18px; height: 18px; }
  .top { padding: 14px 16px 0; font-size: 14px; }
  .game { flex-direction: column; align-items: stretch; gap: 14px; padding: 8px 16px 20px; min-height: 0; }
  .side, .panel { display: contents; }
  .head { order: 1; padding-top: 12px; }
  .title { font-size: 24px; }
  .levels { order: 2; gap: 4px; }
  .levels::-webkit-scrollbar { display: none; }
  .lvl { height: 36px; font-size: 14px; }
  .lv { order: 3; }
  .taptip { order: 5; }
  .bonus { order: 2; }
  .hud { order: 4; }
  .board-wrap { order: 6; align-self: center; }
  .hand { order: 7; }
  .res {
    position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; border-radius: 14px 14px 0 0;
    padding: 18px max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
    background: #121212; box-shadow: 0 -20px 40px rgba(0, 0, 0, 0.7);
  }
  .res__t { font-size: 20px; }
  .res__btns .btn { flex: 1 1 auto; }
  .res__btns .btn--sq { flex: none; }
  .rules { order: 8; }
  .acts { order: 8; }
  .lv__name { font-size: 22px; }
  .card { padding: 10px 8px; gap: 8px; }
  .card svg { width: 22px; height: 22px; }
  .card__name { font-size: 13px; }
  .btn { flex: 1; }
  .cta { font-size: 15px; }
  .cta span { padding: 0 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .coin.on, .cell .badge, .board.is-in .cell { animation: none; }
}
.tool--sol { color: var(--w80); }
