/* ───────────────────────────── Tula Stylesheet ───────────────────────────── */

:root {
  --bg: #0B0911;
  --bg-2: #15121E;
  --bg-3: #221E2D;
  --bg-4: #2E2939;
  --coral: #E85C50;
  --coral-light: #EE7568;
  --coral-dim: rgba(232, 92, 80, 0.18);
  --gold: #F4B860;
  --text: #F5F1EC;
  --text-2: #B4A8AC;
  --text-3: #7A6F73;
  --success: #7CC295;
  --warning: #F4B860;
  --error: #E85C50;
  --live: #FF3D6E;
  --radius: 14px;
  --radius-lg: 20px;
  --font-display: ui-serif, Georgia, "Iowan Old Style", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

a { color: var(--coral-light); }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, select, textarea {
  font-family: inherit;
  font-size: 16px;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--bg-4);
  border-radius: var(--radius);
  padding: 12px 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--coral);
}

.hidden { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }

/* ───────────────────────────── Buttons ───────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius);
  background: var(--bg-3);
  color: var(--text);
  font-weight: 500;
  font-size: 15px;
  transition: transform 0.1s, background 0.15s;
  min-height: 44px;
}
.btn:hover { background: var(--bg-4); }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--coral);
  color: var(--bg);
}
.btn-primary:hover { background: var(--coral-light); }

.btn-secondary {
  background: var(--gold);
  color: var(--bg);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
}
.btn-ghost:hover { background: var(--bg-3); }

.btn-small {
  padding: 8px 14px;
  font-size: 13px;
  min-height: 36px;
}

/* ───────────────────────────── Landing ───────────────────────────── */

body.landing {
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(232, 92, 80, 0.08), transparent 70%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(244, 184, 96, 0.04), transparent 70%),
    var(--bg);
  min-height: 100vh;
}

.hero {
  padding: 60px 20px 30px;
  text-align: center;
  max-width: 720px;
  margin: 0 auto;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-2);
}
.brand-mark {
  color: var(--coral);
  font-size: 12px;
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(34px, 7vw, 56px);
  line-height: 1.05;
  margin: 0 0 18px;
  font-weight: 500;
  letter-spacing: -1.5px;
}
.hero h1 em {
  font-style: italic;
  color: var(--coral-light);
}
.hero .tagline {
  font-size: clamp(15px, 2.4vw, 18px);
  color: var(--text-2);
  max-width: 540px;
  margin: 0 auto;
}

.container {
  max-width: 540px;
  margin: 0 auto;
  padding: 20px 16px 80px;
}

.card {
  background: var(--bg-2);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
  border: 1px solid var(--bg-4);
}
.card h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.3px;
}
.card-secondary {
  background: transparent;
  border-style: dashed;
}

.field {
  display: block;
  margin: 16px 0 0;
}
.field > span {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 6px;
}

.row {
  display: flex;
  gap: 8px;
}
.row input { flex: 1; min-width: 0; }

#createBtn { width: 100%; margin-top: 20px; }

.features {
  margin-top: 40px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 540px) {
  .features { grid-template-columns: 1fr 1fr; }
}
.feature {
  background: var(--bg-2);
  border-radius: var(--radius);
  padding: 18px;
}
.feature-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--coral-dim);
  color: var(--coral);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 10px;
}
.feature h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}
.feature p {
  margin: 0;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
}

.foot {
  text-align: center;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--bg-3);
  font-size: 12px;
  color: var(--text-3);
}

/* ───────────────────────────── Overlay (name / setup / countdown) ─── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 9, 17, 0.92);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.overlay-card {
  background: var(--bg-2);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 380px;
  border: 1px solid var(--bg-4);
}
.overlay-card.overlay-wide { max-width: 480px; }
.overlay-card h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  margin: 0 0 6px;
}
.overlay-card input { margin: 14px 0; }
.overlay-card .btn { width: 100%; }

.setup-tag {
  display: inline-block;
  background: var(--coral-dim);
  color: var(--coral);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.setup-steps {
  margin: 16px 0;
  padding-left: 22px;
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.7;
}
.setup-steps li + li { margin-top: 8px; }
.setup-steps strong { color: var(--text); font-weight: 600; }
.setup-steps em { color: var(--coral-light); font-style: normal; font-weight: 500; }

.ready-row {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.ready-row .btn { flex: 0 0 auto; }
.ready-states {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.ready-pill {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-3);
  color: var(--text-2);
}
.ready-pill.ready {
  background: rgba(124, 194, 149, 0.15);
  color: var(--success);
}

.countdown-num {
  font-family: var(--font-display);
  font-size: clamp(120px, 30vw, 200px);
  line-height: 1;
  color: var(--coral);
  font-weight: 600;
  text-align: center;
  animation: pop 1s ease-in-out infinite;
}
.countdown-label {
  margin-top: 12px;
  font-size: 16px;
  color: var(--text);
  text-align: center;
}
.countdown-label span { color: var(--coral-light); font-weight: 600; }
@keyframes pop {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.85; }
}

/* ───────────────────────────── Room layout ───────────────────────────── */
body.room-body {
  background: #000;
  overflow: hidden;
  height: 100dvh;
  position: fixed;
  inset: 0;
}
.room-main {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100vw;
}

.room-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--bg);
  border-bottom: 1px solid var(--bg-3);
  flex-shrink: 0;
  z-index: 10;
}
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-3);
  color: var(--text);
  font-size: 18px;
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--bg-4); }

.room-meta {
  flex: 1;
  min-width: 0;
}
.room-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.room-sub {
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sync-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-3);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}
.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
}
.sync-badge.in-sync .sync-dot { background: var(--success); }
.sync-badge.drifting .sync-dot { background: var(--warning); }
.sync-badge.broken .sync-dot { background: var(--error); }
.sync-badge.in-sync { color: var(--success); }
.sync-badge.drifting { color: var(--warning); }
.sync-badge.broken { color: var(--error); }

/* Player area */
.player-wrap {
  flex: 1;
  position: relative;
  background: #000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#youtubePlayer, #htmlPlayer {
  width: 100%;
  height: 100%;
  max-width: 100%;
}
#htmlPlayer { background: #000; object-fit: contain; }

/* Companion display */
#companionDisplay {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at 50% 30%, rgba(232, 92, 80, 0.06), transparent 60%),
    var(--bg);
}
#companionDisplay.hidden { display: none; }
.comp-content {
  text-align: center;
  max-width: 360px;
}
.comp-service {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--coral);
  background: var(--coral-dim);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 18px;
}
.comp-title {
  font-family: var(--font-display);
  font-size: clamp(22px, 5vw, 32px);
  font-weight: 500;
  letter-spacing: -0.5px;
  margin-bottom: 24px;
  line-height: 1.2;
}
.comp-position {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(48px, 12vw, 72px);
  font-weight: 600;
  letter-spacing: -1px;
  color: var(--gold);
  margin-bottom: 12px;
}
.comp-status {
  color: var(--text-2);
  font-size: 14px;
  margin-bottom: 20px;
}
.comp-status.drift {
  color: var(--warning);
}

/* Reaction overlay */
.reaction-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 5;
}
.reaction-flying {
  position: absolute;
  font-size: 44px;
  animation: float-up 3.2s ease-out forwards;
  user-select: none;
}
@keyframes float-up {
  0%   { transform: translateY(0) scale(0.4); opacity: 0; }
  10%  { transform: translateY(-30px) scale(1.2); opacity: 1; }
  100% { transform: translateY(-80vh) scale(1); opacity: 0; }
}

/* Toast layer */
.toast-layer {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast {
  background: rgba(34, 30, 45, 0.92);
  backdrop-filter: blur(8px);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  animation: toast-in 0.3s ease-out, toast-out 0.3s ease-in 2.8s forwards;
}
@keyframes toast-in {
  from { transform: translateY(-12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes toast-out {
  to { transform: translateY(-12px); opacity: 0; }
}

/* Action bar */
.action-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 8px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--bg-3);
  flex-shrink: 0;
  z-index: 10;
}
.action-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg-3);
  color: var(--text);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.1s, background 0.15s;
}
.action-btn:hover { background: var(--bg-4); }
.action-btn:active { transform: scale(0.9); }
.action-spacer { flex: 1; }
.action-toggle {
  font-size: 16px;
}
.action-toggle.active {
  background: var(--coral);
  color: var(--bg);
}
.chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--live);
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 999px;
  min-width: 14px;
  text-align: center;
}

/* Members floating strip */
.members-strip {
  position: absolute;
  top: 70px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 6;
  pointer-events: none;
}
.member-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(34, 30, 45, 0.85);
  backdrop-filter: blur(8px);
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}
.member-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--coral), var(--gold));
  color: var(--bg);
  font-weight: 700;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Chat panel */
.chat-panel {
  position: absolute;
  bottom: 70px;
  right: 8px;
  left: 8px;
  max-width: 380px;
  margin-left: auto;
  height: 60vh;
  background: var(--bg-2);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--bg-4);
  z-index: 11;
  overflow: hidden;
}
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--bg-3);
  font-weight: 600;
  font-size: 14px;
}
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-msg { font-size: 14px; line-height: 1.4; }
.chat-msg .from { font-weight: 600; color: var(--coral-light); margin-right: 6px; font-size: 12px; }
.chat-msg.self .from { color: var(--gold); }
.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--bg-3);
}
.chat-input-row input { flex: 1; padding: 10px 12px; }

/* Mobile tweaks */
@media (max-width: 540px) {
  .action-btn { width: 40px; height: 40px; font-size: 20px; }
  .chat-panel { right: 8px; left: 8px; max-width: none; }
}
