/* «Стрелочки» — стиль набора игр: тёмный космос, мягкие пузыри. */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: radial-gradient(120% 90% at 50% 0%, #3d3164 0%, #2a2150 45%, #1d163a 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#bubbles { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
#bubbles span {
  position: absolute; bottom: -14vmin; border-radius: 50%;
  background: rgba(255,255,255,.05);
  animation: floatUp linear infinite;
}
@keyframes floatUp {
  from { transform: translateY(0); }
  to   { transform: translateY(-120vh); }
}

header {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 2.4vmin 3.5vmin 0;
}
#coinbox {
  font-size: clamp(15px, 3.6vmin, 22px); font-weight: 700;
  background: rgba(255,255,255,.1); border-radius: 999px; padding: 1vmin 2.6vmin;
}
#levelbox {
  font-size: clamp(17px, 4.4vmin, 26px); font-weight: 800; letter-spacing: .5px;
  text-shadow: 0 2px 8px rgba(0,0,0,.4);
}
header .btns button {
  font-size: clamp(17px, 4.4vmin, 24px);
  background: rgba(255,255,255,.1); border: none; color: #fff;
  border-radius: 999px; width: clamp(38px, 9vmin, 52px); height: clamp(38px, 9vmin, 52px);
}

main#stage {
  position: relative; z-index: 1;
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3vmin;
  overflow: hidden;
}
#board { position: relative; }
#board svg { display: block; overflow: hidden; }

/* режим «Кубик 3D» */
#scene {
  width: var(--cube); height: var(--cube);
  perspective: calc(var(--cube) * 3.2);
}
#cube {
  width: 100%; height: 100%; position: relative;
  transform-style: preserve-3d;
  will-change: transform;
}
.cface {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}
.cface canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ccell { position: absolute; background: transparent; }
#mode {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: clamp(17px, 4.4vmin, 24px);
  background: rgba(255,255,255,.1); color: #fff; text-decoration: none;
  border-radius: 999px; width: clamp(38px, 9vmin, 52px); height: clamp(38px, 9vmin, 52px);
}
header .btns { display: flex; gap: 1.6vmin; }
.left { display: flex; align-items: center; gap: 1.6vmin; }
a.home {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: clamp(17px, 4.4vmin, 24px);
  background: rgba(255,255,255,.1); color: #fff; text-decoration: none;
  border-radius: 999px; width: clamp(38px, 9vmin, 52px); height: clamp(38px, 9vmin, 52px);
}

.snake { cursor: pointer; }
.snake .ah {
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.4));
  pointer-events: none;
}

#caption {
  font-size: clamp(13px, 3.2vmin, 19px); color: #c9c0ea;
  text-shadow: 0 2px 6px rgba(0,0,0,.4);
  min-height: 1.4em;
  position: relative; z-index: 3;
}

footer {
  position: relative; z-index: 2;
  display: flex; justify-content: center; gap: 5vmin;
  padding: 0 4vmin calc(3vmin + env(safe-area-inset-bottom));
}
footer button {
  position: relative;
  font-size: clamp(22px, 6vmin, 34px);
  width: clamp(58px, 15vmin, 84px); height: clamp(58px, 15vmin, 84px);
  border: none; border-radius: 26px; color: #fff;
  background: linear-gradient(165deg, rgba(255,255,255,.16), rgba(255,255,255,.06));
  box-shadow: 0 6px 14px rgba(0,0,0,.35), inset 0 1px 1px rgba(255,255,255,.25);
  transition: transform .12s ease;
}
footer button:active { transform: scale(.92); }
footer button sup {
  position: absolute; right: 6px; top: 8px;
  font-size: clamp(10px, 2.4vmin, 13px); font-weight: 800; color: #ffd54f;
}
footer button.disabled { opacity: .4; }

.overlay {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(20, 14, 40, .72);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(3px);
}
.overlay.hidden { display: none; }
.overlay .card {
  background: linear-gradient(165deg, #453a70, #332a58);
  border: 2px solid rgba(255,255,255,.18);
  border-radius: 30px; padding: 6vmin 9vmin;
  text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.5);
  animation: pop .35s cubic-bezier(.34,1.56,.64,1);
}
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.card .star { font-size: clamp(44px, 13vmin, 80px); animation: spinstar 1.6s ease infinite alternate; }
@keyframes spinstar { from { transform: rotate(-12deg) scale(1); } to { transform: rotate(12deg) scale(1.15); } }
.card .big { font-size: clamp(20px, 5.4vmin, 32px); font-weight: 800; margin: 2vmin 0 1vmin; }
#winCoins { font-size: clamp(16px, 4.2vmin, 24px); color: #ffd54f; font-weight: 700; margin-bottom: 3.4vmin; }
.card button {
  font-size: clamp(17px, 4.6vmin, 26px); font-weight: 800; color: #4b3200;
  background: linear-gradient(180deg, #ffd54f, #ffb300);
  border: none; border-radius: 999px; padding: 2.2vmin 8vmin;
  box-shadow: 0 4px 10px rgba(0,0,0,.3), inset 0 2px 2px rgba(255,255,255,.5);
}

#toast {
  position: fixed; left: 50%; bottom: 22vmin; transform: translateX(-50%);
  background: rgba(30,22,58,.92); color: #fff; font-size: clamp(14px, 3.4vmin, 19px);
  padding: 1.6vmin 4vmin; border-radius: 999px; opacity: 0;
  transition: opacity .25s ease; pointer-events: none; z-index: 20;
  border: 1px solid rgba(255,255,255,.15); white-space: nowrap;
}
#toast.show { opacity: 1; }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 15; overflow: hidden; }
#confetti i {
  position: absolute; top: -4vmin; display: block;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(115vh) rotate(720deg); opacity: .9; }
}

