:root {
  --blue: #3f6f9f;
  --blue-dark: #24476f;
  --red: #ef626d;
  --ink: #586671;
  --soft: #eef1f4;
  --white: #fff;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: #0b1520; color: var(--ink); overflow: hidden; }
button, input { font: inherit; }
button { border: 0; cursor: pointer; touch-action: manipulation; }

.app { height: 100dvh; display: grid; grid-template-rows: minmax(260px, 1fr) auto; background: var(--soft); }
.stage { position: relative; overflow: hidden; background: linear-gradient(145deg, #5584b8, #23466f); }
.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(35deg, transparent 0 18%, rgba(255,255,255,.06) 18% 19%, transparent 19% 42%, rgba(255,255,255,.05) 42% 43%, transparent 43%),
    linear-gradient(120deg, transparent 0 32%, rgba(0,0,0,.08) 32% 33%, transparent 33% 70%, rgba(255,255,255,.05) 70% 71%, transparent 71%);
  opacity: .9;
}
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #05070b; }
.brand { position: absolute; top: max(18px, env(safe-area-inset-top)); left: 24px; color: rgba(255,255,255,.9); font-weight: 800; font-size: clamp(22px, 7vw, 48px); letter-spacing: 0; }
.brand span, .home-state h1 span { display: inline-block; margin-left: 4px; padding: .05em .28em .14em; color: var(--blue-dark); background: #fff; border-radius: .42em; position: relative; }
.brand span::after, .home-state h1 span::after { content: ""; position: absolute; right: 18%; bottom: -.28em; border: .24em solid transparent; border-top-color: #fff; transform: rotate(-18deg); }
.settings { position: absolute; top: max(18px, env(safe-area-inset-top)); right: 18px; }
.icon-btn { width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.2); color: white; font-size: 25px; backdrop-filter: blur(8px); }
.status-pill { position: absolute; right: 18px; bottom: 18px; padding: 8px 12px; border-radius: 999px; background: rgba(0,0,0,.45); color: white; font-weight: 700; opacity: 0; transform: translateY(8px); transition: .22s; }
.status-pill.show { opacity: 1; transform: translateY(0); }
.status-pill span { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #2ee47f; }

.panel { min-height: 44dvh; background: #f3f4f6; display: flex; flex-direction: column; justify-content: space-between; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.home-state { padding: 26px 14px 8px; text-align: center; }
.home-state h1 { margin: 0; color: white; font-size: clamp(42px, 13vw, 74px); line-height: 1; transform: translateY(-122px); text-shadow: 0 2px 10px rgba(0,0,0,.14); }
.home-state > p:first-of-type { color: white; margin: -104px 0 26px; font-size: 22px; font-weight: 800; }
.selectors { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 auto 32px; max-width: 560px; }
.selector { height: 68px; display: flex; align-items: center; gap: 12px; padding: 0 16px; border-radius: 8px; background: #fff; color: #48607b; box-shadow: 0 2px 10px rgba(30,50,70,.12); font-size: 24px; text-align: left; }
.selector span { font-size: 42px; line-height: 1; }
.selector.muted span { width: 56px; height: 68px; margin: 0 0 0 -16px; display: grid; place-items: center; background: #8cc7d9; color: white; font-size: 34px; }
.rules { max-width: 480px; margin: 0 auto; font-size: clamp(18px, 5vw, 25px); line-height: 1.25; color: #687682; }
.connected-state { padding: 44px 18px 24px; text-align: center; font-size: 24px; }
.connected-state p { margin: 0 0 14px; }
.connected-state strong { display: block; margin-bottom: 24px; font-size: 26px; color: #52616c; }
.report-btn { height: 76px; padding: 0 34px; border-radius: 10px; background: #fff; color: var(--red); font-size: 25px; font-weight: 800; box-shadow: 0 6px 18px rgba(30,50,70,.08); }

.controls { display: grid; grid-template-columns: minmax(130px, 34%) 1fr; gap: 12px; padding: 0 12px 4px; }
.self-wrap { position: relative; height: 194px; border-radius: 7px; overflow: hidden; background: #111; }
#localVideo { width: 100%; height: 100%; object-fit: cover; filter: saturate(.92); }
.tiny-btn { position: absolute; top: 10px; left: 10px; width: 34px; height: 34px; border-radius: 7px; background: rgba(255,255,255,.78); color: #6a7781; font-size: 21px; font-weight: 900; }
.chat-controls { display: grid; grid-template-rows: 68px 1fr; gap: 12px; min-width: 0; }
.message-form { display: grid; grid-template-columns: 1fr 62px; background: white; border-radius: 8px; overflow: hidden; }
.message-form input { min-width: 0; padding: 0 18px; border: 0; color: #57636e; font-size: 20px; outline: 0; }
.message-form input::placeholder { color: #c6ccd2; }
.message-form button { background: #fff; color: #8aa4c4; font-size: 36px; }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stop-btn, .start-btn { border-radius: 8px; color: white; font-size: 36px; font-weight: 900; box-shadow: 0 8px 16px rgba(30,50,70,.16); }
.stop-btn { background: var(--red); }
.stop-btn:disabled { background: #f4aeb5; }
.start-btn { background: var(--blue); }
.start-btn.searching { animation: pulse 1s infinite; }

.sheet, .modal { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.56); display: grid; align-items: end; }
.sheet-card { position: relative; width: 100%; max-height: 92dvh; padding: 30px 24px 28px; background: #f3f4f6; border-radius: 24px 24px 0 0; overflow: auto; }
.grab { position: absolute; top: 10px; left: 50%; width: 62px; height: 7px; margin-left: -31px; border-radius: 99px; background: #aaa; }
.close-btn { position: absolute; top: 24px; right: 24px; width: 52px; height: 52px; border-radius: 50%; background: #b8c4ca; color: white; font-size: 42px; line-height: 1; font-weight: 800; }
.sheet-card h2, .modal-card h2 { margin: 0 0 26px; text-align: center; color: #596874; font-size: 34px; }
.country-list { display: grid; gap: 24px; }
.country-group { background: white; border-radius: 7px; padding: 12px; }
.country-item { width: 100%; height: 72px; display: flex; align-items: center; gap: 18px; padding: 0 18px; border-radius: 7px; background: transparent; color: #6a7781; font-size: 27px; text-align: left; }
.country-item.selected { background: #d6e0ed; color: #335f93; font-weight: 900; }
.country-item .flag { font-size: 44px; width: 48px; text-align: center; filter: drop-shadow(0 3px 3px rgba(0,0,0,.14)); }

.modal { align-items: center; padding: 14px; }
.modal-card { width: 100%; max-width: 560px; margin: auto; padding: 36px 24px 24px; border-radius: 22px; background: #f5f6f7; box-shadow: 0 14px 50px rgba(0,0,0,.28); }
.shots { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 28px; }
.shot { height: 160px; border-radius: 7px; overflow: hidden; background: #090b10; position: relative; }
.shot video { width: 100%; height: 100%; object-fit: cover; }
.local-shot { border: 5px solid var(--red); }
.local-shot span { position: absolute; left: 50%; bottom: -34px; transform: translateX(-50%); width: 74px; height: 74px; display: grid; place-items: center; border-radius: 50%; background: var(--red); color: white; font-size: 44px; }
.modal-card p { text-align: center; font-size: 21px; line-height: 1.35; }
.modal-card button { width: 100%; height: 78px; margin-top: 12px; border-radius: 14px; font-size: 29px; font-weight: 800; }
.danger { background: var(--red); color: white; }
.cancel { background: white; color: #596874; box-shadow: 0 8px 18px rgba(30,50,70,.1); }

.toast { position: fixed; left: 18px; right: 18px; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 50; padding: 14px 16px; border-radius: 12px; background: #132335; color: white; text-align: center; font-weight: 800; box-shadow: 0 10px 30px rgba(0,0,0,.24); }
.hidden { display: none !important; }
@keyframes pulse { 50% { filter: brightness(1.18); transform: translateY(-1px); } }

@media (min-width: 720px) {
  body { display: grid; place-items: center; background: #101923; }
  .app { width: min(430px, 100vw); height: min(860px, 100dvh); box-shadow: 0 24px 70px rgba(0,0,0,.38); }
  .home-state h1 { transform: translateY(-118px); }
}

@media (max-height: 760px) {
  .home-state { padding-top: 16px; }
  .rules { font-size: 18px; }
  .controls { grid-template-columns: 130px 1fr; }
  .self-wrap { height: 154px; }
  .chat-controls { grid-template-rows: 58px 84px; }
  .selector { height: 58px; font-size: 20px; }
}
