/* YouTube Shquared — Kid Pix–inspired 90s paint-party UI */

:root {
  --paper: #fff8e7;
  --paper-2: #ffe9a8;
  --ink: #1a1a1a;
  --crayon-red: #ff3b3b;
  --crayon-orange: #ff8a00;
  --crayon-yellow: #ffe600;
  --crayon-green: #3dcf4a;
  --crayon-blue: #3b7cff;
  --crayon-purple: #b14dff;
  --crayon-pink: #ff5fb8;
  --stamp-shadow: 4px 4px 0 #1a1a1a;
  --fat-border: 4px solid #1a1a1a;
  --font-display: "Luckiest Guy", "Comic Sans MS", "Chalkboard SE", cursive;
  --font-body: "Fredoka", "Comic Sans MS", "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font-body);
  background-color: #7ec8ff;
  background-image:
    radial-gradient(circle at 12% 18%, #ff5fb8 0 14px, transparent 15px),
    radial-gradient(circle at 88% 12%, #ffe600 0 18px, transparent 19px),
    radial-gradient(circle at 70% 80%, #3dcf4a 0 16px, transparent 17px),
    radial-gradient(circle at 20% 78%, #b14dff 0 12px, transparent 13px),
    radial-gradient(circle at 50% 40%, #ff8a00 0 10px, transparent 11px),
    repeating-linear-gradient(
      45deg,
      #6bb8f5 0 18px,
      #7ec8ff 18px 36px
    );
  background-attachment: fixed;
  background-size: 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 56px 56px;
  animation: confetti-drift 28s linear infinite;
}

button, input { font: inherit; color: inherit; }
.hidden { display: none !important; }

#app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 16px 48px;
}

/* Header */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 14px 16px;
  background: var(--paper);
  border: var(--fat-border);
  border-radius: 28px;
  box-shadow: var(--stamp-shadow), 0 0 0 6px #ff8a00;
}

.brand { display: flex; gap: 14px; align-items: center; }

.logo {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  background: conic-gradient(
    var(--crayon-red),
    var(--crayon-yellow),
    var(--crayon-green),
    var(--crayon-blue),
    var(--crayon-purple),
    var(--crayon-red)
  );
  border: var(--fat-border);
  box-shadow: 3px 3px 0 #1a1a1a;
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.35rem);
  letter-spacing: 0.02em;
  color: var(--crayon-red);
  text-shadow: 3px 3px 0 var(--crayon-yellow);
  font-weight: 400;
}

.tagline {
  margin: 4px 0 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--crayon-blue);
}

.pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--crayon-yellow);
  border: var(--fat-border);
  box-shadow: 3px 3px 0 #1a1a1a;
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
}
.pill.ok { background: var(--crayon-green); }
.pill.warn { background: var(--crayon-orange); color: #fff; }
.pill.err { background: var(--crayon-red); color: #fff; }

/* Panels = construction paper */
.panel {
  background: var(--paper);
  border: var(--fat-border);
  border-radius: 26px;
  padding: 22px;
  box-shadow: var(--stamp-shadow), 0 0 0 5px #3b7cff;
  position: relative;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 2px dashed rgba(0, 0, 0, 0.18);
  border-radius: 18px;
  pointer-events: none;
}

.field { display: grid; gap: 8px; margin-bottom: 16px; position: relative; z-index: 1; }
.field span, .label {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--crayon-purple);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type="text"],
input[type="url"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  border: var(--fat-border);
  background: #fff;
  outline: none;
  box-shadow: inset 2px 2px 0 rgba(0,0,0,0.08);
}
input:focus {
  background: #fffde8;
  box-shadow: 0 0 0 4px var(--crayon-yellow);
}

.lobby-actions { display: grid; gap: 12px; position: relative; z-index: 1; }

/* —— Active sessions (lobby directory) —— */
.active-sessions {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 3px dashed rgba(0, 0, 0, 0.18);
  position: relative;
  z-index: 1;
}
.active-sessions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.active-sessions-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.02em;
  color: var(--crayon-purple);
}
.sessions-refresh {
  padding: 6px 12px;
  font-size: 0.85rem;
  border-radius: 14px;
}
.sessions-status {
  margin: 0 0 10px;
  font-size: 0.9rem;
}
.sessions-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.session-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 12px;
  align-items: center;
  padding: 12px 14px;
  background: #fffef6;
  border: var(--fat-border);
  border-radius: 18px;
  box-shadow: 3px 3px 0 var(--crayon-blue);
}
.session-card-main { min-width: 0; }
.session-card-title {
  margin: 0 0 4px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  word-break: break-word;
}
.session-card-meta {
  margin: 0;
  font-size: 0.88rem;
  color: #444;
  line-height: 1.35;
}
.session-card-meta .who {
  font-weight: 600;
  color: var(--crayon-purple);
}
.session-card .btn {
  padding: 10px 14px;
  white-space: nowrap;
}
.session-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}
.session-pill {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  vertical-align: middle;
  color: #5a2d00;
  background: #ffe566;
  border: 2px solid var(--ink);
  border-radius: 999px;
  box-shadow: 1px 1px 0 var(--crayon-orange, #ff8a3d);
}

/* —— Session title chip in room —— */
.session-title {
  margin: 0;
  padding: 6px 12px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: #1a1a1a;
  background: var(--crayon-yellow);
  border: 3px solid #1a1a1a;
  border-radius: 14px;
  box-shadow: 3px 3px 0 var(--crayon-purple);
  text-shadow: 1px 1px 0 #fff;
  max-width: min(280px, 55vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* —— How-to banner (start of session) —— */
.howto-banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin: 0 0 14px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #fff7c2 0%, #ffe0f0 55%, #d6f5ff 100%);
  border: var(--fat-border);
  border-radius: 20px;
  box-shadow: 4px 4px 0 var(--crayon-orange);
  position: relative;
  z-index: 2;
}
.howto-banner.hidden { display: none !important; }
.howto-body { min-width: 0; flex: 1; }
.howto-title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: #1a1a1a;
  letter-spacing: 0.02em;
}
.howto-list {
  margin: 0;
  padding-left: 1.15rem;
  display: grid;
  gap: 4px;
  font-size: 0.92rem;
  line-height: 1.4;
  color: #222;
  font-weight: 500;
}
.howto-list strong { color: var(--crayon-purple); }
.howto-dismiss {
  flex-shrink: 0;
  background: var(--crayon-green);
  color: #1a1a1a;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.9rem;
}


.join-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.hint {
  color: #444;
  font-size: 0.95rem;
  margin: 16px 0 0;
  line-height: 1.45;
  position: relative;
  z-index: 1;
  font-weight: 500;
}

/* Chunky crayon buttons */
.btn {
  border: var(--fat-border);
  background: #fff;
  color: var(--ink);
  padding: 12px 16px;
  border-radius: 18px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 3px 3px 0 #1a1a1a;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 #1a1a1a; }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #1a1a1a; }

.btn.primary {
  background: var(--crayon-red);
  color: #fff;
}
.btn.share {
  background: var(--crayon-yellow);
  font-size: 1rem;
  padding: 12px 18px;
}
.btn.danger {
  background: #ffd0d8;
  color: #8b0020;
}
.btn.ghost {
  background: #fff;
}

.room-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.room-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.host-label {
  margin: 0;
  padding: 6px 12px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: #1a1a1a;
  background: #fff;
  border: 3px solid #1a1a1a;
  border-radius: 14px;
  box-shadow: 3px 3px 0 var(--crayon-blue);
  text-shadow: 1px 1px 0 #fff;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-areas:
    "player side"
    "queue side";
  gap: 16px;
  position: relative;
  z-index: 1;
}
.player-col { grid-area: player; min-width: 0; }
.mobile-panels {
  display: contents;
}
.mobile-panels .queue-block { grid-area: queue; }
.mobile-panels .side { grid-area: side; }
.mobile-tab-bar { display: none; }
.mobile-room-tools { display: none; }
.share-short { display: none; }
.share-full { display: inline; }

#player-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #111;
  border-radius: 20px;
  overflow: hidden;
  border: var(--fat-border);
  box-shadow: 5px 5px 0 var(--crayon-purple);
}
#yt-player, #player-wrap iframe { width: 100% !important; height: 100% !important; }

.controls {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}
.jump-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.jump-btn { padding: 12px 18px; }

/* Kid Pix stamp transport buttons */
.transport {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-start;
  align-items: stretch;
}
.stamp-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 92px;
  padding: 12px 14px 10px;
  border: var(--fat-border);
  border-radius: 20px;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.03em;
  color: var(--ink);
  box-shadow: 4px 4px 0 #1a1a1a;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.stamp-btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 #1a1a1a; }
.stamp-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #1a1a1a; }
.stamp-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: 2px 2px 0 #1a1a1a;
}
.stamp-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 3px solid #1a1a1a;
  border-radius: 14px;
  background: #fff;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.12);
}
.stamp-icon svg { display: block; }
.stamp-label {
  font-size: 1.05rem;
  line-height: 1;
  text-transform: uppercase;
}
.stamp-prev {
  background: var(--crayon-blue);
  color: #fff;
}
.stamp-prev .stamp-icon { color: var(--crayon-blue); }
.stamp-play {
  background: var(--crayon-green);
  color: #08310f;
}
.stamp-play.is-playing {
  background: var(--crayon-orange);
  color: #fff;
}
.stamp-play .stamp-icon { color: var(--crayon-green); }
.stamp-play.is-playing .stamp-icon { color: var(--crayon-orange); }
.stamp-next {
  background: var(--crayon-purple);
  color: #fff;
}
.stamp-next .stamp-icon { color: var(--crayon-purple); }
@media (max-width: 700px) {
  .stamp-btn { min-width: 78px; flex: 1; }
}

.side { display: flex; flex-direction: column; gap: 12px; min-height: 0; }

.side-block {
  background: linear-gradient(180deg, #fff 0%, var(--paper-2) 100%);
  border: var(--fat-border);
  border-radius: 20px;
  padding: 14px;
  box-shadow: 3px 3px 0 var(--crayon-green);
}
.side-block:nth-child(2) { box-shadow: 3px 3px 0 var(--crayon-pink); }

.side-block h2 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 400;
  color: var(--crayon-blue);
  letter-spacing: 0.02em;
}

#peer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
#peer-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #fff;
  border: 3px solid #1a1a1a;
  font-size: 0.95rem;
  font-weight: 600;
}
#peer-list .role {
  color: var(--crayon-purple);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.chat-block { flex: 1; display: flex; flex-direction: column; min-height: 260px; }
.chat-log,
#chat-log-previous,
#chat-log-current {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  max-height: 320px;
  background: #fff;
  border: 3px dashed #1a1a1a;
  border-radius: 14px;
  padding: 10px;
}
.chat-log.hidden { display: none !important; }

.chat-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.chat-tabs.hidden { display: none !important; }
.chat-tab.hidden { display: none !important; }
.chat-tab {
  flex: 1;
  border: var(--fat-border);
  border-radius: 14px;
  background: #fff;
  padding: 8px 10px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 2px 2px 0 #1a1a1a;
}
.chat-tab.active {
  background: var(--crayon-yellow);
  box-shadow: 3px 3px 0 var(--crayon-orange);
}
.chat-tab:hover { background: #fff6c2; }
.chat-tab.active:hover { background: var(--crayon-yellow); }

.chat-line { font-size: 0.95rem; line-height: 1.35; font-weight: 500; }
.chat-line .who {
  color: var(--crayon-red);
  font-weight: 800;
  margin-right: 6px;
}
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--crayon-yellow);
  border: var(--fat-border);
  color: var(--ink);
  padding: 14px 18px;
  border-radius: 18px;
  box-shadow: var(--stamp-shadow);
  z-index: 50;
  max-width: min(92vw, 420px);
  font-weight: 700;
}

.rename-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
  min-width: 180px;
  justify-content: flex-end;
}
.rename-form input {
  flex: 1;
  max-width: 180px;
  padding: 10px 12px;
  border-radius: 14px;
  border: var(--fat-border);
  background: #fff;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
@media (max-width: 700px) {
  .rename-form { flex-basis: 100%; justify-content: stretch; order: 3; }
  .rename-form input { max-width: none; }
  .top { flex-direction: column; align-items: flex-start; }
}

/* Shared video queue */
.queue-block {
  margin-top: 14px;
  box-shadow: 3px 3px 0 var(--crayon-orange) !important;
  position: relative;
  z-index: 1;
}
.now-playing {
  margin: 0 0 10px;
  font-weight: 700;
  color: var(--crayon-purple);
  font-size: 0.95rem;
}
.queue-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 10px;
}
.queue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  counter-reset: q;
}
.queue-list li {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: #fff;
  border: 3px solid #1a1a1a;
  border-radius: 14px;
  font-weight: 600;
  counter-increment: q;
}
.queue-list li::before {
  content: none;
  display: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  /* legacy counter kept inert — badges label Played / Now / Next */
  place-items: center;
  background: var(--crayon-yellow);
  border: 3px solid #1a1a1a;
  font-weight: 800;
  font-size: 0.85rem;
}
.queue-list .meta { min-width: 0; }
.queue-list .title {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.queue-list .by {
  display: block;
  font-size: 0.75rem;
  color: var(--crayon-blue);
  font-weight: 700;
}
.queue-list .rm {
  padding: 6px 10px;
  font-size: 0.8rem;
  border-radius: 12px;
}
.queue-empty-hint { margin-top: 8px; }
.queue-empty-hint.hidden { display: none !important; }


/* Checkbox rows (lobby + host pass-host setting) */
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 14px 0 4px;
  padding: 12px 14px;
  background: #fff;
  border: var(--fat-border);
  border-radius: 18px;
  box-shadow: 3px 3px 0 #1a1a1a;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.35;
}
.check-row input {
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 2px;
  accent-color: var(--crayon-green);
  flex-shrink: 0;
  cursor: pointer;
}
.host-pass-row {
  grid-column: 1 / -1;
  margin: 4px 0 0;
}


/* ---- Motion / Kid Pix energy ---- */
@keyframes confetti-drift {
  0% { background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0; }
  100% { background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 56px 56px; }
}
@keyframes pop-in {
  0% { opacity: 0; transform: translateY(14px) scale(0.96) rotate(-0.6deg); }
  70% { opacity: 1; transform: translateY(-3px) scale(1.02) rotate(0.4deg); }
  100% { opacity: 1; transform: none; }
}
@keyframes stamp-wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-4deg) scale(1.04); }
  75% { transform: rotate(4deg) scale(1.04); }
}
@keyframes logo-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
@keyframes hint-pulse {
  0%, 100% { transform: translateY(0); box-shadow: 3px 3px 0 #1a1a1a; }
  50% { transform: translateY(-2px); box-shadow: 4px 5px 0 #1a1a1a; }
}
@keyframes chat-slide {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: none; }
}
@keyframes peer-bounce {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes toast-pop {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(0.9); }
  100% { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.anim-pop { animation: pop-in 0.45s cubic-bezier(.2,1.4,.3,1) both; }
.logo { animation: logo-spin 14s linear infinite; }
.stamp-btn:hover:not(:disabled) { animation: stamp-wiggle 0.35s ease; }
.stamp-btn:active:not(:disabled) { animation: none; }

.rename-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: min(100%, 280px);
}
.rename-hint {
  margin: 0;
  padding: 8px 12px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: #1a1a1a;
  background: var(--crayon-yellow);
  border: 3px solid #1a1a1a;
  border-radius: 14px;
  box-shadow: 3px 3px 0 #1a1a1a;
  text-shadow: 1px 1px 0 #fff;
  animation: hint-pulse 2.2s ease-in-out infinite;
}
.chat-line { animation: chat-slide 0.28s ease-out both; }
#peer-list li { animation: peer-bounce 0.28s cubic-bezier(.2,1.4,.3,1) both; }
.toast:not(.hidden) { animation: toast-pop 0.28s cubic-bezier(.2,1.4,.3,1) both; }
.side-block { transition: transform 0.15s ease, box-shadow 0.15s ease; }
.side-block:hover { transform: translate(-2px, -2px); }
#player-wrap { transition: box-shadow 0.2s ease, transform 0.2s ease; }
#player-wrap:hover { transform: translate(-1px, -1px); box-shadow: 7px 7px 0 var(--crayon-purple); }
.pill { transition: transform 0.12s ease; }
.pill.ok { animation: peer-bounce 0.35s ease; }

@media (prefers-reduced-motion: reduce) {
  html, body, .logo, .rename-hint, .anim-pop, .stamp-btn:hover:not(:disabled),
  .chat-line, #peer-list li, .toast:not(.hidden), .pill.ok {
    animation: none !important;
  }
  .side-block:hover, #player-wrap:hover { transform: none; }
}


/* Queue timeline: played → now → upcoming */
.queue-list li.played {
  background: #ececec;
  opacity: 0.92;
}
.queue-list li.now {
  background: #fff7a8;
  box-shadow: 3px 3px 0 var(--crayon-orange);
}
.queue-list li.upcoming {
  background: #e8fff0;
}
.queue-list .badge {
  flex-shrink: 0;
  align-self: center;
  padding: 4px 8px;
  border: 2px solid #1a1a1a;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: #fff;
}
.queue-list li.played .badge { background: #cfcfcf; }
.queue-list li.now .badge { background: var(--crayon-orange); color: #fff; }
.queue-list li.upcoming .badge { background: var(--crayon-green); color: #08310f; }

.queue-list li.played,
.queue-list li.upcoming {
  cursor: pointer;
}
.queue-list li.selected {
  outline: 3px solid var(--crayon-purple);
  outline-offset: -3px;
  background: #fff8ff;
}
.queue-list .move-btns {
  display: grid;
  gap: 4px;
}
.queue-list .move-btns .btn {
  padding: 4px 8px;
  font-size: 0.75rem;
  line-height: 1;
  border-radius: 10px;
  min-width: 32px;
}
.queue-list .move-btns .btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.queue-list li.now {
  cursor: default;
  grid-template-columns: auto 1fr;
}
.queue-list li.played {
  grid-template-columns: auto 1fr auto;
}

/* Session action log export */
.session-log-export {
  margin-top: 12px;
  display: grid;
  gap: 6px;
}
.export-log-btn {
  width: 100%;
  background: #e8f7ff;
  color: #0a4a6e;
  font-size: 0.92rem;
  padding: 10px 12px;
  border-radius: 16px;
  box-shadow: 3px 3px 0 var(--crayon-blue);
}
.export-log-btn:hover {
  background: #d6f0ff;
}
.session-log-hint {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
  opacity: 0.85;
}

/* Session load + playback bar */
.session-load,
.lobby-session-load {
  margin-top: 12px;
  display: grid;
  gap: 6px;
}
.load-session-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  cursor: pointer;
  text-align: center;
  background: #fff0f8;
  color: #6b0a45;
  box-shadow: 3px 3px 0 var(--crayon-pink);
}
.load-session-btn:hover { background: #ffe0f0; }

.playback-bar {
  margin-bottom: 16px;
  padding: 12px 14px;
  background: #fffbe8;
  border: var(--fat-border);
  border-radius: 22px;
  box-shadow: var(--stamp-shadow), 0 0 0 5px var(--crayon-purple);
}
.playback-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.playback-controls .btn { padding: 8px 12px; font-size: 0.92rem; }
.playback-speed {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.9rem;
}
.playback-speed select {
  border: 3px solid #1a1a1a;
  border-radius: 10px;
  padding: 6px 8px;
  background: #fff;
  font-weight: 700;
}
.playback-status {
  margin: 10px 0 0;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--crayon-purple);
}
.playback-meta {
  margin: 4px 0 0;
}

.playback-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  margin-bottom: 10px;
}
.playback-timeline {
  margin-bottom: 10px;
}
.playback-events-disclosure {
  margin: 0 0 8px;
}
.playback-events-summary {
  cursor: pointer;
  font-weight: 800;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
  color: var(--crayon-purple);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 3px solid #1a1a1a;
  border-radius: 12px;
  background: #fff;
  box-shadow: 2px 2px 0 #1a1a1a;
  user-select: none;
}
.playback-events-summary::-webkit-details-marker { display: none; }
.playback-events-disclosure[open] .playback-events-summary {
  margin-bottom: 8px;
  background: var(--crayon-yellow);
}
.replay-clock {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.5px;
  color: var(--crayon-purple);
  margin: 0;
  text-shadow: 1px 1px 0 #fff;
  flex: 0 0 auto;
}
.replay-event-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: 200px;
  overflow-y: auto;
  background: #fff;
  border: 3px solid #1a1a1a;
  border-radius: 16px;
  box-shadow: inset 0 0 0 3px #ffe9a8;
}
.replay-event-list li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 7px 10px;
  margin: 3px 0;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  border: 2px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.replay-event-list li:hover {
  background: #fff3c4;
  border-color: #ff8a00;
}
.replay-event-list li.played {
  background: #e8ffe8;
  color: #2a6b32;
}
.replay-event-list li.active {
  background: #e8d6ff;
  border-color: var(--crayon-purple);
  box-shadow: 2px 2px 0 #1a1a1a;
  color: #1a1a1a;
}
.replay-event-list .ev-time {
  flex: 0 0 3.2em;
  font-variant-numeric: tabular-nums;
  color: var(--crayon-blue);
  font-weight: 800;
}
.replay-event-list li.active .ev-time,
.replay-event-list li.played .ev-time {
  color: inherit;
}
.replay-event-list .ev-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.replay-active #guest-note:not(.hidden) {
  border-color: var(--crayon-purple);
}



/* Desktop: event list always visible (disclosure is a mobile collapse affordance) */
@media (min-width: 901px) {
  .playback-events-summary { display: none; }
  .playback-events-disclosure .playback-timeline { display: block; }
}

/* ---- Mobile one-screen room shell (portrait phones) ---- */
@media (max-width: 900px) {
  /* Prefer small viewport (chrome visible). Fallbacks for older browsers. */
  html {
    height: 100%;
    height: 100vh;
    height: 100dvh;
    height: 100svh;
  }
  html, body {
    max-height: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    max-height: 100svh;
  }

  body.room-active {
    overflow: hidden;
    /* Clamp to small viewport so Safari chrome can't push tabs off-screen */
    height: 100vh;
    height: 100dvh;
    height: 100svh;
    max-height: 100vh;
    max-height: 100dvh;
    max-height: 100svh;
  }

  body.room-active #app.app-stage {
    height: 100vh;
    height: 100dvh;
    height: 100svh;
    max-height: 100vh;
    max-height: 100dvh;
    max-height: 100svh;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding:
      calc(6px + env(safe-area-inset-top, 0px))
      10px
      calc(6px + env(safe-area-inset-bottom, 0px));
    max-width: none;
  }

  /* Compact header — one row, a little air below */
  .top {
    flex-direction: row;
    align-items: center;
    flex-shrink: 0;
    margin-bottom: 10px;
    padding: 8px 12px;
    gap: 8px;
    border-radius: 18px;
    box-shadow: 3px 3px 0 #1a1a1a, 0 0 0 4px #ff8a00;
  }
  .top .tagline { display: none; }
  .top .logo {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
  }
  .top h1 {
    font-size: 1.05rem;
    text-shadow: 2px 2px 0 var(--crayon-yellow);
  }
  .brand { gap: 8px; min-width: 0; }
  .brand > div { min-width: 0; }
  .pill {
    padding: 5px 9px;
    font-size: 0.72rem;
    box-shadow: 2px 2px 0 #1a1a1a;
    max-width: 42%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Lobby: tighten only */
  #lobby.panel {
    padding: 14px;
    border-radius: 20px;
  }
  #lobby .hint { margin-top: 10px; font-size: 0.88rem; }
  #lobby .check-row { padding: 10px 12px; margin: 10px 0 4px; font-size: 0.9rem; }
  .active-sessions { margin-top: 12px; padding-top: 10px; }
  .active-sessions-head h2 { font-size: 1.15rem; }
  .session-card {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .session-card .btn { width: 100%; }
  .howto-banner {
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    margin-bottom: 10px;
  }
  .howto-dismiss { width: 100%; }
  .howto-title { font-size: 1.05rem; }
  .howto-list { font-size: 0.86rem; }
  .session-title {
    font-size: 0.8rem;
    padding: 4px 8px;
    max-width: min(200px, 48vw);
  }

  /* Playback bar — collapsed chrome */
  .playback-bar {
    flex-shrink: 0;
    margin-bottom: 6px;
    padding: 8px 10px;
    border-radius: 16px;
    max-height: none;
  }
  body.room-active .playback-bar:not(.hidden) {
    overflow: hidden;
  }
  .playback-compact {
    margin-bottom: 6px;
    gap: 6px 8px;
  }
  .replay-clock {
    font-size: 0.95rem;
    width: 100%;
  }
  .playback-controls {
    gap: 6px;
    width: 100%;
  }
  .playback-controls .btn {
    padding: 6px 10px;
    font-size: 0.8rem;
    border-radius: 12px;
  }
  .playback-status {
    margin: 6px 0 0;
    font-size: 0.8rem;
  }
  .playback-meta { display: none; }
  .playback-events-disclosure:not([open]) .playback-timeline {
    display: none;
  }
  .playback-events-disclosure[open] .replay-event-list {
    max-height: 22svh;
  }
  .playback-events-summary {
    font-size: 0.85rem;
    padding: 4px 8px;
  }

  /* Room fills remaining viewport */
  #room.panel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Inset so 4px borders + stamp shadows aren't clipped */
    padding: 12px 12px 10px;
    border-radius: 18px;
    margin: 0;
  }
  #room.panel::before {
    inset: 6px;
    border-radius: 12px;
  }

  /* Room chrome: Share …… Leave | session + host chips on second row */
  .room-bar {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "share . leave"
      "session session host";
    gap: 8px;
    margin-bottom: 10px;
    align-items: center;
    padding: 0 1px 2px;
  }
  .room-meta {
    display: contents; /* Share / session / host map into grid areas */
  }
  .desktop-rename { display: none !important; }
  .share-full { display: none; }
  .share-short { display: inline; }
  .btn.share {
    grid-area: share;
    padding: 6px 9px;
    font-size: 0.78rem;
    border-radius: 12px;
  }
  #leave-btn {
    grid-area: leave;
    padding: 6px 9px;
    font-size: 0.78rem;
  }
  .session-title {
    grid-area: session;
    font-size: 0.7rem;
    padding: 4px 8px;
    border-width: 2px;
    border-radius: 10px;
    box-shadow: 2px 2px 0 var(--crayon-purple);
    max-width: none;
    width: max-content;
    min-width: 0;
  }
  .host-label {
    grid-area: host;
    justify-self: end;
    padding: 4px 8px;
    font-size: 0.7rem;
    border-width: 2px;
    border-radius: 10px;
    box-shadow: 2px 2px 0 var(--crayon-blue);
    min-width: 0;
    max-width: min(160px, 46vw);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Column: player | panels | tabs */
  .layout {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    gap: 12px;
    grid-template-columns: none;
    grid-template-areas: none;
    align-items: stretch;
  }

  .player-col {
    flex: 0 1 auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    min-height: 0;
  }

  #player-wrap {
    width: 100%;
    aspect-ratio: auto;
    /* Slightly smaller so external AV dock + gaps still fit in svh */
    height: min(20svh, 46vw, 168px);
    max-height: min(20svh, 46vw, 168px);
    border-radius: 12px;
    box-shadow: 3px 3px 0 var(--crayon-purple);
    flex-shrink: 0;
  }
  /* Chat/People need even more list space than Queue+form */
  #room.tab-chat #player-wrap,
  #room.tab-people #player-wrap {
    height: min(16svh, 40vw, 136px);
    max-height: min(16svh, 40vw, 136px);
  }
  #player-wrap:hover {
    transform: none;
    box-shadow: 3px 3px 0 var(--crayon-purple);
  }

  .controls {
    gap: 6px;
    margin-top: 0;
    padding: 0 1px 2px;
    min-width: 0;
    flex-shrink: 0;
  }
  .jump-form,
  .mobile-panels .queue-form,
  .mobile-panels .chat-form {
    gap: 6px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    align-items: stretch;
    padding-bottom: 2px;
  }
  .jump-form input,
  .mobile-panels .queue-form input,
  .mobile-panels .chat-form input,
  .mobile-room-tools .rename-form input {
    min-width: 0;
    width: 100%;
    padding: 8px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.3;
  }
  .jump-btn,
  .mobile-panels .queue-form .btn,
  .mobile-panels .chat-form .btn {
    padding: 8px 12px;
    font-size: 0.8rem;
    flex-shrink: 0;
    align-self: stretch;
  }

  .transport {
    gap: 8px;
    justify-content: stretch;
    padding: 2px 1px 2px;
  }
  .stamp-btn {
    min-width: 0;
    flex: 1;
    padding: 2px 2px 2px;
    border-radius: 10px;
    gap: 1px;
    box-shadow: 2px 2px 0 #1a1a1a;
  }
  .stamp-icon {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    border-width: 2px;
  }
  .stamp-icon svg {
    width: 14px;
    height: 14px;
  }
  .stamp-label {
    font-size: 0.65rem;
  }

  .desktop-host-pass { display: none !important; }

  #guest-note {
    margin: 0;
    font-size: 0.75rem;
    line-height: 1.25;
  }

  /* Panels region — only active pane visible; MUST shrink (no forced min-height) */
  .mobile-panels {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    touch-action: pan-y;
  }

  .mobile-panels .side {
    display: contents;
  }

  .mobile-panels .queue-block,
  .mobile-panels .people-block,
  .mobile-panels .chat-block {
    display: none;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
    margin-top: 0;
    padding: 10px 12px 12px;
    border-radius: 14px;
  }

  #room.tab-queue .mobile-panels .queue-block,
  #room.tab-chat .mobile-panels .chat-block,
  #room.tab-people .mobile-panels .people-block {
    display: flex;
  }

  .mobile-panels .queue-list,
  .mobile-panels .chat-log,
  .mobile-panels #chat-log-previous,
  .mobile-panels #chat-log-current,
  .mobile-panels #peer-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-panels .chat-block {
    min-height: 0;
  }
  /* Override desktop chat min-height: 260px */
  .mobile-panels .chat-block.side-block,
  .mobile-panels .chat-block {
    min-height: 0 !important;
  }
  /* Tab label already names the panel — free vertical space for messages */
  .mobile-panels .side-block > h2 {
    display: none;
  }
  .mobile-panels .chat-form,
  .mobile-panels .queue-form {
    flex-shrink: 0;
  }
  .mobile-panels .chat-tabs {
    flex-shrink: 0;
  }
  .mobile-panels .queue-block {
    margin-top: 0;
  }
  .mobile-panels .chat-log,
  .mobile-panels #chat-log-previous,
  .mobile-panels #chat-log-current {
    min-height: 0;
    padding: 6px;
    gap: 4px;
    margin-bottom: 6px;
  }
  .mobile-panels .chat-line {
    flex-shrink: 0;
    font-size: 0.88rem;
    line-height: 1.35;
    overflow: visible;
  }
  .mobile-panels .queue-list {
    min-height: 0;
  }
  .mobile-panels .side-block h2 {
    font-size: 1.05rem;
    margin-bottom: 4px;
    flex-shrink: 0;
  }
  .mobile-panels .now-playing {
    font-size: 0.8rem;
    margin-bottom: 4px;
    flex-shrink: 0;
  }
  .mobile-panels .side-block:hover {
    transform: none;
  }

  /* People tab: rename + pass-host tools */
  .mobile-room-tools {
    display: grid;
    gap: 6px;
    margin-bottom: 8px;
    flex-shrink: 0;
  }
  .mobile-room-tools .rename-wrap {
    min-width: 0;
  }
  .mobile-room-tools .rename-hint {
    font-size: 0.8rem;
    padding: 5px 8px;
    animation: none;
  }
  .mobile-room-tools .rename-form {
    min-width: 0;
    justify-content: stretch;
  }
  .mobile-room-tools .rename-form input {
    max-width: none;
  }
  .mobile-host-pass {
    margin: 0;
    padding: 7px 9px;
    font-size: 0.8rem;
    border-radius: 12px;
  }
  #room:not(.is-host) .mobile-host-pass {
    display: none !important;
  }

  .session-log-export {
    flex-shrink: 0;
    margin-top: 6px;
  }
  .session-log-hint {
    font-size: 0.65rem;
  }

  /* Bottom tab bar — always reserved at end of flex column */
  .mobile-tab-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    flex-shrink: 0;
    padding: 6px 2px 4px;
    margin: 0;
    position: relative;
    z-index: 2;
  }
  .mobile-tab-bar[hidden] {
    display: none !important;
  }
  .mobile-tab {
    border: var(--fat-border);
    border-radius: 12px;
    background: #fff;
    padding: 8px 4px 9px;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 0.88rem;
    line-height: 1.15;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: 2px 2px 0 #1a1a1a;
    color: var(--ink);
    overflow: visible;
  }
  .mobile-tab.active {
    background: var(--crayon-yellow);
    box-shadow: 3px 3px 0 var(--crayon-orange);
  }
  .mobile-tab:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 #1a1a1a;
  }

  .toast {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }
}

/* Short portrait phones (SE / small visible area with browser chrome) */
@media (max-width: 900px) and (max-height: 740px) {
  body.room-active #app.app-stage {
    padding:
      calc(5px + env(safe-area-inset-top, 0px))
      9px
      calc(5px + env(safe-area-inset-bottom, 0px));
  }
  .top {
    margin-bottom: 7px;
    padding: 6px 10px;
  }
  .top .logo { width: 28px; height: 28px; font-size: 0.85rem; }
  .top h1 { font-size: 0.95rem; }
  #room.panel {
    padding: 10px 10px 8px;
  }
  #room.panel::before { inset: 5px; }
  .room-bar { margin-bottom: 7px; gap: 6px; }
  .layout { gap: 7px; }
  .player-col { gap: 6px; }
  #player-wrap {
    height: min(16svh, 40vw, 128px);
    max-height: min(16svh, 40vw, 128px);
  }
  #room.tab-chat #player-wrap,
  #room.tab-people #player-wrap {
    height: min(13svh, 34vw, 104px);
    max-height: min(13svh, 34vw, 104px);
  }
  .av-dock {
    padding: 4px 7px;
    gap: 4px;
  }
  .av-btn {
    padding: 4px 7px;
    font-size: 0.64rem;
  }
  .av-hint { font-size: 0.55rem; }
  .av-tile {
    width: clamp(40px, 14%, 58px);
  }
  .jump-form input,
  .mobile-panels .queue-form input,
  .mobile-panels .chat-form input {
    padding: 6px 8px;
    font-size: 0.8rem;
  }
  .jump-btn,
  .mobile-panels .queue-form .btn,
  .mobile-panels .chat-form .btn {
    padding: 6px 10px;
    font-size: 0.75rem;
  }
  .stamp-icon { width: 22px; height: 22px; }
  .stamp-icon svg { width: 12px; height: 12px; }
  .stamp-label { font-size: 0.6rem; }
  .mobile-panels .queue-block,
  .mobile-panels .people-block,
  .mobile-panels .chat-block {
    padding: 8px 10px 9px;
  }
  .mobile-panels .now-playing {
    font-size: 0.75rem;
    margin-bottom: 4px;
  }
  .mobile-tab {
    padding: 6px 3px 7px;
    font-size: 0.8rem;
    border-radius: 10px;
  }
  .mobile-tab-bar {
    gap: 6px;
    padding: 4px 1px 3px;
  }
}

/* Very short visible heights (chrome expanded / SE landscape-tall chrome) */
@media (max-width: 900px) and (max-height: 640px) {
  .top .logo { display: none; }
  .top { padding: 5px 8px; margin-bottom: 5px; }
  .top h1 { font-size: 0.9rem; }
  .pill { padding: 3px 7px; font-size: 0.65rem; }
  #room.panel { padding: 8px 8px 6px; }
  .room-bar { margin-bottom: 5px; gap: 5px; }
  .layout { gap: 5px; }
  .player-col { gap: 5px; }
  .btn.share, #leave-btn { padding: 5px 7px; font-size: 0.72rem; }
  .host-label, .session-title { padding: 3px 6px; font-size: 0.66rem; }
  #player-wrap {
    height: min(13svh, 34vw, 96px);
    max-height: min(13svh, 34vw, 96px);
  }
  #room.tab-chat #player-wrap,
  #room.tab-people #player-wrap {
    height: min(10svh, 28vw, 78px);
    max-height: min(10svh, 28vw, 78px);
  }
  .av-dock { padding: 3px 6px; }
  .av-btn { padding: 3px 6px; font-size: 0.6rem; border-radius: 8px; }
  .av-hint { display: none; }
  .av-tile { width: clamp(36px, 13%, 52px); }
  .transport { gap: 5px; padding: 0 1px 1px; }
  .stamp-btn { padding: 1px; border-radius: 8px; }
  .stamp-icon { width: 18px; height: 18px; border-radius: 5px; }
  .stamp-icon svg { width: 10px; height: 10px; }
  .stamp-label { font-size: 0.55rem; }
  .mobile-tab {
    padding: 5px 2px 6px;
    font-size: 0.72rem;
  }
}

@media (max-width: 700px) {
  /* Override older rename/top stacking rules when in room shell */
  body.room-active .top {
    flex-direction: row;
    align-items: center;
  }
  body.room-active .stamp-btn {
    min-width: 0;
  }
}


/* —— Recording privacy modal —— */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 12, 40, 0.55);
  backdrop-filter: blur(2px);
}
.modal-backdrop.hidden,
.modal-backdrop[hidden] {
  display: none !important;
}
body.modal-open {
  overflow: hidden;
}
.modal-card {
  width: min(420px, 100%);
  padding: 22px 22px 18px;
  background: #fffef6;
  border: var(--fat-border);
  border-radius: 22px;
  box-shadow: 6px 6px 0 var(--crayon-purple, #7b4dff);
  text-align: center;
}
.modal-emoji {
  margin: 0 0 6px;
  font-size: 2.4rem;
  line-height: 1;
}
.modal-card h2 {
  margin: 0 0 10px;
  font-size: 1.35rem;
  color: var(--ink);
}
.modal-body {
  margin: 0 0 16px;
  font-size: 0.95rem;
  line-height: 1.45;
  color: #333;
  text-align: left;
}
.modal-card .btn {
  min-width: 180px;
}
body.recording-off .session-log-export {
  display: none !important;
}

.modal-field {
  text-align: left;
  margin: 0 0 16px;
}
.modal-field span {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
  color: var(--crayon-purple);
}
.modal-field input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  font: inherit;
  font-weight: 600;
  border: var(--fat-border);
  border-radius: 14px;
  background: #fff;
  box-shadow: 3px 3px 0 var(--crayon-yellow);
}
.modal-field input:focus {
  outline: none;
  box-shadow: 0 0 0 4px var(--crayon-yellow);
}
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.modal-actions .btn {
  min-width: 120px;
}

/* —— WebRTC video call overlay (Kid Pix bubbles on the player) —— */
.av-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(26, 26, 26, 0.28) 0%, transparent 40%);
}
.av-overlay.av-active {
  background: linear-gradient(to bottom, rgba(26, 26, 26, 0.34) 0%, transparent 44%);
}

.av-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: flex-start;
  padding: 8px 10px 4px;
  max-height: 58%;
  overflow: auto;
  pointer-events: none;
}

.av-tile {
  position: relative;
  width: clamp(88px, 18%, 140px);
  aspect-ratio: 3 / 4;
  border-radius: 22px;
  border: var(--fat-border);
  box-shadow: 3px 3px 0 #1a1a1a, 0 0 0 3px var(--crayon-pink);
  overflow: hidden;
  background: var(--paper);
  pointer-events: auto;
  flex: 0 0 auto;
  animation: peer-bounce 0.35s ease;
}
.av-tile.av-local {
  box-shadow: 3px 3px 0 #1a1a1a, 0 0 0 3px var(--crayon-yellow);
}
.av-tile.cam-off {
  background: conic-gradient(
    from 40deg,
    var(--crayon-blue),
    var(--crayon-purple),
    var(--crayon-pink),
    var(--crayon-yellow),
    var(--crayon-blue)
  );
}

.av-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #111;
  display: block;
  transform: none;
}
.av-tile.av-local .av-video {
  transform: scaleX(-1);
}

.av-avatar {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  color: #fff;
  text-shadow: 2px 2px 0 #1a1a1a;
  background: transparent;
}

.av-label {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  padding: 3px 7px;
  border-radius: 999px;
  border: 2px solid #1a1a1a;
  background: var(--paper);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.25);
}

.av-badges {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 0.9rem;
  line-height: 1;
  filter: drop-shadow(1px 1px 0 #1a1a1a);
}

/* Compact dock BELOW the player (not over video faces) */
.av-dock {
  pointer-events: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-top: 8px;
  background: #fff;
  border: var(--fat-border);
  border-radius: 14px;
  box-shadow: 3px 3px 0 var(--crayon-pink);
  flex-shrink: 0;
}
.av-dock.hidden { display: none !important; }

.av-btn {
  padding: 7px 11px;
  font-size: 0.82rem;
  border-radius: 14px;
  box-shadow: 2px 2px 0 #1a1a1a;
}
.av-btn.av-join {
  background: var(--crayon-pink);
  color: #fff;
  font-weight: 700;
}
.av-btn.is-off {
  background: var(--crayon-orange);
  color: #fff;
}
.av-in-call {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.av-hint {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink);
  text-shadow: none;
  opacity: 0.9;
  flex: 1 1 auto;
  min-width: 0;
}

/* Tiles sit top-right so they don't cover faces mid-frame as much */

@media (max-width: 900px) {
  .av-grid {
    gap: 4px;
    padding: 6px 6px 4px;
    max-height: 62%;
    justify-content: flex-end;
    align-items: flex-start;
  }
  .av-tile {
    width: clamp(44px, 16%, 68px);
    border-radius: 12px;
    border-width: 2px;
    box-shadow: 2px 2px 0 #1a1a1a, 0 0 0 2px var(--crayon-pink);
  }
  .av-label {
    left: 2px;
    right: 2px;
    bottom: 2px;
    padding: 1px 3px;
    font-size: 0.52rem;
    border-width: 1.5px;
  }
  .av-avatar { font-size: 1.1rem; }
  .av-badges { top: 3px; right: 3px; font-size: 0.7rem; }
  .av-dock {
    margin-top: 0;
    padding: 4px 8px;
    gap: 5px 6px;
    border-radius: 12px;
    box-shadow: 2px 2px 0 var(--crayon-pink);
    /* Single compact strip — hint stays inline when space allows */
    flex-wrap: nowrap;
  }
  .av-in-call {
    flex-wrap: nowrap;
    gap: 5px;
  }
  .av-btn {
    padding: 5px 8px;
    font-size: 0.68rem;
    border-radius: 10px;
    white-space: nowrap;
  }
  .av-hint {
    font-size: 0.58rem;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* Light veil only — controls no longer sit on the video */
  .av-overlay {
    background: linear-gradient(to bottom, rgba(26, 26, 26, 0.22) 0%, transparent 38%);
    justify-content: flex-start;
  }
  .av-overlay.av-active {
    background: linear-gradient(to bottom, rgba(26, 26, 26, 0.28) 0%, transparent 42%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .av-tile { animation: none; }
}
