/* Мише 47! — дизайн-система: призма КП, мультяшный лес, толстые контуры,
   «наклеечные» тени, эмодзи (спека §15). Stitch позже ляжет на эти токены. */

/* Шрифты — свои копии: Google Fonts без сети недоступен. Лицензия OFL — в /fonts. */
@font-face {
  font-family: 'Nunito'; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url('/fonts/nunito-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Nunito'; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url('/fonts/nunito-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Rubik'; font-style: normal; font-weight: 800; font-display: swap;
  src: url('/fonts/rubik-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Rubik'; font-style: normal; font-weight: 800; font-display: swap;
  src: url('/fonts/rubik-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --kp-orange: #FF7A1A;  --kp-white: #FFFFFF;
  --forest: #2E7D32;     --forest-dark: #1B5E20;
  --sky: #E3F6FF;        --sun: #FFD23F;
  --ok: #3DDC97;         --bad: #E94F6F;
  --ink: #1D1B16;        --paper: #FFFBF2;
  --radius: 20px;        --outline: 3px solid var(--ink);
  --shadow: 4px 4px 0 var(--ink);
  --font-head: 'Rubik', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--sky); color: var(--ink); font: 400 17px/1.5 var(--font-body); }
/* Длинные слова и ссылки (имя без пробелов, URL в факте) переносятся, а не
   растягивают страницу вбок. word-break: break-word — для iOS до 15.4, где
   overflow-wrap: anywhere ещё нет. */
body { overflow-wrap: anywhere; word-break: break-word; }
h1, h2, h3 { margin: 0 0 12px; font-family: var(--font-head); font-weight: 800; line-height: 1.15; }
h1 { font-size: clamp(38px, 11vw, 60px); }
h2 { font-size: 26px; }
h3 { font-size: 20px; }
p { margin: 0 0 12px; }
a { color: var(--forest-dark); font-weight: 800; }
ul { margin: 0; padding: 0; list-style: none; }

.page { max-width: 640px; margin: 0 auto; padding: 0 16px 48px; }
.section { margin: 32px 0; }
.card { padding: 20px; border: var(--outline); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.muted { opacity: .7; }

/* Плашка демо-копии: слова тренировочной трассы всегда перед глазами. */
.demo-banner { padding: 10px 16px; border-bottom: var(--outline); background: var(--sun); font-weight: 800; text-align: center; }

/* Кнопки-наклейки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 12px 22px; border: var(--outline); border-radius: 999px;
  background: var(--kp-white); box-shadow: var(--shadow); color: var(--ink);
  font: 800 18px/1.1 var(--font-head); text-align: center; text-decoration: none;
  cursor: pointer; transition: transform .08s, box-shadow .08s; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .6; cursor: default; }
.btn--primary { background: var(--kp-orange); }
.btn--forest { background: var(--forest); color: var(--kp-white); }
.btn--sun { background: var(--sun); }
.btn--danger { background: var(--bad); }
.btn--big { width: 100%; min-height: 64px; font-size: 22px; }
.btn--small { min-height: 40px; padding: 8px 14px; font-size: 15px; }

/* Поля: шрифт ≥ 16px, иначе iOS увеличивает страницу при фокусе. */
.field { display: block; margin-bottom: 14px; }
.field__label { display: block; margin-bottom: 6px; font-weight: 800; }
.input {
  width: 100%; min-height: 52px; padding: 12px 14px; border: var(--outline); border-radius: 14px;
  background: var(--kp-white); color: var(--ink); font: 400 18px/1.3 var(--font-body);
}
.input:focus { outline: 3px solid var(--sun); outline-offset: 2px; }
.input--area { min-height: 96px; resize: vertical; }
.form-error { margin: 10px 0 0; color: #B3261E; font-weight: 800; }
.notice { margin: 10px 0; padding: 10px 14px; border: 2px solid var(--ink); border-radius: 14px; background: var(--ok); font-weight: 800; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.chip { display: inline-block; max-width: 100%; padding: 6px 12px; border: 2px solid var(--ink); border-radius: 999px; background: var(--kp-white); font-weight: 800; }

/* Призма КП: бело-оранжевый квадрат по диагонали. */
.kp-flag {
  width: 72px; height: 72px; border: var(--outline); border-radius: 10px; box-shadow: var(--shadow);
  background: linear-gradient(135deg, var(--kp-white) 0 50%, var(--kp-orange) 50% 100%);
  animation: sway 2.4s ease-in-out infinite; transform-origin: top center;
}
@keyframes sway { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }

/* Hero */
.hero { position: relative; overflow: hidden; margin: 0 -16px; padding: 40px 16px 0; text-align: center; }
.hero__lead { max-width: 30em; margin: 0 auto 12px; font-size: 19px; }
.hero .chips { justify-content: center; }
/* Сцена: место под будущий 3D-ролик (спека §4); пока — флажок, бегун и торт. */
.hero__stage { display: flex; align-items: flex-end; justify-content: center; gap: 18px; min-height: 120px; margin: 8px 0 0; font-size: 48px; }
.hero__runner { animation: hop .6s ease-in-out infinite alternate; }
@keyframes hop { to { transform: translateY(-14px); } }
.hero__forest { margin: 0 -16px 20px; font-size: 40px; line-height: 1; white-space: nowrap; overflow: hidden; letter-spacing: -6px; }
.confetti { position: absolute; top: -40px; font-size: 24px; animation: fall 7s linear infinite; pointer-events: none; }
.confetti:nth-child(1) { left: 6%; animation-delay: 0s; }
.confetti:nth-child(2) { left: 28%; animation-delay: 2.1s; }
.confetti:nth-child(3) { left: 52%; animation-delay: 4.3s; }
.confetti:nth-child(4) { left: 74%; animation-delay: 1.2s; }
.confetti:nth-child(5) { left: 92%; animation-delay: 3.4s; }
@keyframes fall { to { transform: translateY(520px) rotate(360deg); } }

.card--master { display: flex; gap: 14px; align-items: flex-start; background: var(--sun); }
.card__emoji { flex: none; font-size: 44px; line-height: 1; }

.rules { display: grid; gap: 12px; }
.rule { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: var(--outline); border-radius: 16px; background: var(--kp-white); }
.rule__emoji { flex: none; font-size: 30px; line-height: 1.1; }
.rule p { margin: 0; }

/* Оракул */
.oracle { padding: 12px 0; text-align: center; }
.oracle__ball { display: inline-block; font-size: 72px; animation: glow 1.2s ease-in-out infinite alternate; }
@keyframes glow {
  from { transform: scale(1); filter: drop-shadow(0 0 0 #B388FF); }
  to { transform: scale(1.12); filter: drop-shadow(0 0 16px #B388FF); }
}
.advice { padding: 16px; border: 3px dashed var(--ink); border-radius: var(--radius); background: var(--kp-white); }
.advice__fact { font-style: italic; }
.advice__text { font-size: 20px; font-weight: 800; }
.advice__note { margin: 0; opacity: .7; font-size: 15px; }
.rsvp-done { font-weight: 800; }

.fact-wall { display: grid; gap: 14px; }
.fact-card { padding: 14px; border: var(--outline); border-radius: 16px; background: var(--kp-white); box-shadow: var(--shadow); transform: rotate(-1deg); }
.fact-card:nth-child(even) { background: #FFF4D6; transform: rotate(1deg); }
.fact-card p { margin: 0 0 6px; }
.fact-card__advice { font-weight: 800; }
.fact-card__author { opacity: .7; font-size: 15px; }

.footer { margin-top: 40px; text-align: center; opacity: .7; font-size: 15px; }

/* Админка */
.admin { max-width: 880px; }
.admin__bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin: 16px 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tab--active { background: var(--kp-orange); }
.admin-row { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 12px 0; border-bottom: 2px dashed rgba(29, 27, 22, .2); }
.admin-row p { margin: 0 0 4px; }

/* Элементы сетки и flex по умолчанию не уже своего содержимого
   (min-width: auto) — без этого перенос длинных слов внутри не работает. */
.fact-wall > *, .admin-row > *, .rule > *, .card--master > * { min-width: 0; }

/* Игра (/game) */
.game-block { text-align: center; }
.game-block .field, .game-block form { text-align: left; }
.game-block .btn { margin-top: 12px; }
.game-emoji { font-size: 56px; }
.game-url { padding: 10px; border: 2px dashed var(--ink); border-radius: 12px; background: var(--kp-white); font-size: 15px; }
.game-secondary { display: inline-flex; margin: 16px auto 0; }
.game-team { font-weight: 800; }
.game-taken { font: 800 22px/1.2 var(--font-head); }
.game-chips { justify-content: center; }
.game-rules { padding-left: 22px; text-align: left; }
.game-rules li { margin-bottom: 8px; }
.btn--huge { width: 100%; min-height: 88px; font-size: 28px; }
.chip--kp { min-width: 44px; background: var(--kp-orange); text-align: center; }
.timer { margin: 8px 0; font: 800 clamp(56px, 18vw, 96px)/1 var(--font-head); font-variant-numeric: tabular-nums; }
.flash { margin: 12px 0; padding: 12px; border: var(--outline); border-radius: 16px; background: var(--sun); font-weight: 800; }
.sync-badge { margin-top: 16px; font-size: 15px; opacity: .8; }
.checklist { margin: 16px 0; text-align: left; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 2px dashed rgba(29, 27, 22, .15); }
.checklist__soft { opacity: .75; }
.member-row { display: flex; gap: 8px; margin-bottom: 10px; }
.member-row .btn { margin-top: 0; }
.input--kp { font: 800 32px/1 var(--font-head); text-align: center; }
.notice--warn { background: var(--sun); }
.result-card { margin-bottom: 16px; background: var(--sun); }
/* «ПРИБЕЖАЛИ!» целиком в строку даже на узком телефоне: при 11vw «!» отрывался. */
.result-card h1 { font-size: clamp(30px, 9vw, 60px); }
.result-place { font: 800 28px/1.2 var(--font-head); }
.protocol { margin-bottom: 16px; text-align: left; }
.shake { animation: shake .4s ease-in-out 2; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }

/* Табло (/results) */
.standings { display: grid; gap: 10px; margin: 12px 0 24px; padding: 0; list-style: none; }
.standing { display: flex; gap: 12px; align-items: center; padding: 12px; border: var(--outline); border-radius: 16px; background: var(--kp-white); }
.standing--top { background: #FFF4D6; box-shadow: var(--shadow); }
.standing__place { flex: none; width: 44px; font: 800 28px/1 var(--font-head); text-align: center; }
.standing__body { flex: 1; min-width: 0; }
.standing__body p, .standing__score p { margin: 0; }
.standing__name { font-weight: 800; }
.standing__score { flex: none; text-align: right; }

/* Админка: КП и команды */
.kp-row { display: grid; grid-template-columns: 64px 1fr; gap: 8px; padding: 10px 0; border-bottom: 2px dashed rgba(29, 27, 22, .2); }
.kp-row .input { min-height: 44px; }
.kp-row__legend { grid-column: 1 / -1; display: flex; gap: 8px; }
.wish-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 2px dashed rgba(29, 27, 22, .2); }
.wish-row .input { flex: 1; min-width: 0; min-height: 44px; }
.wish-row__count { white-space: nowrap; }
.team-row { padding: 12px 0; border-bottom: 2px dashed rgba(29, 27, 22, .2); }
.team-row p { margin: 0 0 4px; }
.team-row__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.manual-form { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.manual-form .input { min-height: 44px; }
.manual-form__note { grid-column: 1 / -1; }

@media (prefers-reduced-motion: reduce) {
  .kp-flag, .hero__runner, .oracle__ball, .shake { animation: none; }
  .confetti { display: none; }
}
