:root {
  --ink: #0c1c2e;
  --paper: #f3f6f8;
  --line: #d5dee6;
  --accent: #007a94;
  --danger: #e11d48;
  --muted: #5b6b7c;
  --panel: #ffffff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, #c9e8ef 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #dfe8f2 0%, transparent 50%),
    var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

.brand {
  margin: 0;
  font-family: Bahnschrift, "Segoe UI Semibold", "Helvetica Neue", sans-serif;
  font-size: 1.6rem;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.lang-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
  flex-shrink: 0;
}

.lang-wrap.compact {
  flex-direction: row;
  align-items: center;
}

.lang-wrap select {
  min-width: 7.5rem;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 0.9rem;
}

html[dir="rtl"] body { text-align: right; }
html[dir="rtl"] .top-row { flex-direction: row-reverse; }
html[dir="rtl"] header { flex-direction: row-reverse; }
html[dir="rtl"] label { text-align: right; }

.panel {
  width: min(420px, calc(100% - 2rem));
  margin: 8vh auto 2rem;
  padding: 1.4rem 1.35rem 1.2rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(12, 28, 46, 0.08);
}

.panel h1 {
  margin: 0.35rem 0 0.4rem;
  font-size: 1.35rem;
  font-weight: 650;
}

.lead, .note {
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.95rem;
}

.note { margin: 1rem 0 0; font-size: 0.85rem; }

label {
  display: block;
  margin-top: 0.85rem;
  font-size: 0.85rem;
  color: var(--muted);
}

input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
}

button {
  appearance: none;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  cursor: pointer;
}

#joinBtn {
  width: 100%;
  margin-top: 1.1rem;
}

.error {
  margin: 0.75rem 0 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.stage {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.9rem;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 2;
}

header .brand { font-size: 1.15rem; }

#status {
  flex: 1;
  color: var(--muted);
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#leaveBtn {
  background: #5b6b7c;
  padding: 0.45rem 0.8rem;
  font-size: 0.9rem;
}

.banner {
  margin: 0.6rem 0.9rem 0;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  font-size: 1rem;
  line-height: 1.35;
}

.screen-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  min-height: 50vh;
}

#frame {
  max-width: 100%;
  max-height: calc(100vh - 5.5rem);
  width: auto;
  height: auto;
  object-fit: contain;
  background: #111827;
  border-radius: 8px;
  display: none;
}

#frame.visible { display: block; }

.waiting {
  position: absolute;
  margin: 0;
  color: var(--muted);
  text-align: center;
  padding: 1rem;
}

@media (max-width: 640px) {
  .panel { margin-top: 4vh; }
  #frame { max-height: calc(100dvh - 5rem); border-radius: 0; }
  .screen-wrap { padding: 0; }
}
