:root {
  color-scheme: dark;
  --bg: #0f0f0f;
  --panel: #181818;
  --panel-2: #212121;
  --line: #303030;
  --text: #f1f1f1;
  --muted: #aaa;
  --red: #ff0033;
  --red-2: #cc0029;
  --green: #2fcf6b;
  --gold: #ffc947;
  --blue: #4fa3ff;
  --shadow: 0 24px 80px rgba(0, 0, 0, .42);
  font-family: Inter, Roboto, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 72% 12%, rgba(255, 0, 51, .16), transparent 28rem),
    linear-gradient(180deg, #171717 0%, var(--bg) 38rem);
  color: var(--text);
}

body.game-focus {
  overflow: hidden;
}

body.game-focus::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 18;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(4px);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.bot-field {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 20px 14px;
  background: rgba(15, 15, 15, .94);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
  padding: 8px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 30px;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  box-shadow: 0 10px 32px rgba(255, 0, 51, .36);
}

.brand strong,
.brand small,
.account-card strong,
.account-card small {
  display: block;
}

.brand small,
.account-card small,
.text-muted,
.today-card small,
.share-card small,
.admin-preview p,
.lead-form small {
  color: var(--muted);
}

.main-nav {
  display: grid;
  gap: 6px;
}

.main-nav a {
  color: var(--text);
  text-decoration: none;
  padding: 12px 14px;
  border-radius: 8px;
  transition: background .2s ease, transform .2s ease;
}

.main-nav a:hover,
.main-nav a.is-active {
  background: var(--panel-2);
}

.main-nav a:active {
  transform: scale(.98);
}

.account-card {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #3a7cff;
  font-weight: 700;
}

.main {
  min-width: 0;
  padding: 18px clamp(14px, 3vw, 34px) 44px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  padding: 10px 0 18px;
  background: linear-gradient(180deg, rgba(15, 15, 15, .96), rgba(15, 15, 15, .82));
  backdrop-filter: blur(16px);
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #121212;
}

.search input {
  width: 100%;
  min-width: 0;
  height: 44px;
  color: var(--text);
  border: 0;
  outline: 0;
  background: transparent;
}

.primary-btn,
.outline-btn,
.ghost-btn,
.share-row button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  color: var(--text);
  background: var(--panel-2);
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}

.primary-btn {
  background: var(--red);
  color: #fff;
  font-weight: 700;
}

.primary-btn:hover {
  background: var(--red-2);
}

.outline-btn {
  border-color: var(--line);
  background: transparent;
}

.ghost-btn {
  background: var(--panel);
}

.primary-btn:active,
.outline-btn:active,
.ghost-btn:active,
.share-row button:active,
.choice-grid button:active {
  transform: translateY(1px) scale(.99);
}

.hero-section {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr);
  gap: 18px;
  align-items: stretch;
  margin: 12px 0 20px;
}

.hero-copy,
.lead-form,
.quiz-stage,
.player-panel,
.admin-form,
.admin-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 24, 24, .86);
  box-shadow: var(--shadow);
}

.hero-copy {
  min-height: 300px;
  padding: clamp(24px, 5vw, 48px);
  overflow: hidden;
  position: relative;
}

.hero-copy::after {
  content: "";
  position: absolute;
  right: -4rem;
  bottom: -4rem;
  width: 24rem;
  height: 15rem;
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, 0)),
    linear-gradient(90deg, #d8002b, #6113ff);
  transform: rotate(-8deg);
  opacity: .55;
}

.hero-copy > * {
  position: relative;
  z-index: 1;
}

.eyebrow,
.pill {
  color: #ffb8c5;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .78rem;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(2.4rem, 7vw, 5.8rem);
  line-height: .95;
}

h2 {
  font-size: clamp(1.35rem, 2vw, 2rem);
}

p {
  line-height: 1.55;
}

.hero-copy p {
  max-width: 620px;
  color: #d7d7d7;
  font-size: 1.08rem;
}

.animated-bullets {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.animated-bullets span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  animation: floatBullet 3.2s ease-in-out infinite;
}

.animated-bullets span:nth-child(2) {
  animation-delay: .35s;
}

.lead-form {
  padding: 22px;
}

.lead-form form,
.admin-form {
  display: grid;
  gap: 12px;
}

.lead-form input,
.admin-form input,
.admin-form select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #111;
  color: var(--text);
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

body.game-focus .studio-grid {
  position: fixed;
  inset: 18px;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: stretch;
}

body.game-focus .quiz-stage,
body.game-focus .player-panel {
  max-height: calc(100vh - 36px);
  overflow: auto;
}

body.game-focus .quiz-stage {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
}

body.game-focus .versus-grid {
  align-content: center;
}

body.game-focus .cover-option img,
body.game-focus .thumbnail-card {
  min-height: min(58vh, 620px);
}

.quiz-stage,
.player-panel {
  padding: 18px;
}

.stage-head,
.section-title,
.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.focus-exit {
  display: none;
}

body.game-focus .focus-exit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.question-meta {
  text-align: right;
}

.question-meta strong,
.question-meta span {
  display: block;
}

.question-meta span {
  color: var(--gold);
}

.progress-track {
  height: 8px;
  overflow: hidden;
  margin: 16px 0;
  border-radius: 999px;
  background: #2b2b2b;
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--gold));
  transition: width .35s ease;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.mode-tabs button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #111;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

.mode-tabs button.is-active {
  border-color: rgba(255, 0, 51, .7);
  background: rgba(255, 0, 51, .18);
}

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

.cover-option {
  position: relative;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #fff;
  background: #050505;
  text-align: left;
  transition: transform .2s ease, border-color .2s ease, filter .2s ease;
}

.cover-option:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, .42);
  filter: brightness(1.08);
}

.cover-option.is-correct {
  border-color: var(--green);
}

.cover-option.is-wrong {
  border-color: var(--red);
}

.cover-option img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.cover-option::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 42%, rgba(0, 0, 0, .86));
  pointer-events: none;
}

.cover-label,
.cover-option strong {
  position: absolute;
  left: 14px;
  right: 14px;
  z-index: 1;
  text-shadow: 0 6px 18px rgba(0, 0, 0, .85);
}

.cover-label {
  top: 12px;
  width: max-content;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--red);
  font-weight: 800;
}

.cover-option strong {
  bottom: 12px;
  font-size: clamp(1rem, 2vw, 1.45rem);
  line-height: 1.08;
}

.thumbnail-card {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 8px;
  background: #050505;
}

.thumbnail-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .55s ease, filter .35s ease;
}

.thumbnail-card:hover img {
  transform: scale(1.035);
}

.thumb-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, .86));
}

.thumb-title {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 14px;
  display: grid;
  gap: 8px;
}

.thumb-title strong {
  max-width: 820px;
  font-size: clamp(1.2rem, 3vw, 2.5rem);
  line-height: 1;
  text-shadow: 0 6px 16px rgba(0, 0, 0, .85);
}

.thumb-title span {
  width: max-content;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--red);
  color: #fff;
  font-weight: 800;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.choice-grid button {
  min-height: 62px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  font-size: clamp(1rem, 2.2vw, 1.35rem);
  font-weight: 800;
  transition: transform .18s ease, filter .18s ease;
}

.hype-btn {
  background: linear-gradient(135deg, #ff0033, #ff7b00);
}

.fail-btn {
  background: linear-gradient(135deg, #222, #5c5c5c);
}

.choice-grid button:hover {
  filter: brightness(1.08);
}

.result-panel {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121212;
  animation: popIn .28s ease;
}

.result-panel strong {
  font-size: clamp(1.5rem, 4vw, 3rem);
}

.player-panel {
  display: grid;
  gap: 14px;
}

.stat-row {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.stat-row strong {
  font-size: 1.5rem;
}

.rank-ladder {
  display: grid;
  gap: 8px;
}

.rank-ladder div {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.rank-ladder div.is-current {
  border-color: rgba(255, 201, 71, .6);
  color: var(--text);
  background: rgba(255, 201, 71, .12);
}

.today-card,
.share-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 8px;
  background: var(--panel-2);
}

.today-card strong {
  font-size: 2.25rem;
}

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

.share-row button {
  padding: 0 8px;
}

.catalog-section,
.leaderboard-section,
.admin-section {
  margin-top: 38px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.category-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: inherit;
  background: var(--panel);
  text-align: left;
  transition: transform .2s ease, border-color .2s ease;
}

.category-card:hover {
  transform: translateY(-3px);
  border-color: #565656;
}

.category-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

.category-card div {
  display: grid;
  gap: 5px;
  padding: 12px;
}

.category-card strong {
  font-size: 1rem;
}

.category-card span {
  color: var(--muted);
  font-size: .9rem;
}

.leaderboard {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.leader-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  min-height: 54px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.leader-row strong {
  min-width: 70px;
  text-align: right;
}

.leader-row span:last-child {
  color: var(--gold);
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  margin-top: 16px;
}

.admin-form,
.admin-preview {
  padding: 18px;
}

.admin-form label {
  display: grid;
  gap: 6px;
  color: #ddd;
}

.folder-list {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.folder-list div {
  display: flex;
  justify-content: space-between;
  padding: 12px;
  border-radius: 8px;
  background: #111;
}

.shake {
  animation: shake .35s ease;
}

@keyframes floatBullet {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes shake {
  20%,
  60% {
    transform: translateX(-6px);
  }
  40%,
  80% {
    transform: translateX(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .main-nav {
    display: flex;
    min-width: max-content;
  }

  .account-card {
    margin-top: 0;
    min-width: 190px;
  }

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

  .player-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.game-focus .studio-grid {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  body.game-focus .player-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
  }
}

@media (max-width: 760px) {
  .topbar,
  .hero-section,
  .choice-grid,
  .mode-tabs,
  .versus-grid,
  .category-grid,
  .player-panel {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: static;
  }

  .sidebar {
    padding: 12px;
  }

  .brand small,
  .account-card {
    display: none;
  }

  .hero-copy {
    min-height: 0;
  }

  .hero-copy::after {
    width: 16rem;
    height: 10rem;
  }

  .section-title,
  .stage-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .question-meta {
    text-align: left;
  }

  .leader-row {
    grid-template-columns: 34px minmax(0, 1fr) auto;
  }

  .leader-row span:last-child {
    display: none;
  }

  body.game-focus .studio-grid {
    inset: 8px;
  }

  body.game-focus .quiz-stage,
  body.game-focus .player-panel {
    max-height: none;
  }

  body.game-focus .cover-option img,
  body.game-focus .thumbnail-card {
    min-height: auto;
  }
}
