/* ── Отдых / Relax — Zen breathing + ambient particle field ─────────────
 * Self-contained canvas experience. No score, no fail state. The page hosts
 * a full-bleed dark canvas with a floating control bar; everything visual is
 * painted on the canvas (orb, particles, gradient), the DOM only carries the
 * controls + stats so they stay crisp and translatable. */

.relax {
  position: relative;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  border-radius: 20px;
  overflow: hidden;
  background: #07070b;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  /* Tall, immersive, but never taller than the viewport. */
  height: min(74vh, 760px);
  min-height: 420px;
  cursor: crosshair;
  touch-action: none;
}

.relax__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Top-left: subtle session stats (breaths · time). Painted lightly so it
 * never competes with the orb. */
.relax__stats {
  position: absolute;
  top: 18px;
  left: 20px;
  font-size: 12.5px;
  letter-spacing: 0.3px;
  color: rgba(255, 255, 255, 0.5);
  user-select: none;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

/* Bottom control bar — pattern picker + play/pause. Floats over the canvas,
 * fades when the pointer is idle (set via .is-dim from JS). */
.relax__bar {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 10px 8px 14px;
  border-radius: 999px;
  background: rgba(10, 10, 16, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: opacity 0.6s ease;
}
.relax__bar.is-dim {
  opacity: 0.18;
}

.relax__patterns {
  display: flex;
  gap: 4px;
}
.relax__patterns button {
  border: none;
  background: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
  white-space: nowrap;
}
.relax__patterns button:hover {
  color: #fff;
}
.relax__patterns button.is-active {
  background: rgba(129, 140, 248, 0.18);
  color: #c7d2fe;
}

.relax__toggle {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.relax__toggle:hover {
  background: rgba(129, 140, 248, 0.18);
  border-color: rgba(129, 140, 248, 0.4);
}
.relax__toggle svg {
  width: 16px;
  height: 16px;
}

/* Page heading above the arcade. */
.relax-head {
  max-width: 1200px;
  margin: 0 auto 16px;
  text-align: center;
}
.relax-head__title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.relax-head__sub {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin: 0;
}

/* ── Arcade game switcher ─────────────────────────────────────────── */
.relax-tabs {
  max-width: 1200px;
  margin: 0 auto 16px;
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.relax-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 12px;
  border: 1px solid rgba(var(--fg-rgb), 0.1);
  background: rgba(var(--panel-rgb), 0.5);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.relax-tab:hover { color: var(--text); }
.relax-tab.is-active {
  color: #c7d2fe;
  border-color: rgba(129, 140, 248, 0.45);
  background: rgba(129, 140, 248, 0.14);
}
.relax-tab.is-soon {
  cursor: default;
  border-style: dashed;
  opacity: 0.6;
}
.relax-tab__icon { font-size: 16px; line-height: 1; }

.relax-stage { position: relative; }
.relax-stage [hidden] { display: none; }

/* ── Game 2: "Wish for today" — only good things come out ──────────── */
.relax-wish {
  position: relative;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  height: min(74vh, 760px);
  min-height: 420px;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(120% 90% at 50% 18%, rgba(129, 140, 248, 0.16), transparent 60%),
    radial-gradient(90% 80% at 50% 100%, rgba(244, 114, 182, 0.12), transparent 55%),
    #07070b;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.relax-wish__card {
  position: relative;
  width: min(86%, 560px);
  min-height: 280px;
  padding: 40px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.4);
}
.relax-wish__date {
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 18px;
}
.relax-wish__emoji {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 18px;
  filter: drop-shadow(0 4px 14px rgba(129, 140, 248, 0.4));
}
.relax-wish__text {
  font-size: 21px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: -0.01em;
  color: #f4f4f8;
  margin: 0 0 4px;
  text-wrap: balance;
}
.relax-wish__prompt {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.62);
  margin: 0 0 22px;
  max-width: 360px;
  line-height: 1.5;
}
/* Reveal animation: gentle scale + fade, no jarring motion. */
.relax-wish__reveal {
  animation: relax-wish-in 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes relax-wish-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); filter: blur(6px); }
  to   { opacity: 1; transform: none; filter: none; }
}

.relax-wish__btn {
  border: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  padding: 13px 28px;
  border-radius: 999px;
  cursor: pointer;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
  transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
}
.relax-wish__btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
.relax-wish__btn:active { transform: translateY(0); }

.relax-wish__again {
  margin-top: 20px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: color 0.2s;
}
.relax-wish__again:hover { color: #c7d2fe; }

@media (max-width: 560px) {
  .relax, .relax-wish, .relax-m3 { height: min(70vh, 600px); border-radius: 16px; }
  .relax__patterns button { padding: 6px 9px; font-size: 12px; }
  .relax-head__title { font-size: 19px; }
  .relax-wish__text { font-size: 18px; }
  .relax-wish__emoji { font-size: 34px; }
  .relax-wish__card { padding: 28px 18px; width: min(92%, 560px); }
  .relax-roulette__item { padding: 0 10px; }
}

/* ── SVG tab icons (replace emoji — render reliably everywhere) ─────── */
.relax-tab__icon { width: 16px; height: 16px; flex-shrink: 0; }
svg.relax-tab__icon { display: block; }

/* ── Wish roulette (casino-style spin reveal) ──────────────────────── */
.relax-roulette { position: relative; width: 100%; max-width: 440px; margin: 2px auto 0; }
.relax-roulette__window {
  position: relative; height: 216px; overflow: hidden; border-radius: 16px;
  background: rgba(0, 0, 0, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);
  mask-image: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);
}
.relax-roulette__reel { will-change: transform; }
.relax-roulette__item {
  height: 72px; box-sizing: border-box; padding: 0 18px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
}
.relax-roulette__emoji { font-size: 22px; line-height: 1; transition: transform 0.3s; }
.relax-roulette__text {
  font-size: 14px; font-weight: 600; line-height: 1.25; color: #f4f4f8;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.relax-roulette__item.is-win .relax-roulette__text { color: #fff; }
.relax-roulette__item.is-win .relax-roulette__emoji { transform: scale(1.2); }
.relax-roulette__marker {
  position: absolute; left: 6px; right: 6px; top: 50%; height: 72px; transform: translateY(-50%);
  border-radius: 12px; pointer-events: none;
  border: 1px solid rgba(129, 140, 248, 0.5);
  box-shadow: inset 0 0 22px rgba(129, 140, 248, 0.22);
  background: linear-gradient(90deg, rgba(129, 140, 248, 0.07), rgba(168, 85, 247, 0.07));
}

/* ── Match-3 ───────────────────────────────────────────────────────── */
.relax-m3 {
  position: relative; width: 100%; max-width: 1200px; margin: 0 auto;
  height: min(74vh, 760px); min-height: 420px; border-radius: 20px; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 16px; box-sizing: border-box;
  background: radial-gradient(120% 90% at 50% 12%, rgba(99, 102, 241, 0.12), transparent 60%), #07070b;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.relax-m3__head { color: rgba(255, 255, 255, 0.7); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.relax-m3__score-val { color: #c7d2fe; }
.relax-m3__board { position: relative; width: min(90vw, 58vh, 520px); overflow: hidden; touch-action: manipulation; }
.relax-m3__gem {
  position: absolute; top: 0; left: 0; padding: 0; border: none; background: none; cursor: pointer;
  transition: transform 0.24s cubic-bezier(0.25, 0.9, 0.35, 1);
}
/* Initial placement / spawn-above: committed instantly (no slide from 0,0).
   The class is cleared one frame later so the real drop animates. */
.relax-m3__gem.is-placing { transition: none; }
.relax-m3__gem::after {
  content: ""; position: absolute; inset: 9%; border-radius: 26%;
  background: var(--m3, #888);
  box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.45), inset 0 -5px 9px rgba(0, 0, 0, 0.32);
  transition: box-shadow 0.15s;
}
/* 5 maximally-distinct base hues; orange + teal are added by the difficulty
 * ramp (closer to red/yellow and green/blue → harder to tell apart). */
.relax-m3__gem--0 { --m3: #ff3b3b; } /* red */
.relax-m3__gem--1 { --m3: #ffd400; } /* yellow */
.relax-m3__gem--2 { --m3: #2ec94e; } /* green */
.relax-m3__gem--3 { --m3: #2f6bff; } /* blue */
.relax-m3__gem--4 { --m3: #9b3bff; } /* purple */
.relax-m3__gem--5 { --m3: #ff8a00; } /* orange (ramp) */
.relax-m3__gem--6 { --m3: #00cdd0; } /* teal (ramp) */
.relax-m3__gem.is-sel::after { box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.5), 0 0 0 3px rgba(255, 255, 255, 0.92); }
.relax-m3__gem.is-clear::after { animation: relax-m3-clear 0.22s ease forwards; }
@keyframes relax-m3-clear { to { transform: scale(0.1); opacity: 0; } }

/* ── Match-3 juice: explosions, bonus labels, combo, shake ─────────── */
.relax-m3__board.is-shake { animation: relax-m3-shake 0.34s ease; }
@keyframes relax-m3-shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-3px, 2px); }
  40% { transform: translate(3px, -2px); }
  60% { transform: translate(-2px, -2px); }
  80% { transform: translate(2px, 2px); }
}

/* Particle spark — flies out from the cluster centre, tinted to the gem. */
.relax-m3__spark {
  position: absolute; width: 9%; height: 9%; max-width: 8px; max-height: 8px;
  margin: -4px 0 0 -4px; border-radius: 50%;
  background: var(--m3, #fff); pointer-events: none;
  box-shadow: 0 0 8px var(--m3, #fff);
  animation: relax-m3-spark 0.6s ease-out forwards;
}
@keyframes relax-m3-spark {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx, 0), var(--dy, 0)) scale(0.2); opacity: 0; }
}

/* Floating bonus label. */
.relax-m3__pop {
  position: absolute; transform: translate(-50%, -50%); margin-top: -4px;
  pointer-events: none; text-align: center; white-space: nowrap; z-index: 3;
  animation: relax-m3-pop 0.95s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.relax-m3__pop-name { display: block; font-size: 12px; font-weight: 800; letter-spacing: 0.4px; text-transform: uppercase; color: #fff; }
.relax-m3__pop-pts { display: block; font-size: 15px; font-weight: 800; color: #ffe07a; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); }
.relax-m3__pop--square .relax-m3__pop-name { color: #7dd3fc; }
.relax-m3__pop--line4 .relax-m3__pop-name { color: #fca5f1; }
.relax-m3__pop--corner .relax-m3__pop-name { color: #fdba74; }
.relax-m3__pop--line5 .relax-m3__pop-name { color: #fde047; font-size: 14px; text-shadow: 0 0 10px rgba(253, 224, 71, 0.7); }
.relax-m3__pop--line5 .relax-m3__pop-pts { font-size: 18px; }
@keyframes relax-m3-pop {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); }
  25% { opacity: 1; transform: translate(-50%, -55%) scale(1.08); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(1); }
}

/* Combo banner — center of the board. */
.relax-m3__combo {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  pointer-events: none; z-index: 4;
  font-size: clamp(22px, 7vw, 40px); font-weight: 900; letter-spacing: 0.5px;
  color: #fff; text-shadow: 0 2px 14px rgba(99, 102, 241, 0.8), 0 0 30px rgba(168, 85, 247, 0.6);
  animation: relax-m3-combo 0.85s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes relax-m3-combo {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotate(-6deg); }
  30% { opacity: 1; transform: translate(-50%, -50%) scale(1.15) rotate(2deg); }
  60% { transform: translate(-50%, -50%) scale(1) rotate(0); }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(1); }
}

/* Match-3 max-combo readout (next to the score). */
.relax-m3__max { margin-left: 2px; }
.relax-m3__sep { margin: 0 9px; opacity: 0.35; }
.relax-m3__max-val { color: #c084fc; }

/* ── Game 4: Runner (бегалка) — LLM-designed levels ────────────────── */
.relax-run {
  position: relative; width: 100%; max-width: 1200px; margin: 0 auto;
  height: min(74vh, 760px); min-height: 420px; border-radius: 20px; overflow: hidden;
  background: #07070b; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  touch-action: none; user-select: none;
}
.relax-run__canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: pointer; }
.relax-run__hud {
  position: absolute; top: 16px; left: 0; right: 0; text-align: center; pointer-events: none;
  font-size: 26px; font-weight: 800; color: #fff; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
  font-variant-numeric: tabular-nums; letter-spacing: 0.5px;
}
.relax-run__overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(5, 5, 12, 0.55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.relax-run__card {
  text-align: center; padding: 34px 30px; max-width: 86%; border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.12); box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
}
.relax-run__title { font-size: 26px; font-weight: 800; color: #fff; letter-spacing: -0.01em; margin-bottom: 8px; }
.relax-run__intro { font-size: 15px; color: rgba(255, 255, 255, 0.7); max-width: 340px; margin: 0 auto 8px; line-height: 1.5; }
.relax-run__hint { font-size: 13px; color: rgba(255, 255, 255, 0.45); margin-bottom: 20px; }
.relax-run__stat { font-size: 16px; color: rgba(255, 255, 255, 0.8); margin-bottom: 20px; }
.relax-run__stat b { color: #fff; }
.relax-run__btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.relax-run__btn {
  border: none; font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
  padding: 12px 24px; border-radius: 999px; transition: transform 0.15s, filter 0.2s, background 0.2s;
}
.relax-run__btn:hover { transform: translateY(-1px); filter: brightness(1.07); }
.relax-run__btn--play { color: #fff; background: linear-gradient(135deg, #6366f1, #a855f7); box-shadow: 0 10px 28px rgba(99, 102, 241, 0.4); }
.relax-run__btn--fresh { color: var(--text, #fff); background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.16); }
@media (max-width: 560px) {
  .relax-run { height: min(70vh, 600px); border-radius: 16px; }
  .relax-run__title { font-size: 22px; }
}

/* Runner — offer-win celebration (fireworks show through a near-clear backdrop) */
.relax-run__overlay--win { background: rgba(5, 5, 12, 0.22); }
.relax-run__overlay--win .relax-run__card {
  border-color: rgba(255, 213, 74, 0.5);
  box-shadow: 0 0 60px rgba(255, 213, 74, 0.35), 0 18px 60px rgba(0, 0, 0, 0.5);
}
.relax-run__title--win {
  font-size: 32px; color: #ffd54a; text-shadow: 0 0 24px rgba(255, 213, 74, 0.6);
  animation: relax-run-pop 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes relax-run-pop { 0% { transform: scale(0.4); opacity: 0; } 55% { transform: scale(1.14); } 100% { transform: scale(1); opacity: 1; } }
