/* ============ Still — iOS-style minimal dark UI ============ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #000000;
  --card: #1c1c1e;
  --card2: #2c2c2e;
  --hairline: rgba(255, 255, 255, 0.07);
  --text: #f2f2f7;
  --muted: #8e8e93;
  --accent1: #7c6cff;
  --accent2: #35e0c9;
  --ok: #30d158;
  --danger: #ff453a;
  --ease-spring: cubic-bezier(0.25, 0.9, 0.3, 1);
  /* стеклянная карточка: мягкий вертикальный градиент */
  --glass: linear-gradient(180deg, #1e1e21, #151517);
}

html { background: var(--bg); }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}

/* ---------- цветная аура фона (глубина поверх чёрного) ---------- */
#ambient { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
#ambient i { position: absolute; border-radius: 50%; filter: blur(90px); }
#ambient i:first-child {
  width: 75vw; height: 75vw; top: -32vw; left: -28vw;
  background: radial-gradient(circle, rgba(124, 108, 255, 0.17), transparent 68%);
}
#ambient i:last-child {
  width: 65vw; height: 65vw; bottom: -30vw; right: -22vw;
  background: radial-gradient(circle, rgba(53, 224, 201, 0.13), transparent 68%);
}

#app { position: relative; z-index: 1; display: flex; flex-direction: column; height: 100dvh; }

/* ---------- topbar ---------- */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 20px 8px;
}
.logo { display: flex; gap: 9px; align-items: center; }
.logo .mark { filter: drop-shadow(0 0 10px rgba(53, 224, 201, 0.35)); }
.logo span { font-size: 19px; font-weight: 700; letter-spacing: -0.3px; }
.hello { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 2px; }
#hello-name { max-width: 44vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- main ---------- */
#content { flex: 1; overflow-y: auto; padding: 6px 20px 110px; -webkit-overflow-scrolling: touch; }
.hidden { display: none !important; }

.screen { animation: screen-in 0.3s var(--ease-spring); }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.tagline {
  color: rgba(142, 142, 147, 0.9); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 2.6px; text-align: center;
  margin: 40px 0 22px;
}

/* ---------- сетка игр ---------- */
.games-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; max-width: 520px; margin: 0 auto; }
.game-card {
  position: relative; overflow: hidden;
  background:
    radial-gradient(130% 95% at 50% 0%, color-mix(in srgb, var(--g2) 15%, transparent) 0%, transparent 58%),
    var(--glass);
  border-radius: 24px;
  padding: 17px 16px 16px;
  display: flex; flex-direction: column; gap: 10px;
  text-align: left; cursor: pointer; color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 12px 32px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s var(--ease-spring), opacity 0.15s ease;
  animation: card-rise 0.5s var(--ease-spring) backwards;
}
/* блик по верхней кромке карточки */
.game-card::before {
  content: ''; position: absolute; inset: 0; border-radius: 24px; padding: 1px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 45%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none;
}
.game-card:nth-child(1) { animation-delay: 0.02s; }
.game-card:nth-child(2) { animation-delay: 0.07s; }
.game-card:nth-child(3) { animation-delay: 0.12s; }
.game-card:nth-child(4) { animation-delay: 0.17s; }
.game-card:nth-child(5) { animation-delay: 0.22s; }
.game-card:nth-child(6) { animation-delay: 0.27s; }
@keyframes card-rise {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
.game-card:active { transform: scale(0.96); opacity: 0.85; }
.game-card .tile {
  width: 52px; height: 52px; border-radius: 16px;
  background: linear-gradient(135deg, var(--g1), var(--g2));
  display: flex; align-items: center; justify-content: center; color: #fff;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--g2) 40%, transparent),
              0 1px 0 rgba(255, 255, 255, 0.25) inset;
}
.game-card .tile svg { width: 26px; height: 26px; }
.game-card .nm { font-size: 16px; font-weight: 700; letter-spacing: -0.2px; }
.game-card .ds { font-size: 12px; color: var(--muted); line-height: 1.35; }

/* ---------- экран игры ---------- */
.game-head { display: flex; align-items: center; margin-bottom: 14px; }
.game-head .back { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; color: var(--accent2); }
.game-head-title { font-size: 17px; font-weight: 700; flex: 1; text-align: center; letter-spacing: -0.2px; }
.head-spacer { width: 38px; }
#game-area { max-width: 560px; margin: 0 auto; }

/* ---------- плавающий док ---------- */
#dock {
  position: fixed; left: 14px; right: 14px; bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  display: flex; justify-content: space-between; gap: 2px;
  padding: 8px 10px;
  background: rgba(24, 24, 27, 0.72);
  backdrop-filter: blur(28px) saturate(180%); -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 30px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.09) inset, 0 14px 44px rgba(0, 0, 0, 0.6);
  z-index: 20;
}
#dock button {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  padding: 7px 0 5px; border-radius: 22px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: background 0.18s var(--ease-spring), color 0.18s ease, transform 0.12s ease;
}
#dock button svg { width: 21px; height: 21px; }
#dock button small { font-size: 9px; font-weight: 600; letter-spacing: 0.2px; }
#dock button:active { transform: scale(0.92); }
#dock button.active {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent1) 38%, transparent), color-mix(in srgb, var(--accent2) 32%, transparent));
  color: #fff;
  box-shadow: 0 4px 18px color-mix(in srgb, var(--accent2) 25%, transparent);
}

/* ---------- кнопки ---------- */
.btn {
  border: 0; border-radius: 16px; padding: 15px 24px; font-size: 16px; font-weight: 700;
  color: #fff; cursor: pointer;
  transition: transform 0.12s var(--ease-spring), opacity 0.12s ease;
}
.btn:active { transform: scale(0.97); opacity: 0.85; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  box-shadow: 0 8px 26px color-mix(in srgb, var(--accent1) 38%, transparent),
              0 1px 0 rgba(255, 255, 255, 0.22) inset;
}
.btn-soft {
  background: var(--card2); color: var(--text);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.07) inset;
}
.ghost-btn {
  background: transparent; border: 0; color: var(--muted);
  padding: 9px; border-radius: 12px; cursor: pointer; line-height: 0;
  display: inline-flex; align-items: center; gap: 6px;
}
.ghost-btn:active { background: var(--card); }

/* ---------- модал имени ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  padding: 24px;
  animation: fade-in 0.25s ease;
}
@keyframes fade-in { from { opacity: 0; } }
.modal-card {
  position: relative; overflow: hidden;
  width: 100%; max-width: 340px;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(53, 224, 201, 0.10), transparent 60%),
    var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.09); border-radius: 28px;
  padding: 34px 24px 24px; text-align: center;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 255, 255, 0.1) inset;
  animation: card-in 0.35s var(--ease-spring);
}
@keyframes card-in { from { opacity: 0; transform: scale(0.92) translateY(16px); } }
.modal-card .mark.big { margin: 0 auto; filter: drop-shadow(0 0 22px rgba(53, 224, 201, 0.3)); }
.modal-card h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.modal-card p { color: var(--muted); font-size: 15px; line-height: 1.45; }
#name-input {
  background: var(--card2); border: 1px solid rgba(255, 255, 255, 0.06); border-radius: 14px;
  padding: 15px 16px; font-size: 17px; color: var(--text); text-align: center; outline: none;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
#name-input:focus { border-color: transparent; box-shadow: 0 0 0 2px var(--accent2), 0 0 24px color-mix(in srgb, var(--accent2) 30%, transparent); }

.link-btn {
  background: transparent; border: 0; color: var(--muted); cursor: pointer;
  font-size: 13px; font-weight: 600; padding: 6px 10px; border-radius: 10px;
}
.link-btn:active { opacity: 0.6; }

.shake { animation: shake 0.3s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.pop { animation: pop 0.25s var(--ease-spring); }
@keyframes pop { 0% { transform: scale(0.6); } 70% { transform: scale(1.1); } 100% { transform: scale(1); } }

/* ============ общие элементы игр ============ */
/* статы — пилюли-чипы */
.hud {
  display: flex; justify-content: center; align-items: center; gap: 10px;
  margin-bottom: 18px; color: var(--muted); font-weight: 600;
}
.hud span {
  display: inline-flex; align-items: baseline; gap: 5px;
  background: var(--card); border: 1px solid var(--hairline);
  border-radius: 999px; padding: 7px 15px; font-size: 12px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.hud b { color: var(--text); font-size: 16px; font-variant-numeric: tabular-nums; }
.hud .hot { color: var(--danger); border-color: rgba(255, 69, 58, 0.45); animation: pop 0.4s ease infinite alternate; }

.result-card {
  background:
    radial-gradient(110% 65% at 50% 0%, rgba(124, 108, 255, 0.12), transparent 60%),
    var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 26px;
  padding: 34px 22px 26px; text-align: center;
  display: flex; flex-direction: column; gap: 10px; align-items: center;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 20px 50px rgba(0, 0, 0, 0.45);
  animation: card-in 0.35s var(--ease-spring);
}
.rc-ring {
  position: relative; width: 92px; height: 92px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
  animation: ring-in 0.5s var(--ease-spring);
  filter: drop-shadow(0 0 26px rgba(53, 224, 201, 0.35));
}
/* кольцо медленно «дышит» градиентом */
.rc-ring::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--accent2), var(--accent1), var(--accent2));
  animation: rot 7s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }
@keyframes ring-in { from { transform: scale(0.5); opacity: 0; } }
.rc-ring .core {
  position: relative; z-index: 1;
  width: 74px; height: 74px; border-radius: 50%; background: var(--card);
  display: flex; align-items: center; justify-content: center;
}
.rc-ring svg { width: 34px; height: 34px; }
.rc-ring .dash { stroke-dasharray: 30; stroke-dashoffset: 30; animation: dash 0.5s 0.3s var(--ease-spring) forwards; }
@keyframes dash { to { stroke-dashoffset: 0; } }
.rc-big {
  font-size: 26px; font-weight: 800; letter-spacing: -0.4px; font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, #ffffff, var(--accent2) 85%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.rc-sub { color: var(--muted); font-size: 15px; }
.result-card .btn { margin-top: 10px; width: 100%; max-width: 240px; }
.result-card .btn-soft { margin-top: 0; }

/* ============ 1. РЕАКЦИЯ ============ */
.rx-panel {
  position: relative; overflow: hidden;
  border-radius: 28px; min-height: 400px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; text-align: center;
  padding: 30px 24px; cursor: pointer;
  background: var(--glass); border: 1px solid var(--hairline);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.rx-panel.idle { background: radial-gradient(90% 65% at 50% 20%, rgba(124, 108, 255, 0.10), transparent 65%), var(--glass); }
.rx-panel.waiting {
  background: radial-gradient(90% 70% at 50% 30%, rgba(255, 69, 58, 0.22), #3a1014 75%);
  border-color: rgba(255, 69, 58, 0.5);
  box-shadow: 0 0 50px rgba(255, 69, 58, 0.18);
}
.rx-panel.ready {
  background: radial-gradient(95% 75% at 50% 32%, rgba(48, 209, 88, 0.32), #0f3d24 78%);
  border-color: var(--ok);
  box-shadow: 0 0 70px rgba(48, 209, 88, 0.28);
}
.rx-status { font-size: 32px; font-weight: 800; letter-spacing: -0.5px; }
.rx-sub { color: rgba(242, 242, 247, 0.72); font-size: 15px; max-width: 310px; line-height: 1.45; }
.rx-round { color: var(--muted); font-size: 13px; font-weight: 600; position: absolute; top: 16px; right: 20px; font-variant-numeric: tabular-nums; }
.rx-panel.ready .rx-status { animation: pop 0.2s ease; }
.rx-panel .btn { margin-top: 8px; }

/* ============ 2. ЛОВУШКА (Струп) ============ */
.stroop { text-align: center; }
.st-word {
  font-size: 46px; font-weight: 900; letter-spacing: 1px;
  margin: 30px 0 10px; min-height: 118px;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  text-shadow: 0 0 36px color-mix(in srgb, currentColor 45%, transparent);
}
.st-hint { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.st-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.st-btn {
  border: 1.5px solid var(--c);
  background: color-mix(in srgb, var(--c) 13%, var(--card));
  color: var(--text); border-radius: 18px; padding: 20px 10px;
  font-size: 17px; font-weight: 700; cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
  transition: transform 0.12s var(--ease-spring), opacity 0.12s ease;
}
.st-btn:active { transform: scale(0.96); opacity: 0.8; }

/* ============ 3. МАТРИЦА ============ */
.mx-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; max-width: 420px; margin: 0 auto 14px; }
.mx-cell {
  aspect-ratio: 1; border: 1px solid var(--hairline); border-radius: 24%;
  background: linear-gradient(180deg, #242428, #19191b); color: var(--text);
  font-size: 20px; font-weight: 700; cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
  transition: transform 0.12s ease, opacity 0.18s ease;
  font-variant-numeric: tabular-nums;
}
.mx-cell:active { transform: scale(0.94); }
.mx-cell.hit { opacity: 0.08; pointer-events: none; transform: scale(0.72); border-color: transparent; }
.mx-hint { text-align: center; color: var(--muted); font-size: 13px; margin-top: 18px; }

/* ============ 4. МАТЕМАТИКА ============ */
.math { text-align: center; }
.mt-q {
  font-size: 42px; font-weight: 800; letter-spacing: -0.5px;
  min-height: 112px; margin: 26px 0 24px;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 34px rgba(53, 224, 201, 0.22);
}
.mt-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mt-btn {
  border: 1px solid var(--hairline); background: linear-gradient(180deg, #242428, #19191b);
  color: var(--text); border-radius: 18px; padding: 22px 10px;
  font-size: 24px; font-weight: 800; cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
  transition: transform 0.12s var(--ease-spring), opacity 0.12s ease, background 0.15s ease;
  font-variant-numeric: tabular-nums;
}
.mt-btn:active { transform: scale(0.96); opacity: 0.8; }
.mt-btn.wrong { background: rgba(255, 69, 58, 0.22); border-color: var(--danger); }

/* ============ 5. ПАРЫ ============ */
.pr-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: 400px; margin: 0 auto; }
.pr-card {
  aspect-ratio: 1; border-radius: 18%; background: transparent; padding: 0;
  border: 0; cursor: pointer; position: relative;
  perspective: 700px; -webkit-perspective: 700px;
  transition: transform 0.12s ease;
}
.pr-card:active { transform: scale(0.95); }
.pr-face {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  transition: transform 0.28s var(--ease-spring); border-radius: 18%;
}
.pr-face svg { width: 56%; height: 56%; }
.pr-back {
  transform: rotateY(0);
  background: linear-gradient(145deg, #26262a, #17171a);
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
}
.pr-back .q {
  width: 34%; height: 34%; border-radius: 50%;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent1) 55%, var(--card2)), color-mix(in srgb, var(--accent2) 55%, var(--card2)));
  box-shadow: 0 0 16px color-mix(in srgb, var(--accent2) 25%, transparent);
}
.pr-front { transform: rotateY(180deg); background: var(--card); }
.pr-card.open .pr-back { transform: rotateY(-180deg); }
.pr-card.open .pr-front { transform: rotateY(0); }
.pr-card.done .pr-front { box-shadow: inset 0 0 0 1.5px var(--ok); animation: pop 0.3s ease; }
.pr-card.done { pointer-events: none; }

/* ============ 6. ПЯТНАШКИ ============ */
.pz-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 400px; margin: 0 auto 14px; }
.pz-cell {
  aspect-ratio: 1; border: 1px solid var(--hairline); border-radius: 20%;
  background: linear-gradient(180deg, #242428, #19191b); color: var(--text);
  font-size: 23px; font-weight: 800; cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
  transition: transform 0.1s ease, background 0.2s ease;
  font-variant-numeric: tabular-nums;
}
.pz-cell:active { transform: scale(0.93); }
.pz-cell.empty { background: transparent; border-color: transparent; box-shadow: none; pointer-events: none; }
.pz-cell.right {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent2) 22%, var(--card)), color-mix(in srgb, var(--accent1) 22%, var(--card)));
  border-color: color-mix(in srgb, var(--accent2) 45%, transparent);
}
.pz-mix { width: 100%; max-width: 400px; display: block; margin: 12px auto 0; }

/* ---------- широкие экраны ---------- */
@media (min-width: 600px) {
  #content { padding-bottom: 120px; }
  #dock { max-width: 560px; left: 50%; right: auto; transform: translateX(-50%); width: min(560px, calc(100% - 28px)); }
}

/* ---------- доступность: меньше движения ---------- */
@media (prefers-reduced-motion: reduce) {
  .screen, .game-card, .modal-card, .result-card, .rc-ring, .rc-ring::before, .pop, .hud .hot { animation: none !important; }
}