:root {
  --bg: #07080b;
  --panel: #11141a;
  --panel-2: #171b23;
  --line: #2a303b;
  --text: #f7f7f2;
  --muted: #a9b0bd;
  --accent: #18e0a7;
  --accent-2: #ffcc3d;
  --danger: #ff4d6d;
  --blue: #4aa3ff;
  --radius: 8px;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #1c222d;
  color: var(--text);
  cursor: pointer;
  min-height: 38px;
  padding: 8px 12px;
}

button:hover {
  border-color: #4a5364;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.file-button:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #03100c;
  font-weight: 800;
}

button.danger {
  border-color: rgba(255, 77, 109, 0.5);
  color: #ffd7df;
}

button.icon {
  width: 38px;
  padding: 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #090b10;
  color: var(--text);
  min-height: 38px;
  padding: 8px 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.home {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.home-panel {
  width: min(520px, 100%);
  padding: 8px;
}

.home h1 {
  margin: 0 0 12px;
  font-size: 42px;
  font-weight: 900;
  line-height: 1;
}

.home p {
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 24px;
}

.home-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 0;
}

.home-grid button {
  width: 100%;
  min-height: 48px;
}

.home-create {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 10px;
  margin-bottom: 18px;
}

.session-list {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.session-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 12px;
}

.session-card strong,
.session-card span {
  display: block;
}

.session-card strong {
  font-size: 15px;
}

.session-card span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.session-card a {
  text-decoration: none;
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px 1fr 480px;
}

.sidebar,
.preview-pane {
  background: #0b0e13;
  border-right: 1px solid var(--line);
  min-height: 100vh;
  padding: 18px;
}

.preview-pane {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  padding: 5px 9px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  text-align: left;
}

.nav button.active {
  border-color: var(--accent);
  background: rgba(24, 224, 167, 0.12);
}

.content {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h2,
.preview-pane h2 {
  margin: 0;
  font-size: 22px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row.wrap {
  flex-wrap: wrap;
}

.panel-actions {
  margin-top: 10px;
}

.panel-actions button {
  flex: 1;
}

.grid {
  display: grid;
  gap: 12px;
}

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

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

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

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

.live-status {
  display: inline-block;
  margin-top: 7px;
  color: #ff5d75;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.live-status.locked {
  color: var(--accent-2);
}

.blackout-button {
  border-color: #555;
  background: #000;
  color: #fff;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.blackout-button.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px #fff;
}

.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 14px;
}

.section-title {
  margin: 0 0 12px;
  font-size: 15px;
}

.participant-list {
  display: grid;
  gap: 10px;
}

.participant {
  display: grid;
  grid-template-columns: 52px 1.4fr 0.8fr 0.7fr 80px minmax(300px, auto);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 10px;
}

.participant-actions {
  align-items: stretch;
  flex-wrap: wrap;
}

.score-step {
  min-width: 42px;
  padding-inline: 7px;
  color: var(--accent);
  font-weight: 800;
}

.score-step.reset-score {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.participant-actions button:not(.icon) {
  min-height: 38px;
  padding: 8px 10px;
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 7px;
  background: #222a36;
  object-fit: cover;
}

.avatar.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.small {
  color: var(--muted);
  font-size: 12px;
}

.error-text {
  min-height: 20px;
  margin: 0 !important;
  color: #ff8297 !important;
  font-size: 13px;
}

.connection-state {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -8px 0 16px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.connection-state i,
.cloud-indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #6f7784;
}

.connection-state.connected i,
.cloud-indicator.connected {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.connection-state.error i,
.cloud-indicator.error {
  background: var(--danger);
}

.cloud-indicator {
  position: fixed;
  z-index: 20;
  right: 8px;
  bottom: 34px;
  opacity: 0.7;
}

.version-badge {
  position: fixed;
  z-index: 50;
  right: 8px;
  bottom: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(4, 6, 9, 0.72);
  color: rgba(255, 255, 255, 0.72);
  font: 800 11px/1 system-ui, sans-serif;
  letter-spacing: 0.08em;
  padding: 5px 8px;
  pointer-events: none;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 4px;
}

.toggle button {
  border: 0;
  border-radius: 999px;
  background: transparent;
  min-height: 30px;
  padding: 5px 10px;
  color: var(--muted);
}

.toggle button.active {
  background: var(--accent);
  color: #03100c;
  font-weight: 800;
}

.sort-toggle {
  justify-self: start;
}

.file-button {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #1c222d;
  color: var(--text);
  cursor: pointer;
  padding: 8px 12px;
  font-size: inherit;
  font-weight: 400;
  text-transform: none;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.session-tools {
  margin-top: 16px;
}

.stage-wrap {
  aspect-ratio: 16 / 9;
  width: 100%;
  background: #000;
  border: 1px solid var(--line);
  overflow: hidden;
}

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: transparent;
  color: var(--stage-text, var(--text));
  font-family: var(--stage-font, inherit);
  background-image: var(--stage-image, none);
  background-position: center;
  background-size: cover;
  container-type: size;
}

.stage.black {
  background: var(--stage-bg, #020306);
}

.stage.blackout,
.blackout-screen {
  background: #000 !important;
}

.blackout-screen {
  position: absolute;
  inset: 0;
}

.show-body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: transparent;
}

.show-body .stage-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(100vw, var(--format-width));
  height: min(100vh, var(--format-height));
  transform: translate(-50%, -50%);
  aspect-ratio: auto;
  border: 0;
  background: transparent;
}

.show-body .stage-wrap.show-format-fill {
  width: 100vw;
  height: 100vh;
  transform: translate(-50%, -50%);
}

.show-body .stage {
  width: 100vw;
  height: 100vh;
}

.show-body:not(.black),
.show-body:not(.black) #app {
  background: transparent;
}

html.show-transparent,
html.show-transparent body,
html.show-transparent #app,
html.show-transparent .stage-wrap,
html.show-transparent .stage:not(.blackout) {
  background-color: transparent !important;
}

.scene-fields {
  margin-top: 16px;
}

.scene-field-group {
  display: grid;
  gap: 12px;
  border-left: 3px solid var(--line);
  padding-left: 14px;
}

.scene-field-group.active {
  border-color: var(--accent);
}

.show-body.black {
  background: #020306;
}

.rank-screen {
  width: 100%;
  height: 100%;
  padding: 4.2%;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 3%;
}

.screen-title {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  justify-content: var(--title-align, left);
  text-align: var(--title-align, left);
}

.screen-title h1 {
  margin: 0;
  font-size: calc(clamp(14px, 4.8cqw, 88px) * var(--font-scale, 1));
  letter-spacing: 0;
  line-height: 0.95;
  text-transform: uppercase;
}

.screen-title span {
  color: var(--accent);
  font-weight: 900;
  font-size: clamp(8px, 1.7cqw, 28px);
}

.ranking {
  position: relative;
  display: grid;
  grid-template-rows: repeat(10, minmax(0, 1fr));
  gap: min(1.2cqh, 12px);
  min-height: 0;
  overflow: hidden;
}

.multi-rank-screen {
  padding: 3.2%;
  gap: 2%;
}

.multi-ranking {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.4cqw;
}

.columns-3 .multi-ranking {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9cqw;
}

.ranking-column {
  min-width: 0;
}

.compact-rank-item {
  grid-template-columns: minmax(20px, 3.5cqw) minmax(20px, 3.5cqw) 1fr minmax(30px, 5cqw);
  gap: 0.65cqw;
  border-left-width: 3px;
  padding: 0.35cqh 0.65cqw;
}

.compact-rank-item .rank-number {
  font-size: clamp(10px, 2.1cqw, 34px);
}

.compact-rank-item .rank-photo {
  width: min(3.5cqw, 54px);
  height: min(3.5cqw, 54px);
}

.compact-rank-item .rank-name strong {
  font-size: clamp(8px, 1.45cqw, 25px);
}

.compact-rank-item .rank-name em {
  font-size: clamp(6px, 0.85cqw, 15px);
}

.compact-rank-item .rank-score {
  font-size: clamp(8px, 1.4cqw, 24px);
}

.columns-3 .compact-rank-item {
  grid-template-columns: minmax(18px, 2.4cqw) minmax(18px, 2.4cqw) 1fr minmax(26px, 3.5cqw);
}

.columns-3 .compact-rank-item .rank-name em {
  display: none;
}

.columns-3 .compact-rank-item .rank-photo {
  width: min(2.4cqw, 40px);
  height: min(2.4cqw, 40px);
}

.rank-item {
  display: grid;
  grid-template-columns: minmax(22px, 5.2cqw) minmax(22px, 5cqw) 1fr minmax(34px, 8cqw);
  align-items: center;
  gap: 1.2cqw;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  border-left: 5px solid var(--accent);
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 28%, var(--stage-surface)), var(--stage-surface));
  padding: 0.65cqh 1.2cqw;
  transform-origin: center;
  border-radius: var(--stage-radius, 0);
  animation: slideIn calc(520ms * var(--animation-speed, 1)) ease both;
}

.rank-number {
  font-size: clamp(11px, 3.3cqw, 56px);
  font-weight: 950;
}

.rank-photo {
  width: min(5cqw, 76px);
  height: min(5cqw, 76px);
  min-width: 20px;
  min-height: 20px;
  object-fit: cover;
  border-radius: 7px;
  background: #252d3a;
}

.rank-item > .rank-photo {
  width: auto;
  height: 100%;
  max-height: 100%;
  max-width: min(5cqw, 76px);
  aspect-ratio: 1;
}

.rank-name {
  min-width: 0;
}

.rank-name strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: calc(clamp(9px, 2.5cqw, 44px) * var(--font-scale, 1));
  text-transform: uppercase;
}

.rank-name em {
  display: block;
  color: var(--stage-muted, var(--muted));
  font-size: clamp(7px, 1.2cqw, 20px);
  font-style: normal;
  text-transform: uppercase;
}

.rank-score {
  font-size: clamp(9px, 2.5cqw, 46px);
  font-weight: 950;
  text-align: right;
}

.podium-screen {
  width: 100%;
  height: 100%;
  padding: 5%;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 5%;
}

.podium {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  align-items: end;
  gap: 3%;
}

.podium-card {
  display: grid;
  align-content: end;
  justify-items: center;
  gap: 1.3cqh;
  min-height: 42%;
  padding: 5%;
  background: linear-gradient(180deg, color-mix(in srgb, var(--stage-surface) 82%, white), var(--stage-surface));
  border-bottom: 7px solid var(--accent);
  border-radius: var(--stage-radius, 0) var(--stage-radius, 0) 0 0;
  animation: revealUp calc(700ms * var(--animation-speed, 1)) ease both;
}

.podium-card.place-1 {
  min-height: 66%;
  animation-delay: 120ms;
  border-color: var(--accent-2);
}

.podium-card.place-2 {
  min-height: 54%;
  animation-delay: 60ms;
  border-color: var(--blue);
}

.podium-card.place-3 {
  animation-delay: 0ms;
}

.podium-card img {
  width: min(14cqw, 210px);
  height: min(14cqw, 210px);
  object-fit: cover;
  border-radius: 8px;
  background: #252d3a;
}

.podium-card strong {
  font-size: calc(clamp(10px, 3cqw, 54px) * var(--font-scale, 1));
  text-transform: uppercase;
  text-align: center;
}

.podium-card span {
  color: var(--stage-muted, var(--muted));
  font-size: clamp(7px, 1.4cqw, 24px);
  text-transform: uppercase;
}

.podium-card b {
  font-size: clamp(10px, 2.6cqw, 48px);
}

.progress-screen {
  width: 100%;
  height: 100%;
  padding: 8%;
  display: grid;
  align-content: center;
  gap: 5cqh;
}

.progress-list {
  display: grid;
  gap: 4cqh;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: end;
  font-size: clamp(10px, 2.8cqw, 54px);
  font-weight: 900;
  text-transform: uppercase;
}

.progress-label span {
  color: var(--accent);
}

.bar {
  height: clamp(14px, 5cqh, 70px);
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  border-radius: var(--stage-radius, 0);
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 800ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.message-screen {
  width: 100%;
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 2cqh;
  padding: 10%;
  text-align: center;
}

.rank-screen,
.podium-screen,
.progress-screen,
.message-screen {
  animation: sceneIn 220ms ease-out both;
}

.message-screen span {
  color: var(--accent);
  font-size: clamp(10px, 1.8cqw, 30px);
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.message-screen h1 {
  margin: 0;
  font-size: calc(clamp(28px, 7cqw, 120px) * var(--font-scale, 1));
  line-height: 0.95;
  text-transform: uppercase;
}

.message-screen p {
  max-width: 26em;
  margin: 0;
  color: var(--stage-muted);
  font-size: clamp(14px, 2.3cqw, 40px);
}

.show-logo {
  position: absolute;
  z-index: 5;
  top: 3%;
  right: 3%;
  width: min(12cqw, 180px);
  max-height: 14cqh;
  object-fit: contain;
}

.ticker {
  position: absolute;
  z-index: 6;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
  padding: 0.7cqh 0;
  background: var(--accent);
  color: #020306;
  font-size: clamp(9px, 1.5cqw, 26px);
  font-weight: 900;
  white-space: nowrap;
}

.ticker span {
  display: inline-block;
  min-width: 100%;
  padding-left: 100%;
  animation: tickerMove calc(16s * var(--animation-speed, 1)) linear infinite;
}

.check-label {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  gap: 10px;
  text-transform: none;
}

.check-label input {
  width: 18px;
  min-height: 18px;
}

.empty-state {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  text-align: center;
  padding: 8%;
}

.hidden {
  display: none !important;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-4%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes revealUp {
  from {
    opacity: 0;
    transform: translateY(18%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes tickerMove {
  to { transform: translateX(-200%); }
}

@keyframes sceneIn {
  from { opacity: 0; transform: scale(0.992); }
  to { opacity: 1; transform: scale(1); }
}

@media (max-width: 1180px) {
  .admin-shell {
    grid-template-columns: 260px 1fr;
  }

  .preview-pane {
    grid-column: 1 / -1;
    min-height: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .admin-shell,
  .two,
  .three,
  .four,
  .scene-grid,
  .home-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .participant {
    grid-template-columns: 52px 1fr;
  }

  .content,
  .sidebar,
  .preview-pane {
    padding: 14px;
  }

  .home-create {
    grid-template-columns: 1fr;
  }

  .sort-toggle {
    display: grid;
    width: 100%;
    border-radius: 8px;
  }
}
