/* ========== ROOT: DESIGN TOKENS ========== */
:root {
  /* Color Palette */
  --bg: #0e1621;
  --fg: #fff;
  --muted: #aeb7c2;
  --accent: #2ea6ff;

  /* Semantic Colors */
  --color-error: #ff4444;
  --color-success: #4caf50;
  --color-warning: #ff9800;
  --color-text-secondary: var(--muted);
  
  /* Theme-adaptive colors (set by JavaScript) */
  --card-bg: rgba(255, 255, 255, 0.04);
  --stroke-color: rgba(255, 255, 255, 0.08);
  --elem-bg: rgba(255, 255, 255, 0.06);
  --modal-bg: var(--bg);
  --icon-bg: rgba(255, 255, 255, 0.06);
  --color-border: var(--stroke-color);

  /* Typography Scale */
  --fs-12: 12px;
  --fs-13: 13px;
  --fs-14: 14px;
  --fs-15: 15px;
  --fs-16: 16px;
  --fs-18: 18px;
  --fs-20: 20px;
  --fs-22: 22px;
  
  --lh-tight: 1.15;
  --lh-normal: 1.35;
  --lh-base: 1.45;

  /* Spacing Scale (8px module) */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 56px;

  /* Border Radius Scale */
  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* Telegram Theme Override */
  --tg-bg: var(--bg);
  --tg-tx: var(--fg);
  --tg-hint: var(--muted);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  
  /* Additional Colors */
  --color-accent-contrast: #00131f;
  --color-gold: #d4af37;
  --color-gold-shadow: rgba(212, 175, 55, 0.6);
  --color-info: #007AFF;
  
  /* Overlays & Shadows */
  --overlay-dark: rgba(0, 0, 0, 0.85);
  --overlay-medium: rgba(0, 0, 0, 0.4);
  --overlay-light: rgba(0, 0, 0, 0.25);
  --shadow-text: 0 1px 2px rgba(0, 0, 0, 0.85), 0 0 8px rgba(0, 0, 0, 0.5);
  --shadow-text-default: 0 1px 3px rgba(0, 0, 0, 0.7), 0 0 8px rgba(0, 0, 0, 0.5);
  --bg-overlay-light: rgba(0, 0, 0, 0.15);
  
  /* Common Values */
  --border-default: 1px solid var(--color-border);
  --color-transparent: transparent;
  
  /* UI Element Sizes */
  --size-touch: 44px;
  --size-icon: 48px;
  --size-thumb-sm: 52px;
  --size-thumb-md: 88px;
  --size-avatar: 128px;
  
  /* Miscellaneous */
  --opacity-secondary: 0.7;
  --transition-fast: 0.1s ease;
  --transition-base: 0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
}

body {
  font: var(--fs-16) / var(--lh-base) system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu;
  background: var(--tg-bg);
  color: var(--tg-tx);
  -webkit-font-smoothing: antialiased;
  max-width: 920px;
  margin: auto;
  touch-action: pan-y;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

main.container {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  height: 100vh;
  height: 100dvh;
}

.hidden,
.hidden-input,
.waves-empty.hidden,
.waves-meta-list--empty,
.thumbs-row:empty {
  display: none;
}

.topbar-action.hidden,
.lightbox.hidden,
.filter-modal.hidden {
  display: none !important;
}
.mt-sm { margin-top: var(--space-2); }

/* ========== TOPBAR ========== */
.topbar {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: var(--space-4);
  margin-bottom: var(--space-4);
  position: relative;
  padding: 0 var(--space-4);
}
.title { font-size: var(--fs-20); font-weight: 600; white-space: pre-line; text-align: center; }

.topbar-action {
  position: absolute;
  right: var(--space-4);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--card-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: none;
  transition: transform 0.2s ease;
}

.topbar-action-left {
  right: auto;
  left: var(--space-4);
  width: auto;
  min-width: 44px;
  padding: 0 var(--space-3);
  gap: var(--space-2);
  justify-content: center;
}

.topbar-action img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
}

.balance-value {
  font-size: var(--fs-15);
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
}

/* ========== TOPBAR BALANCE - LIGHT THEME ========== */
/* Черное число магатамы в топбаре при светлой теме */
.theme-light .balance-value {
  color: #000;
}

/* Белое название карты в первой карточке на странице сюжет при светлой теме */
.theme-light .story-hero-card--with-bg .story-hero-title {
  color: #fff;
}

.topbar-action:active {
  transform: scale(0.94);
}

.topbar-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}


/* ========== CARD ========== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin: var(--space-4);
  margin-bottom: var(--card-spacing, var(--space-4));
  padding: var(--space-4);
  position: relative;
}

.card:last-child { margin-bottom: 0; }

.card-title { 
  font-weight: 600; 
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.card-title-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
}

/* ========== COMMENTS ========== */
.comments-list {
  margin-bottom: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

#publicCommentForm .input {
  margin-bottom: var(--space-1);
}

.comment-item {
  padding: var(--space-3);
  background: var(--elem-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.comment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}

.comment-author {
  font-weight: 600;
  font-size: var(--fs-14);
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.comment-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}


.comment-date {
  font-size: var(--fs-12);
  color: var(--color-text-secondary);
}

.comment-text {
  font-size: var(--fs-14);
  line-height: var(--lh-base);
  color: var(--tg-tx);
  word-wrap: break-word;
  white-space: pre-wrap;
}

/* ========== GRID & FIELDS ========== */
.profile-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
.field label { font-size: var(--fs-12); color: var(--tg-hint); margin-bottom: var(--space-1); display: block; }
.value { font-size: var(--fs-15); word-break: break-word; }
.value.lines { white-space: pre-line; }

/* Custom username chip for participant detail page */
#participantDetailScreen .author-chip#participant_username {
  background: linear-gradient(135deg, rgba(51, 144, 236, 0.15) 0%, rgba(51, 144, 236, 0.15) 100%);
  color: var(--tg-button-color, #3390ec);
  border: 1px solid rgba(51, 144, 236, 0.3);
  padding: var(--space-1) var(--space-2) var(--space-1) var(--space-1);
  font-weight: 500;
  box-shadow: 0 1px 4px rgba(51, 144, 236, 0.1);
  min-height: 28px;
  font-size: var(--fs-14);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

#participantDetailScreen .author-chip#participant_username .username-chip-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: block;
}

/* ========== FORMS ========== */
.form { display: grid; }
.input label { font-size: var(--fs-13); color: var(--tg-hint); margin-bottom: var(--space-1); }
.input input,
.input textarea,
.input select {
  width: 100%;
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--tg-tx);
  font-size: var(--fs-16);
  line-height: var(--lh-normal);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
}
.input textarea {
  resize: none;
  min-height: calc(1em + 24px);
  max-height: 200px;
  overflow-y: auto;
}
.input select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23aeb7c2' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  background-size: 12px 8px;
  padding-right: calc(var(--space-3) + 12px + var(--space-2));
}
.input select option {
  background-color: var(--modal-bg);
  color: var(--tg-tx);
  padding: var(--space-2);
}
.input input:focus,
.input textarea:focus,
.input select:focus { 
  border-color: var(--accent); 
}
.input label.muted {
  color: var(--tg-hint);
  opacity: var(--opacity-secondary);
}
.birthday-selects {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.birthday-selects select {
  flex: 1;
  min-width: 80px;
}
.birthday-selects select:nth-child(2) {
  min-width: 120px;
}
.birthday-selects select:nth-child(3) {
  min-width: 100px;
}

/* ========== ACTIONS BAR ========== */
.actions-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin: var(--space-4) ;
}
.actions-bar .wide {
  width: 100%;
  grid-column: 1 / -1;
}
/* Кнопка отправки заявки мастерства должна быть полной ширины */
#masteryApplicationCard .actions-bar .btn,
#top50ApplicationCard .actions-bar .btn,
#trophyApplicationCard .actions-bar .btn,
#seasonTrophyApplicationCard .actions-bar .btn,
#hellmodeApplicationCard .actions-bar .btn {
  width: 100%;
}
/* Убираем боковые отступы у actions-bar в карточках заявок */
#masteryApplicationCard .actions-bar,
#top50ApplicationCard .actions-bar,
#trophyApplicationCard .actions-bar,
#seasonTrophyApplicationCard .actions-bar,
#hellmodeApplicationCard .actions-bar {
  margin-left: 0;
  margin-right: 0;
  margin-bottom: 0;
}

#homeFeedbackBtnContainer {
  margin-bottom: var(--space-0);
}

/* ========== UPLOAD & SHOTS ========== */
.shots-two {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: var(--space-2);
  justify-content: flex-start;
}

.shots-two .upload-box {
  width: var(--size-thumb-md);
  height: var(--size-thumb-md);
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--card-bg);
  font-size: 28px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}

.shots-two .shot-thumb {
  width: var(--size-thumb-md);
  height: var(--size-thumb-md);
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  overflow: hidden;
  background: var(--elem-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.shots-two .shot-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  border-radius: inherit;
}

/* ========== CHIPS ========== */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--tg-tx);
  cursor: pointer;
  font-size: var(--fs-15);
  min-height: var(--size-touch);
}
.chip-btn.active {
  background: var(--accent);
  border-color: transparent;
  color: var(--color-accent-contrast);
  font-weight: 600;
}

/* ========== BUTTONS ========== */
.btn {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  background: transparent;
  color: var(--tg-tx);
  cursor: pointer;
  min-height: var(--size-touch);
  font-size: var(--fs-16);
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn.primary { background: var(--accent); border-color: transparent; color: var(--color-accent-contrast); font-weight: 700; }
.btn.danger { background: var(--color-error); border-color: transparent; color: var(--color-accent-contrast); font-weight: 700; }

/* ========== КНОПКИ С ФОНОВЫМИ ИЗОБРАЖЕНИЯМИ ========== */
/* Синие кнопки (blue.png) - по ID */
#sendFeedbackBtn,
#profileEditBtn,
#createBuildBtn,
#joinTelegramBtn,
#startScreenSaveBtn,
#filterModalOkBtn {
  background: none !important;
  background-image: url('../assets/system/blue.png') !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  border-color: var(--color-transparent) !important;
  position: relative;
  z-index: 1;
  color: #fff !important;
  text-shadow: var(--shadow-text-default);
}

#sendFeedbackBtn::before,
#profileEditBtn::before,
#createBuildBtn::before,
#joinTelegramBtn::before,
#startScreenSaveBtn::before,
#filterModalOkBtn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg-overlay-light);
  border-radius: inherit;
  z-index: 0;
  pointer-events: none;
}

/* Кнопка publishBuildBtn - синяя по умолчанию, красная когда показывает "Скрыть" */
#publishBuildBtn:not(.btn--red):not(.danger) {
  background: none !important;
  background-image: url('../assets/system/blue.png') !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  border-color: var(--color-transparent) !important;
  position: relative;
  z-index: 1;
  color: #fff !important;
  text-shadow: var(--shadow-text-default);
}

#publishBuildBtn:not(.btn--red):not(.danger)::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg-overlay-light);
  border-radius: inherit;
  z-index: 0;
  pointer-events: none;
}

/* Зеленые кнопки (green.png) - по ID */
#feedbackSubmitBtn,
#top50ApplicationSubmitBtn,
#profileSaveBtn,
#buildSubmitBtn,
#buildEditSubmitBtn {
  background: none !important;
  background-image: url('../assets/system/green.png') !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  border-color: var(--color-transparent) !important;
  position: relative;
  z-index: 1;
  color: #fff !important;
  text-shadow: var(--shadow-text-default);
}

#feedbackSubmitBtn::before,
#profileSaveBtn::before,
#buildSubmitBtn::before,
#buildEditSubmitBtn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg-overlay-light);
  border-radius: inherit;
  z-index: 0;
  pointer-events: none;
}

/* Красные кнопки (red.png) - по ID */
#deleteBuildBtn {
  background: none !important;
  background-image: url('../assets/system/red.png') !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  border-color: var(--color-transparent) !important;
  position: relative;
  z-index: 1;
  color: #fff !important;
  text-shadow: var(--shadow-text-default);
}

#deleteBuildBtn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg-overlay-light);
  border-radius: inherit;
  z-index: 0;
  pointer-events: none;
}

/* Кнопка publishBuildBtn - красная когда показывает "Скрыть" */
#publishBuildBtn.btn--red,
#publishBuildBtn.danger {
  background: none !important;
  background-image: url('../assets/system/red.png') !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  border-color: var(--color-transparent) !important;
  position: relative;
  z-index: 1;
  color: #fff !important;
  text-shadow: var(--shadow-text-default);
}

#publishBuildBtn.btn--red::before,
#publishBuildBtn.danger::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg-overlay-light);
  border-radius: inherit;
  z-index: 0;
  pointer-events: none;
}

/* Динамически создаваемые кнопки через data-bg-image атрибут */
button.btn.primary[type="submit"],
button.btn.primary[data-bg-image="green"],
button.btn[data-bg-image="green"],
#masteryApplicationSubmitBtn {
  background: none !important;
  background-image: url('../assets/system/green.png') !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  border-color: var(--color-transparent) !important;
  position: relative;
  z-index: 1;
  color: #fff !important;
  text-shadow: var(--shadow-text-default);
}

button.btn.primary[type="submit"]::before,
button.btn.primary[data-bg-image="green"]::before,
button.btn[data-bg-image="green"]::before,
#masteryApplicationSubmitBtn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg-overlay-light);
  border-radius: inherit;
  z-index: 0;
  pointer-events: none;
}

button.btn[data-bg-image="blue"] {
  background: none !important;
  background-image: url('../assets/system/blue.png') !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  border-color: var(--color-transparent) !important;
  position: relative;
  z-index: 1;
  color: #fff !important;
  text-shadow: var(--shadow-text-default);
}

button.btn[data-bg-image="blue"]::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg-overlay-light);
  border-radius: inherit;
  z-index: 0;
  pointer-events: none;
}

button.btn[data-bg-image="red"] {
  background: none !important;
  background-image: url('../assets/system/red.png') !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  border-color: var(--color-transparent) !important;
  position: relative;
  z-index: 1;
  color: #fff !important;
  text-shadow: var(--shadow-text-default);
}

button.btn[data-bg-image="red"]::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg-overlay-light);
  border-radius: inherit;
  z-index: 0;
  pointer-events: none;
}
.btn.wide { width: 100%; }
.btn:active { transform: translateY(1px); }

/* ========== HOME ========== */
#telegramGroupBtn {
  text-align: center;
  text-decoration: none;
  display: inline-block;
}
/* Защита всех изображений и SVG от контекстного меню и перетаскивания */
img, svg {
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* Разрешаем pointer-events для интерактивных элементов */
button img,
button svg,
a img,
a svg,
.build-icon img,
.build-stat-icon,
.mastery-icon,
.shot-thumb img,
.upload-box img {
  pointer-events: auto;
}

/* Разрешаем полное взаимодействие со скриншотами в детальном просмотре билда */
.shots-grid .shot-thumb img,
.story-scroll-images img,
.lightbox img {
  pointer-events: auto;
  -webkit-user-drag: auto;
  user-select: auto;
  -webkit-user-select: auto;
  -moz-user-select: auto;
  -ms-user-select: auto;
}

.story-scroll-images img {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  object-fit: cover;
}

.lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  transition: transform 0.2s ease-out;
  transform-origin: center center;
  touch-action: pan-x pan-y pinch-zoom;
  user-select: none;
  -webkit-user-drag: none;
}

/* Логотип на главной странице */
.logo { 
  width: var(--size-avatar); 
  height: var(--size-avatar); 
  object-fit: contain; 
}

/* ========== WAVES ========== */
.waves-meta-card {
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  color: var(--fg);
  min-height: 96px;
}
.waves-mod-icons {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  display: flex;
  gap: var(--space-2);
  align-items: center;
  z-index: 2;
}
.waves-mod-icon {
  width: 36px;
  height: 36px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: rgba(14, 22, 33, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Ротация: мод-иконки в правом верхнем углу внутри кнопок */
.badge-btn .rotation-mod-icons {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  display: flex;
  gap: var(--space-2);
  align-items: center;
  z-index: 2;
}

/* Таймер ротации */
.rotation-countdown-timer {
  font-size: var(--fs-16);
  font-weight: 600;
  letter-spacing: .5px;
}

/* Отступы заголовка таймера: сверху var(--space-3), снизу 0 */
.rotation-countdown-title {
  font-size: var(--fs-16);
  margin-top: var(--space-3);
  margin-bottom: 0;
}

/* Хедер карточек с правой кнопкой */
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

/* Хиро-блок главной */
.home-hero {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-3);
  padding-left: var(--space-4);
  padding-right: var(--space-4);
  padding-bottom: 0;
  margin-bottom: 0;
  text-align: center;
}

.home-hero-logo {
  width: 128px;
  height: 128px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.home-hero-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(139, 0, 0, 0.25)) 
          drop-shadow(0 0 18px rgba(220, 20, 60, 0.2));
  animation: logoGlow 3s ease-in-out infinite alternate;
}

@keyframes logoGlow {
  from {
    filter: drop-shadow(0 0 10px rgba(139, 0, 0, 0.25)) 
            drop-shadow(0 0 18px rgba(220, 20, 60, 0.2));
  }
  to {
    filter: drop-shadow(0 0 12px rgba(139, 0, 0, 0.3)) 
            drop-shadow(0 0 22px rgba(220, 20, 60, 0.25));
  }
}

.home-hero .actions-bar {
  width: 100%;
  margin: 0;
  grid-template-columns: 1fr;
  gap: 0;
}

.home-hero .actions-bar .btn {
  width: 100%;
}

.start-screen-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.start-screen-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: var(--elem-bg);
}

.start-screen-option input[type="radio"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.start-screen-option span {
  font-size: var(--fs-16);
  font-weight: 600;
  color: var(--fg);
}

.start-screen-actions {
  margin-top: var(--space-4);
  margin-left: 0;
  margin-right: 0;
  grid-template-columns: 1fr;
}

/* Карточка последних наград */
.recent-events-list,
.recent-comments-list,
.upcoming-birthdays-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.recent-event-item {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.recent-event-item:active {
  background-color: transparent;
  opacity: 1;
}

.recent-comment-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--elem-bg);
  border: 1px solid var(--color-border) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--fg);
  text-transform: uppercase;
  overflow: hidden;
  flex-shrink: 0;
  padding: 0;
  box-sizing: border-box;
  margin: 0;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.recent-comment-avatar img {
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.recent-comment-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}

.recent-event-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.recent-event-headline {
  font-size: var(--fs-15);
  font-weight: 600;
  line-height: var(--lh-normal);
  color: var(--fg);
}

.recent-event-link {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.recent-event-link.recent-comment-avatar {
  border: 1px solid var(--color-border) !important;
}

.recent-event-details {
  font-size: var(--fs-13);
  color: var(--muted);
  line-height: var(--lh-tight);
}

/* ========== RECENT EVENTS - LIGHT THEME ========== */
/* Черный текст в карточке "Последние награды" при светлой теме */
.theme-light .recent-event-headline {
  color: #000;
}

.theme-light .recent-event-details {
  color: #666;
}

.theme-light .recent-comment-meta {
  color: #666;
}

.theme-light .upcoming-birthday-date {
  color: #666;
}

.theme-light .waves-subtitle {
  color: #666;
}

.theme-light .build-author {
  color: #666;
}

.theme-light .build-stat-count {
  color: #666;
}

.theme-light .muted {
  color: #666;
}

.theme-light .season-trophy-timer {
  color: #666;
}

.theme-light .avatar-placeholder {
  color: #666;
}

.theme-light .version-date {
  color: #666;
}

.recent-comments-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.recent-comment-item {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.recent-comment-item:active {
  background-color: transparent;
  opacity: 1;
}

.recent-comment-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}

.recent-comment-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.recent-comment-meta {
  font-size: var(--fs-13);
  color: var(--muted);
}

.recent-comment-author {
  font-size: var(--fs-15);
  font-weight: 600;
  line-height: var(--lh-normal);
  color: var(--fg);
}

.recent-comment-build {
  font-size: var(--fs-15);
  font-weight: 600;
  cursor: pointer;
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 10px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: transparent;
  align-self: flex-start;
  max-width: 240px;
}
.recent-comment-build span {
  display: inline-block;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-comment-text {
  font-size: var(--fs-15);
  line-height: 1.3;
  color: var(--fg);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Светлая тема для карточки комментариев */
.theme-light .recent-comment-author,
.theme-light .recent-comment-text {
  color: #000;
}

.theme-light .recent-comment-build img {
  filter: invert(1);
}

/* ========== UPCOMING BIRTHDAYS CARD ========== */
.upcoming-birthday-item {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.upcoming-birthday-item:active {
  background-color: transparent;
  opacity: 1;
}

.upcoming-birthday-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.upcoming-birthday-name {
  font-size: var(--fs-15);
  font-weight: 600;
  line-height: var(--lh-normal);
  color: var(--fg);
}

.upcoming-birthday-link {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.upcoming-birthday-link.recent-comment-avatar {
  border: 1px solid var(--color-border) !important;
}

/* ========== WEEK HEROES CARD ========== */
.week-heroes-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.week-hero-item {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.week-hero-item:active {
  background-color: transparent;
  opacity: 1;
}

/* ========== WEEK HEROES CARD ========== */
.week-hero-avatar-wrapper {
  position: relative;
  flex-shrink: 0;
}

.week-hero-avatar--leader {
  border: 2px solid #DC143C !important;
  box-shadow: 0 0 12px rgba(220, 20, 60, 0.4);
}

.week-hero-item--leader {
  background: linear-gradient(135deg, rgba(220, 20, 60, 0.08), rgba(139, 0, 0, 0.03));
  border-radius: var(--radius-md);
  padding: var(--space-2);
  margin: calc(var(--space-2) * -1);
  border: 1px solid rgba(220, 20, 60, 0.2);
}

.week-hero-crown {
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 20px;
  z-index: 10;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  animation: crown-glow 2s ease-in-out infinite;
}

@keyframes crown-glow {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  }
  50% {
    transform: scale(1.1);
    filter: drop-shadow(0 2px 8px rgba(220, 20, 60, 0.6));
  }
}

.week-hero-progress {
  width: 100%;
  height: 4px;
  background: var(--elem-bg);
  border-radius: 999px;
  overflow: hidden;
  margin-top: var(--space-2);
}

.week-hero-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #DC143C, #B22222);
  border-radius: 999px;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px rgba(220, 20, 60, 0.5);
}

.week-hero-item--leader .week-hero-progress-bar {
  background: linear-gradient(90deg, #DC143C, #FF1744);
  box-shadow: 0 0 12px rgba(220, 20, 60, 0.7);
}

.upcoming-birthday-date {
  font-size: var(--fs-13);
  color: var(--muted);
  line-height: var(--lh-tight);
}
.waves-mod-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ========== ROTATION MODE BUTTONS ========== */
#rotationScreen .badge-btn {
  min-height: calc(var(--size-touch) + var(--space-4) + var(--space-2));
  padding: var(--space-4);
}

.rotation-mode-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex: 1;
}

.rotation-mode-name {
  font-size: var(--fs-14);
  color: var(--tg-hint);
  font-weight: 500;
}

.rotation-mode-map {
  font-size: var(--fs-16);
  font-weight: 600;
  line-height: var(--lh-normal);
  word-break: break-word;
}

.rotation-mode-mod {
  font-size: var(--fs-14);
  font-weight: 600;
  line-height: var(--lh-normal);
  word-break: break-word;
  margin-top: 2px;
}

.rotation-mode-hint {
  font-size: var(--fs-14);
  margin-top: 2px;
}

.rotation-mod-icons {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}

/* Стили для числа награды в квадратике с magatama */
.waves-mod-icon {
  position: relative;
}

/* Прямоугольник с наградой внизу справа */
.badge-btn .quest-reward-badge,
.waves-meta-card .quest-reward-badge,
.story-hero-card .quest-reward-badge,
.trials-meta-card .quest-reward-badge {
  position: absolute !important;
  bottom: var(--space-3);
  right: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: rgba(14, 22, 33, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  backdrop-filter: blur(6px);
  z-index: 3 !important;
  min-width: fit-content;
}

.quest-reward-badge .quest-reward-value {
  font-size: var(--fs-14);
  font-weight: 600;
  color: #fff;
  line-height: 1;
  white-space: nowrap;
}

.quest-reward-badge .quest-reward-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  object-fit: contain;
}


/* ========== UPCOMING BIRTHDAYS - LIGHT THEME ========== */
/* Черные ники участников в карточке дней рождения при светлой теме */
.theme-light .upcoming-birthday-name {
  color: #000;
}

/* Уменьшаем размер иконки класса в карточке заданий */
.quest-card .waves-mod-icon--class img,
.waves-meta-card .waves-mod-icon--class img {
  width: 80%;
  height: 80%;
}

/* Стили для подсказки в карточке заданий */
.rotation-mode-hint {
  font-size: var(--fs-12);
  color: rgba(255, 255, 255, 0.8);
  margin-top: 2px;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.65), 0 0 4px rgba(0, 0, 0, 0.45);
}

.badge-btn--with-bg .rotation-mode-hint {
  color: rgba(255, 255, 255, 0.8);
}

.waves-meta-card .waves-header {
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}
.waves-title {
  font-size: var(--fs-18);
  font-weight: 600;
}
.waves-subtitle {
  font-size: var(--fs-15);
  color: var(--muted);
}
.waves-meta-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(14, 22, 33, 0.2), rgba(14, 22, 33, 0.4));
  opacity: 0;
  transition: opacity var(--transition-base);
  z-index: 1;
  pointer-events: none;
}
.waves-meta-card--with-bg::before {
  opacity: 1;
}
.waves-meta-card--with-bg .waves-subtitle {
  color: rgba(255, 255, 255, 0.85);
}
.waves-meta-card--with-bg .waves-title,
.waves-meta-card--with-bg .waves-header {
  text-shadow: var(--shadow-text);
}

/* ========== STORY SCREEN ========== */
.story-hero-card {
  position: relative;
  overflow: hidden;
  min-height: 120px;
  display: flex;
  align-items: flex-end;
}

.story-hero-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(14, 22, 33, 0.2), rgba(14, 22, 33, 0.4));
  z-index: 1;
  pointer-events: none;
}

.story-hero-mod-main {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 2;
}

.story-hero-mod-chapters {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  display: flex;
  gap: var(--space-2);
  z-index: 2;
}

.story-hero-header {
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 2;
}

.story-hero-title {
  font-size: var(--fs-18);
  font-weight: 600;
}

.story-hero-subtitle {
  font-size: var(--fs-15);
}

.story-hero-card--with-bg .story-hero-subtitle {
  color: rgba(255, 255, 255, 0.85);
}

.story-hero-card--with-bg .story-hero-title,
.story-hero-card--with-bg .story-hero-header {
  text-shadow: var(--shadow-text);
}

/* Увеличенные иконки модификаторов глав в карточке сюжета */
.story-hero-mod-chapters .waves-mod-icon {
  width: 44px;
  height: 44px;
}

/* ========== TRIALS META CARD ========== */
.trials-meta-card .waves-title,
.trials-meta-card .waves-header {
  text-shadow: var(--shadow-text);
}

.trials-meta-card--with-bg .waves-subtitle {
  color: rgba(255, 255, 255, 0.85);
}

.trials-meta-card--with-bg .waves-title,
.trials-meta-card--with-bg .waves-header {
  text-shadow: var(--shadow-text);
}

/* ========== ТОП-50 СТРАНИЦА ========== */
#top50DetailContainer .story-hero-card,
#top50DetailContainer .trials-meta-card {
  min-height: 96px;
  align-items: flex-start;
}

#top50DetailContainer .story-hero-header {
  margin-top: 0;
}

/* ========== ТАБЛИЦА НАГРАД ТОП-50 ========== */
.top50-rewards-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-3);
}

.top50-rewards-table tbody tr {
  border-bottom: 1px solid var(--border);
}

.top50-rewards-table tbody tr:last-child {
  border-bottom: none;
}

.top50-rewards-table td {
  text-align: left;
}

.top50-rewards-table td:first-child {
  font-weight: 500;
}

.top50-rewards-table td:last-child {
  text-align: right;
  white-space: nowrap;
}

.story-mod-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.story-mod-row img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

/* Дополнительный отступ после строки «Модификатор недели» перед блоком глав */
.story-mod-row + .muted {
  margin-top: var(--space-3);
}

.story-scroll-title {
  margin-top: var(--space-3);
  margin-bottom: var(--space-2);
  font-weight: 600;
}

.story-scroll-images {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.story-scroll-images img {
  width: 50%;
}

.story-scroll-description {
  font-size: var(--fs-14);
  line-height: var(--lh-normal);
  color: var(--tg-tx);
}

.card.waves-table {
  padding: 0;
  margin: var(--space-4);
  margin-bottom: var(--card-spacing, var(--space-4));
  width: calc(100% - (var(--space-4) * 2));
  box-sizing: border-box;
  overflow: hidden;
}

.waves-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: center;
}
.waves-table th,
.waves-table td {
  padding: 0 var(--space-1);
  font-size: var(--fs-14);
  border-bottom: 1px solid var(--color-border);
  height: 38px;
}
.waves-table td:first-child,
.waves-table td:nth-child(2),
.waves-table td:nth-child(3) {
  border-bottom: 1px solid var(--color-border);
}
.waves-table td {
  vertical-align: middle;
  font-size: var(--fs-14);
}
.waves-table th {
  font-weight: 600;
  color: var(--tg-hint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: var(--fs-12);
}
.waves-icon {
  width: 42px;
  min-width: 42px;
  padding: 0;
  text-align: center;
}
.waves-icon-img {
  display: block;
  width: 18px;
  height: 18px;
  object-fit: contain;
  position: relative;
  z-index: 1;
}
.waves-icon-badge {
  position: relative;
  width: 30px;
  height: 30px;
  margin: 0 auto;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}
.waves-icon-badge--objective {
  background: rgba(46, 166, 255, 0.18);
  border-color: rgba(46, 166, 255, 0.6);
  box-shadow: 0 0 12px rgba(46, 166, 255, 0.35);
}
.waves-icon-badge--mod {
  background: rgba(212, 175, 55, 0.18);
  border-color: rgba(212, 175, 55, 0.65);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.32);
}
.waves-icon-tag {
  position: absolute;
  top: -5px;
  right: -8px;
  font-size: 8px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  z-index: 2;
}
.waves-icon-badge--objective .waves-icon-tag {
  background: #2ea6ff;
  color: #00131f;
}
.waves-icon-badge--mod .waves-icon-tag {
  background: #d4af37;
  color: #1c1200;
}
.waves-table tr:last-child td {
  border-bottom: none;
}
.waves-number {
  width: 3ch;
  min-width: 3ch;
  padding-left: var(--space-2);
  padding-right: var(--space-2);
  text-align: right;
  white-space: nowrap;
  font-weight: 600;
  color: var(--accent);
}
.waves-spawns {
  text-align: left;
}
.waves-table tr.waves-strong {
  background: rgba(255, 82, 82, 0.12);
}
.waves-empty {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--space-4);
  margin: var(--space-4);
  margin-bottom: var(--card-spacing, var(--space-4));
  text-align: center;
}
.waves-meta-extra {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: 0px;
}
.waves-meta-section-title {
  margin-top: var(--space-2);
}
.waves-meta-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.waves-meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.waves-meta-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}
.waves-meta-text {
  flex: 1;
  font-size: var(--fs-14);
  line-height: var(--lh-base);
}

/* ========== WHAT'S NEW ========== */
.version-date {
  font-size: var(--fs-14);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-3);
}

.changelog-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--space-2);
}

.changelog-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  line-height: var(--lh-normal);
}

.changelog-icon {
  font-size: var(--fs-16);
  flex-shrink: 0;
  margin-top: 1px;
}

.changelog-text {
  flex: 1;
  font-size: var(--fs-15);
}

/* ========== LIST ========== */
.grid-list,
.list-buttons {
  display: grid;
  gap: var(--space-2);
}

.grid-list > .badge-btn {
  width: 100%;
}

/* Кнопки заданий должны иметь такую же высоту как на странице ротации */
.quest-card .badge-btn {
  min-height: calc(var(--size-touch) + var(--space-4) + var(--space-2));
  padding: var(--space-4);
}
.list-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--tg-tx);
  cursor: pointer;
  min-height: 64px;
  font-size: var(--fs-16);
}

.list-btn:active { 
  transform: translateY(1px); 
}

.list-btn.success {
  border-color: rgba(46, 166, 255, 0.6);
  box-shadow:
    0 0 0 1px rgba(46, 166, 255, 0.5),
    0 0 6px rgba(46, 166, 255, 0.24);
}

.list-btn.is-static {
  cursor: default;
  pointer-events: none;
}

.list-btn.is-static:active {
  transform: none;
}

.list-btn-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--elem-bg);
  border: 1px solid var(--color-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.list-btn-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.list-btn-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}

.list-btn-trailing {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.list-btn-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.list-btn-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.list-btn-name {
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mastery-icons {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
}

.list-btn .mastery-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  object-fit: contain;
  filter: none;
  /* Защита от контекстного меню и перетаскивания */
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.list-btn .right { 
  opacity: 0.7;
  margin-left: var(--space-2);
  flex-shrink: 0;
}

/* ========== FILE LINE ========== */
.fileline-btn {
  width: 100%;
  min-height: var(--size-touch);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--tg-tx);
  font-size: var(--fs-15);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  cursor: pointer;
}
.fileline-btn:active { transform: translateY(1px); }

/* ========== THUMBS ROW ========== */
.thumbs-row {
  display: flex;
  gap: var(--space-1);
  margin-top: var(--space-1);
  flex-wrap: nowrap;
  overflow: visible;
}
.thumbs-row .preview-item,
.thumbs-row .preview-more {
  width: var(--size-thumb-sm);
  height: var(--size-thumb-sm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--elem-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 18px;
  flex: 0 0 auto;
  position: relative;
}
.thumbs-row .preview-item img {
  width: 100%; height: 100%;
  object-fit: cover; display: block; border-radius: inherit;
}
.thumbs-row .preview-more {
  border: 1px dashed var(--color-border);
  font-weight: 700; opacity: .9;
}

.preview-item.removable::after {
  content: "✕";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: var(--tg-tx);
  background: var(--overlay-light);
  opacity: .35;
  pointer-events: none;
}
.preview-item.removable:active::after { opacity: .6; }

.thumbs-row .preview-item.is-video {
  background: rgba(46, 166, 255, 0.2);
}
.preview-video-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
}
.preview-video-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  border-radius: inherit;
}
.preview-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  padding: 1px 5px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.btn.is-loading {
  pointer-events: none;
  opacity: 0.85;
}

/* ========== ERROR & ANIMATIONS ========== */
.error { border-color: var(--color-error); }
.error-text { color: var(--color-error); font-size: var(--fs-12); margin-top: var(--space-1); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-4px); }
}
.shake { animation: shake .3s; }

/* ========== BUILDS ========== */
.build-item {
  display: grid; grid-template-columns: var(--size-icon) 1fr; gap: var(--space-3); align-items: center;
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); border: 1px solid var(--color-border);
  background: transparent; cursor: pointer; min-height: var(--size-icon); color: var(--tg-tx);
}
.build-item:active { transform: translateY(1px); }
.build-item.published { border-color: var(--color-info); }
.build-icon {
  width: var(--size-icon); height: var(--size-icon); border-radius: var(--radius-sm); border: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: center;
  background: var(--icon-bg); overflow: hidden;
}
.build-icon img { 
  width: 70%; 
  height: 70%; 
  object-fit: contain; 
  opacity: .95;
  pointer-events: auto;
}
.theme-light .build-icon img {
  filter: brightness(0) saturate(100%);
  opacity: 0.8;
}
.build-title {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: var(--space-1);
  font-size: var(--fs-16);
  color: var(--tg-tx);
}
.build-title > div:first-child {
  width: 100%;
  text-align: left;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: none;
  white-space: pre-line;
}
.build-author {
  font-size: var(--fs-13);
  color: var(--muted);
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.build-stats {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-shrink: 0;
}

.build-stat-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  cursor: default;
}

.build-stat-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.8;
  pointer-events: auto;
}

.build-stat-count {
  font-size: var(--fs-12);
  color: var(--muted);
  line-height: 1;
}
.muted { color: var(--tg-hint); font-size: var(--fs-14); }
.is-dimmed { opacity: 0.5; }

/* ========== SHOTS GRID ========== */
.shots-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-2); }
.shots-grid .shot-thumb {
  width: 100%; height: 160px; border-radius: var(--radius-sm); border: 1px solid var(--color-border);
  overflow: hidden; background: var(--elem-bg);
  display: flex; align-items: center; justify-content: center;
}
.shot-thumb img { 
  width: 100%; 
  height: 100%; 
  object-fit: cover; 
  pointer-events: auto;
}

/* ========== LIGHTBOX ========== */
.lightbox {
  position: fixed;
  inset: 0;
  background: var(--overlay-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  overflow: hidden;
  cursor: grab;
}
.lightbox:active { cursor: grabbing; }
.lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  user-select: none;
  -webkit-user-drag: none;
}

/* ========== BUILD DETAIL SCREENS ========== */
#buildDetailScreen .profile-grid,
#buildPublicDetailScreen .profile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

/* Отступ для полей, чтобы не перекрывались с чипом номера билда */
#buildDetailScreen .card .profile-grid,
#buildPublicDetailScreen .card .profile-grid {
  margin-top: var(--space-8);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 640px) {
  .profile-grid { grid-template-columns: 1fr; }
  .shots-grid { grid-template-columns: 1fr; }
  .shots-two { grid-template-columns: repeat(2, auto); gap: var(--space-2); }
  .actions-bar { grid-template-columns: 1fr; gap: var(--space-2); }
  .story-scroll-images {
    flex-direction: row;
  }
}
@media (max-width: 360px) {
  .thumbs-row { gap: var(--space-1); }
  .thumbs-row .preview-item,
  .thumbs-row .preview-more { width: 48px; height: 48px; }
}

/* ========== TOUCH ========== */
button, .list-btn, .chip-btn, .build-item, .upload-box, .class-tab {
  -webkit-user-select: none; -moz-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}

/* ========== CLASS TABS ========== */
.class-tabs-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}

.class-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--size-touch);
  height: var(--size-touch);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--icon-bg);
  cursor: pointer;
  padding: 0;
  transition: background-color var(--transition-base), border-color var(--transition-base), transform var(--transition-fast);
}

.class-tab:active {
  transform: translateY(1px);
}

.class-tab img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.theme-light .class-tab img {
  filter: brightness(0) saturate(100%);
  opacity: 0.7;
}

.class-tab.active {
  background: var(--accent);
  border-color: transparent;
}

.class-tab.active img {
  opacity: 1;
  filter: brightness(0) saturate(100%) invert(8%) sepia(19%) saturate(3011%) hue-rotate(179deg) brightness(95%) contrast(99%);
}

/* ========== MASTERY BADGES ========== */
.badge-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--tg-tx);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  min-height: calc(var(--size-touch) + var(--space-1));
  line-height: inherit;
  font-size: inherit;
  font-family: inherit;
  vertical-align: baseline;
  -webkit-appearance: none;
  appearance: none;
}

/* Полупрозрачный overlay для фоновых изображений */
.badge-btn[style*="background-image"]::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--overlay-medium);
  border-radius: var(--radius-lg);
  pointer-events: none;
  z-index: 1;
}

/* Контент должен быть поверх overlay */
.badge-btn > * {
  position: relative;
  z-index: 2;
}
.badge-btn:active { transform: translateY(1px); }
.badge-btn:disabled {
  cursor: default;
  transform: none;
}

.badge-btn.badge-btn--with-bg .mastery-level-name {
  color: #fff;
  text-shadow:
    0 0 2px rgba(0, 0, 0, 0.85),
    0 0 6px rgba(0, 0, 0, 0.6),
    0 1px 3px rgba(0, 0, 0, 0.9);
}
.badge-btn.badge-btn--with-bg .mastery-category-name {
  color: #fff;
  text-shadow:
    0 0 2px rgba(0, 0, 0, 0.65),
    0 0 4px rgba(0, 0, 0, 0.45);
}
.badge-btn.badge-btn--with-bg .mastery-level-number {
  color: #fff;
  text-shadow:
    0 0 2px rgba(0, 0, 0, 0.85),
    0 0 6px rgba(0, 0, 0, 0.6),
    0 1px 3px rgba(0, 0, 0, 0.9);
}

/* Ротация: текст на кнопках с фоном всегда белый, как в мастерстве */
.badge-btn.badge-btn--with-bg .rotation-mode-text,
.badge-btn.badge-btn--with-bg .rotation-mode-name,
.badge-btn.badge-btn--with-bg .rotation-mode-map {
  color: #fff;
  text-shadow:
    0 0 2px rgba(0, 0, 0, 0.85),
    0 0 6px rgba(0, 0, 0, 0.6),
    0 1px 3px rgba(0, 0, 0, 0.9);
}

/* ========== HELLMODE BUTTON ON HOME PAGE ========== */
/* Иконки HellMode на главной странице - сверху слева */
#questCardHellmodeBtn .rotation-mod-icons {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 2;
}

/* Отступ для текста в кнопке HellMode, чтобы не перекрывался иконками слева */
#questCardHellmodeBtn .rotation-mode-text {
  padding-top: var(--size-touch);
}

/* Бейдж награды в кнопке HellMode - справа сверху */
#questCardHellmodeBtn .quest-reward-badge {
  bottom: auto;
  top: var(--space-3);
}

.mastery-header-card.mastery-header-card--with-bg .reward-detail-header,
.mastery-header-card.mastery-header-card--with-bg .mastery-level-name,
.mastery-level-card.mastery-header-card--with-bg .mastery-level-name {
  color: #fff;
  text-shadow:
    0 0 2px rgba(0, 0, 0, 0.85),
    0 0 6px rgba(0, 0, 0, 0.6),
    0 1px 3px rgba(0, 0, 0, 0.9);
}

.mastery-header-card.mastery-header-card--with-bg .mastery-progress-container .mastery-level-number {
  color: #fff;
}
.theme-light .mastery-progress-svg [data-role="progress-bg"] {
  stroke: rgba(0, 0, 0, 0.16);
}

.theme-light .badge-btn:not(.badge-btn--with-bg) .mastery-progress-svg [data-role="progress-bg"],
.theme-light .mastery-header-card:not(.mastery-header-card--with-bg) .mastery-progress-svg [data-role="progress-bg"] {
  stroke: rgba(0, 0, 0, 0.28);
}

.badge-btn.badge-btn--with-bg .mastery-progress-svg [data-role="progress-bg"],
.mastery-header-card.mastery-header-card--with-bg .mastery-progress-svg [data-role="progress-bg"] {
  stroke: rgba(255, 255, 255, 0.45);
}

.theme-light .badge-btn.badge-btn--with-bg .mastery-progress-svg [data-role="progress-bg"],
.theme-light .mastery-header-card.mastery-header-card--with-bg .mastery-progress-svg [data-role="progress-bg"] {
  stroke: rgba(255, 255, 255, 0.7);
}
 
/* ========== MASTERY COMPONENTS ========== */
/* Контейнер для текста (левая часть badge) */
.mastery-text-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex: 1;
  z-index: 2;
  position: relative;
}

/* Название категории */
.mastery-category-name {
  font-size: var(--fs-14);
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85), 0 0 6px rgba(0, 0, 0, 0.45);
}

/* Название уровня (используется и в кнопках, и в детальном экране) */
.mastery-level-name {
  font-size: var(--fs-16);
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85), 0 0 8px rgba(0, 0, 0, 0.5);
  margin: 0;
  flex: 1;
  z-index: 2;
  position: relative;
}

/* Убираем свечение в карточке "Что нового" для светлой темы */
.theme-light #whatsNewPreviewCard .mastery-level-name,
.theme-light #whatsNewPreviewCard .mastery-category-name {
  text-shadow: none;
}

/* Контейнер для прогресса/иконки (правая часть badge) */
.mastery-progress-container {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  z-index: 2;
}

/* Иконка максимального уровня */
.mastery-icon {
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  filter: drop-shadow(0 0 6px rgba(212, 175, 55, 0.6)) drop-shadow(0 0 10px rgba(212, 175, 55, 0.35));
  opacity: 0.95;
  pointer-events: auto;
}

/* Цифра уровня в центре прогресса */
.mastery-level-number {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  font-weight: 700;
  color: var(--tg-tx);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9), 0 0 8px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  line-height: 1;
}

/* SVG контейнер для прогресса */
.mastery-progress-svg {
  width: 100%;
  height: 100%;
}

/* Header card в детальном экране */
.mastery-header-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  position: relative;
  overflow: hidden;
}

/* Полупрозрачный overlay для фоновых изображений в header card */
.mastery-header-card[style*="background-image"]::before,
.mastery-level-card[style*="background-image"]::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--overlay-medium);
  border-radius: var(--radius-lg);
  pointer-events: none;
  z-index: 1;
}

/* Контент должен быть поверх overlay */
.mastery-header-card > *,
.mastery-level-card > * {
  position: relative;
  z-index: 2;
}

/* ========== MASTERY SCREEN ========== */
.list-buttons#masteryButtonsContainer {
  gap: var(--space-2);
}

/* ========== TILE GRID ========== */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--space-2);
  width: 100%;
}

.tile-btn {
  aspect-ratio: 1;
  width: 100%;
  padding: 0;
  background: var(--elem-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}

.tile-btn:active {
  transform: scale(0.95);
}

.tile-btn.is-active {
  border-color: var(--accent);
  background: rgba(46, 166, 255, 0.12);
  box-shadow: 0 0 0 2px rgba(46, 166, 255, 0.24);
}

.tile-icon {
  width: 60%;
  height: 60%;
  object-fit: contain;
  pointer-events: none;
}

.trophy-description {
  font-size: var(--fs-15);
  line-height: var(--lh-normal);
  color: var(--tg-tx);
  margin-top: var(--space-2);
}

.trophy-proof {
  font-size: var(--fs-14);
  color: var(--tg-hint);
  line-height: var(--lh-normal);
  white-space: pre-line;
}

.trophy-proof.with-divider {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}

/* ========== SEASON TROPHY CARD ========== */
#seasonTrophyCard {
  margin: var(--space-4);
  margin-bottom: var(--card-spacing, var(--space-4));
}

.season-trophy-card {
  width: 100%;
  min-height: 120px;
  padding: var(--space-4);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease;
  text-align: left;
  /* Красивый цветной градиент: красный, бордовый, оранжевый, черный, белый */
  background: linear-gradient(
    135deg,
    rgba(255, 0, 0, 0.5) 0%,
    rgba(128, 0, 32, 0.5) 25%,
    rgba(255, 165, 0, 0.5) 50%,
    rgba(0, 0, 0, 0.6) 75%,
    rgba(255, 255, 255, 0.3) 100%
  );
  background-size: 200% 200%;
  animation: season-trophy-gradient 8s ease infinite;
  
  /* Блестящая рамка с анимацией через box-shadow */
  box-shadow: 
    0 0 0 2px rgba(212, 175, 55, 0.3),
    0 0 10px rgba(212, 175, 55, 0.2),
    0 0 20px rgba(255, 215, 0, 0.1);
  animation: season-trophy-border-glow 3s ease-in-out infinite, season-trophy-gradient 8s ease infinite;
}

/* Фон с паттерном из иконки трофея (повернутый на 45 градусов) */
.season-trophy-bg {
  position: absolute;
  /* Увеличиваем размер, чтобы покрыть повернутый паттерн и заполнить углы */
  top: -75%;
  left: -75%;
  width: 250%;
  height: 250%;
  /* Фон устанавливается через inline стиль в JS */
  /* Размер ячейки паттерна - 50px (создается через canvas в JS) */
  background-size: 50px 50px;
  background-repeat: repeat;
  background-position: 0 0;
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
  transform: rotate(45deg);
  transform-origin: center center;
}

/* Дополнительный слой для затемнения фона и улучшения читаемости */
.season-trophy-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(14, 22, 33, 0.2) 0%,
    rgba(14, 22, 33, 0.35) 100%
  );
  pointer-events: none;
  z-index: 1;
  border-radius: var(--radius-lg);
}

/* Блестящий эффект через отдельный элемент внутри карточки */
.season-trophy-shine {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(255, 255, 255, 0.15) 50%,
    transparent 70%
  );
  animation: season-trophy-shine 4s linear infinite;
  pointer-events: none;
  z-index: 2;
}

/* Анимация градиента фона */
@keyframes season-trophy-gradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* Анимация свечения рамки */
@keyframes season-trophy-border-glow {
  0%, 100% {
    box-shadow: 
      0 0 0 2px rgba(212, 175, 55, 0.4),
      0 0 15px rgba(212, 175, 55, 0.3),
      0 0 25px rgba(255, 215, 0, 0.2),
      inset 0 0 20px rgba(212, 175, 55, 0.1);
  }
  50% {
    box-shadow: 
      0 0 0 2px rgba(255, 215, 0, 0.6),
      0 0 20px rgba(255, 215, 0, 0.4),
      0 0 35px rgba(255, 255, 255, 0.3),
      inset 0 0 30px rgba(255, 215, 0, 0.15);
  }
}


@keyframes season-trophy-shine {
  0% {
    transform: translateX(-100%) translateY(-100%) rotate(45deg);
  }
  100% {
    transform: translateX(100%) translateY(100%) rotate(45deg);
  }
}

.season-trophy-card:active {
  transform: scale(0.98);
}

.season-trophy-content {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  position: relative;
  z-index: 3;
  background: rgba(14, 22, 33, 0.3);
  border-radius: var(--radius-md);
  padding: var(--space-2);
}

.season-trophy-icon-wrapper {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--elem-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.season-trophy-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.season-trophy-text-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.season-trophy-text {
  font-size: var(--fs-22);
  font-weight: 700;
  color: var(--fg);
  text-shadow: var(--shadow-text);
  line-height: var(--lh-tight);
}

.season-trophy-timer {
  font-size: var(--fs-14);
  font-weight: 500;
  color: var(--muted);
  text-shadow: var(--shadow-text);
  opacity: 0.9;
}

/* ========== HELLMODE QUEST DETAIL ========== */
/* Иконки HellMode на странице деталей - сверху слева */
#hellmodeQuestDetailContainer .waves-meta-card .waves-mod-icons {
  right: auto;
  left: var(--space-3);
}

/* Отступ для заголовка в карточке HellMode, чтобы не перекрывался иконками */
#hellmodeQuestDetailContainer .waves-meta-card .waves-header {
  padding-top: 36px;
}

/* Бейдж награды в карточке HellMode на странице деталей - справа сверху */
#hellmodeQuestDetailContainer .waves-meta-card .quest-reward-badge {
  bottom: auto;
  top: var(--space-3);
}

/* ========== HELLMODE QUEST DETAIL - LIGHT THEME ========== */
/* Инвертирование иконок в карточке "Описание" при светлой теме (кроме магатамы) */
.theme-light #hellmodeQuestDetailContainer .profile-grid .value img:not([alt="Награда"]) {
  filter: brightness(0) saturate(100%);
  opacity: 0.8;
}

/* Инвертирование иконки share на странице детального просмотра билда при светлой теме */
.theme-light .build-edit-btn img[src*="share.svg"] {
  filter: brightness(0) saturate(100%);
  opacity: 0.8;
}

/* Черный текст в карточке "Доказательство" при светлой теме */
.theme-light #hellmodeQuestDetailContainer .trophy-proof {
  color: #000 !important;
}

.card.current-level {
  border-left: 4px solid var(--color-success);
}

.card.next-level {
  border-left: 4px solid var(--accent);
  opacity: 0.95;
}

.card.max-level {
  border-left: 4px solid var(--color-gold-shadow);
  background: rgba(212, 175, 55, 0.05);
}

.mastery-description {
  font-size: var(--fs-15);
  line-height: var(--lh-normal);
  color: var(--tg-tx);
  margin-top: var(--space-2);
}

.mastery-proof {
  font-size: var(--fs-14);
  color: var(--tg-hint);
  line-height: var(--lh-normal);
}

/* ========== MASTERY DETAIL SCREEN ========== */
/* Контейнер для иконки категории */
.mastery-detail-icon-wrapper,
.trophy-detail-icon-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: var(--space-4) 0;
}

/* Иконка категории (128x128) */
.mastery-detail-icon,
.trophy-detail-icon {
  width: 128px;
  height: 128px;
  object-fit: contain;
  animation: mastery-icon-glow 2s ease-in-out infinite;
}

/* Анимация свечения для иконки мастерства */
@keyframes mastery-icon-glow {
  0%, 100% {
    filter: drop-shadow(0 0 6px rgba(212, 175, 55, 0.3)) drop-shadow(0 0 12px rgba(212, 175, 55, 0.15));
  }
  50% {
    filter: drop-shadow(0 0 10px rgba(212, 175, 55, 0.5)) drop-shadow(0 0 20px rgba(212, 175, 55, 0.25));
  }
}

/* Текст в карточке про иконку/максимальный уровень */
.mastery-detail-main-text {
  text-align: left;
  line-height: 1.5;
}

/* Заголовок "Следующий уровень:" перед карточкой */
.mastery-next-level-title {
  font-size: var(--fs-16);
  font-weight: 600;
  margin: var(--space-4) var(--space-4) var(--space-2) var(--space-4);
}

/* Текст с прогрессом "Завершено X из Y" (по размеру как топбар) */
.mastery-progress-summary {
  font-size: var(--fs-20);
  font-weight: 600;
  text-align: center;
  margin: var(--space-4) 0;
}

/* Карточка уровня */
.mastery-level-card {
  position: relative;
  overflow: hidden;
  min-height: 60px;
  display: flex;
  align-items: center;
}

/* Заголовок карточки уровня (название + галочка) */
.mastery-level-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  position: relative;
  z-index: 2;
  width: 100%;
}

/* Контейнер для галочки */
.mastery-level-check {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

/* Иконка галочки */
.mastery-level-check-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.85));
}

/* ========== FILTER MODAL ========== */
.filter-modal {
  position: fixed;
  inset: 0;
  background: var(--overlay-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: var(--space-4);
}

.filter-modal-content {
  background: var(--modal-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  max-width: 400px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.filter-modal-title {
  font-size: var(--fs-18);
  font-weight: 600;
  margin-bottom: var(--space-3);
  text-align: center;
}

.filter-modal-options {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.filter-category-section {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.filter-category-section:last-child {
  margin-bottom: 0;
}

.filter-category-title {
  font-size: var(--fs-18);
  font-weight: 700;
  color: var(--fg);
  margin-bottom: var(--space-2);
}

.theme-light .filter-category-title {
  color: #000;
}

/* Стили для страницы участников - выравнивание инпута и кнопки фильтра */
#participantsScreen .input input {
  height: var(--size-touch);
  padding: 0 var(--space-3);
  box-sizing: border-box;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: var(--elem-bg);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.filter-option input[type="checkbox"],
.filter-option input[type="radio"] {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
}

.filter-option span {
  font-size: var(--fs-16);
  font-weight: 600;
  color: var(--fg);
}

/* ========== FILTER MODAL ACTIONS BAR ========== */
.filter-modal-content .actions-bar {
  margin-top: var(--space-4);
  margin-left: 0;
  margin-right: 0;
  grid-template-columns: 1fr;
}

/* ========== START SCREEN MODAL - LIGHT THEME ========== */
.theme-light .filter-modal-title,
.theme-light .start-screen-option span,
.theme-light .filter-option span {
  color: #000;
}

/* ========== AUTHOR FIELD ========== */
.author-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.author-field label {
  margin-bottom: 0;
  flex-shrink: 0;
}

/* ========== AUTHOR CHIP ========== */
.author-chip {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--tg-tx);
  cursor: pointer;
  font-size: var(--fs-14);
  min-height: 28px;
  transition: transform 0.1s ease;
  text-align: left;
  width: auto;
  max-width: 200px;
}

.author-chip:active {
  transform: translateY(1px);
}

/* ========== РЕАКЦИИ (ЛАЙКИ/ДИЗЛАЙКИ) ========== */
.reactions-field {
  margin-top: var(--space-3);
}

.reactions-container {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke-color);
  background: var(--elem-bg);
  color: var(--fg);
  font-size: var(--fs-14);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.reaction-chip:active {
  transform: scale(0.96);
}

.reaction-chip:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* При активном состоянии - красим только контур (border), не фон */
.reaction-chip.liked {
  background: var(--elem-bg); /* Оставляем стандартный фон */
  border-color: #4caf50; /* Зеленый контур */
}

.reaction-chip.disliked {
  background: var(--elem-bg); /* Оставляем стандартный фон */
  border-color: #ff4444; /* Красный контур */
}

.reaction-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: block;
}

.reaction-count {
  font-size: var(--fs-14);
  font-weight: 500;
  min-width: 1ch;
  text-align: center;
}

#profileScreen,
#buildsScreen,
#buildCreateScreen,
#buildDetailScreen,
#buildPublicDetailScreen {
  padding-top: 0;
}

#buildsScreen .actions-bar:first-of-type,
#buildDetailScreen .actions-bar:first-of-type {
  margin-top: 0;
}

#profileEditScreen .actions-bar,
#buildCreateScreen .actions-bar,
#buildDetailScreen .actions-bar:last-of-type {
  margin-bottom: 0;
}

/* ========== iOS KEYBOARD IMPROVEMENTS ========== */
/* Улучшения для работы с клавиатурой на iOS */

/* Предотвращаем зум при фокусе на полях ввода на iOS */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
  .input input,
  .input textarea {
    font-size: 16px; /* Минимальный размер шрифта для предотвращения зума */
  }
}

/* Улучшаем визуальную обратную связь при тапе */
.input input:active,
.input textarea:active {
  transform: scale(0.98);
  transition: transform var(--transition-fast);
}

/* Стили для лучшего отображения клавиатуры на iOS */
@supports (-webkit-touch-callout: none) {
  /* iOS Safari */
  .input input,
  .input textarea {
    -webkit-appearance: none;
    appearance: none;
    border-radius: var(--radius-md);
  }
  
  /* Убираем стандартные стили iOS для полей ввода */
  .input input[type="text"],
  .input input[type="email"],
  .input input[type="password"],
  .input textarea {
    -webkit-appearance: none;
    appearance: none;
    -webkit-border-radius: var(--radius-md);
    border-radius: var(--radius-md);
  }
}

/* Дополнительные стили для улучшения UX на мобильных устройствах */
@media (max-width: 768px) {
  .input input,
  .input textarea {
    /* Увеличиваем область тапа для лучшего UX */
    min-height: var(--size-touch);
    padding: var(--space-3) var(--space-3);
  }
  
  /* Улучшаем читаемость текста на мобильных */
  .input input::placeholder,
  .input textarea::placeholder {
    opacity: var(--opacity-secondary);
  }
}

/* Build edit button */
.build-edit-btn {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  opacity: 0.8;
  z-index: 10;
  transition: opacity var(--transition-base);
}

.build-edit-btn--left {
  left: var(--space-3);
  right: auto;
}

.build-edit-btn:active {
  opacity: 1;
}

.build-edit-btn img,
.build-edit-btn svg {
  width: 18px;
  height: 18px;
  opacity: 0.8;
}

/* Avatar upload button */
.avatar-upload-btn,
.avatar-display {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--elem-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 10;
}

.avatar-upload-btn {
  border: 2px dashed var(--color-border);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.avatar-placeholder {
  font-size: 32px;
  color: var(--muted);
  user-select: none;
}

.avatar-upload-btn.has-avatar {
  border-style: solid;
  border-width: 1px;
}

/* Avatar display (read-only, for participant profile) */
.avatar-display {
  border: 1px solid var(--color-border);
}

/* ========== BOTTOM NAVIGATION ========== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-top: 1px solid var(--color-border);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--space-2));
  padding-top: var(--space-1);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  gap: 0;
  z-index: 1000;
  max-width: 920px;
  margin: 0 auto;
}

.bottom-nav::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--tg-bg);
  opacity: 0.7;
  z-index: -1;
}

.bottom-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2);
  background: transparent;
  border: none;
  cursor: pointer;
  min-height: 44px;
  transition: opacity var(--transition-base);
  position: relative;
}

/* Индикатор активной вкладки (синяя полоска сверху) */
.bottom-nav-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 0 0 4px 4px;
  transition: width 0.3s ease;
  z-index: 1;
}

.bottom-nav-btn.active::before {
  width: 60%;
}

.bottom-nav-icon {
  width: 30px;
  height: 30px;
  transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55),
              opacity var(--transition-base);
  object-fit: contain;
}

.bottom-nav-btn.active .bottom-nav-icon {
  opacity: 1;
  filter: drop-shadow(0 0 8px rgba(46, 166, 255, 0.5)) grayscale(0%);
  transform: scale(1.15);
}

.bottom-nav-btn:not(.active) .bottom-nav-icon {
  opacity: 0.6;
  filter: grayscale(50%);
}

#bottomNavGroupBtn .bottom-nav-icon {
  opacity: 1;
  filter: grayscale(0%);
}

.bottom-nav-btn:active {
  opacity: 0.7;
}

.bottom-nav-btn:active .bottom-nav-icon {
  transform: scale(0.9);
}