:root {
  --bg: #F4F6FA;
  --card: #FFFFFF;
  --blue: #2F80ED;
  --blue-soft: #EAF3FF;
  --text: #1F2937;
  --muted: #6B7280;
  --line: #E5E7EB;
  --green: #22C55E;
  --green-soft: #EAFBF1;
  --red: #EF4444;
  --red-soft: #FEECEC;
  --gold: #F59E0B;
  --gold-soft: #FFF7D6;
  --shadow: 0 4px 20px rgba(0, 0, 0, .06);
  --nav-height: 84px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "SF Pro Display", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:active {
  transform: scale(.98);
}

.app {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(var(--nav-height) + 28px + env(safe-area-inset-bottom));
  position: relative;
}

.screen {
  display: grid;
  gap: 16px;
  animation: rise .25s ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  background: var(--card);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.hero-card {
  min-height: 140px;
  padding: 22px;
  display: grid;
  align-content: space-between;
  overflow: hidden;
  position: relative;
}

.hero-card::after {
  content: "";
  width: 118px;
  height: 118px;
  border-radius: 36px;
  background: linear-gradient(140deg, rgba(47, 128, 237, .16), rgba(34, 197, 94, .12));
  position: absolute;
  right: -28px;
  top: -22px;
  transform: rotate(14deg);
}

.hero-top,
.hero-stats,
.hero-actions {
  position: relative;
  z-index: 1;
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.hero-name {
  margin: 0;
  color: var(--text);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.hero-caption {
  margin-top: 6px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.35;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 15px;
}

.stat-chip {
  min-height: 34px;
  padding: 8px 10px;
  border-radius: 999px;
  background: #F8FAFC;
  color: var(--muted);
  white-space: nowrap;
}

.subscription-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: #A16207;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.subscription-pill.active {
  background: var(--green-soft);
  color: #15803D;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
}

.section-title {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.15;
}

.section-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.icon-btn,
.small-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: 16px;
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
  transition: all .25s ease;
}

.icon-btn {
  width: 44px;
  padding: 0;
}

.small-btn {
  padding: 0 14px;
  font-size: 14px;
  font-weight: 700;
}

.icon-btn:hover,
.small-btn:hover,
.menu-card:hover,
.ticket-card:hover,
.answer-btn:hover,
.leader-card:hover,
.mistake-card:hover {
  transform: translateY(-2px);
}

.icon {
  width: 28px;
  height: 28px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.menu-card {
  min-height: 110px;
  width: 100%;
  padding: 20px;
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 54px 1fr auto;
  align-items: center;
  gap: 16px;
  color: var(--text);
  text-align: left;
  transition: all .25s ease;
}

.menu-icon {
  width: 48px;
  height: 48px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--blue-soft);
  color: var(--blue);
}

.menu-icon.green {
  background: var(--green-soft);
  color: #16A34A;
}

.menu-icon.gold {
  background: var(--gold-soft);
  color: #B45309;
}

.menu-icon.red {
  background: var(--red-soft);
  color: var(--red);
}

.menu-title {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.2;
}

.menu-desc {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.chevron {
  color: #CBD5E1;
}

.tickets-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ticket-card {
  min-height: 142px;
  padding: 18px;
  display: grid;
  align-content: space-between;
  gap: 18px;
  text-align: left;
  color: var(--text);
  transition: all .25s ease;
}

.ticket-number {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  font-size: 19px;
  font-weight: 800;
}

.ticket-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.progress {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: var(--blue);
  transition: width .25s ease;
}

.question-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.question-chip {
  aspect-ratio: 1;
  min-width: 0;
  border-radius: 16px;
  background: var(--card);
  color: var(--text);
  border: 2px solid var(--line);
  font-size: 15px;
  font-weight: 800;
  transition: all .25s ease;
}

.question-chip.correct {
  background: var(--green-soft);
  border-color: rgba(34, 197, 94, .35);
  color: #15803D;
}

.question-chip.wrong {
  background: var(--red-soft);
  border-color: rgba(239, 68, 68, .35);
  color: #B91C1C;
}

.question-card {
  min-height: 220px;
  padding: 24px;
  display: grid;
  gap: 16px;
}

.question-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.timer {
  min-width: 82px;
  padding: 8px 10px;
  border-radius: 999px;
  background: #F8FAFC;
  color: var(--text);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.question-text {
  margin: 0;
  color: var(--text);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.question-media {
  width: 100%;
  min-height: 158px;
  border-radius: 20px;
  overflow: hidden;
  background: #EEF2F7;
}

.question-media svg {
  width: 100%;
  height: auto;
  display: block;
}

.question-media img {
  width: 100%;
  height: auto;
  display: block;
}

.answers {
  display: grid;
  gap: 16px;
}

.answer-btn {
  width: 100%;
  min-height: 68px;
  padding: 16px 18px;
  border-radius: 20px;
  background: var(--card);
  border: 2px solid var(--line);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.3;
  transition: all .25s ease;
}

.answer-index {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: #F8FAFC;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
  flex: 0 0 auto;
}

.answer-btn.correct {
  background: var(--green);
  border-color: var(--green);
  color: #FFFFFF;
}

.answer-btn.wrong {
  background: var(--red);
  border-color: var(--red);
  color: #FFFFFF;
}

.answer-btn.correct .answer-index,
.answer-btn.wrong .answer-index {
  background: rgba(255, 255, 255, .22);
  color: #FFFFFF;
}

.answer-btn:disabled {
  cursor: default;
}

.primary-btn,
.secondary-btn,
.danger-btn,
.premium-btn {
  width: 100%;
  min-height: 62px;
  padding: 0 18px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  transition: all .25s ease;
}

.primary-btn {
  background: var(--blue);
  color: #FFFFFF;
}

.secondary-btn {
  background: #FFFFFF;
  color: var(--text);
  border: 2px solid var(--line);
}

.danger-btn {
  background: var(--red);
  color: #FFFFFF;
}

.premium-btn {
  background: var(--gold);
  color: #FFFFFF;
}

.result-card {
  padding: 18px;
  display: grid;
  gap: 12px;
}

.result-card.success {
  background: var(--green-soft);
  color: #14532D;
}

.result-card.error {
  background: var(--red-soft);
  color: #7F1D1D;
}

.result-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 800;
}

.result-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
}

.leader-card {
  min-height: 80px;
  padding: 20px;
  border-radius: 22px;
  background: var(--card);
  box-shadow: 0 4px 20px rgba(0, 0, 0, .05);
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 14px;
  transition: all .25s ease;
}

.leader-card.place-1 {
  background: #FFF7D6;
}

.leader-card.place-2 {
  background: #F1F5F9;
}

.leader-card.place-3 {
  background: #FFE7D6;
}

.rank {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .72);
  display: grid;
  place-items: center;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
}

.leader-name {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.leader-meta {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.leader-score {
  min-width: 62px;
  text-align: right;
  font-size: 18px;
  font-weight: 800;
  color: var(--blue);
}

.profile-head {
  padding: 24px;
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
}

.avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--blue), #76B6FF);
  color: #FFFFFF;
  font-size: 36px;
  font-weight: 800;
  box-shadow: 0 12px 34px rgba(47, 128, 237, .24);
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-name {
  margin: 0;
  color: var(--text);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.profile-id {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  min-height: 90px;
  padding: 17px;
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow);
  display: grid;
  align-content: center;
  gap: 6px;
}

.stat-value {
  font-size: 25px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
}

.history-list,
.mistake-list {
  display: grid;
  gap: 12px;
}

.history-row,
.admin-row {
  min-height: 60px;
  padding: 15px 16px;
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-main {
  min-width: 0;
}

.history-title {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.history-date {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.history-state {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 800;
}

.history-state.good {
  color: #16A34A;
}

.history-state.bad {
  color: var(--red);
}

.mistake-card {
  padding: 18px;
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
  transition: all .25s ease;
}

.mistake-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.mistake-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.35;
}

.mistake-answer {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.review-tabs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 0 6px;
  scrollbar-width: none;
}

.review-tabs::-webkit-scrollbar {
  display: none;
}

.review-tab {
  min-width: 78px;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 16px;
  background: #FFFFFF;
  border: 2px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  transition: all .25s ease;
}

.review-tab.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #FFFFFF;
}

.review-list {
  display: grid;
  gap: 12px;
}

.review-card {
  min-height: 82px;
  padding: 16px;
  border-radius: 22px;
  background: #FFFFFF;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 14px;
  color: var(--text);
  text-align: left;
  transition: all .25s ease;
}

.review-card:hover {
  transform: translateY(-2px);
}

.review-number {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  background: var(--blue-soft);
  color: var(--blue);
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 800;
}

.review-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.review-meta {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.empty-state {
  min-height: 220px;
  padding: 24px;
  display: grid;
  place-items: center;
  gap: 14px;
  text-align: center;
}

.empty-icon {
  width: 62px;
  height: 62px;
  border-radius: 22px;
  background: var(--blue-soft);
  color: var(--blue);
  display: grid;
  place-items: center;
}

.empty-title {
  margin: 0;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.2;
}

.empty-text {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 50;
  width: 100%;
  max-width: 480px;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0;
  background: #FFFFFF;
  box-shadow: 0 -5px 25px rgba(0, 0, 0, .08);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(var(--nav-count, 3), 1fr);
  gap: 6px;
}

.nav-btn {
  width: 100%;
  min-width: 0;
  min-height: 62px;
  padding: 7px 4px;
  border-radius: 20px;
  background: transparent;
  color: #9CA3AF;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  transition: all .25s ease;
}

.nav-btn.active {
  color: var(--blue);
  background: var(--blue-soft);
}

.nav-btn .icon {
  width: 28px;
  height: 28px;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(0, 0, 0, .4);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}

.sheet-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 80;
  width: 100%;
  max-width: 480px;
  height: 80dvh;
  padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
  border-radius: 32px 32px 0 0;
  background: #FFFFFF;
  box-shadow: 0 -18px 50px rgba(15, 23, 42, .18);
  transform: translate(-50%, 105%);
  transition: transform .25s ease;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
}

.bottom-sheet.open {
  transform: translate(-50%, 0);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sheet-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
}

.sheet-content {
  overflow: auto;
  padding-bottom: 6px;
  display: grid;
  gap: 16px;
}

.video-box {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 24px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, .16), transparent 34%),
    linear-gradient(145deg, #111827, #273349);
  display: grid;
  place-items: center;
  color: #FFFFFF;
}

.video-play {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  display: grid;
  place-items: center;
  backdrop-filter: blur(8px);
}

.video-player {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 24px;
  background: #111827;
  display: block;
}

.explain-card {
  padding: 18px;
  border-radius: 22px;
  background: #F8FAFC;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

.admin-panel {
  display: grid;
  gap: 12px;
}

.admin-row {
  align-items: flex-start;
  flex-direction: column;
}

.admin-row strong {
  font-size: 15px;
}

.admin-row span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.admin-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.admin-metric {
  min-height: 104px;
  padding: 18px;
  border-radius: 22px;
  background: #FFFFFF;
  box-shadow: var(--shadow);
  display: grid;
  align-content: center;
  gap: 8px;
}

.admin-metric-value {
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.admin-metric-label {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.admin-form {
  padding: 18px;
  border-radius: 24px;
  background: #FFFFFF;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 52px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #FFFFFF;
  color: var(--text);
  padding: 13px 14px;
  outline: none;
  transition: all .25s ease;
}

.field textarea {
  min-height: 104px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(47, 128, 237, .12);
}

.admin-users {
  display: grid;
  gap: 10px;
}

.admin-user {
  min-height: 74px;
  padding: 16px;
  border-radius: 20px;
  background: #FFFFFF;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}

.admin-user-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
}

.admin-user-meta {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.admin-status {
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #F8FAFC;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.admin-status.good {
  background: var(--green-soft);
  color: #15803D;
}

.admin-status.bad {
  background: var(--red-soft);
  color: #B91C1C;
}

.hidden-input {
  display: none;
}

@media (max-width: 360px) {
  .app {
    padding-left: 12px;
    padding-right: 12px;
  }

  .hero-name {
    font-size: 23px;
  }

  .section-title {
    font-size: 22px;
  }

  .tickets-grid {
    grid-template-columns: 1fr;
  }

  .question-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .answer-btn {
    font-size: 16px;
  }

  .admin-metrics,
  .form-grid {
    grid-template-columns: 1fr;
  }
}
