:root {
  color-scheme: dark;
  --bg: #101114;
  --surface: #181b20;
  --surface-2: #172522;
  --text: #f7fbff;
  --muted: #afbbc7;
  --line: rgba(247, 251, 255, 0.16);
  --gold: #f2c94c;
  --mint: #42dfb2;
  --rose: #ff5f7e;
  --ink: #07100d;
  --shadow: 0 24px 90px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(255, 95, 126, 0.14), transparent 34%),
    linear-gradient(230deg, rgba(66, 223, 178, 0.16), transparent 40%),
    linear-gradient(160deg, #101114 0%, #151923 48%, #111d1a 100%);
  color: var(--text);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.app-shell {
  width: min(1200px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 86px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.25rem, 5.4vw, 5.25rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(247, 251, 255, 0.06);
  white-space: nowrap;
}

.connection-pill.online {
  color: var(--ink);
  background: var(--mint);
  border-color: transparent;
}

.role-panel,
.controls {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 27, 32, 0.8);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.role-panel {
  padding: 16px;
}

.identity-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  align-items: end;
  gap: 12px;
}

.name-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.name-field input,
.sin-form input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  padding: 0 14px;
  color: var(--text);
  background: rgba(247, 251, 255, 0.08);
}

.name-field input:focus,
.sin-form input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(245, 201, 80, 0.16);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(247, 251, 255, 0.05);
}

.role-button {
  min-width: 118px;
  padding: 0 16px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.role-button.active {
  color: var(--ink);
  background: var(--gold);
}

.primary-button,
.send-button,
.effect-button {
  height: 46px;
  border-radius: 8px;
  padding: 0 18px;
  color: var(--ink);
  background: var(--mint);
  font-weight: 900;
  white-space: nowrap;
}

.status-line {
  min-height: 22px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.95rem;
}

.stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
  margin-top: 22px;
}

.video-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(8, 10, 12, 0.78);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 251, 255, 0.05);
}

.panel-header span {
  font-size: 1.04rem;
  font-weight: 900;
}

.panel-header strong {
  min-width: 86px;
  text-align: right;
  color: var(--muted);
  font-size: 0.84rem;
}

.video-frame {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #050505;
}

video,
.video-empty {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

video {
  object-fit: cover;
  transform: scaleX(-1);
}

.video-empty {
  display: grid;
  place-items: center;
  color: rgba(247, 251, 255, 0.58);
  font-size: clamp(1rem, 2vw, 1.25rem);
  font-weight: 900;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25% 50%, rgba(255, 255, 255, 0.04) 50% 75%, transparent 75%),
    #080806;
  background-size: 34px 34px;
}

.video-empty.hidden {
  display: none;
}

.transfer-lane {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100%;
}

.lane-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 3px;
  transform: translateY(-50%);
  background: linear-gradient(90deg, var(--rose), var(--gold), var(--mint));
  box-shadow: 0 0 24px rgba(245, 201, 80, 0.45);
}

.lane-line::after {
  content: "";
  position: absolute;
  right: -1px;
  top: 50%;
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 16px solid var(--mint);
  transform: translateY(-50%);
}

.lane-orb {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  border: 2px solid rgba(247, 251, 255, 0.3);
  border-radius: 50%;
  color: var(--ink);
  background: var(--gold);
  font-size: 0.75rem;
  font-weight: 900;
  box-shadow: 0 0 42px rgba(245, 201, 80, 0.48);
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 310px;
  gap: 12px;
  padding: 16px;
}

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

.send-button {
  background: var(--gold);
}

.effect-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  align-content: center;
  min-width: 330px;
}

.effect-button {
  background: var(--rose);
  color: #fff;
}

.mic-button {
  background: var(--mint);
  color: var(--ink);
}

.mic-button.muted {
  background: #6c7380;
  color: #fff;
}

.voice-status {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
}

.lobby {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 46px;
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.lobby-title {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
}

.lobby-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.lobby-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--text);
  background: rgba(247, 251, 255, 0.09);
  font-size: 0.82rem;
  font-weight: 800;
}

.lobby-chip[data-role="imam"] {
  background: rgba(94, 224, 181, 0.16);
}

.lobby-chip[data-role="customer"] {
  background: rgba(245, 201, 80, 0.16);
}

.bubble-layer {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow: hidden;
}

.sin-bubble {
  position: absolute;
  left: var(--from-x);
  top: var(--from-y);
  max-width: min(260px, 48vw);
  padding: 12px 14px;
  border: 1px solid rgba(247, 251, 255, 0.38);
  border-radius: 999px;
  color: var(--ink);
  background: var(--gold);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.36);
  font-size: 0.92rem;
  font-weight: 900;
  overflow-wrap: anywhere;
  animation: transfer 1.9s cubic-bezier(0.2, 0.75, 0.23, 1) forwards;
}

.money-drop {
  position: absolute;
  left: var(--x);
  top: var(--top);
  font-size: var(--size);
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.35));
  animation: moneyRain var(--duration) linear forwards;
}

.light-drop {
  position: absolute;
  left: var(--x);
  top: var(--top);
  font-size: var(--size);
  filter: drop-shadow(0 0 16px rgba(242, 201, 76, 0.7));
  animation: lightFall var(--duration) ease-out forwards;
}

.blessing-caption {
  position: absolute;
  left: var(--x);
  top: var(--y);
  max-width: min(260px, 48vw);
  padding: 11px 14px;
  border: 1px solid rgba(255, 255, 255, 0.44);
  border-radius: 999px;
  color: var(--ink);
  background: linear-gradient(90deg, #fff7b0, #ffffff);
  box-shadow: 0 0 34px rgba(242, 201, 76, 0.52);
  font-size: 0.88rem;
  font-weight: 900;
  text-align: center;
  overflow-wrap: anywhere;
  animation: blessingCaption 1.8s ease-out forwards;
}

@keyframes transfer {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
  }
  14% {
    opacity: 1;
  }
  72% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(var(--to-x) - var(--from-x) - 50%), calc(var(--to-y) - var(--from-y) - 50%)) scale(1.08);
  }
}

@keyframes moneyRain {
  0% {
    opacity: 0;
    transform: translate(-50%, -22px) rotate(-18deg) scale(0.8);
  }
  12% {
    opacity: 1;
  }
  86% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, var(--fall)) rotate(28deg) scale(1.08);
  }
}

@keyframes lightFall {
  0% {
    opacity: 0;
    transform: translate(-50%, -30px) scale(0.82);
  }
  14% {
    opacity: 1;
  }
  82% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, var(--fall)) scale(1.16);
  }
}

@keyframes blessingCaption {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.78);
  }
  16% {
    opacity: 1;
  }
  78% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -72%) scale(1.04);
  }
}

@media (max-width: 900px) {
  .identity-row,
  .controls {
    grid-template-columns: 1fr;
  }

  .stage {
    grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr);
    gap: 7px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
  }

  .segmented {
    width: 100%;
  }

  .role-button,
  .primary-button,
  .send-button,
  .effect-button {
    width: 100%;
  }

  .effect-actions {
    min-width: 0;
  }

  .transfer-lane {
    min-height: 100%;
  }

  .lane-line {
    left: 0;
    right: 0;
    width: auto;
    transform: translateY(-50%);
    transform-origin: center;
  }

  .lane-line::after {
    display: block;
    border-top-width: 7px;
    border-bottom-width: 7px;
    border-left-width: 10px;
  }

  .lane-orb {
    width: 34px;
    height: 34px;
    border-width: 1px;
    font-size: 0;
  }

  .lane-orb::before {
    content: ">";
    font-size: 1rem;
    font-weight: 900;
  }

  .panel-header {
    min-height: 38px;
    padding: 0 8px;
  }

  .panel-header span {
    font-size: 0.86rem;
  }

  .panel-header strong {
    min-width: auto;
    font-size: 0.68rem;
  }

  .video-frame {
    aspect-ratio: 3 / 4;
  }

  .video-empty {
    font-size: 0.86rem;
  }

  .lobby {
    padding-left: 0;
    padding-top: 14px;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100vw - 20px, 1200px);
    padding-top: 10px;
  }

  h1 {
    font-size: clamp(1.85rem, 12vw, 3.35rem);
  }

  .role-panel,
  .controls {
    margin-top: 12px;
    padding: 10px;
  }

  .stage {
    margin-top: 12px;
  }

  .sin-form {
    grid-template-columns: 1fr;
  }
}
