:root {
  color-scheme: dark;
  --bg: #07111f;
  --surface: rgba(15, 23, 42, 0.92);
  --surface-soft: rgba(30, 41, 59, 0.72);
  --border: rgba(148, 163, 184, 0.18);
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #38bdf8;
  --accent: #22c55e;
  --warning: #f59e0b;
  --danger: #fb7185;
  --shadow: 0 20px 60px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(14,165,233,.20), transparent 35%),
    radial-gradient(circle at top right, rgba(34,197,94,.12), transparent 30%),
    var(--bg);
  color: var(--text);
}

button, select, input { font: inherit; }

button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 20px 14px 40px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 12px 4px 22px;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
}

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

h1 {
  margin-bottom: 6px;
  font-size: clamp(30px, 8vw, 48px);
  line-height: 1;
}

h2 { margin-bottom: 5px; font-size: 19px; }

.subtitle, .section-title p, .tip, footer, small {
  color: var(--muted);
}

.subtitle { margin-bottom: 0; line-height: 1.5; }

.badge {
  border: 1px solid rgba(56,189,248,.3);
  background: rgba(56,189,248,.12);
  color: var(--primary);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 24px;
  padding: 16px;
  margin-bottom: 14px;
  backdrop-filter: blur(16px);
}

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

.section-title p { margin: 0; font-size: 13px; line-height: 1.4; }
.section-title.compact { margin-bottom: 6px; }

.status {
  flex: 0 0 auto;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  padding: 7px 10px;
}

.status-idle { background: rgba(148,163,184,.14); color: var(--muted); }
.status-live { background: rgba(34,197,94,.14); color: #86efac; }

.camera-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  overflow: hidden;
  border-radius: 18px;
  background: #020617;
  border: 1px solid var(--border);
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 7px;
  color: var(--muted);
}

.camera-placeholder.hidden { display: none; }
.camera-icon { font-size: 40px; }

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

.btn {
  border: 0;
  border-radius: 14px;
  padding: 13px 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .15s ease, opacity .15s ease;
}

.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #082f49; }
.btn-accent { background: var(--accent); color: #052e16; }
.btn-secondary { background: #334155; color: var(--text); }
.btn-joker { background: var(--warning); color: #3a2200; }

.progress-panel {
  margin-top: 12px;
  background: var(--surface-soft);
  padding: 12px;
  border-radius: 14px;
}

.hidden { display: none !important; }
.progress-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.progress-track { height: 8px; background: #0f172a; border-radius: 999px; overflow: hidden; margin-top: 9px; }
.progress-bar { width: 0; height: 100%; background: var(--primary); transition: width .2s ease; }
.tip { margin: 12px 2px 0; font-size: 12px; line-height: 1.5; }

.tiles-list {
  display: grid;
  gap: 9px;
}

.tile-row {
  display: grid;
  grid-template-columns: 52px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-soft);
}

.tile-face {
  width: 52px;
  height: 66px;
  background: #f8fafc;
  color: #111827;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 24px;
  box-shadow: inset 0 0 0 2px #e2e8f0;
}

.tile-face.joker {
  font-size: 28px;
  background: linear-gradient(160deg, #fff7ed, #fef3c7);
}

.tile-info strong { display: block; }
.tile-info small { display: block; margin-top: 3px; }

.icon-btn {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 12px;
  background: #334155;
  color: var(--text);
  cursor: pointer;
}

.icon-btn.delete { background: rgba(251,113,133,.14); color: #fda4af; }

.empty-state {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 24px 10px;
  color: var(--muted);
}
.empty-state span { font-size: 34px; }
.empty-state p { margin: 0; }

.manual-panel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.manual-panel label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.manual-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.35fr;
  gap: 8px;
}

select {
  width: 100%;
  border: 1px solid var(--border);
  background: #0f172a;
  color: var(--text);
  border-radius: 12px;
  padding: 12px;
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--danger);
  font-weight: 800;
  cursor: pointer;
}

.switch-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  position: relative;
  padding: 10px 2px 2px;
  cursor: pointer;
}

.switch-row strong, .switch-row small { display: block; }
.switch-row small { margin-top: 4px; }

.switch-row input {
  position: absolute;
  opacity: 0;
}

.switch {
  width: 54px;
  height: 30px;
  border-radius: 999px;
  background: #334155;
  position: relative;
  transition: .2s;
}

.switch::after {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: white;
  transition: .2s;
}

.switch-row input:checked + .switch { background: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(24px); }

.total-card {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 20px;
  border-radius: 24px;
  background: linear-gradient(135deg, #0ea5e9, #22c55e);
  color: #02111f;
  box-shadow: var(--shadow);
}

.total-card > div:not(.divider) { display: grid; gap: 4px; }
.total-card > div:last-child { text-align: right; }

.total-label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.total-card strong { font-size: clamp(34px, 10vw, 54px); line-height: 1; }
.divider { width: 1px; height: 54px; background: rgba(2,17,31,.25); }

footer { text-align: center; font-size: 12px; padding-top: 18px; }

dialog {
  border: 0;
  padding: 0;
  background: transparent;
  width: min(92vw, 420px);
}

dialog::backdrop { background: rgba(2,6,23,.8); backdrop-filter: blur(4px); }

.dialog-card {
  padding: 20px;
  border-radius: 22px;
  background: #0f172a;
  border: 1px solid var(--border);
  color: var(--text);
}

.dialog-card p { color: var(--muted); }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }

@media (max-width: 560px) {
  .action-grid { grid-template-columns: 1fr; }
  .manual-row { grid-template-columns: 1fr 1fr; }
  .manual-row .btn-joker { grid-column: 1 / -1; }
  .tile-row { grid-template-columns: 46px 1fr auto auto; }
  .tile-face { width: 46px; height: 60px; }
}
