/* ==========================================================================
   Party Line — late-night intercom.
   Warm plum dark, amber "on air" glow, cream text.
   Written for old devices: no flex-gap, no aspect-ratio, no dvh.
   ========================================================================== */

:root {
  --ink: #181123;
  --surface: #221933;
  --raised: #2d2342;
  --line: #3e3157;
  --cream: #f4ede2;
  --dim: #a899bf;
  --amber: #ffb054;
  --amber-deep: #e2842b;
  --red: #ff6a5c;
  --sans: "Avenir Next", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* author display rules (e.g. .screen-room's flex) must not defeat [hidden] */
[hidden] { display: none !important; }

html, body { height: 100%; }

/* iOS: 100% of the *visible* viewport, so the controls never hide under the bar */
@supports (-webkit-touch-callout: none) {
  html, body, #app { height: -webkit-fill-available; }
}

body {
  background: var(--ink);
  color: var(--cream);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

#app { height: 100%; }

button { font-family: inherit; cursor: pointer; }

input:focus, button:focus {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}
input:focus { outline-offset: 0; }

/* ---- shared bits ------------------------------------------------------- */

.screen {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.eyebrow {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}

.mono { font-family: var(--mono); font-size: 12px; }
.dim { color: var(--dim); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
}

.field {
  width: 100%;
  padding: 13px 14px;
  font-size: 16px; /* prevents iOS zoom-on-focus */
  font-family: inherit;
  color: var(--cream);
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  -webkit-appearance: none;
  appearance: none;
}
.field::-webkit-input-placeholder { color: var(--dim); opacity: 0.7; }
.field::placeholder { color: var(--dim); opacity: 0.7; }

.btn {
  display: block;
  width: 100%;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  color: var(--ink);
  background: var(--amber);
}
.btn:active { background: var(--amber-deep); }

/* ---- wordmark / brand --------------------------------------------------- */

.wordmark {
  font-weight: 800;
  letter-spacing: -0.035em;
  color: var(--cream);
}
.wordmark em {
  font-style: normal;
  color: var(--amber);
}

.lamp {
  display: block;
  width: 14px;
  height: 14px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 18px 4px rgba(255, 176, 84, 0.55);
  -webkit-animation: lamp-breathe 3.2s ease-in-out infinite;
  animation: lamp-breathe 3.2s ease-in-out infinite;
}

@-webkit-keyframes lamp-breathe {
  0%, 100% { box-shadow: 0 0 14px 2px rgba(255, 176, 84, 0.4); }
  50% { box-shadow: 0 0 26px 7px rgba(255, 176, 84, 0.7); }
}
@keyframes lamp-breathe {
  0%, 100% { box-shadow: 0 0 14px 2px rgba(255, 176, 84, 0.4); }
  50% { box-shadow: 0 0 26px 7px rgba(255, 176, 84, 0.7); }
}

/* ---- name screen -------------------------------------------------------- */

.screen-name {
  background: -webkit-radial-gradient(50% 0%, 120% 60%, rgba(255, 176, 84, 0.09), rgba(24, 17, 35, 0) 70%), var(--ink);
  background: radial-gradient(120% 60% at 50% 0%, rgba(255, 176, 84, 0.09), rgba(24, 17, 35, 0) 70%), var(--ink);
}

.name-inner {
  max-width: 420px;
  margin: 0 auto;
  padding: 12vh 20px 40px;
  text-align: center;
}

.brand .wordmark { font-size: 44px; line-height: 1.05; }

.tagline {
  margin-top: 10px;
  color: var(--dim);
  font-size: 15px;
}

.name-card {
  margin-top: 36px;
  text-align: left;
}
.name-card .field { margin-top: 10px; }
.name-card .btn { margin-top: 12px; }

.conn-note {
  margin-top: 16px;
  min-height: 1.5em;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
}

/* ---- lobby --------------------------------------------------------------- */

.screen-lobby {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.lobby-head {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: baseline;
  align-items: baseline;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  padding: 4px 4px 16px;
}
.wordmark-small { font-size: 20px; }
.lobby-hello { color: var(--dim); font-size: 14px; }

.create-card { padding: 16px; }
.create-row {
  display: -webkit-flex;
  display: flex;
  margin-top: 10px;
}
.create-row .field {
  -webkit-flex: 1;
  flex: 1;
  min-width: 0;
}
.btn-create {
  width: auto;
  margin-left: 8px;
  padding: 13px 20px;
}

.lobby-list-head {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: baseline;
  align-items: baseline;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  margin: 26px 4px 10px;
}

.room-card {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 10px;
  color: var(--cream);
}
.room-card:active { background: var(--raised); }

.room-card-main {
  -webkit-flex: 1;
  flex: 1;
  min-width: 0;
  padding-right: 12px;
}
.room-card-name {
  font-weight: 700;
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.room-card-names {
  margin-top: 2px;
  font-size: 13px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-card-live {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
}
.room-card-count {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--amber);
  margin-right: 10px;
}

/* little equalizer: proof of life */
.eq {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: flex-end;
  align-items: flex-end;
  height: 18px;
}
.eq i {
  display: block;
  width: 3px;
  height: 6px;
  margin-left: 3px;
  border-radius: 2px;
  background: var(--amber);
  -webkit-animation: eq-bounce 0.9s ease-in-out infinite;
  animation: eq-bounce 0.9s ease-in-out infinite;
}
.eq i:nth-child(2) { -webkit-animation-delay: 0.25s; animation-delay: 0.25s; height: 12px; }
.eq i:nth-child(3) { -webkit-animation-delay: 0.5s; animation-delay: 0.5s; height: 9px; }

@-webkit-keyframes eq-bounce {
  0%, 100% { -webkit-transform: scaleY(0.5); transform: scaleY(0.5); }
  50% { -webkit-transform: scaleY(1.6); transform: scaleY(1.6); }
}
@keyframes eq-bounce {
  0%, 100% { -webkit-transform: scaleY(0.5); transform: scaleY(0.5); }
  50% { -webkit-transform: scaleY(1.6); transform: scaleY(1.6); }
}

.empty-card {
  text-align: center;
  padding: 36px 20px;
  color: var(--dim);
  font-size: 15px;
}
.empty-card .lamp {
  -webkit-animation: none;
  animation: none;
  opacity: 0.4;
  box-shadow: none;
  margin-bottom: 14px;
}

/* ---- room ---------------------------------------------------------------- */

.screen-room {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  overflow: hidden;
  max-width: 720px;
  margin: 0 auto;
}

.room-head {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.room-title { min-width: 0; padding-right: 10px; }
.room-name {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.onair {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--amber);
  border: 1px solid rgba(255, 176, 84, 0.5);
  border-radius: 8px;
  padding: 5px 9px;
  white-space: nowrap;
}
.onair-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--amber);
  vertical-align: 1px;
  -webkit-animation: lamp-breathe 2.4s ease-in-out infinite;
  animation: lamp-breathe 2.4s ease-in-out infinite;
}

/* the stage: whoever is screen sharing */
.stage {
  position: relative;
  background: #000;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.stage video {
  display: block;
  width: 100%;
  max-height: 38vh;
  background: #000;
}
.stage-label {
  position: absolute;
  top: 8px;
  left: 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--amber);
  background: rgba(24, 17, 35, 0.8);
  border: 1px solid rgba(255, 176, 84, 0.4);
  border-radius: 8px;
  padding: 4px 9px;
  pointer-events: none;
}
.stage:-webkit-full-screen video { max-height: 100%; height: 100%; }
.stage:fullscreen video { max-height: 100%; height: 100%; }

/* participants strip */
.participants {
  display: -webkit-flex;
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 12px 12px;
  border-bottom: 1px solid var(--line);
  background: -webkit-radial-gradient(50% 0%, 100% 100%, rgba(255, 176, 84, 0.05), rgba(24, 17, 35, 0) 75%);
  background: radial-gradient(100% 100% at 50% 0%, rgba(255, 176, 84, 0.05), rgba(24, 17, 35, 0) 75%);
}

.tile {
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
  width: 84px;
  text-align: center;
  margin: 0 4px;
}

.avatar {
  position: relative;
  width: 60px;
  height: 60px;
  margin: 0 auto;
  border-radius: 50%;
  font-weight: 800;
  font-size: 22px;
  line-height: 60px;
  color: var(--ink);
  border: 2px solid transparent;
  -webkit-transition: box-shadow 0.15s ease, border-color 0.15s ease;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

/* THE signature: the on-air ring when a voice is live */
.tile.speaking .avatar {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(255, 176, 84, 0.25), 0 0 22px 4px rgba(255, 176, 84, 0.5);
}

.badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 24px;
  height: 24px;
  line-height: 1;
  border-radius: 50%;
  background: var(--ink);
  border: 1px solid var(--line);
  color: var(--red);
  display: none;
}
.badge svg { margin-top: 4px; }
.tile.is-muted .badge-mute { display: block; }
.tile.is-deafened .badge-deaf { display: block; }
.tile.is-deafened .badge-mute { display: none; }

.badge-host {
  right: auto;
  bottom: auto;
  left: -5px;
  top: -6px;
  border-color: rgba(255, 176, 84, 0.5);
  color: var(--amber);
}
.tile.is-host .badge-host { display: block; }
.tile.moddable { cursor: pointer; }
.tile.moddable:active .avatar { opacity: 0.75; }

.tile-name {
  margin-top: 8px;
  font-size: 12px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile.speaking .tile-name { color: var(--cream); }

/* chat */
.chat-log {
  -webkit-flex: 1;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px;
}

.msg {
  display: -webkit-flex;
  display: flex;
  margin-bottom: 12px;
}
.msg-avatar {
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  margin-right: 10px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
  line-height: 34px;
  text-align: center;
  color: var(--ink);
}
.msg-body {
  -webkit-flex: 1;
  flex: 1;
  min-width: 0;
}
.msg-head { font-size: 13px; font-weight: 700; }
.msg-head .msg-time {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  color: var(--dim);
  margin-left: 8px;
}
.msg-text {
  font-size: 15px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.msg-link {
  color: var(--amber);
  word-break: break-all;
}

/* tap-to-play YouTube embed */
.yt-embed {
  margin-top: 8px;
  max-width: 420px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  cursor: pointer;
}
.yt-inner {
  position: relative;
  padding-top: 56.25%; /* 16:9 without aspect-ratio, for old browsers */
}
.yt-thumb, .yt-frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.yt-thumb { object-fit: cover; }
.yt-play {
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -28px 0 0 -28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid rgba(255, 176, 84, 0.5);
  background: rgba(24, 17, 35, 0.85);
  color: var(--amber);
}
.yt-play svg { vertical-align: middle; margin-left: 3px; }
.msg-system {
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
  margin: 10px 0;
}

.chat-form {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}
.chat-field {
  -webkit-flex: 1;
  flex: 1;
  min-width: 0;
  border-radius: 22px;
  background: var(--surface);
}
.btn-send {
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  margin-left: 8px;
  border: none;
  border-radius: 50%;
  background: var(--amber);
  color: var(--ink);
}
.btn-send:active { background: var(--amber-deep); }
.btn-send svg { vertical-align: middle; }

/* controls */
.controls {
  display: -webkit-flex;
  display: flex;
  -webkit-justify-content: center;
  justify-content: center;
  padding: 10px 12px;
  padding-bottom: calc(10px + constant(safe-area-inset-bottom));
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.ctl {
  -webkit-flex: 0 1 88px;
  flex: 0 1 88px;  /* four buttons must fit a 320px screen */
  min-width: 58px;
  padding: 10px 0 8px;
  margin: 0 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--raised);
  color: var(--cream);
  text-align: center;
}
.ctl-label {
  display: block;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}
.ctl svg .slash { display: none; }

/* active (muted / deafened): lamp goes out — cream chip, dark icon */
.ctl.on {
  background: var(--cream);
  border-color: var(--cream);
  color: var(--ink);
}
.ctl.on .ctl-label { color: var(--ink); }
.ctl.on svg .slash { display: block; }

.ctl-danger { color: var(--red); }
.ctl-danger .ctl-label { color: var(--red); }
.ctl-danger:active { background: var(--red); color: var(--ink); }
.ctl-danger:active .ctl-label { color: var(--ink); }

/* ---- host moderation sheet -------------------------------------------------- */

.mod-sheet {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: rgba(10, 7, 16, 0.6);
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: flex-end;
  align-items: flex-end;
  -webkit-justify-content: center;
  justify-content: center;
}
.mod-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  padding: 20px 16px 16px;
  padding-bottom: calc(16px + constant(safe-area-inset-bottom));
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.mod-name {
  font-weight: 800;
  font-size: 17px;
  text-align: center;
  margin-bottom: 12px;
}
.mod-btn {
  margin-top: 8px;
  background: var(--raised);
  color: var(--cream);
  border: 1px solid var(--line);
}
.mod-btn-danger { color: var(--red); }
.mod-btn-cancel {
  background: transparent;
  border-color: transparent;
  color: var(--dim);
}

/* ---- toast ---------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  max-width: 86%;
  background: var(--cream);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  z-index: 50;
}

/* ---- wider screens --------------------------------------------------------- */

@media (min-width: 600px) {
  .brand .wordmark { font-size: 56px; }
  .tile { width: 96px; }
  .avatar { width: 68px; height: 68px; line-height: 68px; }
}

/* ---- reduced motion --------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .lamp, .onair-dot, .eq i {
    -webkit-animation: none;
    animation: none;
  }
  .avatar { -webkit-transition: none; transition: none; }
}
