/* ============================================================
   «Мой тренер» — дизайн-система
   Референсы: Duolingo (чанковые кнопки, нижний лист фидбэка,
   энергия/серия), Khan Academy Kids (тёплый детский тон, крупные
   элементы), Hockey IQ (спортивная подача, разбор эпизодов).
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; }

:root {
  /* Фон — ночной лёд */
  --ink: #061626;
  --bg: #0c2a45;
  --bg-2: #0a2039;
  --surface: #14395c;
  --surface-2: #1a4570;
  --line: #2a5f92;

  /* Акценты */
  --amber: #ffb43a;
  --amber-deep: #d4830f;
  --ice: #7fd4ff;
  --ice-deep: #2f9fd4;
  --green: #3ecf7a;
  --green-deep: #1f9b52;
  --red: #ff5f6d;
  --red-deep: #c93744;
  --violet: #b07fd8;

  --text: #f3f9ff;
  --muted: #a2c0dc;

  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;

  --font: ui-rounded, 'SF Pro Rounded', 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html, body { height: 100%; }

body {
  font-family: var(--font);
  background:
    radial-gradient(900px 500px at 50% -8%, #1b4d78 0%, transparent 60%),
    linear-gradient(180deg, #0c2a45 0%, #081f35 100%);
  background-attachment: fixed;
  color: var(--text);
  display: flex;
  flex-direction: column;
  max-width: 620px;
  margin: 0 auto;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ===================== Шапка ===================== */
header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 16px 10px;
  padding-top: calc(12px + env(safe-area-inset-top));
  flex-shrink: 0;
}

.badge {
  width: 44px; height: 44px;
  border-radius: 15px;
  overflow: hidden;
  background: linear-gradient(160deg, var(--amber), #ff9c2f);
  display: grid; place-items: center;
  box-shadow: 0 4px 14px rgba(255, 180, 58, .3);
  flex-shrink: 0;
}
.badge img { width: 100%; height: 100%; object-fit: cover; }

h1 { font-size: 18px; font-weight: 800; letter-spacing: -.2px; }
#status { font-size: 12px; color: var(--muted); }

.header-stats { margin-left: auto; display: flex; gap: 7px; }
.hchip {
  background: rgba(255,255,255,.07);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; gap: 3px;
}

/* ===================== Экраны ===================== */
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.screen.hidden { display: none; }
.scroll-area { flex: 1; overflow-y: auto; padding: 6px 16px 24px; }

/* ===================== Чат ===================== */
#chat {
  flex: 1; overflow-y: auto;
  padding: 8px 16px;
  display: flex; flex-direction: column; gap: 12px;
}

.msg {
  max-width: 84%;
  padding: 12px 15px;
  border-radius: var(--r-md);
  line-height: 1.5;
  font-size: 16px;
  white-space: pre-wrap;
  animation: rise .22s ease-out;
}
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

.msg.coach {
  background: linear-gradient(165deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  align-self: flex-start;
}
.msg.me {
  background: linear-gradient(165deg, #eef6ff, #dbe9f8);
  color: #0d2a44;
  font-weight: 600;
  border-bottom-right-radius: 6px;
  align-self: flex-end;
}
.msg.typing { color: var(--muted); font-style: italic; }

.coach-row { display: flex; gap: 9px; align-items: flex-end; align-self: flex-start; max-width: 92%; }
.coach-row .mini-wolf {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface-2); border: 1.5px solid var(--line);
  object-fit: cover;
  flex-shrink: 0;
}
.coach-row .msg { max-width: 100%; }

#quick { display: flex; gap: 8px; padding: 6px 16px; overflow-x: auto; flex-shrink: 0; }
#quick::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  font-family: var(--font);
  background: rgba(255,255,255,.06);
  color: var(--text);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 9px 15px;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  transition: transform .1s;
}
.chip:active { transform: scale(.95); }

footer {
  display: flex; gap: 9px;
  padding: 8px 16px 10px;
  flex-shrink: 0;
}
#inp {
  flex: 1;
  font-family: var(--font);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 13px 18px;
  font-size: 16px;
  background: rgba(255,255,255,.95);
  color: #0d2a44;
  outline: none;
  font-weight: 500;
}
#inp::placeholder { color: #7d99b3; }

#send, #mic {
  width: 48px; height: 48px;
  border: none; border-radius: 50%;
  font-size: 20px; cursor: pointer; flex-shrink: 0;
  transition: transform .1s;
}
#send { background: linear-gradient(165deg, var(--amber), #ff9c2f); color: #10263c; box-shadow: 0 4px 0 var(--amber-deep); }
#send:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--amber-deep); }
#mic { background: var(--surface); color: var(--text); border: 1.5px solid var(--line); }
#mic.rec { background: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.1); } }

/* ===================== Кнопки ===================== */
.btn {
  display: block; width: 100%;
  font-family: var(--font);
  border: none;
  border-radius: var(--r-md);
  padding: 16px;
  font-size: 17px; font-weight: 800;
  letter-spacing: .2px;
  cursor: pointer;
  margin-top: 12px;
  transition: transform .08s, box-shadow .08s;
}
.btn-primary {
  background: linear-gradient(170deg, #ffc45c, var(--amber));
  color: #17334d;
  box-shadow: 0 5px 0 var(--amber-deep);
}
.btn-green { background: linear-gradient(170deg, #58e08e, var(--green)); color: #06301a; box-shadow: 0 5px 0 var(--green-deep); }
.btn-ghost {
  background: rgba(255,255,255,.06); color: var(--text);
  border: 1.5px solid var(--line);
  box-shadow: 0 5px 0 rgba(0,0,0,.25);
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--amber-deep); }
.btn-green:active { box-shadow: 0 1px 0 var(--green-deep); }
.btn-ghost:active { box-shadow: 0 1px 0 rgba(0,0,0,.25); }

/* ===================== Игра: главный экран ===================== */
.hero {
  text-align: center;
  padding: 6px 0 4px;
  position: relative;
}
.hero-wolf {
  width: 168px; height: 168px;
  object-fit: contain;
  filter: drop-shadow(0 14px 26px rgba(0,0,0,.45));
  animation: float 4s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-9px); } }

.bubble {
  display: inline-block;
  background: linear-gradient(165deg, var(--surface-2), var(--surface));
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 11px 16px;
  font-size: 15px; font-weight: 600;
  line-height: 1.4;
  max-width: 300px;
  position: relative;
  margin-bottom: 6px;
}
.bubble::after {
  content: '';
  position: absolute; bottom: -8px; left: 50%; margin-left: -8px;
  border: 8px solid transparent;
  border-top-color: var(--surface);
  border-bottom: 0;
}

.rank-row { display: flex; align-items: center; justify-content: center; gap: 9px; margin-top: 10px; }
.rank-icon { font-size: 26px; }
.rank-name { font-size: 20px; font-weight: 800; }

.xp-bar {
  height: 14px;
  background: rgba(0,0,0,.3);
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 26px 0;
  border: 1px solid rgba(255,255,255,.08);
}
.xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--amber), #ffd68a);
  border-radius: 999px;
  transition: width .5s cubic-bezier(.3,1.4,.5,1);
  box-shadow: 0 0 12px rgba(255,180,58,.5);
}
.xp-label { font-size: 13px; color: var(--muted); margin-top: 7px; font-weight: 600; }

.day-stats { display: flex; justify-content: center; gap: 10px; margin-top: 12px; }
.stat-pill {
  background: rgba(255,255,255,.06);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px; font-weight: 800;
  display: flex; align-items: center; gap: 5px;
}
.stat-pill.hot { border-color: #ff8a3d; background: rgba(255,138,61,.14); }
.energy { letter-spacing: 2px; display: flex; gap: 1px; }
.energy .spent { opacity: .22; filter: grayscale(1); }

.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 11px; }
.cat-btn {
  font-family: var(--font);
  background: linear-gradient(165deg, var(--surface-2), var(--surface));
  color: var(--text);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 8px;
  font-size: 14.5px; font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,.28);
  transition: transform .08s, box-shadow .08s;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.cat-btn .ci { font-size: 22px; }
.cat-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.28); }

/* ===================== Игра: вопрос ===================== */
.round-top { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; }
.q-progress {
  flex: 1; height: 12px;
  background: rgba(0,0,0,.3);
  border-radius: 999px; overflow: hidden;
  border: 1px solid rgba(255,255,255,.08);
}
.q-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ice-deep), var(--ice));
  border-radius: 999px;
  transition: width .35s ease;
}
.q-counter { font-size: 13px; font-weight: 800; color: var(--muted); }

.q-text {
  font-size: 18px; font-weight: 700; line-height: 1.42;
  margin: 12px 0 14px;
}

.q-options { display: flex; flex-direction: column; gap: 9px; }
.opt {
  font-family: var(--font);
  background: linear-gradient(165deg, var(--surface-2), var(--surface));
  color: var(--text);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 15px;
  font-size: 15.5px; font-weight: 600;
  text-align: left; line-height: 1.35;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,.28);
  transition: transform .08s, box-shadow .08s, background .15s;
  display: flex; align-items: center; gap: 12px;
}
.opt .key {
  width: 27px; height: 27px; flex-shrink: 0;
  border-radius: 9px;
  background: rgba(255,255,255,.1);
  border: 1.5px solid var(--line);
  display: grid; place-items: center;
  font-size: 13px; font-weight: 800;
  color: var(--muted);
}
.opt:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.28); }
.opt.right {
  background: linear-gradient(165deg, #2b8f5b, #1d7a4b);
  border-color: var(--green);
  box-shadow: 0 4px 0 #145c37;
}
.opt.right .key { background: var(--green); color: #06301a; border-color: var(--green); }
.opt.wrong {
  background: linear-gradient(165deg, #a13d47, #8a2f39);
  border-color: var(--red);
  box-shadow: 0 4px 0 #6d2029;
}
.opt.wrong .key { background: var(--red); color: #fff; border-color: var(--red); }
.opt.dim { opacity: .45; }

/* Схема площадки */
.rink-wrap {
  background: rgba(255,255,255,.04);
  border: 1.5px solid var(--line);
  border-radius: var(--r-lg);
  padding: 10px 10px 6px;
  margin-bottom: 4px;
}
.rink { width: 100%; max-height: 250px; display: block; }
.legend {
  display: flex; gap: 13px; justify-content: center;
  font-size: 11.5px; color: var(--muted); margin-top: 5px; font-weight: 600;
}
.l-opp { color: #ff9195; } .l-mate { color: #8fc2ee; } .l-goalie { color: var(--amber); }

/* ===== Нижний лист фидбэка (как в Duolingo) ===== */
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-width: 620px; margin: 0 auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  transform: translateY(110%);
  transition: transform .3s cubic-bezier(.2,1,.3,1);
  z-index: 40;
  border-top: 2px solid;
}
#sheet.show { transform: translateY(0); }
#sheet.ok { background: linear-gradient(180deg, #14563a, #0e4630); border-color: var(--green); }
#sheet.no { background: linear-gradient(180deg, #5c2630, #4a1f27); border-color: var(--red); }

.sheet-head { display: flex; align-items: center; gap: 11px; margin-bottom: 8px; }
.sheet-wolf {
  width: 58px; height: 58px; object-fit: contain; flex-shrink: 0;
  animation: popin .35s cubic-bezier(.3,1.5,.5,1);
}
@keyframes popin { from { transform: scale(.4) rotate(-12deg); opacity: 0; } }
.sheet-title { font-size: 20px; font-weight: 800; }
.sheet-text { font-size: 15px; line-height: 1.5; opacity: .95; }
#sheet .btn { margin-top: 14px; }

/* ===================== Итоги раунда ===================== */
.round-end { text-align: center; padding-top: 8px; }
.end-wolf {
  width: 180px; height: 180px; object-fit: contain;
  filter: drop-shadow(0 14px 26px rgba(0,0,0,.45));
  animation: popin .45s cubic-bezier(.3,1.5,.5,1);
}
.score-big {
  font-size: 46px; font-weight: 900; letter-spacing: -1px;
  background: linear-gradient(180deg, #fff, var(--amber));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.xp-gain { font-size: 19px; color: var(--amber); font-weight: 800; margin-bottom: 12px; }

.award {
  background: linear-gradient(165deg, var(--surface-2), var(--surface));
  border: 1.5px solid var(--amber);
  border-radius: var(--r-md);
  padding: 13px; margin: 9px 0;
  font-size: 15px; font-weight: 600; line-height: 1.45;
  animation: popin .4s cubic-bezier(.3,1.5,.5,1);
}
.award.levelup { background: linear-gradient(165deg, #6b4a12, #4a3413); }
.award.done-day { border-color: var(--green); background: linear-gradient(165deg, #1a5c3c, #12472e); }
.cheer { color: var(--muted); margin: 12px 0 2px; font-size: 15px; font-weight: 600; }

/* Конфетти */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.cfi {
  position: absolute; width: 9px; height: 15px; top: -20px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(105vh) rotate(720deg); opacity: .2; }
}

/* ===================== Профиль ===================== */
.sec-h { font-size: 18px; font-weight: 800; margin: 22px 0 10px; display: flex; align-items: center; gap: 7px; }
.sec-h small { color: var(--muted); font-weight: 600; font-size: 14px; }
.hint { font-size: 13px; color: var(--muted); margin-bottom: 10px; }

.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.abadge {
  background: linear-gradient(165deg, var(--surface-2), var(--surface));
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 6px; text-align: center;
  min-height: 88px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
}
.abadge.got { border-color: var(--amber); box-shadow: 0 0 18px rgba(255,180,58,.16) inset; }
.abadge.locked { opacity: .34; }
.b-icon { font-size: 26px; }
.b-name { font-size: 11px; font-weight: 700; line-height: 1.25; }

.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.gcard {
  background: linear-gradient(165deg, var(--surface-2), var(--surface));
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 13px 6px; text-align: center;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,.28);
  transition: transform .1s;
}
.gcard:active { transform: translateY(3px); }
.gcard.legend { border-color: var(--amber); background: linear-gradient(165deg, #55420f, #3a2d0d); box-shadow: 0 4px 0 #2a2109, 0 0 20px rgba(255,180,58,.18); }
.gcard.epic { border-color: var(--violet); background: linear-gradient(165deg, #3d2c55, #2c2040); box-shadow: 0 4px 0 #221833; }
.gcard.locked { opacity: .3; box-shadow: none; }
.g-emoji { font-size: 30px; }
.g-emoji.big { font-size: 56px; }
.g-name { font-size: 12px; font-weight: 700; margin-top: 5px; line-height: 1.2; }
.g-rar { font-size: 10px; color: var(--muted); margin-top: 3px; font-weight: 600; }

.reset-link {
  display: block; margin: 28px auto 8px;
  background: none; border: none;
  font-family: var(--font);
  color: var(--muted); opacity: .5;
  font-size: 12.5px; text-decoration: underline;
  cursor: pointer;
}

.modal {
  position: fixed; inset: 0; background: rgba(3, 12, 22, .72);
  backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 22px; z-index: 50;
  animation: fadein .2s;
}
@keyframes fadein { from { opacity: 0; } }
.modal.hidden { display: none; }
.modal-card {
  background: linear-gradient(180deg, var(--surface), var(--bg));
  border: 2px solid var(--amber);
  border-radius: var(--r-lg);
  padding: 22px; max-width: 420px; width: 100%;
  max-height: 84vh; overflow-y: auto; text-align: center;
  animation: popin .3s cubic-bezier(.3,1.4,.5,1);
}
.modal-card.epic { border-color: var(--violet); }
.modal-card h3 { font-size: 21px; margin-top: 6px; }
.modal-card ul { text-align: left; margin: 14px 0; padding-left: 20px; font-size: 15px; line-height: 1.55; }
.modal-card li { margin-bottom: 6px; }
.g-meta { font-size: 13.5px; color: var(--muted); margin-top: 5px; line-height: 1.5; }
.g-lesson {
  background: rgba(255,255,255,.07);
  border-radius: var(--r-sm);
  padding: 12px; font-size: 14.5px; line-height: 1.5;
  text-align: left;
}

/* ===================== Экран входа (PIN) ===================== */
.pin-screen {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(700px 420px at 50% 6%, #1b4d78 0%, #081f35 65%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 24px calc(24px + env(safe-area-inset-bottom));
  gap: 6px;
}
.pin-wolf { width: 132px; height: 132px; object-fit: contain; animation: float 4s ease-in-out infinite; }
.pin-title { font-size: 19px; font-weight: 800; margin-top: 4px; }

.pin-dots { display: flex; gap: 14px; margin: 16px 0 4px; }
.pin-dots span {
  width: 17px; height: 17px; border-radius: 50%;
  border: 2.5px solid var(--line); background: transparent;
  transition: transform .15s, background .15s;
}
.pin-dots span.on { background: var(--amber); border-color: var(--amber); transform: scale(1.18); }

.pin-err { color: #ff9195; font-size: 14px; font-weight: 700; height: 20px; }

.pin-pad {
  display: grid; grid-template-columns: repeat(3, 74px);
  gap: 13px; margin-top: 10px;
}
.pin-key {
  font-family: var(--font);
  height: 68px;
  border-radius: 20px;
  border: 1.5px solid var(--line);
  background: linear-gradient(165deg, var(--surface-2), var(--surface));
  color: var(--text);
  font-size: 25px; font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,.3);
  transition: transform .07s, box-shadow .07s;
}
.pin-key:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.3); }
.pin-del { font-size: 20px; color: var(--muted); }

.pin-screen.shake { animation: shake .38s; }
@keyframes shake {
  20%, 60% { transform: translateX(-9px); }
  40%, 80% { transform: translateX(9px); }
}

/* ===================== Нижняя навигация ===================== */
#nav {
  display: flex;
  background: rgba(9, 30, 50, .92);
  backdrop-filter: blur(8px);
  border-top: 1.5px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  flex-shrink: 0;
}
.nav-btn {
  flex: 1;
  font-family: var(--font);
  background: none; border: none;
  color: var(--muted);
  font-size: 21px;
  padding: 9px 0 7px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  position: relative;
  transition: color .15s;
}
.nav-btn span { font-size: 11px; font-weight: 700; }
.nav-btn.active { color: var(--amber); }
.nav-btn.active::before {
  content: ''; position: absolute; top: 0; left: 22%; right: 22%;
  height: 3px; border-radius: 0 0 4px 4px; background: var(--amber);
}
