:root {
  color-scheme: dark;
  --bg: #050817;
  --ink: #f7fbff;
  --muted: #b9c8df;
  --panel: rgba(7, 20, 55, 0.82);
  --panel-strong: rgba(10, 34, 88, 0.94);
  --blue: #174cbd;
  --blue-2: #0d2f86;
  --gold: #ffd35f;
  --gold-2: #d99324;
  --red: #e14952;
  --green: #25cf8a;
  --cyan: #53d6ff;
  --line: rgba(255, 255, 255, 0.16);
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.36);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: #050817;
  color: var(--ink);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

.app-root {
  min-height: 100vh;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  padding: 18px;
  isolation: isolate;
}

.app-shell::before {
  position: fixed;
  inset: 0;
  z-index: -3;
  content: "";
  background: url("./assets/studio.svg") center top / cover no-repeat;
}

.app-shell::after {
  position: fixed;
  inset: 0;
  z-index: -2;
  content: "";
  background:
    linear-gradient(180deg, rgba(5, 8, 23, 0.36), rgba(5, 8, 23, 0.88) 62%, #050817),
    radial-gradient(circle at 12% 22%, rgba(255, 211, 95, 0.24), transparent 28%),
    radial-gradient(circle at 88% 18%, rgba(83, 214, 255, 0.22), transparent 30%);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  max-width: 1480px;
  margin: 0 auto 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(3, 9, 27, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.brand > div {
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border: 2px solid rgba(255, 211, 95, 0.8);
  border-radius: 50%;
  background: radial-gradient(circle, #ffec9a 0 16%, #f6b033 17% 42%, #174cbd 43% 100%);
  color: #06143b;
  font-weight: 900;
}

.brand-title {
  margin: 0;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1;
  text-transform: uppercase;
}

.brand-subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-self: end;
  min-width: 0;
}

.online-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 9px;
  border: 1px solid rgba(37, 207, 138, 0.5);
  border-radius: 999px;
  background: rgba(37, 207, 138, 0.1);
  color: #b8ffe3;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.online-badge small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px rgba(37, 207, 138, 0.88);
}

.avatar {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border: 2px solid rgba(255, 211, 95, 0.74);
  border-radius: 50%;
  background: linear-gradient(135deg, #ffd35f, #53d6ff);
  color: #08183d;
  font-weight: 900;
}

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

.profile-name {
  max-width: 180px;
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  max-width: 1480px;
  margin: 0 auto;
}

.layout-tabs {
  display: block;
}

.tabbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-width: 1480px;
  margin: 0 auto 10px;
}

.tab-button {
  min-height: 38px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(3, 9, 27, 0.72);
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
}

.tab-button:hover,
.tab-button:focus-visible,
.tab-button.active {
  border-color: rgba(255, 211, 95, 0.72);
  background: rgba(255, 211, 95, 0.13);
  color: var(--gold);
  outline: 0;
}

.tab-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(280px, 1fr) minmax(280px, 1fr);
  gap: 14px;
}

.main-column,
.side-column {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel-pad {
  padding: 18px;
}

.stage-panel {
  overflow: hidden;
}

.stage-copy {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  min-height: 150px;
  padding: 20px 24px;
  background:
    linear-gradient(90deg, rgba(4, 11, 33, 0.9), rgba(4, 11, 33, 0.24)),
    radial-gradient(circle at 78% 16%, rgba(255, 211, 95, 0.22), transparent 24%);
}

.stage-title {
  margin: 0;
  max-width: 820px;
  font-size: clamp(30px, 5vw, 58px);
  line-height: 0.95;
  text-transform: uppercase;
}

.stage-text {
  max-width: 680px;
  margin: 9px 0 0;
  color: #d8e5f8;
  font-size: clamp(14px, 2vw, 17px);
  line-height: 1.42;
}

.stage-number {
  display: grid;
  min-width: 100px;
  min-height: 100px;
  place-items: center;
  border: 2px solid rgba(255, 211, 95, 0.78);
  border-radius: 8px;
  background: rgba(12, 47, 134, 0.82);
  color: var(--gold);
  font-size: 40px;
  font-weight: 900;
  box-shadow: inset 0 0 30px rgba(83, 214, 255, 0.18);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
}

.section-title h2,
.section-title h3 {
  margin: 0;
  font-size: 22px;
}

.section-kicker {
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.btn:hover,
.btn:focus-visible {
  border-color: rgba(255, 211, 95, 0.72);
  background: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
  outline: 0;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.btn-primary {
  border-color: rgba(255, 211, 95, 0.8);
  background: linear-gradient(180deg, #ffe18a, #d89222);
  color: #06143b;
}

.btn-danger {
  border-color: rgba(225, 73, 82, 0.8);
  background: rgba(225, 73, 82, 0.2);
}

.btn-ghost {
  background: rgba(7, 20, 55, 0.4);
}

.btn-small {
  min-height: 34px;
  padding: 8px 10px;
  font-size: 13px;
}

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

.room-box,
.mission,
.leader-row,
.stat-box,
.player-chip,
.rules-list li {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(4, 12, 36, 0.58);
}

.room-box {
  display: flex;
  min-height: 148px;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
}

.room-box h3 {
  margin: 0 0 6px;
}

.room-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.38;
}

.room-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 211, 95, 0.65);
  border-radius: 8px;
  background: rgba(255, 211, 95, 0.12);
  color: var(--gold);
  font-size: 20px;
  font-weight: 900;
}

.input-row {
  display: flex;
  gap: 10px;
}

.input {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  outline: none;
}

.input:focus {
  border-color: rgba(83, 214, 255, 0.82);
}

.players {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(154px, 1fr));
  gap: 10px;
}

.player-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px;
}

.player-chip.active {
  border-color: rgba(255, 211, 95, 0.78);
  background: rgba(255, 211, 95, 0.1);
}

.player-chip.winner {
  border-color: rgba(37, 207, 138, 0.8);
}

.player-info {
  min-width: 0;
}

.player-name {
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-score {
  margin-top: 3px;
  color: var(--gold);
  font-weight: 900;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(142px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.board-wrap {
  overflow-x: auto;
  padding-bottom: 4px;
}

.board-desktop {
  display: block;
}

.board-mobile {
  display: none;
}

.board {
  display: grid;
  min-width: 850px;
  grid-template-columns: minmax(150px, 1.28fr) repeat(7, minmax(78px, 1fr));
  gap: 6px;
}

.board-head,
.theme-cell,
.question-cell {
  min-height: 66px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
}

.board-head {
  display: grid;
  place-items: center;
  background: rgba(6, 18, 52, 0.88);
  color: var(--muted);
  font-weight: 800;
}

.theme-cell {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(9, 39, 114, 0.9), rgba(12, 89, 139, 0.72));
  color: #f5f9ff;
  font-weight: 900;
  line-height: 1.18;
}

.question-cell {
  display: grid;
  width: 100%;
  place-items: center;
  background: linear-gradient(180deg, #174cbd, #0d2f86);
  color: var(--gold);
  cursor: pointer;
  font-size: clamp(20px, 2.6vw, 30px);
  font-weight: 950;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.question-cell:hover,
.question-cell:focus-visible {
  border-color: rgba(255, 211, 95, 0.86);
  box-shadow: inset 0 0 28px rgba(255, 211, 95, 0.18);
  outline: 0;
}

.question-cell.opened {
  cursor: default;
  background: rgba(10, 18, 40, 0.62);
  color: rgba(255, 255, 255, 0.26);
  text-shadow: none;
}

.theme-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(4, 12, 36, 0.58);
}

.theme-mobile-title {
  color: #f5f9ff;
  font-size: 16px;
  font-weight: 900;
  line-height: 1.2;
}

.mobile-level-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.question-cell-mobile {
  min-height: 56px;
  font-size: 22px;
}

.question-cell.locked {
  cursor: not-allowed;
  opacity: 0.55;
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 14px;
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.pill.gold {
  border-color: rgba(255, 211, 95, 0.55);
  background: rgba(255, 211, 95, 0.11);
  color: var(--gold);
}

.pill.green {
  border-color: rgba(37, 207, 138, 0.55);
  background: rgba(37, 207, 138, 0.12);
  color: #88ffd1;
}

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

.stat-box {
  padding: 12px;
}

.stat-value {
  color: var(--gold);
  font-size: 26px;
  font-weight: 950;
}

.stat-label {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.tickets-count {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.tickets-count strong {
  color: var(--gold);
  font-size: 42px;
  line-height: 1;
}

.side-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.missions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mission {
  padding: 12px;
}

.mission-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.mission-title {
  font-weight: 850;
}

.mission-reward {
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--gold));
}

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

.leader-tabs .btn.active {
  border-color: rgba(255, 211, 95, 0.8);
  background: rgba(255, 211, 95, 0.14);
  color: var(--gold);
}

.leader-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leader-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
}

.leader-place {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 211, 95, 0.14);
  color: var(--gold);
  font-weight: 950;
}

.leader-name {
  overflow: hidden;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leader-score {
  color: var(--gold);
  font-weight: 950;
}

.rules-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.rules-list li {
  padding: 10px 12px;
  color: #d8e5f8;
  line-height: 1.4;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 36px));
  padding: 14px 16px;
  border: 1px solid rgba(255, 211, 95, 0.55);
  border-radius: 8px;
  background: rgba(4, 11, 33, 0.95);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: grid;
  padding: 18px;
  place-items: center;
  background: rgba(0, 0, 0, 0.68);
}

.question-modal {
  width: min(760px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
  border: 1px solid rgba(255, 211, 95, 0.55);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(10, 34, 88, 0.98), rgba(4, 11, 33, 0.98));
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.58);
}

.question-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.question-body {
  padding: 22px;
}

.question-body h2 {
  margin: 0 0 14px;
  color: var(--gold);
  font-size: clamp(24px, 4vw, 38px);
}

.question-text {
  min-height: 118px;
  margin: 0 0 18px;
  font-size: clamp(20px, 3vw, 30px);
  font-weight: 850;
  line-height: 1.25;
}

.answer-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
}

.answer-result {
  margin-top: 14px;
  color: var(--muted);
  line-height: 1.45;
}

.empty {
  padding: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none !important;
}

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

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

  .stage-copy {
    min-height: 136px;
    padding: 18px 20px;
  }

  .stage-number {
    min-width: 86px;
    min-height: 86px;
    font-size: 34px;
  }

  .side-column {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .board-desktop {
    display: none;
  }

  .board-mobile {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 10px;
  }

  .panel-pad {
    padding: 14px;
  }

  .topbar,
  .stage-copy,
  .grid-2,
  .side-column {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: start;
    padding: 12px;
  }

  .profile {
    width: 100%;
    justify-self: start;
  }

  .brand {
    align-items: start;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
  }

  .brand-subtitle {
    font-size: 13px;
  }

  .profile-name {
    max-width: 60vw;
  }

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

  .actions {
    align-items: stretch;
  }

  .actions .btn {
    width: 100%;
  }

  .stage-copy {
    min-height: 236px;
    padding: 18px;
  }

  .stage-number {
    min-width: 86px;
    min-height: 86px;
    font-size: 34px;
  }

  .answer-form,
  .input-row {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .answer-form {
    display: flex;
    flex-direction: column;
  }

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

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

  .theme-card {
    padding: 10px;
  }

  .theme-mobile-title {
    font-size: 15px;
  }

  .mobile-level-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .question-cell-mobile {
    min-height: 52px;
    font-size: 20px;
  }

  .modal-backdrop {
    align-items: end;
    padding: 10px;
  }

  .question-body {
    padding: 18px;
  }

  .question-text {
    min-height: 92px;
  }
}
