/* ============================================
   YapApp — Mobile-first PWA Styles
   ============================================ */

:root {
  --primary: #6C5CE7;
  --primary-light: #A29BFE;
  --primary-dark: #5541D7;
  --bg: #F8F9FA;
  --surface: #FFFFFF;
  --text: #2D3436;
  --text-muted: #888;
  --border: #E9ECEF;
  --danger: #E74C3C;
  --success: #27AE60;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
}

/* ============================================
   Header
   ============================================ */

#app-header {
  display: flex;
  flex-direction: column;
  padding: 8px 16px;
  padding-top: calc(8px + var(--safe-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  overflow: visible;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}


#header-title {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s;
}

.icon-btn:active {
  background: var(--border);
}

.icon-btn.active {
  color: var(--primary);
}

/* Back button — hidden on touch devices (swipe-right handles navigation).
   Shown on pointer-fine (desktop/trackpad) devices when not .hidden. */
.back-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--primary);
  border-radius: 8px;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.back-btn:active { opacity: 0.6; }
@media (hover: hover) and (pointer: fine) {
  .back-btn:not(.hidden) { display: flex; }
}


/* ============================================
   Hamburger Menu
   ============================================ */

.hamburger-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 200;
  overflow: hidden;
}

.hamburger-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 12px;
}

.hamburger-avatar-wrap {
  flex-shrink: 0;
}

.hamburger-display-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hamburger-divider {
  height: 1px;
  background: var(--border);
  margin: 0;
}

.hamburger-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 13px 16px;
  background: transparent;
  border: none;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s;
}

.hamburger-item:active {
  background: var(--border);
}

.hamburger-sign-out {
  color: var(--danger, #e74c3c);
}

/* ============================================
   Avatars
   ============================================ */

.avatar-small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-large {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  color: white;
  font-weight: 700;
  font-size: 14px;
}

.avatar-large.avatar-placeholder {
  font-size: 32px;
}

/* ============================================
   Layout helpers
   ============================================ */

.hidden { display: none !important; }

.page-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  gap: 16px;
  text-align: center;
  min-height: 50vh;
}

.error-state-msg {
  font-weight: 600;
  color: var(--text);
}

.page-pad {
  padding: 16px;
}

.text-muted { color: var(--text-muted); }
.text-small { font-size: 13px; }
.subtitle { color: var(--text-muted); font-size: 15px; }

/* ============================================
   Buttons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
  text-decoration: none;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; pointer-events: none; }

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

.btn-small {
  padding: 8px 16px;
  font-size: 14px;
}

.btn-google {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* ============================================
   Landing
   ============================================ */

.landing-logo {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  background: var(--primary);
  color: white;
  font-size: 40px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================
   Auth Form (landing page)
   ============================================ */

.auth-divider {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-full {
  width: 100%;
}

.auth-switch {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-switch a {
  color: var(--primary);
  text-decoration: none;
}

.auth-error {
  text-align: center;
  font-size: 13px;
  color: var(--danger);
  padding: 8px;
  border-radius: var(--radius-sm);
  background: rgba(231, 76, 60, 0.08);
}

/* ============================================
   Forms
   ============================================ */

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-input {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  background: var(--surface);
  resize: none;
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus {
  border-color: var(--primary);
}

/* ============================================
   Topic list
   ============================================ */

.topic-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.topic-card {
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.topic-card-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topic-card-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
  text-decoration: none;
}

.topic-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.topic-card-thumb-empty {
  background: var(--border);
}

.topic-card-title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.topic-card-title {
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topic-challenge-note {
  font-size: 12px;
  color: var(--primary, #3b82f6);
  font-weight: 500;
  display: block;
}

.topic-challenge-note .chal-status,
.topic-challenge-note .chal-title {
  display: block;
}

.chal-title {
  color: #f59e0b;
  font-weight: 600;
}

.new-posts-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  height: 22px;
  border-radius: 11px;
  flex-shrink: 0;
  white-space: nowrap;
}

.topic-card-actions {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--border);
}

.topic-action-btn {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}

.topic-action-btn:active {
  opacity: 0.6;
}

.topic-action-btn.active {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(108, 92, 231, 0.08);
}

.topic-action-add {
  border-color: var(--success);
  color: var(--success);
}

.drag-handle {
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  color: var(--text-muted);
  cursor: grab;
  padding: 4px 2px;
  flex-shrink: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.topic-list.edit-feeds-mode .drag-handle {
  display: flex;
}

.topic-reorder-btns {
  display: none;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.topic-list.edit-feeds-mode .topic-reorder-btns {
  display: flex;
}

.topic-reorder-btn {
  font-size: 11px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.4;
}

.topic-reorder-btn:active {
  background: var(--primary);
  color: #fff;
}

.topic-list.edit-feeds-mode .topic-card-actions {
  display: flex;
}

.topic-list.edit-feeds-mode .new-posts-badge {
  display: none;
}

.topic-card.dragging {
  opacity: 0.4;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}

/* ============================================
   FAB (floating action button)
   ============================================ */

.fab {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 28px;
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(108, 92, 231, 0.3);
  transition: transform 0.15s;
  z-index: 50;
}

.fab:active { transform: scale(0.9); }

/* ============================================
   Topic view / Posts
   ============================================ */

.topic-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.topic-desc-bar {
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-muted);
}

.ptr-indicator {
  height: 0;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.ptr-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  opacity: 0.35;
  transition: opacity 0.15s;
}

.ptr-indicator.ptr-ready .ptr-spinner {
  opacity: 1;
}

.ptr-indicator.ptr-loading .ptr-spinner {
  opacity: 1;
  animation: spin 0.6s linear infinite;
}

.posts-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 140px;
}

.post-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  border: 1px solid #C8CDD2;
}

@keyframes post-highlight-fade {
  0%   { box-shadow: 0 0 0 3px var(--primary); }
  100% { box-shadow: var(--shadow); }
}

.post-card.post-highlight {
  animation: post-highlight-fade 2s ease-out forwards;
}

.badge-new {
  display: inline-flex;
  align-items: center;
  background: var(--primary);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  flex-shrink: 0;
  margin-bottom: 4px;
}

.post-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.post-author {
  font-size: 14px;
  font-weight: 600;
}

.post-time {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
}

.post-body {
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
}

.post-photo-wrap {
  margin: 8px -14px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--bg-secondary, #f5f5f5);
  cursor: pointer;
}

.post-photo-wrap--stack {
  position: relative;
  overflow: visible;
  margin: 8px 0 10px; /* override -14px bleed so layers stay inside the card */
}

.post-photo-stack-layer {
  position: absolute;
  inset: 0;
  background: var(--surface, #fff);
  border-radius: 6px;
  border: 1px solid var(--border, #E9ECEF);
  box-shadow: 0 3px 10px rgba(0,0,0,0.13);
}
.post-photo-stack-layer-1 { transform: rotate(2deg) translate(4px, 5px); z-index: 0; }
.post-photo-stack-layer-2 { transform: rotate(-1.5deg) translate(-3px, 4px); z-index: 1; }

.post-photo-wrap--stack .post-photo {
  position: relative;
  z-index: 2;
  border-radius: 6px;
}

.post-photo-wrap--stack:active .post-photo {
  transform: scale(0.99);
  transition: transform 0.15s ease;
}

.post-photo-stack-badge {
  position: absolute;
  top: 10px; right: 10px; z-index: 10;
  background: rgba(0,0,0,0.62);
  color: #fff; font-size: 13px; font-weight: 700;
  padding: 4px 10px; border-radius: 12px;
  pointer-events: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  letter-spacing: 0.3px;
}

.post-photo {
  width: 100%;
  height: 100%;
  display: block;
  max-height: 500px;
  object-fit: contain;
}

.post-location {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.post-location::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5'%3E%3Cpath d='M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z'/%3E%3Ccircle cx='12' cy='10' r='3'/%3E%3C/svg%3E") no-repeat center;
}

/* ============================================
   Reactions
   ============================================ */

.reaction-bar {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  font-size: 15px;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 32px;
}

.reaction-btn:active { transform: scale(0.92); }

.reaction-btn.active {
  border-color: var(--primary-light);
  background: rgba(108, 92, 231, 0.08);
}

.reaction-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.reaction-btn--hidden { display: none; }
.reaction-bar.expanded .reaction-btn--hidden { display: inline-flex; }

.btn-react-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px dashed var(--border);
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-react-add:hover,
.reaction-bar.expanded .btn-react-add {
  border-color: var(--primary);
  border-style: solid;
  color: var(--primary);
}

/* ============================================
   Replies
   ============================================ */

.replies-section {
  margin-top: 8px;
  padding-left: 12px;
  border-left: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reply {
  padding-top: 8px;
}

.reply .post-header {
  margin-bottom: 4px;
}

.reply .avatar-small {
  width: 24px;
  height: 24px;
}

.reply-media .post-photo-wrap {
  display: inline-block;
}

.reply-media img,
.reply-media video {
  max-width: 180px;
  max-height: 180px;
  border-radius: 8px;
  object-fit: cover;
  cursor: pointer;
}

#media-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

#media-lightbox img,
#media-lightbox video {
  max-width: 95vw;
  max-height: 90vh;
  border-radius: 6px;
  object-fit: contain;
}

#media-lightbox img {
  touch-action: none;
  user-select: none;
  cursor: zoom-in;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 8px;
}

.lightbox-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
  border-radius: 2px;
}

#media-lightbox.has-actions img {
  max-height: 82vh;
}

.lightbox-actions {
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
}

.lightbox-action-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 20px;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  padding: 9px 22px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  white-space: nowrap;
}

.lightbox-action-btn:active {
  background: rgba(255, 255, 255, 0.28);
}

.lightbox-toast {
  position: absolute;
  bottom: max(80px, calc(env(safe-area-inset-bottom) + 56px));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  border-radius: 12px;
  padding: 8px 16px;
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
}

.lightbox-counter {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  color: #fff; font-size: 14px; font-weight: 500;
  background: rgba(0,0,0,0.45); padding: 4px 12px; border-radius: 12px;
  pointer-events: none; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  z-index: 10;
}

.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  color: #fff; background: rgba(0,0,0,0.35);
  border: none; border-radius: 50%; width: 44px; height: 44px;
  font-size: 26px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  z-index: 10;
}
.lightbox-nav--prev { left: 16px; }
.lightbox-nav--next { right: 16px; }
.lightbox-nav:disabled { opacity: 0.25; cursor: default; }
@media (pointer: coarse) and (hover: none) { .lightbox-nav { display: none; } }

.btn-reply {
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  background: none;
  border: 1px solid var(--primary);
  color: var(--primary);
  margin-left: auto;
  margin-top: 6px;
}

.btn-reply:hover {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.post-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  position: relative;
}

.post-footer-actions {
  display: flex;
  align-items: center;
}

/* ⋯ overflow menu */
.btn-post-menu {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  padding: 0 4px;
  letter-spacing: 1px;
  line-height: 1;
  border-radius: 4px;
}
.btn-post-menu:hover { color: var(--text); background: var(--bg); }

.post-actions-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 100;
  min-width: 140px;
  overflow: hidden;
}

.post-action-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}
.post-action-item:hover { background: var(--bg); }
.post-action-item.btn-delete-post { color: var(--danger); }

/* Reply delete ✕ icon */
.btn-delete-icon {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  opacity: 0.45;
  padding: 2px 4px;
  line-height: 1;
}
.btn-delete-icon:hover { color: var(--danger); opacity: 1; }

.crosspost-origin-badge {
  display: inline-block;
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 8px;
}

.crosspost-topic-list {
  list-style: none;
  margin: 0;
  padding: 0 0 env(safe-area-inset-bottom);
}
.crosspost-topic-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.crosspost-topic-item.crosspost-linked { opacity: 0.55; }
.crosspost-topic-title { flex: 1; font-size: 15px; }
.crosspost-check { font-size: 13px; color: var(--text-muted); }

/* ============================================
   Post form
   ============================================ */

.post-form--hidden { display: none; }

.btn-fab-back, .btn-fab-post {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  z-index: 89;
}
.btn-fab-back:active, .btn-fab-post:active { transform: scale(0.94); }
.btn-fab-back { left: 20px; font-size: 26px; }
.btn-fab-post { right: 20px; font-size: 32px; }
.btn-fab-post.hidden { display: none; }

.btn-form-dismiss {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  padding: 0 6px;
  margin-right: auto;
  line-height: 1;
}
.btn-form-dismiss:hover { color: var(--text); }

.post-form-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 600px;
  margin: 0 auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  padding-bottom: calc(10px + var(--safe-bottom));
  z-index: 90;
}

.post-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.post-form-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.post-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.4;
}

.post-input:focus {
  border-color: var(--primary);
}

.photo-attach-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  cursor: pointer;
  color: var(--text-muted);
  flex-shrink: 0;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.post-form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.crosspost-toggle-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.crosspost-toggle-label input[type="checkbox"] {
  accent-color: var(--primary);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* Photo preview */
.photo-preview-item {
  position: relative;
  display: inline-block;
}

.photo-preview-item img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.photo-remove-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: var(--danger);
  color: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-attach-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  cursor: pointer;
  color: var(--text-muted);
  flex-shrink: 0;
}

.attach-wrap {
  position: relative;
  flex-shrink: 0;
}

.attach-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  cursor: pointer;
  color: var(--text-muted);
}

.video-preview {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.post-video-wrap {
  margin: 8px -14px;
  position: relative;
}

.post-video {
  width: 100%;
  display: block;
  max-height: 500px;
  background: #000;
  cursor: pointer;
}

.video-anim-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.post-video-wrap:not(.video-not-started) .video-anim-preview {
  display: none;
}

.video-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: rgba(0,0,0,0.15);
}

.video-play-overlay-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.video-play-overlay:hover .video-play-overlay-btn {
  background: rgba(0,0,0,0.75);
}

.video-play-overlay-btn svg {
  margin-left: 4px;
}

.video-not-started .video-controls {
  display: none;
}

.post-video-wrap:not(.video-not-started) .video-play-overlay {
  display: none;
}

.video-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.55));
  pointer-events: none;
}

.video-controls > * {
  pointer-events: auto;
}

.video-play-btn,
.video-fs-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  padding: 2px;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0.9;
}

.video-progress {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.35);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}

.video-progress-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  background: #fff;
  border-radius: 2px;
  pointer-events: none;
}

.post-video-processing {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* Reply indicator */
#reply-indicator {
  font-size: 13px;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.reply-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  padding: 6px 8px;
  color: var(--text-secondary, var(--text-muted));
}

.reply-preview-photo {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.reply-preview-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}

.cancel-reply {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

/* Sign in prompt */
.sign-in-prompt {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 600px;
  margin: 0 auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-muted);
}

/* ============================================
   Profile page
   ============================================ */

.profile-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding-top: 40px;
}

.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.profile-card h2 {
  font-size: 22px;
}

/* ============================================
   Toast
   ============================================ */

/* ============================================
   App Overlay Banner
   ============================================ */

#app-overlay-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 500;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 12px 16px;
  padding-top: calc(12px + var(--safe-top));
  font-size: 14px;
  line-height: 1.4;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  animation: slideDown 0.25s ease;
}

#app-overlay-banner.hidden { display: none; }

#app-overlay-banner .overlay-msg { flex: 1; }

#app-overlay-banner .overlay-dismiss {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to   { transform: translateY(0); }
}

/* Push page content down when banner is visible */
body.has-overlay #nav { top: var(--overlay-height, 48px); }
body.has-overlay #content { padding-top: calc(var(--header-height, 56px) + var(--overlay-height, 48px)); }

.toast {
  --toast-slide: 16px;
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(var(--toast-slide));
  background: var(--primary);
  color: #fff;
  padding: 14px 22px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 500;
  max-width: min(320px, calc(100vw - 32px));
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 200;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-note {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 5px;
}

/* ============================================
   Spinner
   ============================================ */

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.posts-sentinel {
  height: 1px;
}
.posts-sentinel.loading {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   Scrollbar (subtle)
   ============================================ */

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ============================================
   Main content area
   ============================================ */

#app-content {
  flex: 1;
  overflow-y: auto;
}

/* ============================================
   Photo Search Modal
   ============================================ */

.ps-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: var(--safe-bottom);
}

.ps-modal {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding-bottom: calc(16px + var(--safe-bottom));
}

.ps-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
  border-bottom: 1px solid var(--border);
}

.ps-title {
  font-size: 17px;
  font-weight: 700;
}

.ps-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--border);
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.ps-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ps-hint {
  font-size: 14px;
  color: var(--text-muted);
}

.ps-upload-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
  transition: background 0.15s;
}

.ps-upload-btn:active {
  background: rgba(108, 92, 231, 0.06);
}

.ps-preview {
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.ps-preview-img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-sm);
}

.ps-status {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  padding: 8px 0;
}

.ps-result {
  margin-top: 4px;
}

/* Found state */
.ps-found {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ps-found-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--success);
}

.ps-pct {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 13px;
}

.ps-match-photo {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.ps-match-meta {
  font-size: 13px;
  color: var(--text-muted);
}

.ps-more-hint {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* No match state */
.ps-no-match {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 0;
  text-align: center;
}

.ps-no-match-msg {
  font-size: 15px;
  font-weight: 600;
}

.ps-no-match-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

/* Error */
.ps-error {
  font-size: 14px;
  color: var(--danger);
  text-align: center;
  padding: 8px;
  background: rgba(231, 76, 60, 0.08);
  border-radius: var(--radius-sm);
}

/* Post highlight on scroll-to */
@keyframes ps-pulse {
  0%, 100% { box-shadow: var(--shadow); }
  50% { box-shadow: 0 0 0 3px var(--primary-light); }
}

.ps-highlight {
  animation: ps-pulse 0.6s ease 2;
}

/* ============================================
   Settings section (profile page)
   ============================================ */

.settings-section {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.threshold-slider {
  width: 100%;
  margin-top: 6px;
  accent-color: var(--primary);
}

/* ============================================
   Topic behavior config (new-topic form)
   ============================================ */

.behavior-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
}

.behavior-toggle-icon {
  font-size: 12px;
}

.behavior-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.behavior-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.behavior-group-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.behavior-options {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.behavior-options label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
}

.behavior-options input[type="radio"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

/* ============================================
   Rating slider input (post form)
   ============================================ */

.rating-input {
  padding: 6px 0 2px;
}

.rating-readout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 6px;
}

.rating-face {
  font-size: 28px;
  line-height: 1;
  transition: filter 0.15s;
}

.rating-num {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 28px;
  text-align: center;
}

.rating-num.negative { color: #e74c3c; }
.rating-num.positive { color: #27ae60; }

.rating-track-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rating-pole {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}

.rating-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: #e0e0e0;
  outline: none;
  cursor: pointer;
}

.rating-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #888;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  transition: background 0.15s, transform 0.1s;
}

.rating-slider:active::-webkit-slider-thumb {
  transform: scale(1.15);
}

.rating-slider.negative::-webkit-slider-thumb {
  background: #e74c3c;
}

.rating-slider.positive::-webkit-slider-thumb {
  background: #27ae60;
}

.rating-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #888;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.rating-required {
  display: block;
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
}

.photo-required svg {
  stroke: var(--primary);
}

/* ============================================
   Post: rating display & image description
   ============================================ */

.post-rating {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.post-rating-emoji {
  font-size: 20px;
  line-height: 1;
}

.post-rating-value {
  font-size: 14px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
}

.post-rating-value.negative {
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.1);
}

.post-rating-value.neutral {
  color: #888;
  background: rgba(136, 136, 136, 0.1);
}

.post-rating-value.positive {
  color: #27ae60;
  background: rgba(39, 174, 96, 0.1);
}

.translation-blocks { display: flex; flex-direction: column; gap: 6px; }
.translation-block { display: flex; align-items: baseline; gap: 6px; }
.lang-badge { font-size: 10px; font-weight: 700; letter-spacing: 0.05em; color: var(--text-muted); background: var(--bg); border: 1px solid var(--border); border-radius: 3px; padding: 1px 4px; flex-shrink: 0; }
.translation-pending { font-size: 12px; margin-left: 4px; opacity: 0.6; }

.post-image-description {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border-left: 3px solid var(--primary-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ============================================
   Subscribe bar
   ============================================ */

.subscribe-bar {
  padding: 8px 16px 0;
}

.btn-subscribe {
  width: 100%;
}

.topic-photo-search-bar {
  display: flex;
  padding: 8px 16px 0;
}

/* ============================================
   Manage modal / bottom sheet
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  transition: background 0.3s;
  pointer-events: none;
}

.modal-overlay.open {
  background: rgba(0, 0, 0, 0.4);
  pointer-events: all;
}

.modal-sheet {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  -webkit-overflow-scrolling: touch;
}

.modal-overlay.open .modal-sheet {
  transform: translateY(0);
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
}

.modal-body {
  padding: 16px 16px calc(24px + var(--safe-bottom));
}

/* Prolific Posters leaderboard */
.prolific-sheet { max-width: 380px; max-height: 85vh; display: flex; flex-direction: column; }
.prolific-body { padding-top: 0.75rem; overflow-y: auto; flex: 1; }
.prolific-item { padding: 0.5rem 0; }
.prolific-item + .prolific-item { border-top: 1px solid var(--border); }
.prolific-item.is-self { background: var(--highlight-bg, rgba(0,122,255,0.05)); margin: 0 -1rem; padding-left: 1rem; padding-right: 1rem; }
.prolific-row1 { display: flex; align-items: center; gap: 0.6rem; }
.prolific-rank { width: 1.75rem; text-align: center; font-weight: 700; font-size: 0.9rem; flex-shrink: 0; }
.prolific-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.prolific-row2 { display: flex; gap: 0.25rem; margin-top: 0.2rem; margin-left: 2.35rem; font-size: 0.78rem; color: var(--text-muted); }
.prolific-stat { white-space: nowrap; }
.prolific-stat strong { color: var(--text); font-weight: 600; }
.prolific-streak { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }
.prolific-avatar-img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.prolific-avatar-initials { width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 600; flex-shrink: 0; }
.prolific-loading { text-align: center; padding: 2rem; color: var(--text-muted); }
.prolific-error { text-align: center; padding: 2rem; }
.prolific-error p { color: var(--text-muted); margin-bottom: 1rem; }
.prolific-empty { text-align: center; padding: 2rem 1rem; color: var(--text-muted); }
.prolific-footer { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); text-align: center; font-size: 0.85rem; color: var(--text-muted); }

/* Mini-Games */
.game-canvas-wrap { display: flex; justify-content: center; gap: 8px; padding: 8px 0; }
.game-canvas { border: 2px solid var(--border); border-radius: 4px; background: #000; }
.game-panel { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 56px; }
.game-panel-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; }
.game-panel-canvas { border: 1px solid var(--border); border-radius: 2px; background: #000; }
.game-controls { display: flex; justify-content: center; gap: 6px; padding: 8px 0; touch-action: none; }
.game-btn { width: 60px; height: 60px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); font-size: 1.4rem; display: flex; align-items: center; justify-content: center; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.game-btn:active { background: var(--primary); color: #fff; }
.game-score { text-align: center; font-size: 0.85rem; margin-bottom: 0.25rem; }
.game-score-row { display: flex; justify-content: center; gap: 12px; }
.game-score-row strong { font-size: 1rem; }
.game-score-targets { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.game-score-targets strong { font-size: 0.8rem; color: var(--text); }

/* Game-over leaderboard */
.tetris-leaderboard { width: 100%; border-collapse: collapse; font-size: 0.75rem; }
.tetris-leaderboard th { color: #888; font-weight: 600; padding: 4px 6px; text-align: left; border-bottom: 1px solid #444; position: sticky; top: 0; background: #1a1a1a; }
.tetris-leaderboard td { padding: 3px 6px; border-bottom: 1px solid #333; }
.tetris-leaderboard .tetris-lb-me td { background: rgba(255,255,255,0.08); font-weight: 600; }
.tetris-leaderboard tbody tr:hover { background: rgba(255,255,255,0.05); }

/* Mini-game lobby list */
.minigame-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 0; cursor: pointer; }
.minigame-item + .minigame-item { border-top: 1px solid var(--border); }
.minigame-icon { font-size: 1.5rem; }
.minigame-info { flex: 1; }
.minigame-name { font-weight: 600; }
.minigame-top { font-size: 0.8rem; color: var(--text-muted); }
.minigame-you { font-size: 0.78rem; color: var(--primary); }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
  min-width: 0;
}

.form-select {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-select:focus {
  border-color: var(--primary);
}

.manage-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.manage-section:last-child {
  border-bottom: none;
}

.manage-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.manage-danger {
  background: rgba(231, 76, 60, 0.04);
}

.danger-title {
  color: var(--danger);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

/* ─── Trivia widget (active game) ──────────────────── */

#trivia-widget-slot.trivia-active-mode {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: #1e3a8a;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}

.trivia-widget {
  width: 100%;
  max-width: 480px;
  color: #fff;
}

.trivia-loading {
  text-align: center;
  opacity: 0.7;
  font-size: 1rem;
  padding: 2rem 0;
}

.trivia-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.trivia-title {
  font-weight: 700;
  font-size: 0.9rem;
  opacity: 0.85;
  flex: 1;
}

.trivia-difficulty {
  font-size: 0.78rem;
  opacity: 0.6;
  white-space: nowrap;
}

.trivia-progress {
  font-size: 0.85rem;
  opacity: 0.7;
  white-space: nowrap;
}

.trivia-timer {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  min-width: 3.5rem;
  text-align: right;
}

.tt-mode-badge {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  border-radius: 2rem;
  padding: 0.2rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.tt-streak-badge {
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: #facc15;
  margin-bottom: 0.5rem;
}

.tt-eliminated-banner {
  text-align: center;
  background: rgba(239,68,68,0.25);
  border: 1px solid rgba(239,68,68,0.5);
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.trivia-question {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  margin-bottom: 1.75rem;
  color: #fff;
}

.trivia-choices {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.trivia-choice {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.85rem 1rem;
  background: rgba(255,255,255,0.12);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 0.75rem;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.trivia-choice:active {
  transform: scale(0.98);
  background: rgba(255,255,255,0.2);
}

.trivia-choice--locked {
  cursor: default;
  pointer-events: none;
}

.trivia-choice--selected {
  border-color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.2);
}

.trivia-choice--correct {
  background: #15803d !important;
  border-color: #22c55e !important;
  color: #fff;
}

.trivia-choice--wrong {
  background: rgba(239,68,68,0.35) !important;
  border-color: #ef4444 !important;
  color: #fff;
}

.trivia-choice--wrong .trivia-choice-text {
  text-decoration: line-through;
  opacity: 0.75;
}

.trivia-choice-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.trivia-choice--correct .trivia-choice-letter {
  background: rgba(255,255,255,0.25);
}

.trivia-choice-text {
  flex: 1;
  line-height: 1.3;
}

.tt-answer-count {
  text-align: center;
  font-size: 0.82rem;
  opacity: 0.6;
  margin-bottom: 0.75rem;
  min-height: 1.2em;
}

.tt-scoreboard {
  margin-top: 0.5rem;
}

/* Compact per-question scoreboard rows */
.trivia-scoreboard {
  background: rgba(255,255,255,0.1);
  border-radius: 0.75rem;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.75rem;
}

.trivia-scoreboard-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.55;
  margin-bottom: 0.4rem;
}

.trivia-score-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0;
  font-size: 0.88rem;
}

.trivia-score-rank {
  width: 1.25rem;
  flex-shrink: 0;
  font-size: 0.75rem;
  opacity: 0.55;
}

.trivia-score-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.trivia-score-indicators {
  display: flex;
  gap: 0.1rem;
  flex-shrink: 0;
}

.tri-ind {
  font-size: 0.65rem;
  line-height: 1;
}

.tri-ind--star    { color: #facc15; font-size: 0.75rem; }
.tri-ind--correct { color: #4ade80; }
.tri-ind--wrong   { color: #f87171; }
.tri-ind--answered { color: rgba(255,255,255,0.7); font-size: 0.5rem; }
.tri-ind--miss    { color: rgba(255,255,255,0.2); }

.trivia-score-pts {
  font-weight: 700;
  font-size: 0.88rem;
  white-space: nowrap;
  min-width: 2.5rem;
  text-align: right;
}

.tt-notice {
  text-align: center;
  opacity: 0.7;
  font-size: 0.9rem;
  padding: 1rem 0;
}

.tt-host-controls {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.15);
}

.tt-btn-host {
  flex: 1;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-weight: 700;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 0.5rem;
}

.tt-btn-host:active {
  background: rgba(255,255,255,0.25);
}

.tt-btn-end {
  background: rgba(239,68,68,0.25);
  border-color: rgba(239,68,68,0.5);
}

.tt-btn-end:active {
  background: rgba(239,68,68,0.4);
}

/* Lobby screen */
.trivia-lobby-badge {
  font-size: 0.75rem;
  opacity: 0.6;
  font-style: italic;
  white-space: nowrap;
}

.trivia-lobby-info {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 0.75rem;
  margin-bottom: 1rem;
  overflow: hidden;
}

.trivia-lobby-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.trivia-lobby-stat:last-child {
  border-bottom: none;
}

.trivia-lobby-label {
  font-size: 0.82rem;
  opacity: 0.65;
}

.trivia-lobby-value {
  font-size: 0.9rem;
  font-weight: 700;
}

.trivia-lobby-rules {
  margin-bottom: 1rem;
}

.trivia-lobby-rule {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  border-radius: 2rem;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  margin-right: 0.4rem;
}

.trivia-lobby-players {
  margin-bottom: 1.25rem;
}

.trivia-lobby-players-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.55;
  margin-bottom: 0.5rem;
}

.trivia-checkin-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-height: 2rem;
}

.trivia-checkin-player {
  background: rgba(255,255,255,0.15);
  border-radius: 2rem;
  padding: 0.3rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.trivia-checkin-empty {
  font-size: 0.85rem;
  opacity: 0.5;
  font-style: italic;
}

.trivia-lobby-actions {
  display: flex;
  justify-content: center;
  padding-top: 0.5rem;
}

.tt-btn-start-game {
  width: 100%;
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  background: #fff;
  color: #1e3a8a;
  border: none;
  border-radius: 0.75rem;
}

.tt-btn-start-game:active {
  background: rgba(255,255,255,0.85);
  transform: scale(0.98);
}

.tt-btn-checkin {
  width: 100%;
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 2px solid rgba(255,255,255,0.35);
  border-radius: 0.75rem;
}

.tt-btn-checkin:disabled {
  opacity: 0.55;
  cursor: default;
}

.tt-btn-checkin:not(:disabled):active {
  background: rgba(255,255,255,0.25);
}

/* Completed game leaderboard */
.trivia-complete {
  padding: 1rem;
  color: var(--text);
}

.trivia-winner {
  text-align: center;
  padding: 1.25rem 1rem;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  border-radius: 1rem;
  color: #1c1400;
}

.trivia-winner-trophy {
  font-size: 2.5rem;
  line-height: 1;
  margin-bottom: 0.4rem;
}

.trivia-winner-name {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 0.2rem;
}

.trivia-winner-score {
  font-size: 1rem;
  font-weight: 600;
  opacity: 0.75;
}

.trivia-complete-actions {
  margin-top: 1.25rem;
  display: flex;
  justify-content: center;
}

.tt-btn-dismiss {
  padding: 0.65rem 2.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 2rem;
}

.tt-btn-dismiss:active {
  background: rgba(255, 255, 255, 0.25);
}

.trivia-complete-note {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.trivia-leaderboard {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.trivia-leaderboard-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.trivia-medal {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.trivia-leaderboard-name {
  flex: 1;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trivia-leaderboard-score {
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

.trivia-no-scores {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 1rem 0;
}

/* ─── Trivia admin form ─────────────────────────────── */

.trivia-admin-form {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 16px 20px calc(28px + var(--safe-bottom));
}

.trivia-form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.trivia-form-field:last-of-type {
  border-bottom: none;
}

.trivia-form-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.trivia-form-input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  box-sizing: border-box;
}

.trivia-form-input:focus {
  border-color: var(--primary);
}

.trivia-subject-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.trivia-subject-chip {
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2rem;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.trivia-subject-chip:active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

select.trivia-form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.trivia-toggles {
  border: none;
  padding: 14px 0 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.trivia-toggles legend {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0;
  margin-bottom: 10px;
}

.trivia-toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  cursor: pointer;
}

.trivia-toggle-label:last-child {
  border-bottom: none;
}

.trivia-toggle-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.trivia-form-actions {
  padding-top: 20px;
}

.trivia-form-actions .btn {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
}

/* Subscribers list */

.subscribers-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  min-height: 32px;
}

.subscriber-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.subscriber-name {
  flex: 1;
  font-size: 14px;
}

.btn-remove-subscriber {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: color 0.15s;
}

.btn-remove-subscriber:hover {
  color: var(--danger);
}

.add-subscriber-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.add-subscriber-row .form-input {
  flex: 1;
  padding: 10px 12px;
  font-size: 14px;
}

.spinner-small {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 4px auto;
}

.text-danger {
  color: var(--danger);
}

/* ============================================
   Add Yappers sheet
   ============================================ */

.yappers-topic-label {
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 16px 8px;
  border-bottom: 1px solid var(--border);
}

.yapper-list {
  list-style: none;
  padding: 0;
}

.yapper-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.yapper-item:last-child {
  border-bottom: none;
}

.yapper-name {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================
   YapBot Admin (Control Room)
   ============================================ */

.admin-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
}

.admin-section h3 {
  margin: 0 0 0.75rem 0;
  font-size: 15px;
}

.person-config {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
}

.person-config:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.person-config-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.person-config-header strong {
  flex: 1;
}

.config-form {
  padding-top: 0.25rem;
}

/* ============================================
   Notification History Page
   ============================================ */

.notif-history-page {
  padding: 0.5rem 0;
}

.notif-history-list {
  display: flex;
  flex-direction: column;
}

.notif-history-item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
}

.notif-history-item:last-child {
  border-bottom: none;
}

.notif-history-item:active {
  background: var(--surface);
}

.notif-history-icon {
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.notif-history-body {
  flex: 1;
  min-width: 0;
}

.notif-history-title {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.15rem;
}

.notif-history-preview {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.2rem;
}

.notif-history-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ============================================
   Trivia Widget
   ============================================ */

/* Active game — fixed full-screen blue overlay */
#trivia-widget-slot.trivia-active-mode {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: #1e3a8a;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}

.trivia-widget {
  width: 100%;
  max-width: 480px;
  color: #fff;
}

/* Header bar */
.trivia-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.trivia-title {
  font-weight: 700;
  font-size: 0.9rem;
  opacity: 0.85;
  flex: 1;
}

.trivia-progress {
  font-size: 0.85rem;
  opacity: 0.7;
  white-space: nowrap;
}

.trivia-timer {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  min-width: 3.5rem;
  text-align: right;
}

/* Question text */
.trivia-question {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  margin-bottom: 1.75rem;
  color: #fff;
}

/* Choices — vertical stack */
.trivia-choices {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.trivia-choice {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.75rem;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.trivia-choice:active {
  transform: scale(0.98);
  background: rgba(255, 255, 255, 0.2);
}

.trivia-choice--locked {
  cursor: default;
  pointer-events: none;
}

.trivia-choice--selected {
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.2);
}

.trivia-choice--correct {
  background: #15803d !important;
  border-color: #22c55e !important;
  color: #fff;
}

.trivia-choice--wrong {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: #ef4444 !important;
  color: rgba(255, 255, 255, 0.7);
}

.trivia-choice--wrong .trivia-choice-text {
  text-decoration: line-through;
  text-decoration-color: #ef4444;
  text-decoration-thickness: 2px;
}

.trivia-choice-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.trivia-choice--correct .trivia-choice-letter {
  background: rgba(255, 255, 255, 0.25);
}

.trivia-choice-text {
  flex: 1;
  line-height: 1.3;
}

/* Live scoreboard */
.trivia-scoreboard {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 0.75rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  overflow-x: auto;
}

/* Score table */
.tst {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.tst thead th {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.55;
  padding: 0.25rem 0.3rem;
  white-space: nowrap;
}

.tst tbody tr + tr {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.tst-rank {
  width: 1.2rem;
  text-align: center;
  opacity: 0.5;
  font-size: 0.72rem;
  padding: 0.3rem 0.2rem;
}

.tst-name-col,
.tst-name {
  text-align: left;
  padding: 0.3rem 0.4rem 0.3rem 0.2rem;
}

.tst-name {
  font-weight: 600;
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tst-q-col {
  text-align: center;
  padding: 0.25rem 0.15rem;
}

.tst-pts-col {
  text-align: right;
  padding: 0.25rem 0 0.25rem 0.4rem;
}

.tst-pts {
  text-align: right;
  font-weight: 700;
  padding: 0.3rem 0 0.3rem 0.4rem;
  white-space: nowrap;
}

.tst-cell {
  text-align: center;
  padding: 0.25rem 0.15rem;
  font-size: 0.8rem;
  border-radius: 3px;
}

.tst-cell--star {
  color: #facc15;
  font-size: 0.85rem;
}

.tst-cell--correct {
  color: #4ade80;
}

.tst-cell--wrong {
  color: #f87171;
}

.tst-cell--miss {
  color: rgba(255, 255, 255, 0.2);
  font-size: 0.7rem;
}

.tst-cell--answered {
  color: rgba(255, 255, 255, 0.55);
}

.tst-q-col--live {
  color: #facc15;
  opacity: 1;
}

/* Controls */
.trivia-controls {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.5rem;
}

.trivia-waiting {
  text-align: center;
  font-size: 0.85rem;
  opacity: 0.6;
  font-style: italic;
}

/* Generating state */
.trivia-generating .trivia-header {
  justify-content: center;
}

/* Game-over card — shown inside blue overlay, collapses inline after dismiss */
.trivia-complete {
  padding: 1rem;
  color: #fff;
}

.trivia-complete-msg {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.65);
  margin: 0.5rem 0 0;
}

/* Leaderboard rows styled for blue overlay */
#trivia-widget-slot.trivia-active-mode .trivia-leaderboard-row {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

#trivia-widget-slot.trivia-active-mode .trivia-leaderboard-score {
  color: #facc15;
}

/* Dismiss button (✕) in the overlay header */
.trivia-dismiss-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
  border-radius: 0.4rem;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.trivia-dismiss-btn:hover,
.trivia-dismiss-btn:active {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}

/* Join prompt — inline card shown when game is in progress but user hasn't joined */
.trivia-join-prompt {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 0.75rem;
  margin: 0.5rem 0;
}

.trivia-join-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.trivia-join-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.trivia-join-info strong {
  font-size: 0.9rem;
  color: #1e3a8a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trivia-join-info span {
  font-size: 0.78rem;
  color: #64748b;
}

.trivia-join-btn {
  flex-shrink: 0;
  background: #1e3a8a;
  color: #fff;
  border: none;
  border-radius: 1.5rem;
  padding: 0.45rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.trivia-join-btn:active {
  background: #1e40af;
}

/* Rejoin banner — thin strip shown after leaving mid-game */
.trivia-rejoin-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  color: #1e3a8a;
  margin: 0.5rem 0;
}

.trivia-rejoin-link {
  background: none;
  border: 1px solid #1e3a8a;
  color: #1e3a8a;
  border-radius: 1rem;
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.trivia-rejoin-link:active {
  background: #dbeafe;
}

/* Leave button — small, in overlay header during active game */
.trivia-leave-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.65);
  border-radius: 1rem;
  padding: 0.2rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.trivia-leave-btn:active {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.6);
}

/* Topic list trivia indicator */
.topic-trivia-note {
  display: block;
  font-size: 0.78rem;
  color: #3b82f6;
  font-weight: 600;
  margin-top: 0.15rem;
  line-height: 1.3;
}

/* Avoid-repeats toggle */
.form-check-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  padding: 0.25rem 0 0.75rem;
  user-select: none;
}

.form-check-label input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
  accent-color: var(--primary);
}

/* Subject history chips */
.trivia-subject-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.trivia-history-chip {
  padding: 0.25rem 0.65rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2rem;
  font-size: 0.8rem;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.trivia-history-chip:active {
  background: var(--border);
}

.music-embed-wrap {
  margin-top: 0.5rem;
}

.music-embed {
  width: 100%;
  max-width: 660px;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  display: block;
}

.music-service-links {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}

.music-service-links a {
  font-size: 0.8rem;
  color: var(--text-muted, #888);
  text-decoration: none;
}

.music-service-links a:hover {
  text-decoration: underline;
}

.music-service-links-loading {
  font-size: 0.8rem;
  color: var(--text-muted, #888);
}
.song-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-bottom: 0.4rem;
}
.song-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary, #111);
  line-height: 1.2;
}
.song-artist {
  font-size: 0.82rem;
  color: var(--text-muted, #888);
}
.song-meta--loading {
  font-size: 0.8rem;
  color: var(--text-muted, #888);
}

