/* ============================================================================
   QuizArena — casino fruity dark
   ============================================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow-x: hidden; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: #0a0410;
  color: #f3eaff;
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

:root {
  --bg-deep: #0a0410;
  --bg-dark: #14081f;
  --bg-card: #1f1030;
  --bg-card-hi: #2a163f;
  --line: rgba(255, 215, 130, 0.08);
  --line-hi: rgba(255, 215, 130, 0.18);

  --c-cherry: #ff2e63;
  --c-grape: #a06bff;
  --c-orange: #ff8a25;
  --c-lime: #c0ff35;
  --c-cyan: #16e0e0;
  --c-gold: #ffc640;
  --c-gold-deep: #d99a1c;

  --text: #f3eaff;
  --text-dim: #8b7aa8;
  --text-darker: #5d4f72;
}

#app {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* ============ BACKGROUND (исходный из первого дизайна) ============ */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 10% 0%, rgba(255, 46, 99, 0.12), transparent 50%),
    radial-gradient(ellipse at 100% 100%, rgba(160, 107, 255, 0.12), transparent 50%);
  pointer-events: none;
  z-index: 0;
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85'/%3E%3CfeColorMatrix values='0 0 0 0 1, 0 0 0 0 1, 0 0 0 0 1, 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.4;
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 1;
}
.emoji-pattern { display: none; }
.alarm-corner { display: none; }

/* ============ ДИАГОНАЛЬНЫЕ ПОТОКИ ИКОНОК ============ */
/* Каждая диагональ — узкая полоса с repeating-паттерном иконки,
   двигается к центру и затухает к нему через mask-image. */

/* ============ COBALT-STYLE: 2 ДИАГОНАЛИ ИЗ УГЛОВ ============
   smile — из верхнего-правого угла, alarm — из нижнего-левого.
   Маска радиальная — затухание во все стороны от угла, без острых краёв. */

.diag-smile, .diag-alarm {
  position: fixed;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
  opacity: 0;
  width: 90vmax;
  height: 90vmax;
  transition: opacity 0.3s;
}
/* Видны только на экране логина (до авторизации) */
body:has(#screen-login.active) .diag-smile,
body:has(#screen-login.active) .diag-alarm {
  opacity: 0.18;
}
/* smile из верхнего-правого угла, более резкое затухание (больше пустоты у центра) */
.diag-smile {
  top: -25vmax;
  right: -25vmax;
  -webkit-mask-image: radial-gradient(circle at 100% 0%, rgba(0,0,0,1) 0%, rgba(0,0,0,0.25) 30%, transparent 55%);
  mask-image: radial-gradient(circle at 100% 0%, rgba(0,0,0,1) 0%, rgba(0,0,0,0.25) 30%, transparent 55%);
}
/* alarm из нижнего-левого угла */
.diag-alarm {
  bottom: -25vmax;
  left: -25vmax;
  -webkit-mask-image: radial-gradient(circle at 0% 100%, rgba(0,0,0,1) 0%, rgba(0,0,0,0.25) 30%, transparent 55%);
  mask-image: radial-gradient(circle at 0% 100%, rgba(0,0,0,1) 0%, rgba(0,0,0,0.25) 30%, transparent 55%);
}

/* Внутренний слой: повторяющаяся иконка.
   Анимируем background-position (без rotate в keyframes — нет дёрганий). */
.diag-smile::before, .diag-alarm::before {
  content: '';
  position: absolute;
  inset: -20%;
  width: 140%;
  height: 140%;
  background-repeat: repeat;
  background-size: 64px 64px;
  /* Анимируем только background-position — рендер плавный */
}
.diag-smile::before {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23ffc640'><path d='M11.874 9A4.005 4.005 0 0 1 8 12a4.005 4.005 0 0 1-3.874-3h7.748zM0 8c0-4.418 3.59-8 8-8 4.418 0 8 3.59 8 8 0 4.418-3.59 8-8 8-4.418 0-8-3.59-8-8zm2 0c0 3.307 2.686 6 6 6 3.307 0 6-2.686 6-6 0-3.307-2.686-6-6-6-3.307 0-6 2.686-6 6zm3-3h2v2H5V5zm4 0h2v2H9V5z' fill-rule='evenodd'/></svg>");
  animation: smileFlow 14s linear infinite;
}
.diag-alarm::before {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23ff8a25'><path d='M3.957 1.457L1.457 3.957L0.043 2.543L2.543 0.043L3.957 1.457Z'/><path fill-rule='evenodd' clip-rule='evenodd' d='M14.5 8.5C14.5 9.805 14.115 11.021 13.453 12.039L15.707 14.293L14.293 15.707L12.116 13.531C10.995 14.449 9.562 15 8 15C6.438 15 5.004 14.449 3.883 13.531L1.707 15.707L0.293 14.293L2.547 12.039C1.885 11.021 1.5 9.805 1.5 8.5C1.5 4.91 4.41 2 8 2C11.59 2 14.5 4.91 14.5 8.5ZM7 5V9.414L9.293 11.707L10.707 10.293L9 8.586V5H7Z'/><path d='M12.043 1.457L14.543 3.957L15.957 2.543L13.457 0.043L12.043 1.457Z'/></svg>");
  animation: alarmFlow 14s linear infinite;
}

/* smile верхний-правый → текут К ЦЕНТРУ (вниз-влево) */
@keyframes smileFlow {
  from { background-position: 0 0; }
  to   { background-position: -64px 64px; }
}
/* alarm нижний-левый → текут К ЦЕНТРУ (вверх-вправо) */
@keyframes alarmFlow {
  from { background-position: 0 0; }
  to   { background-position: 64px -64px; }
}

/* ============ SCREENS ============ */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  /* Базовый padding + добавочный учёт safe-area снизу (для нотч-панели жестов) */
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  /* Дополнительно: гарантируем место в самом низу при скролле */
  scroll-padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 2;
  -webkit-overflow-scrolling: touch;
}
.screen::after {
  /* Невидимый «ножной» резерв чтобы последняя карточка не обрезалась */
  content: '';
  display: block;
  flex-shrink: 0;
  height: env(safe-area-inset-bottom, 0px);
}
/* В fullscreen — растягиваем на весь экран без отступов под нотч */
:fullscreen .screen,
:-webkit-full-screen .screen {
  padding: 8px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}
:fullscreen body, :-webkit-full-screen body {
  background: var(--bg-deep);
}
.screen.active {
  display: flex;
  animation: screenIn 0.45s cubic-bezier(0.34, 1.4, 0.64, 1);
}
@keyframes screenIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.hidden { display: none !important; }

/* ============ TYPOGRAPHY ============ */
.display {
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: 0.04em;
}

/* ============ LOGO ============ */
.logo {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 52px;
  letter-spacing: 5px;
  line-height: 1;
  color: var(--c-gold);
  text-shadow:
    0 0 1px var(--c-gold),
    0 0 12px rgba(255, 198, 64, 0.5),
    0 4px 0 var(--c-gold-deep),
    0 8px 24px rgba(255, 46, 99, 0.3);
  margin-bottom: 8px;
}
.logo span {
  display: block;
  font-size: 26px;
  letter-spacing: 14px;
  color: var(--c-cherry);
  text-shadow:
    0 0 2px var(--c-cherry),
    0 0 16px rgba(255, 46, 99, 0.6);
  margin-top: 6px;
  padding-left: 14px;
}

/* ============ LOGIN ============ */
#screen-login {
  justify-content: center;
  align-items: center;
}
/* Готическая карточка с минималистичным дизайном */
.login-card {
  position: relative;
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-dark) 100%);
  padding: 40px 28px 60px;
  text-align: center;
  width: 100%;
  max-width: 380px;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.7),
    inset 0 0 0 1px var(--c-gold-deep),
    inset 0 0 0 4px var(--bg-deep),
    inset 0 0 0 5px rgba(255, 198, 64, 0.3);
  clip-path: polygon(
    14px 0, calc(100% - 14px) 0, 100% 14px,
    100% calc(100% - 14px), calc(100% - 14px) 100%,
    14px 100%, 0 calc(100% - 14px), 0 14px
  );
}

/* Универсальный готический орнамент в самом низу — реальный SVG */
.ornament {
  display: block;
  margin: 0 auto;
  width: 70%;
  height: 28px;
  -webkit-mask-image: url("ornament-flourish.svg");
  mask-image: url("ornament-flourish.svg");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  background-color: var(--c-gold);
  pointer-events: none;
  opacity: 0.75;
}
.ornament.divider {
  -webkit-mask-image: url("ornament-divider.svg");
  mask-image: url("ornament-divider.svg");
}
.ornament.cherry { background-color: var(--c-cherry); }

/* Орнамент абсолютно внизу карточки логина */
.login-card .ornament {
  position: absolute;
  left: 15%;
  right: 15%;
  width: auto;
  bottom: 14px;
}
.subtitle {
  color: var(--text-dim);
  margin-bottom: 24px;
  font-size: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.login-hint {
  font-size: 11px;
  color: var(--c-gold);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: -4px 0 12px;
}
.login-error {
  font-size: 12px;
  color: var(--c-cherry);
  letter-spacing: 0.5px;
  margin: -4px 0 12px;
  font-weight: 700;
}

/* ============ SPLASH ============ */
#screen-splash {
  justify-content: center;
  align-items: center;
}
.splash-inner { text-align: center; }
.splash-spinner {
  width: 40px;
  height: 40px;
  margin: 32px auto 0;
  border: 2px solid transparent;
  border-top-color: var(--c-gold);
  border-right-color: var(--c-cherry);
  border-radius: 50%;
  animation: splashSpin 1s linear infinite;
}
@keyframes splashSpin { to { transform: rotate(360deg); } }

/* ============ INPUTS (готические) ============ */
input[type="text"], input[type="password"] {
  width: 100%;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  color: var(--text);
  padding: 14px 18px;
  font-size: 16px;
  font-family: inherit;
  margin-bottom: 12px;
  outline: none;
  transition: box-shadow 0.2s, background 0.2s;
  text-align: center;
  letter-spacing: 2px;
  /* Двойная рамка через box-shadow */
  box-shadow:
    inset 0 0 0 1px var(--c-gold-deep),
    0 0 0 2px var(--bg-deep),
    0 0 0 3px rgba(255, 198, 64, 0.2);
}
input[type="text"]:focus, input[type="password"]:focus {
  background: rgba(255, 198, 64, 0.08);
  box-shadow:
    inset 0 0 0 1px var(--c-gold),
    0 0 0 2px var(--bg-deep),
    0 0 0 3px var(--c-gold),
    0 0 16px rgba(255, 198, 64, 0.3);
}
input::placeholder { color: var(--text-darker); letter-spacing: 1.5px; }

/* ============ BUTTONS ============ */
.btn-primary, .btn-secondary {
  width: 100%;
  padding: 16px 20px;
  font-family: 'Bebas Neue', sans-serif;
  font-weight: 400;
  font-size: 20px;
  letter-spacing: 4px;
  cursor: pointer;
  border: none;
  transition: transform 0.15s cubic-bezier(0.34, 1.7, 0.64, 1), box-shadow 0.2s, filter 0.2s;
  text-transform: uppercase;
  position: relative;
}
.btn-primary {
  background: linear-gradient(180deg, var(--c-gold) 0%, var(--c-gold-deep) 100%);
  color: #1a0a25;
  border-radius: 10px; /* Золотая кнопка остаётся округлой */
  box-shadow:
    0 4px 0 var(--c-gold-deep),
    0 8px 24px rgba(255, 198, 64, 0.4),
    0 0 0 1px rgba(0, 0, 0, 0.2) inset;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}
.btn-primary:active {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 var(--c-gold-deep),
    0 4px 12px rgba(255, 198, 64, 0.3);
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: none;
  margin-top: 8px;
  letter-spacing: 3px;
  font-size: 16px;
  /* Готическая двойная рамка вместо тонкого outline */
  box-shadow:
    inset 0 0 0 1px var(--c-gold-deep),
    inset 0 0 0 3px var(--bg-deep),
    inset 0 0 0 4px rgba(255, 198, 64, 0.2);
  /* Срез углов */
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
}
.btn-secondary:hover {
  background: rgba(255, 198, 64, 0.06);
}
.btn-secondary:active {
  transform: translateY(2px) scale(0.99);
  background: rgba(255, 198, 64, 0.12);
}

.btn-full { width: 100%; margin-top: 16px; }

.btn-icon {
  width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.04);
  border: none;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s cubic-bezier(0.34, 1.7, 0.64, 1), background 0.2s;
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: 1px;
  clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px), 0 6px);
  box-shadow: inset 0 0 0 1px rgba(255, 198, 64, 0.25), inset 0 0 0 2px var(--bg-deep);
}
.btn-icon:active {
  transform: scale(0.92);
  background: rgba(255, 198, 64, 0.1);
}
.btn-icon.btn-logout { color: var(--c-cherry); }

.btn-back {
  background: rgba(255, 255, 255, 0.04);
  border: none;
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s cubic-bezier(0.34, 1.7, 0.64, 1);
  clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px), 0 6px);
  box-shadow: inset 0 0 0 1px rgba(255, 198, 64, 0.25), inset 0 0 0 2px var(--bg-deep);
}
.btn-back:active { transform: scale(0.92) translateX(-2px); }

/* ============ TOPBAR ============ */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}
.topbar h2 {
  flex: 1;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  letter-spacing: 3px;
  font-weight: 400;
}
.user-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.nick {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.5px;
}
.badge {
  font-size: 10px;
  padding: 4px 10px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--c-gold), var(--c-gold-deep));
  color: #1a0a25;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2) inset, 0 0 12px rgba(255, 198, 64, 0.4);
}
.badge.admin {
  background: linear-gradient(180deg, var(--c-cherry), #c61b48);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2) inset, 0 0 12px rgba(255, 46, 99, 0.5);
  text-shadow: none;
}
.badge:empty { display: none; }

/* ============ HOME ============ */
.greeting {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 28px;
  letter-spacing: 3px;
  margin-bottom: 4px;
  color: var(--c-gold);
}
.greeting-sub {
  color: var(--text-dim);
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 20px;
}

.section-label {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 14px;
  letter-spacing: 4px;
  color: var(--text-darker);
  margin: 24px 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-label::before, .section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.subjects {
  display: grid;
  gap: 12px;
}
/* Готическая карточка предмета: срезы по углам + двойная рамка + орнамент */
.subject-card {
  background:
    linear-gradient(180deg, var(--bg-card-hi) 0%, var(--bg-card) 100%);
  padding: 18px 24px;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.34, 1.7, 0.64, 1), filter 0.2s;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  /* Углы срезаны */
  clip-path: polygon(
    10px 0, calc(100% - 10px) 0, 100% 10px,
    100% calc(100% - 10px), calc(100% - 10px) 100%,
    10px 100%, 0 calc(100% - 10px), 0 10px
  );
  /* Двойная рамка через два box-shadow */
  box-shadow:
    inset 0 0 0 1px var(--accent, var(--c-gold)),
    inset 0 0 0 4px var(--bg-deep),
    inset 0 0 0 5px rgba(255, 198, 64, 0.15);
}
/* Тонкая золотая полоска-акцент слева */
.subject-card::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 22px;
  bottom: 22px;
  width: 2px;
  background: var(--accent, var(--c-gold));
  box-shadow: 0 0 6px var(--accent, var(--c-gold));
}
.subject-card[data-subject="philosophy"] { --accent: var(--c-cherry); }
.subject-card[data-subject="taxes"]      { --accent: var(--c-lime); }
.subject-card[data-subject="demo"]       { --accent: var(--c-cyan); }

.subject-card:active {
  transform: scale(0.98);
  filter: brightness(1.15);
}

.subject-info {
  position: relative;
  flex: 1;
  min-width: 0;
  padding-left: 18px; /* место для ромба */
}
.subject-name {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 28px;
  letter-spacing: 3px;
  font-weight: 400;
  line-height: 1;
  color: var(--accent);
}
.subject-card[data-subject="philosophy"] .subject-name { text-shadow: 0 0 14px rgba(255, 46, 99, 0.35); }
.subject-card[data-subject="taxes"] .subject-name { text-shadow: 0 0 14px rgba(192, 255, 53, 0.35); }
.subject-card[data-subject="demo"] .subject-name { text-shadow: 0 0 14px rgba(22, 224, 224, 0.35); }

.subject-count {
  color: var(--text-dim);
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  position: relative;
}
.subject-arrow {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 26px;
  color: var(--accent);
  position: relative;
  opacity: 0.7;
  letter-spacing: 0;
}

.admin-panel {
  margin-top: 24px;
  background: rgba(255, 46, 99, 0.06);
  border: none;
  padding: 18px 14px 24px;
  position: relative;
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 10px);
  box-shadow: inset 0 0 0 1px var(--c-cherry), inset 0 0 0 3px var(--bg-deep);
}
.admin-panel::after {
  content: '';
  position: absolute;
  bottom: 6px;
  left: 20%;
  right: 20%;
  height: 14px;
  -webkit-mask-image: url("ornament-flourish.svg");
  mask-image: url("ornament-flourish.svg");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  background-color: var(--c-cherry);
  opacity: 0.5;
  pointer-events: none;
}
.admin-panel h3 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 14px;
  letter-spacing: 4px;
  color: var(--c-cherry);
  margin-bottom: 10px;
}

/* ============ LEADERBOARD ON HOME ============ */
/* Барабан-будильник: фиксированная высота, центральная строка — текущая.
   Высота строки ~56px (контент 10+10 padding + ~36 шрифт), берём 60.
   Контейнер 5 строк = 300px. Padding сверху/снизу = 2 строки = 120px,
   чтобы первая и последняя могли встать в центр. */
.leaderboard-mini {
  --lb-row: 60px;
  --lb-rows-visible: 5;
  display: flex;
  flex-direction: column;
  gap: 0;
  height: calc(var(--lb-row) * var(--lb-rows-visible));
  max-height: calc(var(--lb-row) * var(--lb-rows-visible));
  padding: calc(var(--lb-row) * 2) 0;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  perspective: 900px;
  position: relative;
  mask-image: linear-gradient(180deg, transparent 0%, #000 25%, #000 75%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 25%, #000 75%, transparent 100%);
}
.leaderboard-mini::-webkit-scrollbar { display: none; }
.leaderboard-mini .lb-item-mini {
  /* Snap по центру — строка останавливается в середине барабана */
  scroll-snap-align: center;
  scroll-snap-stop: always;
  height: var(--lb-row);
  min-height: var(--lb-row);
  box-sizing: border-box;
  transition: transform 0.15s ease-out;
  will-change: transform;
  flex-shrink: 0;
  opacity: 1 !important; /* данные всегда видны */
}
.lb-item-mini {
  background: var(--bg-card);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  /* Готический срез по правому углу */
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}
.lb-item-mini::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--rank-color, transparent);
  box-shadow: 0 0 8px var(--rank-color, transparent);
}
.lb-item-mini:nth-child(1) { --rank-color: var(--c-gold); }
.lb-item-mini:nth-child(2) { --rank-color: #c0c0c0; }
.lb-item-mini:nth-child(3) { --rank-color: #cd7f32; }
.lb-item-mini.you {
  --rank-color: var(--c-cherry);
  background: linear-gradient(90deg, rgba(255, 46, 99, 0.1), var(--bg-card));
}
.lb-rank {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 24px;
  width: 32px;
  text-align: center;
  color: var(--text-darker);
}
.lb-item-mini:nth-child(1) .lb-rank { color: var(--c-gold); text-shadow: 0 0 12px rgba(255, 198, 64, 0.6); }
.lb-item-mini:nth-child(2) .lb-rank { color: #c0c0c0; }
.lb-item-mini:nth-child(3) .lb-rank { color: #cd7f32; }
.lb-nick {
  flex: 1;
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.lb-score {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 24px;
  letter-spacing: 1px;
  color: var(--c-lime);
  text-shadow: 0 0 12px rgba(192, 255, 53, 0.4);
}
.lb-item-mini:nth-child(1) .lb-score { color: var(--c-gold); text-shadow: 0 0 12px rgba(255, 198, 64, 0.5); }

/* ============ SECTION SELECT ============ */
.sections {
  display: grid;
  gap: 10px;
}
.section-card {
  background: var(--bg-card);
  padding: 14px 20px;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.34, 1.7, 0.64, 1), filter 0.2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
  box-shadow: inset 0 0 0 1px var(--c-gold-deep), inset 0 0 0 3px var(--bg-deep);
}
.section-card:active { transform: scale(0.98); filter: brightness(1.15); }
.section-card .section-name {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 20px;
  letter-spacing: 2px;
}
.section-card .section-meta {
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 2px;
}
.section-card .section-arrow {
  color: var(--c-gold);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 26px;
}

/* ============ QUIZ ============ */
#screen-quiz { padding: 16px; }
.quiz-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 10px;
}
.quiz-progress {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 18px;
  letter-spacing: 2px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 10px;
}
.quiz-score {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 32px;
  letter-spacing: 2px;
  color: var(--c-gold);
  text-shadow: 0 0 16px rgba(255, 198, 64, 0.5);
  flex: 1;
  text-align: center;
  transition: transform 0.3s cubic-bezier(0.34, 1.8, 0.64, 1);
}
.quiz-score.bump { animation: scoreBump 0.5s cubic-bezier(0.34, 1.8, 0.64, 1); }
@keyframes scoreBump {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); color: var(--c-lime); }
}

.quiz-timer {
  position: relative;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.timer-ring {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}
.timer-bg, .timer-fg {
  fill: none;
  stroke-width: 3;
}
.timer-bg { stroke: rgba(255, 255, 255, 0.08); }
.timer-fg {
  stroke: var(--c-cyan);
  stroke-linecap: round;
  stroke-dasharray: 100.53;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.3s;
  filter: drop-shadow(0 0 6px var(--c-cyan));
}
.quiz-timer.warn .timer-fg { stroke: var(--c-orange); filter: drop-shadow(0 0 8px var(--c-orange)); }
.quiz-timer.danger .timer-fg { stroke: var(--c-cherry); filter: drop-shadow(0 0 10px var(--c-cherry)); animation: dangerPulse 0.5s ease infinite alternate; }
@keyframes dangerPulse {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}
#timer-num {
  position: relative;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  letter-spacing: 1px;
}

.question-box {
  background: linear-gradient(180deg, var(--bg-card-hi) 0%, var(--bg-card) 100%);
  padding: 24px;
  margin-bottom: 14px;
  min-height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow:
    inset 0 0 0 1px var(--c-gold-deep),
    inset 0 0 0 3px var(--bg-deep),
    inset 0 0 0 4px rgba(255, 198, 64, 0.2);
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 10px);
}
.question-text {
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  line-height: 1.4;
}

.answers {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}
.answers.solo { grid-template-columns: 1fr; }
.answers.three { grid-template-columns: 1fr 1fr; }
.answers.three .answer-btn:nth-child(3) { grid-column: 1 / -1; }
.answers.five { grid-template-columns: 1fr 1fr; }
.answers.five .answer-btn:nth-child(5) { grid-column: 1 / -1; }

.answer-btn {
  --c: var(--c-cherry);
  background: linear-gradient(180deg, var(--c) 0%, color-mix(in srgb, var(--c) 65%, black) 100%);
  border: none;
  color: #fff;
  border-radius: 14px;
  padding: 14px 12px 14px 56px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  line-height: 1.3;
  transition:
    transform 0.15s cubic-bezier(0.34, 1.7, 0.64, 1),
    filter 0.2s,
    box-shadow 0.2s;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 4px 0 color-mix(in srgb, var(--c) 50%, black),
    0 8px 16px color-mix(in srgb, var(--c) 35%, transparent),
    0 0 0 1px rgba(0, 0, 0, 0.2) inset,
    0 1px 0 rgba(255, 255, 255, 0.15) inset;
}
.answer-btn::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 35%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.15), transparent);
  pointer-events: none;
}
.answer-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 color-mix(in srgb, var(--c) 50%, black),
    0 4px 8px color-mix(in srgb, var(--c) 35%, transparent),
    0 0 0 1px rgba(0, 0, 0, 0.2) inset;
}
.answer-btn[data-color="0"] { --c: var(--c-cherry); }
.answer-btn[data-color="1"] { --c: var(--c-grape); }
.answer-btn[data-color="2"] { --c: var(--c-orange); }
.answer-btn[data-color="3"] { --c: var(--c-lime); color: #1a0a25; }
.answer-btn[data-color="4"] { --c: var(--c-cyan); color: #1a0a25; }

.answer-letter {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  letter-spacing: 0;
  z-index: 1;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}
.answer-text {
  flex: 1;
  word-break: break-word;
  position: relative;
  z-index: 1;
}

.answer-btn.correct {
  filter: brightness(1.15);
  box-shadow:
    0 0 0 3px var(--c-lime),
    0 0 40px var(--c-lime),
    0 4px 0 color-mix(in srgb, var(--c) 50%, black);
  animation: correctBounce 0.7s cubic-bezier(0.34, 1.8, 0.64, 1);
}
.answer-btn.wrong:not(.picked-wrong) {
  opacity: 0.35;
  filter: grayscale(0.6);
}
.answer-btn.picked-wrong {
  filter: brightness(0.7);
  box-shadow:
    0 0 0 3px var(--c-cherry),
    0 0 30px var(--c-cherry);
  animation: wrongShake 0.5s ease;
}
@keyframes correctBounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.08); }
  70% { transform: scale(0.97); }
  100% { transform: scale(1); }
}
@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.quiz-feedback {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card-hi);
  border: none;
  padding: 14px 28px;
  text-align: center;
  z-index: 10;
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 10px);
  box-shadow:
    inset 0 0 0 1px var(--c-gold),
    inset 0 0 0 3px var(--bg-deep),
    0 12px 32px rgba(0, 0, 0, 0.5);
  display: flex;
  gap: 16px;
  align-items: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  animation: fbIn 0.4s cubic-bezier(0.34, 1.7, 0.64, 1);
}
@keyframes fbIn {
  from { opacity: 0; transform: translate(-50%, 24px) scale(0.9); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
.feedback-text {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 24px;
  letter-spacing: 2px;
}
.feedback-text.correct { color: var(--c-lime); text-shadow: 0 0 12px rgba(192, 255, 53, 0.5); }
.feedback-text.wrong { color: var(--c-cherry); text-shadow: 0 0 12px rgba(255, 46, 99, 0.5); }
.feedback-points {
  color: var(--c-gold);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 24px;
  letter-spacing: 1px;
  text-shadow: 0 0 12px rgba(255, 198, 64, 0.5);
}

/* ============ RESULT ============ */
#screen-result { justify-content: center; align-items: center; }
.result-card {
  background: linear-gradient(180deg, var(--bg-card-hi) 0%, var(--bg-dark) 100%);
  padding: 36px 28px 56px;
  text-align: center;
  width: 100%;
  max-width: 400px;
  position: relative;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.7),
    inset 0 0 0 1px var(--c-gold-deep),
    inset 0 0 0 4px var(--bg-deep),
    inset 0 0 0 5px rgba(255, 198, 64, 0.3);
  clip-path: polygon(
    14px 0, calc(100% - 14px) 0, 100% 14px,
    100% calc(100% - 14px), calc(100% - 14px) 100%,
    14px 100%, 0 calc(100% - 14px), 0 14px
  );
}
.result-card .ornament {
  position: absolute;
  bottom: 14px;
  left: 15%;
  right: 15%;
  width: auto;
}
.result-card h2 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 36px;
  letter-spacing: 6px;
  color: var(--c-gold);
  margin-bottom: 16px;
  text-shadow: 0 0 20px rgba(255, 198, 64, 0.4);
}
.result-score {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 88px;
  line-height: 1;
  color: var(--c-lime);
  text-shadow:
    0 0 1px var(--c-lime),
    0 0 32px rgba(192, 255, 53, 0.5),
    0 4px 0 #6e9420;
  animation: scoreReveal 1s cubic-bezier(0.34, 1.6, 0.64, 1);
}
@keyframes scoreReveal {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.result-score small {
  display: block;
  font-size: 14px;
  color: var(--text-dim);
  letter-spacing: 6px;
  margin-top: 8px;
  text-shadow: none;
}
.result-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin: 28px 0;
}
.stat { text-align: center; }
.stat-num {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 48px;
  line-height: 1;
}
.stat-num.correct { color: var(--c-lime); text-shadow: 0 0 12px rgba(192, 255, 53, 0.4); }
.stat-num.wrong { color: var(--c-cherry); text-shadow: 0 0 12px rgba(255, 46, 99, 0.4); }
.stat-label {
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-top: 4px;
}

/* ============ REVIEW ============ */
.review-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 4px;
  border-left: 3px solid var(--c-gold);
}
.rs-block { text-align: center; }
.rs-num {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 28px;
  line-height: 1;
}
.rs-num.gold { color: var(--c-gold); text-shadow: 0 0 12px rgba(255, 198, 64, 0.4); }
.rs-num.lime { color: var(--c-lime); text-shadow: 0 0 12px rgba(192, 255, 53, 0.4); }
.rs-num.cherry { color: var(--c-cherry); text-shadow: 0 0 12px rgba(255, 46, 99, 0.4); }
.rs-label {
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-darker);
  margin-top: 4px;
}

.review-filters {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.review-filter {
  flex: 1;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text-dim);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 13px;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: all 0.2s;
}
.review-filter.active {
  color: var(--c-gold);
  border-color: var(--c-gold);
  background: rgba(255, 198, 64, 0.08);
}

.review-list { display: grid; gap: 8px; }
.review-item {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0;
  overflow: hidden;
  position: relative;
}
.review-item.correct { border-left: 3px solid var(--c-lime); }
.review-item.wrong { border-left: 3px solid var(--c-cherry); }

.review-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--line);
}
.review-num {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 18px;
  letter-spacing: 1px;
  color: var(--text-darker);
  background: rgba(255, 255, 255, 0.04);
  padding: 2px 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.review-status {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 12px;
  letter-spacing: 2px;
  flex: 1;
  text-align: right;
}
.review-status.correct { color: var(--c-lime); }
.review-status.wrong { color: var(--c-cherry); }

.review-q {
  padding: 14px 14px 6px;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.4;
}
.review-options {
  display: grid;
  gap: 4px;
  padding: 0 10px 10px;
}
.review-option {
  padding: 8px 12px 8px 36px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.02);
  font-size: 12px;
  border-left: 2px solid transparent;
  position: relative;
  line-height: 1.3;
}
.review-option::before {
  content: attr(data-letter);
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 14px;
  color: var(--text-darker);
  letter-spacing: 0;
}
.review-option.correct {
  background: rgba(192, 255, 53, 0.06);
  border-left-color: var(--c-lime);
  color: var(--c-lime);
}
.review-option.correct::before { color: var(--c-lime); }
.review-option.picked-wrong {
  background: rgba(255, 46, 99, 0.06);
  border-left-color: var(--c-cherry);
  color: var(--c-cherry);
}
.review-option.picked-wrong::before { color: var(--c-cherry); }
.review-option.correct::after {
  content: '✓';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-lime);
  font-weight: 800;
}
.review-option.picked-wrong::after {
  content: '✗';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-cherry);
  font-weight: 800;
}

/* ============ HISTORY / LEADERBOARD / ADMIN ============ */
.history-list, .leaderboard, .users-list, .attempts-list { display: grid; gap: 8px; }

.history-item, .lb-item, .user-item, .attempt-item {
  background: var(--bg-card);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.34, 1.7, 0.64, 1), filter 0.2s;
  position: relative;
  border-left: 2px solid var(--c-gold-deep);
  box-shadow: inset 0 0 0 1px rgba(255, 198, 64, 0.15);
}
.history-item:active, .attempt-item:active { transform: scale(0.98); filter: brightness(1.15); }

.history-item .h-subject {
  font-weight: 800;
  flex: 1;
  font-size: 14px;
}
.history-item .h-score {
  font-family: 'Bebas Neue', sans-serif;
  color: var(--c-gold);
  font-size: 24px;
  letter-spacing: 1px;
}
.history-item .h-meta {
  color: var(--text-dim);
  font-size: 11px;
  width: 100%;
  margin-top: 2px;
  letter-spacing: 0.5px;
}
.history-item { flex-wrap: wrap; cursor: pointer; }

.lb-item .lb-rank {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 26px;
  width: 36px;
  text-align: center;
  color: var(--c-gold);
}
.lb-item:nth-child(1) .lb-rank { color: var(--c-gold); text-shadow: 0 0 12px rgba(255, 198, 64, 0.6); }
.lb-item:nth-child(2) .lb-rank { color: #c0c0c0; }
.lb-item:nth-child(3) .lb-rank { color: #cd7f32; }
.lb-item .lb-nick { flex: 1; font-weight: 800; }
.lb-item .lb-score {
  font-family: 'Bebas Neue', sans-serif;
  color: var(--c-lime);
  font-size: 22px;
  letter-spacing: 1px;
}

.user-item { flex-wrap: wrap; cursor: default; }
.user-item:active { transform: none; background: var(--bg-card); }
.user-item .u-actions {
  display: flex;
  gap: 6px;
  width: 100%;
  margin-top: 10px;
}
.user-item button {
  flex: 1;
  padding: 8px 6px;
  font-size: 10px;
  border: none;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: 1.5px;
  transition: transform 0.15s cubic-bezier(0.34, 1.7, 0.64, 1), background 0.2s;
  clip-path: polygon(5px 0, calc(100% - 5px) 0, 100% 5px, 100% calc(100% - 5px), calc(100% - 5px) 100%, 5px 100%, 0 calc(100% - 5px), 0 5px);
  box-shadow: inset 0 0 0 1px var(--c-gold-deep), inset 0 0 0 2px var(--bg-deep);
}
.user-item button:active { transform: scale(0.95); }
.user-item button.danger { color: var(--c-cherry); border-color: rgba(255, 46, 99, 0.3); }
.user-item button.gold { color: var(--c-gold); border-color: rgba(255, 198, 64, 0.3); }

.attempt-item { flex-wrap: wrap; }
.attempt-item .a-nick { font-weight: 800; flex: 1; font-size: 14px; }
.attempt-item .a-score {
  font-family: 'Bebas Neue', sans-serif;
  color: var(--c-gold);
  font-size: 20px;
  letter-spacing: 1px;
}
.attempt-item .a-meta {
  color: var(--text-dim);
  font-size: 10px;
  width: 100%;
  margin-top: 2px;
  letter-spacing: 0.5px;
}

/* ============ EMPTY STATE ============ */
.empty {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-darker);
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ============ DESKTOP ============ */
@media (min-width: 768px) {
  .screen { padding: 32px; }
  #app { max-width: 600px; margin: 0 auto; }
  .answers { gap: 14px; }
  .answer-btn { min-height: 96px; font-size: 15px; }
  .question-text { font-size: 19px; }
}
