:root {
  color-scheme: light;
  font-family: "Rubik", "SF Arabic", "Noto Sans Arabic", "Geeza Pro", system-ui, sans-serif;
  color: #173f36;
  background: #f7f6f0;
  --paper: #f7f6f0;
  --ink: #173f36;
  --green: #174a3e;
  --muted: #516258;
  --line: #d4d9ce;
  --mint: #e3ebdd;
  --coral: #b05236;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; min-height: 100svh; }
button, input { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid #aa542f;
  outline-offset: 4px;
}
button:disabled { opacity: .6; cursor: wait; }
h1:focus { outline: none; }
h1, h2, p, ol { margin: 0; }
button svg, [data-icon] svg { display: block; width: 100%; height: 100%; }
button [data-icon], .privacy-badge [data-icon] { display: inline-flex; width: 22px; height: 22px; flex: none; }
.masthead, main { width: min(1120px, calc(100% - 96px)); margin-inline: auto; }
.masthead {
  min-height: 97px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.brand, .help-button, .privacy-badge, .button, .icon-button, .action-row, .call-clock, .call-controls {
  display: inline-flex;
  align-items: center;
}
.brand { gap: 12px; }
.wordmark { font-size: 36px; line-height: 1.6; font-weight: 800; }
.brand-mark { 
  position: relative; width: 45px; height: 45px; display: inline-block;
  border-radius: 15px; background: var(--green); flex: none;
}
.brand-mark i {
  position: absolute; width: 14px; height: 14px; border: 3px solid #e8edcf;
  border-radius: 5px; transform: rotate(-21deg);
}
.brand-mark i:first-child { top: 19px; right: 10px; }
.brand-mark i:last-child { top: 11px; right: 21px; border-color: #f3a582; }
.help-button, .icon-button, .text-button { background: transparent; border: 0; color: var(--ink); }
.help-button { min-height: 44px; padding: 4px 13px; gap: 8px; font-size: 14px; font-weight: 650; border-radius: 25px; }
.help-button [data-icon] { width: 19px; height: 19px; }
.help-button:hover, .text-button:hover { background: #e9ece2; }
main { padding-block: clamp(36px, 6vw, 84px) max(24px, env(safe-area-inset-bottom)); }
.lobby-view { display: grid; grid-template-columns: 1fr 1.02fr; gap: clamp(42px, 6vw, 90px); align-items: center; }
.lobby-content { min-width: 0; padding: 12px 0 18px; }
.privacy-badge { gap: 7px; border-radius: 24px; background: var(--mint); color: #315946; padding: 6px 12px; font-size: 12px; font-weight: 650; line-height: 1.7; }
.privacy-badge [data-icon] { width: 15px; height: 15px; }
h1 { font-size: clamp(45px, 5.1vw, 78px); line-height: 1.36; font-weight: 730; }
#heading { margin-block: 20px 8px; text-wrap: balance; }
#heading em { display: block; font-style: normal; color: var(--coral); }
.lead { color: var(--muted); max-width: 41ch; font-size: clamp(16px, 1.4vw, 19px); line-height: 1.95; }
.action-row { gap: 10px; flex-wrap: wrap; }
#action-primary:not(:has(> :not([hidden]))) { display: none; }
#action-primary:not(:empty), #invite-box, #verify-box, #passcode-form { margin-block-start: 24px; }
.button {
  border: 1px solid transparent; border-radius: 14px; gap: 12px; font-size: 16px; line-height: 1.7;
  font-weight: 650; min-height: 54px; padding: 10px 23px; justify-content: center;
  transition: background-color .15s ease, transform .15s ease;
}
.button:active { transform: translateY(1px); }
.button.primary { color: #fffef6; background: var(--green); }
.button.primary:hover { background: #113a31; }
.button.secondary { background: transparent; color: var(--ink); border-color: #aebcb1; }
.button.secondary:hover { background: #e9ece2; }
#start, #join { min-width: 170px; }
.lobby-art {
  overflow: hidden; border-radius: 28px; position: relative;
  aspect-ratio: 1.13; background: #dbd0af; isolation: isolate;
}
.lobby-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.trial-hint { margin-top: clamp(36px, 5vw, 72px); padding-block: 24px; display: flex; gap: 16px; align-items: center; border-block-start: 1px solid var(--line); }
.hint-icon { width: 46px; height: 46px; padding: 11px; background: #eceee4; border-radius: 14px; flex: none; color: #526b59; }
.trial-hint h2 { font-size: 15px; line-height: 1.8; font-weight: 690; }
.trial-hint p { color: var(--muted); font-size: 14px; line-height: 1.9; }
body:not([data-state="lobby"]):not([data-state="loading"]):not([data-state="invited"]) #heading {
  font-size: clamp(34px, 3.6vw, 54px);
}
body[data-state="error"] #heading { color: #903d30; }
label { display: block; margin-block-end: 6px; color: var(--ink); font-size: 14px; font-weight: 650; }
input { min-width: 0; min-height: 48px; width: 100%; padding: 8px 13px; border-radius: 10px; border: 1px solid #aebbb0; background: #fffef8; color: var(--ink); font-size: 16px; }
#invite-box, #passcode-form { max-width: 390px; }
.input-row { display: flex; gap: 8px; align-items: center; }
#invite-link { font: 14px/1.5 ui-monospace, monospace; text-overflow: ellipsis; }
.icon-button { min-height: 46px; min-width: 46px; border: 1px solid #aebbb0; border-radius: 11px; justify-content: center; flex: none; }
.icon-button:hover { background: var(--mint); }
#invite-box .button, #passcode-form .button { margin-top: 14px; }
.text-button { border-radius: 9px; min-height: 44px; font-size: 14px; line-height: 1.6; font-weight: 600; text-decoration: underline; text-underline-offset: 4px; padding: 6px 10px; margin-block-start: 12px; }
#cancel { display: block; }
.feedback, .notice { font-size: 14px; line-height: 1.75; color: #385d48; margin-top: 12px; }
#verify-code {
  display: inline-flex; justify-content: center; align-items: center;
  background: #fffef8; border: 1px solid #aebbb0; border-radius: 14px;
  font: 650 clamp(34px, 4vw, 48px)/1.3 ui-monospace, "SFMono-Regular", monospace;
  font-variant-numeric: tabular-nums; padding: 8px 18px;
  letter-spacing: .07em; white-space: pre;
}
#verify-actions { display: flex; margin-top: 18px; }
.activity { display: inline-block; width: 22px; height: 22px; border: 2px solid #cbd5c9; border-top-color: var(--green); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

body[data-state="active"] main { padding-top: 28px; }
#call-view { max-width: 900px; margin-inline: auto; }
.call-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.call-header h1 { font-size: clamp(24px,3vw,36px); }
.call-clock { font: 500 16px/1.2 ui-monospace, monospace; color: var(--green); gap: 8px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #3d7e5b; }
.video-stage { position: relative; display: grid; place-items: center; width: 100%; height: min(56vw, 55vh); min-height: 280px; overflow: hidden; border-radius: 20px; background: #152d28; }
#remote-video { width: 100%; height: 100%; position: absolute; inset: 0; object-fit: contain; }
.self-view { position: absolute; inset-block-start: 15px; inset-inline-end: 15px; width: clamp(92px, 16%, 148px); aspect-ratio: .78; border: 1px solid #d6ddd5; background: #293b34; border-radius: 13px; overflow: hidden; }
.self-view video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.self-view span { position: absolute; inset-block-end: 5px; inset-inline-start: 6px; padding: 1px 7px; border-radius: 6px; background: #13271de0; font-size: 12px; color: white; }
.playback { z-index: 1; color: var(--ink); background: var(--paper); box-shadow: 0 3px 12px #142b2138; }
.call-controls { width: 100%; justify-content: center; align-items: start; gap: clamp(14px,5vw,46px); margin-block-start: 20px; }
.control { width: 92px; color: var(--ink); font-size: 13px; line-height: 1.8; font-weight: 600; border: none; background: transparent; padding: 0; display: grid; justify-items: center; gap: 5px; border-radius: 9px; }
.control .control-icon { width: 50px; height: 50px; padding: 13px; border-radius: 50%; background: var(--mint); }
.control[aria-pressed="false"] .control-icon { background: #e7d5c8; color: #873d2c; }
.control.end { color: #9f392d; }
.control.end .control-icon { color: #fff; background: #a64234; }

dialog { padding: 24px; width: min(480px, calc(100vw - 32px)); max-height: 85vh; border: 1px solid var(--line); border-radius: 20px; color: var(--ink); background: var(--paper); box-shadow: 0 20px 70px #10251e30; }
dialog::backdrop { background: #0f211acc; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-head h2 { font-size: 24px; }
.dialog-head .icon-button { border: 0; }
.help-steps { padding-inline-start: 24px; margin-top: 16px; }
.help-steps li { margin-top: 13px; padding-inline-start: 5px; }
.help-steps li::marker { color: var(--coral); font-weight: 700; }
.help-steps p { color: var(--muted); font-size: 14px; line-height: 1.9; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; padding: 0; margin: -1px; border: 0; clip-path: inset(50%); }

@media (max-width: 790px) {
  .masthead, main { width: calc(100% - 48px); }
  .masthead { min-height: 76px; }
  .lobby-view { gap: 32px; }
  .lobby-art { border-radius: 21px; aspect-ratio: .84; }
  h1 { font-size: 44px; }
}
@media (max-width: 620px) {
  .masthead, main { width: calc(100% - 36px); }
  .masthead { min-height: 70px; }
  .brand { gap: 9px; }
  .brand-mark { width: 40px; height: 40px; border-radius: 13px; }
  .brand-mark i:first-child { top: 17px; right: 8px; }
  .brand-mark i:last-child { top: 9px; right: 19px; }
  .wordmark { font-size: 30px; }
  main { padding-block-start: 27px; }
  .lobby-view { grid-template-columns: 1fr; gap: 24px; }
  .lobby-content { padding: 0 0 3px; }
  h1 { font-size: clamp(37px, 10.3vw, 54px); }
  #heading { margin-block: 13px 5px; }
  #heading em { display: inline; }
  .lead { font-size: 16px; line-height: 1.85; }
  .lobby-art { aspect-ratio: 1.7; border-radius: 19px; }
  .lobby-art img { object-position: center 53%; }
  .button { min-height: 50px; }
  #action-primary:not(:empty), #invite-box, #verify-box, #passcode-form { margin-block-start: 18px; }
  .trial-hint { margin-top: 24px; padding-block: 17px; gap: 11px; align-items: flex-start; }
  .trial-hint p { font-size: 13px; }
  .hint-icon { width: 39px; height: 39px; padding: 8px; }
  body:not([data-state="lobby"]):not([data-state="loading"]):not([data-state="invited"]) .lobby-art { display: none; }
  #verify-actions { gap: 8px; }
  #verify-actions .button { font-size: 14px; padding-inline: 13px; }
  .video-stage { height: 56vh; height: 56svh; min-height: 225px; }
  .self-view { inset-block-start: 10px; inset-inline-end: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
