@font-face { font-family: Nunito; font-weight: 700; font-display: swap; src: url(fonts/nunito-cyrillic-700-normal.woff2) format('woff2'); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Nunito; font-weight: 700; font-display: swap; src: url(fonts/nunito-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: Nunito; font-weight: 900; font-display: swap; src: url(fonts/nunito-cyrillic-900-normal.woff2) format('woff2'); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Nunito; font-weight: 900; font-display: swap; src: url(fonts/nunito-latin-900-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }

:root {
  --bg: #fff6e5;
  --paper: #ffffff;
  --ink: #3a2e7a;
  --ink-soft: #6b5fa8;
  --pink: #ff5d8f;
  --yellow: #ffb703;
  --teal: #2ec4b6;
  --blue: #4cc9f0;
  --purple: #8f5cff;
  --green: #7bd34a;
  --red: #ff4d4d;
  --ok-bg: #e5f9da;
  --warn-bg: #fff1c7;
  --err-bg: #ffe0e3;
  --line: 3px solid var(--ink);
  --pop: 0 6px 0 var(--ink);
  --radius: 22px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 700 17px/1.45 Nunito, 'Comic Sans MS', system-ui, sans-serif;
  overflow-x: hidden;
}
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }

/* ---------- фон ---------- */
.sky { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(2px); opacity: .55; }
.b1 { width: 420px; height: 420px; background: #ffd6e5; top: -140px; left: -120px; }
.b2 { width: 360px; height: 360px; background: #d4f4ff; top: 30%; right: -150px; }
.b3 { width: 300px; height: 300px; background: #e3ffd1; bottom: -120px; left: 20%; }
.float { position: absolute; font-size: 34px; animation: drift 9s ease-in-out infinite; }
.f1 { top: 14%; right: 8%; }
.f2 { top: 55%; left: 3%; animation-delay: -3s; }
.f3 { top: 78%; right: 12%; animation-delay: -5s; }
.f4 { top: 32%; left: 46%; animation-delay: -7s; opacity: .5; }
@keyframes drift { 0%, 100% { transform: translateY(0) rotate(-8deg); } 50% { transform: translateY(-22px) rotate(8deg); } }

/* ---------- шапка ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  max-width: 1180px; margin: 0 auto; padding: 16px 16px 6px;
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-icon {
  display: grid; place-items: center; width: 52px; height: 52px; font-size: 30px;
  background: var(--pink); border: var(--line); border-radius: 16px; box-shadow: 0 4px 0 var(--ink);
  transform: rotate(-6deg); transition: transform .2s;
}
.logo:hover .logo-icon { transform: rotate(6deg) scale(1.08); }
.logo-text { font-weight: 900; font-size: 30px; letter-spacing: -.5px; }
.nav { display: flex; gap: 8px; }
.nav a {
  text-decoration: none; padding: 8px 14px; border-radius: 999px; border: var(--line);
  background: var(--paper); box-shadow: 0 3px 0 var(--ink);
}
.nav a[aria-current] { background: var(--yellow); }

main { max-width: 1180px; margin: 0 auto; padding: 8px 16px 64px; }

/* ---------- кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; min-height: 52px; border: var(--line); border-radius: 18px;
  background: var(--yellow); box-shadow: var(--pop); cursor: pointer;
  font-weight: 900; font-size: 18px; text-decoration: none; white-space: nowrap;
  transition: transform .08s, box-shadow .08s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 0 var(--ink); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: var(--pop); }
.btn.big { font-size: 24px; min-height: 66px; padding: 14px 34px; }
.btn.pink { background: var(--pink); color: #fff; }
.btn.teal { background: var(--teal); }
.btn.blue { background: var(--blue); }
.btn.white { background: var(--paper); }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: 15px; border-radius: 14px; box-shadow: 0 4px 0 var(--ink); }

.field { display: grid; gap: 6px; }
.field > span { font-weight: 900; }
.input {
  width: 100%; padding: 12px 16px; border: var(--line); border-radius: 16px; background: var(--paper);
  font-size: 18px; box-shadow: inset 0 3px 0 rgba(58, 46, 122, .08);
}
textarea.input { min-height: 110px; resize: vertical; }

.panel {
  background: var(--paper); border: var(--line); border-radius: var(--radius); box-shadow: var(--pop);
  padding: 22px;
}
h1, h2, h3 { font-weight: 900; line-height: 1.15; margin: 0 0 10px; }
h1 { font-size: clamp(30px, 6vw, 48px); letter-spacing: -1px; }
h2 { font-size: clamp(24px, 4vw, 32px); }
.muted { color: var(--ink-soft); }

/* ---------- каталог ---------- */
.hero { display: flex; align-items: center; gap: 18px; margin: 18px 0 22px; }
.hero-emoji { font-size: 64px; animation: bounce 1.8s ease-in-out infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-14px) rotate(6deg); } }
.hero p { margin: 0; font-size: 20px; color: var(--ink-soft); }

.toolbar { display: grid; gap: 14px; margin-bottom: 24px; }
.search { position: relative; }
.search .input { padding-left: 52px; font-size: 20px; min-height: 58px; }
.search::before { content: '🔎'; position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-size: 22px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 14px; border: var(--line); border-radius: 999px; background: var(--paper);
  box-shadow: 0 3px 0 var(--ink); cursor: pointer; font-weight: 900; white-space: nowrap;
}
.chip[aria-pressed='true'] { background: var(--teal); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.count { color: var(--ink-soft); }

.grid { display: grid; gap: 22px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card {
  position: relative; display: flex; flex-direction: column; text-decoration: none;
  background: var(--paper); border: var(--line); border-radius: var(--radius); box-shadow: var(--pop);
  overflow: hidden; transition: transform .15s;
}
.card:nth-child(3n+1) { --tilt: -1.2deg; }
.card:nth-child(3n+2) { --tilt: 1deg; }
.card:hover { transform: translateY(-4px) rotate(var(--tilt, 0deg)); }
.card:hover .card-art span { animation: wiggle .5s ease-in-out; }
@keyframes wiggle { 25% { transform: rotate(-12deg) scale(1.1); } 75% { transform: rotate(12deg) scale(1.1); } }
.card-art {
  display: grid; place-items: center; aspect-ratio: 4 / 3; border-bottom: var(--line);
  background: var(--c, var(--yellow));
  background-image: radial-gradient(circle at 20% 20%, rgba(255,255,255,.45) 0 12%, transparent 13%), radial-gradient(circle at 85% 75%, rgba(255,255,255,.3) 0 16%, transparent 17%);
}
.card-art span { font-size: 76px; line-height: 1; filter: drop-shadow(0 4px 0 rgba(58,46,122,.25)); }
.card-art img { width: 58%; aspect-ratio: 1; object-fit: contain; border-radius: 24%; filter: drop-shadow(0 5px 0 rgba(58,46,122,.3)); }
.card-body { padding: 14px 16px 16px; display: grid; gap: 4px; }
.card-title { font-size: 21px; font-weight: 900; line-height: 1.2; }
.card-meta { font-size: 14px; color: var(--ink-soft); }
.sticker {
  position: absolute; top: 12px; right: -6px; padding: 4px 14px 4px 12px; background: var(--pink); color: #fff;
  border: var(--line); border-right: 0; border-radius: 14px 0 0 14px; font-weight: 900; font-size: 14px; transform: rotate(4deg);
}
.sticker.grey { background: #b9b4d6; color: var(--ink); }
.cat-badge { display: inline-block; justify-self: start; padding: 2px 10px; border-radius: 999px; background: var(--bg); border: 2px solid var(--ink); font-size: 13px; }

.empty { text-align: center; padding: 50px 20px; font-size: 22px; }
.empty .big-emoji { font-size: 80px; display: block; margin-bottom: 8px; }

/* ---------- страница игры ---------- */
.back { display: inline-flex; gap: 6px; margin: 10px 0 16px; text-decoration: none; font-weight: 900; }
.game-hero {
  display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr); align-items: center;
  background: var(--paper); border: var(--line); border-radius: 30px; box-shadow: var(--pop); overflow: hidden;
}
.game-hero .card-art { aspect-ratio: auto; min-height: 240px; border-bottom: var(--line); }
.game-hero .card-art span { font-size: 130px; }
.game-hero .card-art img { width: 200px; }
.game-info { padding: 0 24px 26px; display: grid; gap: 12px; }
.game-info .desc { white-space: pre-line; font-size: 19px; margin: 0; }
.actions { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
@media (min-width: 820px) {
  .game-hero { grid-template-columns: 380px 1fr; }
  .game-hero .card-art { min-height: 380px; border-bottom: 0; border-right: var(--line); }
  .game-info { padding: 28px 30px 28px 0; }
}
.tip { margin-top: 22px; background: #eaf9ff; border: var(--line); border-radius: var(--radius); padding: 16px 20px; }
.tip h3 { font-size: 19px; margin-bottom: 4px; }
.tip p { margin: 0; }
.pager { display: flex; justify-content: space-between; gap: 10px; margin: 28px 0 8px; flex-wrap: wrap; }
.section-title { margin: 34px 0 16px; }

/* ---------- игра в окне ---------- */
body.playing { overflow: hidden; }
body.playing .top, body.playing .sky { display: none; }
body.playing main { max-width: none; padding: 0; }
.player { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--ink); }
.player-bar {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--yellow); border-bottom: var(--line);
}
.player-title { flex: 1; min-width: 0; font-weight: 900; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.player iframe { flex: 1; width: 100%; border: 0; background: #fff; }
@media (max-width: 520px) { .player-bar .label { display: none; } }

/* ---------- мастерская ---------- */
.studio-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 16px 0 22px; }
.login { max-width: 440px; margin: 40px auto; display: grid; gap: 16px; text-align: center; }
.login .big-emoji { font-size: 70px; }
.error-text { color: #c4002d; font-weight: 900; }
.list { display: grid; gap: 14px; }
.list-item { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px; }
.list-item .mini { width: 64px; height: 64px; flex: none; border-radius: 16px; border: var(--line); display: grid; place-items: center; font-size: 34px; background: var(--c); overflow: hidden; }
.list-item .mini img { width: 80%; height: 80%; object-fit: contain; }
.list-item .grow { flex: 1; min-width: 160px; }
.list-item .btns { display: flex; gap: 8px; flex-wrap: wrap; }

.steps { display: flex; align-items: center; gap: 8px; margin: 10px 0 22px; padding: 0; list-style: none; counter-reset: step; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px; border: var(--line); background: var(--paper); color: var(--ink-soft); }
.step::before { counter-increment: step; content: counter(step); display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--bg); border: 2px solid var(--ink); color: var(--ink); font-weight: 900; }
.step.on { background: var(--yellow); color: var(--ink); }
.step.passed::before { content: '✓'; background: var(--green); }

.drop {
  display: grid; place-items: center; gap: 14px; text-align: center; padding: 40px 20px;
  border: 4px dashed var(--ink); border-radius: 30px; background: var(--paper); transition: background .15s, transform .15s;
}
.drop.over { background: #eaf9ff; transform: scale(1.01); }
.drop .big-emoji { font-size: 84px; animation: bounce 2s ease-in-out infinite; }
.busy { display: grid; place-items: center; gap: 12px; padding: 40px; font-size: 20px; text-align: center; }
.spinner { font-size: 64px; animation: spin 1.2s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.checks { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.check { border: var(--line); border-radius: 18px; padding: 12px 14px; display: grid; grid-template-columns: 34px 1fr; gap: 4px 10px; align-items: start; }
.check .mark { font-size: 24px; line-height: 1.2; }
.check.ok { background: var(--ok-bg); }
.check.warn { background: var(--warn-bg); }
.check.error { background: var(--err-bg); }
.check .sub { grid-column: 2; font-size: 14px; color: var(--ink-soft); word-break: break-word; }
.ai { grid-column: 2; margin-top: 6px; background: var(--paper); border: 2px dashed var(--ink); border-radius: 14px; padding: 10px 12px; display: grid; gap: 8px; }
.ai b { font-size: 14px; }
.ai q { font-size: 15px; quotes: none; }
.ai .btn { justify-self: start; }
.check-block { margin-bottom: 22px; }
.check-block h3 { display: flex; gap: 8px; align-items: center; }

.testbed { border: var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--pop); background: #fff; }
.testbed iframe { display: block; width: 100%; height: min(70vh, 640px); border: 0; }
.confirm {
  display: flex; gap: 14px; align-items: center; margin: 22px 0; padding: 16px 18px; cursor: pointer;
  border: var(--line); border-radius: var(--radius); background: var(--paper); font-size: 20px; font-weight: 900;
}
.confirm input { width: 34px; height: 34px; accent-color: var(--green); flex: none; }

.form-grid { display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .form-grid { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; } .form-grid .preview { position: sticky; top: 16px; } }
.form { display: grid; gap: 18px; }
.picker { display: flex; flex-wrap: wrap; gap: 8px; }
.picker button {
  width: 50px; height: 50px; font-size: 26px; border: var(--line); border-radius: 14px; background: var(--paper); cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
}
.picker button[aria-pressed='true'] { background: var(--yellow); transform: translateY(-3px); box-shadow: 0 6px 0 var(--ink); }
.picker.colors button { background: var(--c); }
.picker.colors button[aria-pressed='true'] { background: var(--c); outline: 4px solid var(--ink); outline-offset: 2px; }
.preview .card { pointer-events: none; }

.done { text-align: center; padding: 40px 10px; }
.done .big-emoji { font-size: 110px; display: block; animation: bounce 1.2s ease-in-out infinite; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 10; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 12px; height: 18px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20; max-width: calc(100% - 32px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 16px; font-weight: 900;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 560px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .card-art span { font-size: 54px; }
  .card-body { padding: 10px 12px 12px; }
  .card-title { font-size: 17px; }
  .hero-emoji { font-size: 44px; }
}
