:root {
  color-scheme: dark;
  --bg: #0f1114;
  --panel: #191d21;
  --panel-soft: #22272c;
  --text: #f4efe7;
  --muted: #aeb6b3;
  --line: rgba(255, 255, 255, 0.14);
  --green: #39d6bb;
  --yellow: #ffd166;
  --blue: #79b8ff;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button,
input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
}

button {
  min-height: 42px;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
}

button:hover,
a:hover {
  border-color: var(--green);
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  background: #111417;
  color: var(--text);
}

textarea {
  resize: vertical;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.eyebrow,
.kicker {
  margin-bottom: 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.lead {
  max-width: 680px;
  color: var(--muted);
  font-size: 20px;
  line-height: 1.7;
}

.entry-page {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 70px 0;
}

.entry-hero h1 {
  margin-bottom: 16px;
  font-size: clamp(42px, 7vw, 92px);
  line-height: 1;
}

.entry-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 44px;
}

.entry-grid-four {
  grid-template-columns: repeat(4, 1fr);
}

.entry-card,
.panel,
.screen-card,
.mobile-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.entry-card {
  min-height: 230px;
  padding: 22px;
}

.entry-card span {
  color: var(--yellow);
  font-weight: 900;
}

.entry-card strong {
  display: block;
  margin: 28px 0 12px;
  font-size: 28px;
}

.entry-card p,
.panel p,
.mobile-header p {
  color: var(--muted);
  line-height: 1.6;
}

.screen-body {
  overflow: hidden;
}

.screen-shell {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 100vh;
  padding: 34px;
}

.screen-header,
.control-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.screen-header h1,
.control-title h1 {
  margin-bottom: 0;
  font-size: clamp(36px, 5.5vw, 76px);
  line-height: 1;
}

.environment-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 22px 0;
  padding: 16px 18px;
  border: 1px solid rgba(255, 209, 102, 0.65);
  border-radius: 8px;
  background: rgba(255, 209, 102, 0.09);
}

.environment-notice strong {
  color: var(--yellow);
}

.environment-notice p {
  margin: 4px 0 0;
  color: var(--muted);
}

.primary-link {
  flex: 0 0 auto;
  padding: 11px 16px;
  border-radius: 8px;
  background: var(--green);
  color: #07110f;
  font-weight: 800;
}

.phase-badge {
  flex: 0 0 auto;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--yellow);
  font-weight: 800;
}

.screen-view {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

.screen-card {
  padding: 28px;
}

.profile-card,
.active-contestant {
  display: grid;
  grid-template-columns: minmax(220px, 32vw) minmax(0, 1fr);
  gap: 32px;
  align-items: center;
}

.profile-card h2,
.active-contestant h2,
.question-card h2,
.ranking-card h2,
.awards-card h2 {
  margin-bottom: 12px;
  font-size: clamp(36px, 6vw, 88px);
  line-height: 1.05;
}

.role {
  margin-bottom: 22px;
  color: var(--yellow);
  font-size: clamp(20px, 2vw, 30px);
  font-weight: 800;
}

.profile-facts {
  display: grid;
  gap: 14px;
  margin: 0;
}

.profile-facts div {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 18px;
}

.profile-facts dt {
  color: var(--green);
  font-weight: 800;
}

.profile-facts dd {
  margin: 0;
  color: var(--text);
  font-size: clamp(18px, 2vw, 28px);
  line-height: 1.45;
}

.avatar {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.avatar-placeholder {
  display: grid;
  place-items: center;
  color: #061411;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.24) 0 1px, transparent 1px 16px),
    var(--green);
  font-size: clamp(38px, 6vw, 92px);
  font-weight: 900;
}

.avatar.medium {
  width: 132px;
}

.avatar.small {
  width: 54px;
}

.avatar-placeholder.small {
  font-size: 20px;
}

.avatar.large {
  width: min(360px, 100%);
}

.round-label {
  grid-column: 1 / -1;
  color: var(--green);
  font-weight: 900;
}

.big-line {
  color: var(--muted);
  font-size: clamp(24px, 3vw, 44px);
  line-height: 1.35;
}

.question-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  align-items: center;
  gap: 24px;
}

.big-timer {
  display: grid;
  place-items: center;
  width: 160px;
  height: 160px;
  border: 2px solid var(--yellow);
  border-radius: 8px;
  color: var(--yellow);
  font-size: 78px;
  font-weight: 900;
}

.judge-panel {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 20px;
  align-items: center;
}

.judge-score span,
.meter-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.judge-score strong {
  display: block;
  color: var(--green);
  font-size: 84px;
  line-height: 1;
}

.judge-panel p {
  grid-column: 1 / -1;
  margin-bottom: 0;
  font-size: clamp(22px, 3vw, 40px);
  line-height: 1.45;
}

.meter-label {
  display: flex;
  justify-content: space-between;
}

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

.meter i {
  display: block;
  height: 100%;
  background: var(--blue);
}

.tag-row {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tag {
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-weight: 800;
}

.ranking-list {
  display: grid;
  gap: 12px;
}

.ranking-list div {
  display: grid;
  grid-template-columns: 56px 1fr 120px;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  font-size: clamp(20px, 2vw, 32px);
}

.ranking-list span,
.ranking-list b {
  color: var(--yellow);
}

.winner-row {
  display: flex;
  align-items: center;
  gap: 24px;
  margin: 26px 0;
}

.winner-row strong {
  font-size: clamp(32px, 5vw, 72px);
}

.award-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.award-grid div {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.award-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
}

.control-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 60px;
}

.top-links {
  display: flex;
  gap: 10px;
}

.top-links a {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.control-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 320px;
  gap: 16px;
  margin-top: 28px;
  align-items: start;
}

.workspace-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  width: min(440px, 100%);
  margin-top: 28px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.workspace-tab {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.workspace-tab.active {
  background: var(--green);
  color: #061411;
}

.competition-layout {
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
}

.management-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
  margin-top: 28px;
  align-items: start;
}

.checkin-panel {
  position: sticky;
  top: 16px;
}

.qr-frame {
  padding: 14px;
  border-radius: 8px;
  background: #fff;
}

.qr-frame img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
}

.helper-text,
.photo-status,
.pending-copy small,
.roster-item small {
  color: var(--muted);
  line-height: 1.5;
}

.photo-status {
  max-width: 240px;
  margin: 2px 0 0;
  font-size: 13px;
  text-align: center;
}

.crop-dialog {
  width: min(520px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.camera-dialog {
  width: min(520px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.camera-dialog::backdrop {
  background: rgba(0, 0, 0, 0.9);
}

.camera-dialog-card {
  padding: 20px;
}

.camera-stage {
  position: relative;
  width: min(100%, 420px);
  aspect-ratio: 3 / 4;
  margin: 0 auto 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #05070a;
}

.camera-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.camera-face-guide {
  position: absolute;
  top: 10%;
  left: 16%;
  width: 68%;
  height: 72%;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 48%;
  pointer-events: none;
}

.registration-profile-card {
  margin-top: 20px;
  text-align: left;
}

.registration-profile-card .profile-avatar {
  display: block;
  width: min(100%, 320px);
  aspect-ratio: 1;
  margin: 0 auto 18px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.registration-profile-card h3 {
  margin-bottom: 6px;
  font-size: 28px;
}

.registration-profile-card dl {
  display: grid;
  gap: 12px;
  margin: 20px 0 0;
}

.registration-profile-card dt {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.registration-profile-card dd {
  margin: 3px 0 0;
  line-height: 1.6;
}

.generation-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  padding: 14px;
  border: 1px solid rgba(121, 184, 255, 0.42);
  border-radius: 8px;
  background: rgba(121, 184, 255, 0.08);
  text-align: left;
}

.generation-progress strong,
.generation-progress small {
  display: block;
}

.generation-progress small {
  margin-top: 3px;
  color: var(--muted);
}

.generation-spinner {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 3px solid rgba(121, 184, 255, 0.2);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: generation-spin 0.9s linear infinite;
}

@keyframes generation-spin {
  to { transform: rotate(360deg); }
}

.profile-link {
  display: block;
  margin-top: 18px;
  text-align: center;
}

.crop-dialog::backdrop {
  background: rgba(0, 0, 0, 0.82);
}

.crop-dialog-card {
  padding: 20px;
}

.crop-dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.crop-dialog-heading h2 {
  margin-bottom: 14px;
  font-size: 24px;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 28px;
  line-height: 1;
}

.crop-stage {
  position: relative;
  width: min(100%, 420px);
  aspect-ratio: 1;
  margin: 0 auto 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #05070a;
  touch-action: none;
}

.crop-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.crop-guide {
  position: absolute;
  inset: 8%;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  pointer-events: none;
}

.crop-guide::before,
.crop-guide::after {
  position: absolute;
  content: "";
  background: rgba(255, 255, 255, 0.22);
}

.crop-guide::before {
  top: 50%;
  left: -10%;
  width: 120%;
  height: 1px;
}

.crop-guide::after {
  top: -10%;
  left: 50%;
  width: 1px;
  height: 120%;
}

.zoom-control {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.zoom-control input {
  padding: 0;
  accent-color: var(--green);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.section-heading h2 {
  margin-bottom: 0;
}

.count-badge {
  display: grid;
  place-items: center;
  min-width: 38px;
  min-height: 38px;
  border-radius: 8px;
  background: var(--yellow);
  color: #17130a;
  font-weight: 900;
}

.pending-list,
.roster-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.pending-item {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.pending-copy strong,
.roster-item strong {
  display: block;
  margin-bottom: 4px;
}

.pending-copy p {
  margin: 8px 0 0;
  color: var(--text);
}

.avatar-job-status {
  display: inline-block;
  margin-top: 8px;
  color: var(--yellow);
  font-size: 12px;
  font-weight: 800;
}

.avatar-job-status.ready {
  color: var(--green);
}

.avatar-job-status.failed {
  color: #ff8f8f;
}

.pending-actions {
  display: grid;
  gap: 8px;
  width: 110px;
}

.roster-panel {
  margin-top: 16px;
}

.roster-editor {
  min-height: 420px;
}

.editor-empty-state {
  display: none;
  min-height: 380px;
  place-items: center;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.roster-editor.is-empty .editor-empty-state {
  display: grid;
}

.roster-editor.is-empty .photo-uploader,
.roster-editor.is-empty .form-stack {
  display: none;
}

.save-feedback {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--green) !important;
  font-size: 13px;
  font-weight: 700;
}

.profile-shell {
  width: min(680px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 60px;
}

.profile-avatar-panel {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.profile-avatar-panel img,
.profile-avatar-placeholder {
  width: 112px;
  aspect-ratio: 1;
  border-radius: 8px;
  object-fit: cover;
}

.profile-avatar-placeholder {
  display: grid;
  place-items: center;
  border: 1px dashed var(--blue);
  color: var(--blue);
  font-weight: 900;
}

.profile-save-feedback {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--green);
  text-align: center;
}

.roster-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.2fr);
  gap: 22px;
  margin-top: 18px;
}

.roster-item {
  display: grid;
  grid-template-columns: 36px 54px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  cursor: pointer;
}

.roster-item.selected {
  border-color: var(--green);
  box-shadow: inset 3px 0 0 var(--green);
}

.order-number {
  color: var(--yellow);
  font-weight: 900;
}

.order-actions {
  display: grid;
  grid-template-columns: 36px 36px;
  gap: 6px;
}

.order-actions button {
  min-height: 36px;
}

.danger {
  border-color: rgba(255, 104, 104, 0.65);
  color: #ff9d9d;
}

.empty-state {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.panel {
  padding: 18px;
}

.panel h2,
.mobile-section h2 {
  margin-bottom: 16px;
  font-size: 22px;
}

.panel label {
  display: block;
  margin: 14px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.button-row,
.fault-grid,
.vote-control {
  display: grid;
  gap: 10px;
}

.button-row {
  grid-template-columns: 1fr 1fr;
}

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

.fault-grid {
  grid-template-columns: 1fr 1fr;
  margin-top: 14px;
}

.primary {
  border-color: transparent;
  background: var(--green);
  color: #061411;
  font-weight: 900;
}

.secondary {
  margin-top: 18px;
}

.full {
  width: 100%;
}

.timer-control {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.timer-control strong {
  display: block;
  margin-bottom: 12px;
  color: var(--yellow);
  font-size: 56px;
  line-height: 1;
  text-align: center;
}

.profile-editor {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 18px;
}

.photo-uploader {
  display: grid;
  align-content: start;
  gap: 10px;
}

.photo-preview {
  min-height: 132px;
}

.upload-button {
  display: grid;
  place-items: center;
  min-height: 42px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text) !important;
  cursor: pointer;
  text-align: center;
}

.upload-button input {
  display: none;
}

.form-stack {
  min-width: 0;
}

.vote-control {
  grid-template-columns: 1fr 92px 1fr;
  align-items: center;
  margin-top: 18px;
}

.vote-control strong {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--yellow);
  font-size: 24px;
}

.audience-shell {
  width: min(520px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.join-shell {
  width: min(560px, calc(100% - 28px));
  margin: 0 auto;
  padding: 34px 0 54px;
}

.join-header {
  margin-bottom: 20px;
}

.join-header p:last-child {
  color: var(--muted);
}

.role-choice {
  display: grid;
  gap: 12px;
}

.role-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 4px 14px;
  align-items: center;
  min-height: 130px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
}

.role-card:hover {
  border-color: var(--green);
}

.role-number {
  grid-row: 1 / 3;
  color: var(--yellow);
  font-size: 24px;
  font-weight: 900;
}

.role-card strong {
  font-size: 26px;
}

.role-card small {
  color: var(--muted);
  line-height: 1.5;
}

.registration-section {
  margin-top: 0;
}

.registration-section label,
.roster-editor label,
.profile-shell label {
  display: block;
  margin: 14px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.registration-photo {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 14px;
  align-items: end;
  margin-bottom: 12px;
}

.text-button {
  min-height: auto;
  margin-bottom: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--green);
}

.success-state {
  margin-top: 0;
  padding: 28px;
  text-align: center;
}

.success-mark {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: var(--green);
  color: #061411;
  font-size: 40px;
  font-weight: 900;
}

.mobile-header h1 {
  margin-bottom: 8px;
  font-size: 34px;
  line-height: 1.08;
}

.mobile-section {
  margin-top: 16px;
  padding: 16px;
}

.mobile-contestant {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.mobile-contestant .avatar {
  width: 92px;
}

.mobile-contestant h3 {
  margin-bottom: 6px;
  font-size: 22px;
}

.mobile-contestant p {
  margin-bottom: 0;
  color: var(--muted);
}

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

.vote-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  text-align: left;
}

.vote-item b {
  color: var(--yellow);
}

@media (max-width: 980px) {
  .entry-grid,
  .entry-grid-four,
  .control-layout,
  .management-layout,
  .roster-layout,
  .award-grid {
    grid-template-columns: 1fr;
  }

  .screen-body {
    overflow: auto;
  }

  .profile-card,
  .active-contestant,
  .question-card,
  .judge-panel,
  .profile-editor {
    grid-template-columns: 1fr;
  }

  .checkin-panel {
    position: static;
  }

  .big-timer {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .screen-shell {
    padding: 18px;
  }

  .screen-header,
  .control-title {
    display: grid;
  }

  .profile-facts div,
  .ranking-list div {
    grid-template-columns: 1fr;
  }

  .top-links {
    flex-wrap: wrap;
  }

  .pending-item {
    grid-template-columns: 54px minmax(0, 1fr);
  }

  .pending-actions {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
    width: auto;
  }

  .roster-item {
    grid-template-columns: 30px 46px minmax(0, 1fr);
  }

  .roster-item .avatar.small {
    width: 46px;
  }

  .order-actions {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
  }

  .profile-avatar-panel {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .profile-avatar-panel img,
  .profile-avatar-placeholder {
    width: 88px;
  }
}
