:root {
  color-scheme: light;
  --bg: #FFF4E3;
  --panel: #FFFFFF;
  --panel-2: #F5F1E8;
  --ink: #16171C;
  --text: var(--ink);
  --text-dim: #5B5C63;

  --pink: #FF5C8A;
  --yellow: #FFD23F;
  --green: #6BCB77;
  --violet: #8C6FF7;
  --sky: #4EA8DE;
  --orange: #FF8C42;
  --danger: #FF3B3B;

  --radius: 18px;
  --radius-sm: 12px;
  --bw: 3px;
  --sh: 5px;

  --font-display: "Space Grotesk", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "Space Mono", ui-monospace, monospace;
  --font-body: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

body {
  background-image: radial-gradient(rgba(22,23,28,.10) 1.5px, transparent 1.5px);
  background-size: 22px 22px;
}

a { color: var(--pink); font-weight: 700; }

h1, h2, h3 { font-family: var(--font-display); }

/* ---------- sticker button system ---------- */
button {
  font-family: var(--font-display);
  cursor: pointer;
  border: var(--bw) solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--sh) var(--sh) 0 var(--ink);
  transform: translate(0, 0);
  transition: transform .08s ease, box-shadow .08s ease, background .1s ease;
}
button:hover {
  transform: translate(-2px, -2px);
  box-shadow: calc(var(--sh) + 2px) calc(var(--sh) + 2px) 0 var(--ink);
}
button:active {
  transform: translate(var(--sh), var(--sh));
  box-shadow: 0 0 0 var(--ink);
}
button:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
  box-shadow: var(--sh) var(--sh) 0 var(--ink);
}
button.secondary { background: var(--panel-2); color: var(--ink); }
button.danger { background: var(--danger); color: #fff; }

/* primary call-to-action buttons get the pink pop */
#btnCreate, #btnJoin, #btnSetSource, #btnSend {
  background: var(--pink);
  color: #fff;
}
#btnPlayPause { background: var(--green); }
#btnCopyLink { background: var(--sky); color: #fff; }
.pip-btn { background: var(--violet); color: #fff; }
.emoji-btn { background: var(--yellow); }
#btnScreenShare { background: var(--orange); color: #fff; font-size: 12px; padding: 8px 14px; }
#btnScreenShare.sharing { background: var(--danger); }

input[type="text"], input[type="url"] {
  font-family: var(--font-body);
  background: var(--panel-2);
  border: var(--bw) solid var(--ink);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 600;
  width: 100%;
}
input::placeholder { color: var(--text-dim); font-weight: 500; }
input:focus {
  outline: none;
  box-shadow: 3px 3px 0 var(--ink);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 10px;
  background: var(--panel-2);
  border: var(--bw) solid var(--ink);
  border-radius: 999px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--yellow);
  border: var(--bw) solid var(--ink);
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
}
input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--yellow);
  border: var(--bw) solid var(--ink);
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
}
input[type="range"]:disabled { opacity: .5; }

.emoji-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  font-size: 22px;
  background: var(--yellow);
  border: var(--bw) solid var(--ink);
  border-radius: 999px;
  box-shadow: 3px 3px 0 var(--ink);
  transform: rotate(-6deg);
  margin-right: 10px;
  vertical-align: middle;
}
.emoji-badge.small {
  width: 34px;
  height: 34px;
  font-size: 17px;
  box-shadow: 2px 2px 0 var(--ink);
}

/* ---------- Landing page ---------- */
.landing {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.landing-card {
  width: 100%;
  max-width: 440px;
  background: var(--panel);
  border: var(--bw) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 8px 8px 0 var(--ink);
  padding: 30px;
  transform: rotate(-1deg);
}
.landing-card h1 {
  font-size: 26px;
  font-weight: 800;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
}
.landing-card p.sub {
  color: var(--text-dim);
  margin: 0 0 24px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.6;
}
.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}
.tabs button {
  flex: 1;
  background: var(--panel-2);
  color: var(--text-dim);
}
.tabs button.active {
  background: var(--yellow);
  color: var(--ink);
}
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.panel-view { display: none; }
.panel-view.active { display: block; }
.hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 18px;
  line-height: 1.7;
  font-weight: 500;
}
.error-msg {
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
  margin-top: 10px;
  min-height: 18px;
}

.password-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(22,23,28,.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.password-gate-card {
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  border: var(--bw) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 8px 8px 0 var(--ink);
  padding: 26px;
  text-align: center;
}
.password-gate-card h3 { font-family: var(--font-display); margin: 0 0 16px; }
.password-gate-card input { margin-bottom: 12px; text-align: center; }
.password-gate-card button { width: 100%; background: var(--pink); color: #fff; }
.terms-gate .password-gate-card { max-width: 400px; text-align: left; }
.terms-gate h3 { text-align: center; }
.terms-gate-points { margin: 0 0 14px; padding-left: 1.2em; color: var(--text-dim); font-size: 13.5px; line-height: 1.55; }
.terms-gate-points li { margin: 4px 0; }
.terms-gate-check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; font-weight: 600; line-height: 1.5; margin: 0 0 12px; cursor: pointer; }
.terms-gate-check input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--pink); }
.terms-gate-check a { color: #1F5FD1; }
.terms-gate button:disabled { background: var(--panel-2); color: var(--text-dim); cursor: not-allowed; }
.password-gate-error { color: var(--danger); font-size: 13px; font-weight: 700; min-height: 16px; margin: 10px 0 0; }

/* ---------- Room page ---------- */
.room-wrap {
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 340px;
  grid-template-rows: auto 1fr;
  gap: 14px;
  padding: 14px;
}
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 10px 16px;
  background: var(--panel);
  border: var(--bw) solid var(--ink);
  border-radius: var(--radius-sm);
  box-shadow: 4px 4px 0 var(--ink);
}
.my-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: 999px;
  border: var(--bw) solid var(--ink);
  background: var(--panel-2);
  color: var(--text-dim);
  flex-shrink: 0;
  white-space: nowrap;
}
.badge.host { background: var(--yellow); color: var(--ink); }
.users-list {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  margin-left: auto;
  align-items: center;
}
.user-chip {
  font-size: 12px;
  font-weight: 700;
  background: var(--panel-2);
  border: 2px solid var(--ink);
  padding: 4px 11px;
  border-radius: 999px;
  color: var(--text-dim);
  flex-shrink: 0;
  white-space: nowrap;
}
.user-chip.host { background: var(--yellow); color: var(--ink); }

.main-area {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: var(--bw) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 6px 6px 0 var(--ink);
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}
.video-box {
  flex: 1;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
#playerContent { display: contents; }
.video-box video, .video-box iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: none;
}
.video-empty {
  color: #9a9bb0;
  text-align: center;
  padding: 20px;
  max-width: 420px;
}
.video-empty h3 { color: #fff; font-family: var(--font-display); margin-bottom: 8px; }
.viewer-lock-note {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--ink);
  border: 2px solid #fff;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
.pip-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 6;
  font-size: 12px;
  padding: 7px 12px;
}
.activate-overlay {
  position: absolute;
  inset: 0;
  background: rgba(22,23,28,.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  cursor: pointer;
}
.activate-overlay button {
  font-size: 16px;
  padding: 16px 26px;
  pointer-events: none;
  background: var(--yellow);
}
.generic-warning {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--orange);
  border-top: var(--bw) solid var(--ink);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 10px;
  text-align: center;
}

.host-controls {
  background: var(--panel);
  border-top: var(--bw) solid var(--ink);
  padding: 12px 14px;
}
.source-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.source-row input { flex: 1; }
.share-row { margin-bottom: 10px; }
.share-row button { width: 100%; }
.playback-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.playback-row input[type="range"] { flex: 1; }
.time-label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  min-width: 96px;
  text-align: center;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: var(--bw) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 6px 6px 0 var(--ink);
  min-height: 0;
  overflow: hidden;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-msg {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  word-break: break-word;
  background: var(--panel-2);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 6px 10px;
  align-self: flex-start;
  max-width: 92%;
}
.chat-msg .who {
  font-family: var(--font-display);
  font-weight: 800;
  margin-right: 6px;
}
.chat-msg.mine {
  align-self: flex-end;
  background: #FFE3EC;
}
.chat-msg.mine .who { color: var(--pink); }
.chat-msg.host-msg .who { color: #B8860B; }
.chat-msg.system {
  align-self: center;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  max-width: 100%;
}
.chat-input-area {
  border-top: var(--bw) solid var(--ink);
  padding: 10px;
  position: relative;
}
.chat-input-row {
  display: flex;
  gap: 8px;
}
.chat-input-row input { flex: 1; }
.emoji-picker {
  position: absolute;
  bottom: 60px;
  right: 10px;
  background: var(--panel);
  border: var(--bw) solid var(--ink);
  border-radius: var(--radius-sm);
  box-shadow: 5px 5px 0 var(--ink);
  padding: 10px;
  display: none;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  width: 280px;
  max-height: 180px;
  overflow-y: auto;
}
.emoji-picker.open { display: grid; }
.emoji-picker span {
  cursor: pointer;
  text-align: center;
  padding: 4px;
  font-size: 18px;
  border-radius: 8px;
}
.emoji-picker span:hover { background: var(--panel-2); }

@media (max-width: 860px) {
  .room-wrap { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; padding: 10px; gap: 10px; }
  .chat-panel { height: 260px; }
}

.legal-links { text-align: center; font-size: 13px; color: var(--text-dim); margin: 14px 0 0; }
.legal-links a { color: var(--text-dim); font-weight: 700; }

/* ---------- Global homepage (ScreenParty) ---------- */
.landing-wrap { width: 100%; max-width: 480px; }
.landing-top { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.lang-toggle {
  padding: 6px 14px;
  font-size: 13px;
  background: var(--panel);
  color: var(--ink);
}
.hero { display: flex; align-items: center; gap: 16px; margin: 4px 0 12px; }
.hero-icon {
  width: 88px; height: 88px; flex: none;
  border: var(--bw) solid var(--ink);
  border-radius: 22px;
  box-shadow: 5px 5px 0 var(--ink);
}
.hero h1 { font-size: 34px; font-weight: 800; margin: 0; line-height: 1.1; }
.hero-tagline { margin: 6px 0 0; font-size: 16px; font-weight: 700; }
.hero-sub { font-size: 15px; font-weight: 600; line-height: 1.6; margin: 0 0 10px; }
.hero-features { margin: 0 0 22px; padding-left: 1.2em; font-size: 14px; font-weight: 600; line-height: 1.7; }
.landing-wrap .landing-card { max-width: none; }
.android-note { text-align: center; font-size: 13px; font-weight: 700; margin: 22px 0 0; }
@media (max-width: 420px) {
  .hero-icon { width: 68px; height: 68px; border-radius: 17px; }
  .hero h1 { font-size: 28px; }
}
.room-logo { display: inline-flex; flex: none; }
.room-logo img { border: 2px solid var(--ink); border-radius: 9px; box-shadow: 2px 2px 0 var(--ink); }
.topbar .lang-toggle { padding: 6px 12px; font-size: 13px; }
/* top bar on phones: keep buttons on one line; the users strip scrolls instead of squashing them */
.topbar button { white-space: nowrap; flex-shrink: 0; }
@media (max-width: 520px) {
  .topbar { gap: 8px; padding: 8px 10px; }
  .topbar .my-name { display: none; }          /* your name is already in the member strip */
  .topbar #btnCopyLink { padding: 8px 12px; font-size: 13px; }
}

/* in-page notices (instead of alert) */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  max-width: min(92vw, 460px); padding: 12px 16px; z-index: 100;
  background: var(--ink); color: #fff; font-weight: 700; font-size: 14px; line-height: 1.5;
  border-radius: 12px; box-shadow: 4px 4px 0 rgba(0,0,0,.25);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.viewer-time {
  margin-top: 8px; text-align: right; font-size: 13px; font-weight: 800;
  color: var(--text-dim); font-family: var(--font-mono, monospace);
}
.leave-btn { padding: 6px 12px; font-size: 13px; }

/* moderation menus */
.user-chip.clickable { cursor: pointer; }
.chat-msg { position: relative; }
.msg-more {
  position: absolute; right: 4px; top: 2px; padding: 0 6px; font-size: 14px; line-height: 1.4;
  background: transparent; border: 0; box-shadow: none; color: var(--text-dim); opacity: .55;
}
.msg-more:hover, .msg-more:focus { opacity: 1; }
.chat-msg:not(.system) { padding-right: 26px; }
.mod-menu {
  position: fixed; z-index: 90; min-width: 180px; display: flex; flex-direction: column;
  background: var(--panel); border: var(--bw) solid var(--ink); border-radius: 12px;
  box-shadow: 4px 4px 0 var(--ink); overflow: hidden;
}
.mod-menu button {
  border: 0; border-radius: 0; box-shadow: none; text-align: left; padding: 10px 14px;
  background: var(--panel); color: var(--ink); font-size: 14px;
}
.mod-menu button + button { border-top: 1px solid #e6dfd0; }
.mod-menu button:hover { background: var(--panel-2); }
.mod-menu button.danger { color: var(--danger); }
.lock-btn { padding: 6px 10px; font-size: 14px; }
