:root {
  --bg: #000;
  --fg: #fff;
  --muted: #666;
  --surface: #111;
  --border: #222;
  --font: 'IBM Plex Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-weight: 300;
}

body.grain:not(.admin-body) {
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

html {
  overflow-x: hidden;
}

.grain::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 1000;
}

.muted { color: var(--muted); font-size: 0.75rem; letter-spacing: 0.15em; }
.error { color: #f55; font-size: 0.8rem; }
.hidden { display: none !important; }
.center { text-align: center; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.overlay-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem;
  align-items: flex-start;
}

.overlay-scroll .overlay-box {
  margin: auto;
  flex-shrink: 0;
}

.overlay-box {
  text-align: center;
  padding: 2rem 2.25rem;
  max-width: 360px;
  width: calc(100% - 2rem);
  margin: 1rem;
}

.modal-box {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1.25rem;
  border: 1px solid var(--border);
  background: #0a0a0a;
}

.modal-title {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
}

.modal-row {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
  width: 100%;
}

.modal-row input {
  flex: 1;
  min-width: 0;
  padding: 0.85rem 1rem;
}

.modal-submit {
  flex-shrink: 0;
  width: 3rem;
  padding: 0.85rem 0;
  font-size: 1.1rem;
}

.modal-input-full,
.modal-btn-full {
  width: 100%;
  padding: 0.85rem 1rem;
}

.modal-box .error {
  margin: -0.5rem 0 0;
  min-height: 1rem;
}

.btn-link {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.5rem;
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  color: var(--muted);
}

.btn-link:hover {
  color: var(--fg);
}

.brand, .brand-sm {
  letter-spacing: clamp(0.35em, 4vw, 0.55em);
  font-weight: 400;
  white-space: nowrap;
}

.brand-sm {
  font-size: clamp(1.05rem, 5.5vw, 1.45rem);
  font-weight: 400;
  color: #fff;
  text-shadow: 0 0 28px rgba(255, 255, 255, 0.18);
  line-height: 1;
}

.brand { font-size: 1.25rem; margin: 1rem 0 0.5rem; }

.main {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 clamp(0.65rem, 3vw, 1rem) 3.75rem;
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 0.75rem;
  width: 100%;
  padding: clamp(0.65rem, 2vh, 1.1rem) 0 clamp(0.35rem, 1vh, 0.6rem);
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: clamp(0.15rem, 0.5vh, 0.35rem);
}

.header-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(0.5rem, 3vw, 0.85rem);
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.15rem 0;
}

.logo-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(36px, 10vw, 48px);
  height: clamp(36px, 10vw, 48px);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.06) 0%, transparent 70%);
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.07);
}

.logo-sm {
  width: 100%;
  height: 100%;
  flex-shrink: 0;
  display: block;
}

.online-badge {
  flex: 0 1 100%;
  font-size: clamp(0.5rem, 2.2vw, 0.6rem);
  color: var(--muted);
  text-align: center;
  letter-spacing: 0.08em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  padding: 0 0.25rem;
  opacity: 0.85;
}

.timer-section {
  text-align: center;
  padding: clamp(0.35rem, 1.5vh, 1rem) 0 clamp(0.25rem, 1vh, 0.75rem);
  flex-shrink: 0;
}

.timer-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem 1rem;
  max-width: 420px;
  margin: 0 auto;
}

.timer-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.timer-val {
  font-size: clamp(1.5rem, 6vw, 2.75rem);
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.timer-lbl {
  font-size: clamp(0.45rem, 2vw, 0.55rem);
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: lowercase;
  text-align: center;
  line-height: 1.2;
}

.timer-label { margin-top: clamp(0.35rem, 1vh, 0.75rem); }

.chat-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tabs {
  flex-shrink: 0;
}

.flicker {
  animation: flicker 8s infinite;
}

@keyframes flicker {
  0%, 97%, 100% { opacity: 1; }
  98% { opacity: 0.85; }
  99% { opacity: 1; }
}

.timer-label { margin-top: clamp(0.35rem, 1vh, 1rem); }

@media (max-width: 380px) {
  .timer-grid {
    gap: 0.35rem 0.5rem;
    max-width: 100%;
  }
}

@media (max-height: 640px) {
  .timer-section {
    padding: 0.25rem 0 0.2rem;
  }
  .timer-val {
    font-size: clamp(1.15rem, 5vw, 1.65rem);
  }
  .timer-label {
    margin-top: 0.25rem;
    font-size: 0.65rem;
  }
  .header {
    padding-top: 0.3rem;
  }
}

@media (min-width: 520px) {
  .header {
    flex-wrap: nowrap;
    justify-content: space-between;
    padding-bottom: 0.75rem;
  }
  .header-brand {
    flex: 1 1 auto;
    justify-content: center;
  }
  .online-badge {
    flex: 0 0 auto;
    max-width: 38%;
    text-align: right;
  }
}

input, button {
  font-family: var(--font);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
}

input:focus, button:focus { outline: 1px solid var(--muted); }

button {
  cursor: pointer;
  letter-spacing: 0.1em;
}

button:hover { border-color: var(--muted); }

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.tab {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.65rem 0.35rem;
  font-size: clamp(0.55rem, 2.5vw, 0.65rem);
  color: var(--muted);
  min-width: 0;
}

.tab.active {
  color: var(--fg);
  border-bottom-color: var(--fg);
}

.panel { display: none; flex: 1; min-height: 0; flex-direction: column; overflow: hidden; }
.panel.active { display: flex; }

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid var(--border);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  line-height: 1.6;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.messages::-webkit-scrollbar {
  display: none;
}

.chat-form {
  flex-shrink: 0;
}

.room-active {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.room-active.hidden {
  display: none !important;
}

.rooms-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
}

.rooms-list::-webkit-scrollbar {
  display: none;
}

.msg { margin-bottom: 0.5rem; word-break: break-word; }
.msg .name { color: var(--muted); margin-right: 0.5rem; }
.msg-deleted { opacity: 0.55; }
.msg-deleted .name { text-decoration: line-through; }
.msg-deleted-text {
  color: var(--muted);
  font-style: italic;
  letter-spacing: 0.06em;
}
.msg-pending { opacity: 0.55; }
.msg-system {
  opacity: 0.85;
  letter-spacing: 0.04em;
}
.msg-system .name {
  color: var(--fg);
  opacity: 0.7;
}
.msg-system:not(.msg-deleted) span:last-child {
  font-style: italic;
}

/* ARG — signal page */
.signal-body, .dossier-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.signal-wrap, .dossier-wrap {
  width: min(32rem, 92vw);
  padding: 2rem 1rem;
}
.signal-header, .dossier-header {
  letter-spacing: 0.2em;
  margin-bottom: 1.5rem;
}
.signal-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}
.signal-form input {
  flex: 1;
  background: #111;
  border: 1px solid #222;
  color: var(--fg);
  padding: 0.5rem;
  font-family: inherit;
}
.signal-form button {
  background: transparent;
  border: 1px solid #333;
  color: var(--fg);
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-family: inherit;
}
.signal-log {
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--muted);
}
.signal-hint { margin-top: 0.75rem; font-size: 0.85rem; }
.signal-back, .dossier-back { margin-top: 2rem; }
.signal-footer { margin-top: 1rem; }

/* ARG — dossier page */
.dossier-sub { margin-bottom: 2rem; }
.dossier-block { margin-bottom: 1.25rem; }
.dossier-val { font-size: 1.05rem; }
.dossier-fragments {
  margin: 2rem 0;
  padding-top: 1rem;
  border-top: 1px solid #222;
}
.dossier-fragments p { margin-bottom: 0.5rem; font-style: italic; }
.dossier-truth { margin-top: 1.5rem; }
.dossier-teaser { margin-top: 1rem; font-size: 0.85rem; }
.recap-dossier-link {
  color: var(--fg);
  text-decoration: none;
  letter-spacing: 0.08em;
}
.recap-dossier-link:hover { text-decoration: underline; }

.chat-form {
  display: flex;
  gap: 0.5rem;
}

.chat-form input { flex: 1; }

.rooms-toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.rooms-toolbar input { width: 5rem; text-transform: uppercase; }

.rooms-list { margin-bottom: 1rem; }

.room-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  cursor: pointer;
}

.room-item:hover { color: var(--muted); }

.room-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
}

.owner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.owner-actions button { font-size: 0.65rem; padding: 0.35rem 0.5rem; }

.check { display: block; margin: 0; font-size: 0.8rem; color: var(--muted); text-align: left; }

/* Recap */
.recap-body { overflow: hidden; }

.recap-credits {
  height: 70vh;
  overflow: hidden;
  position: relative;
  mask-image: linear-gradient(transparent, #000 10%, #000 90%, transparent);
}

.credits-inner {
  animation: scroll-up 120s linear infinite;
  text-align: center;
  padding: 2rem;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  line-height: 2;
}

.credits-title { font-size: 1.2rem; letter-spacing: 0.5em; }
.credits-gap { height: 2rem; }
.credits-name { color: var(--muted); font-size: 0.75rem; }

@keyframes scroll-up {
  from { transform: translateY(100%); }
  to { transform: translateY(-100%); }
}

.recap-readonly {
  padding: 2rem;
  border-top: 1px solid var(--border);
}

/* Admin */
.admin-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
  font-size: 0.8rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.stat-box {
  border: 1px solid var(--border);
  padding: 1rem;
  text-align: center;
}

.stat-box .val { font-size: 1.5rem; display: block; margin-top: 0.5rem; }

.heatmap {
  display: grid;
  gap: 2px;
  margin: 1rem 0;
  max-width: 400px;
}

.heatmap-cell {
  aspect-ratio: 1;
  background: #111;
  min-width: 12px;
}

.admin-tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.admin-tabs button { font-size: 0.7rem; }

.warning-row {
  border: 1px solid var(--border);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}

.warning-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; }
.warning-actions button { font-size: 0.65rem; }

.badge {
  background: #400;
  color: #f88;
  padding: 0.15rem 0.4rem;
  font-size: 0.65rem;
  margin-left: 0.5rem;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 120px;
  margin: 1rem 0 2rem;
  overflow-x: auto;
  padding-bottom: 1.2rem;
}

.bar-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 14px;
  height: 100%;
  position: relative;
}

.bar-fill {
  width: 100%;
  background: #555;
  min-height: 2px;
  margin-top: auto;
}

.bar-lbl {
  font-size: 0.5rem;
  color: var(--muted);
  position: absolute;
  bottom: -1rem;
  transform: rotate(-45deg);
  white-space: nowrap;
}

.admin-table-wrap { overflow-x: auto; margin: 1rem 0; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.7rem;
}

.admin-table th,
.admin-table td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.5rem;
  text-align: left;
}

.admin-table th { color: var(--muted); font-weight: 400; }

.admin-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.admin-actions button { font-size: 0.6rem; }

.admin-filter-row { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.admin-filter-row button.active { border-color: #fff; }

.mod-msg {
  border: 1px solid var(--border);
  padding: 0.6rem;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
}

.mod-msg.deleted { opacity: 0.4; }
.mod-msg-meta { margin-bottom: 0.35rem; font-size: 0.65rem; }

/* Admin page: allow scroll (main site keeps overflow:hidden) */
body.admin-body {
  overflow-x: hidden;
  overflow-y: auto;
  height: auto;
  min-height: 100vh;
}

body.admin-body .admin-wrap {
  padding-bottom: 3rem;
}

/* Site announcement — cinématique droite → gauche → pause */
.announcement {
  overflow: hidden;
  font-size: 0.78rem;
  font-weight: 400;
  color: #fff;
  padding: 0.55rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.35);
  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
  background: linear-gradient(90deg, #050505 0%, #151515 50%, #050505 100%);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  flex-shrink: 0;
  width: 100%;
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.04);
  transition: box-shadow 0.35s ease;
}

.announcement.announcement-active {
  box-shadow: 0 0 32px rgba(255, 255, 255, 0.1);
}

.announcement-viewport {
  overflow: hidden;
  width: 100%;
  mask-image: linear-gradient(90deg, transparent 0%, #000 8%, #000 92%, transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 8%, #000 92%, transparent 100%);
}

.announcement-track {
  display: inline-flex;
  width: max-content;
  will-change: transform;
}

.announcement-text {
  display: inline-block;
  white-space: nowrap;
  color: #fff;
  flex-shrink: 0;
}

@media (prefers-reduced-motion: reduce) {
  .announcement-viewport {
    mask-image: none;
    -webkit-mask-image: none;
  }
  .announcement-track {
    width: 100%;
    justify-content: center;
    transform: none !important;
  }
}

.controls-status {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  margin-bottom: 1rem;
  min-height: 1rem;
}

.controls-status.pending { color: #888; }
.controls-status.ok { color: #6a6; }
.controls-status.err { color: #f66; }

/* Share & contact FABs */
.contact-fab,
.share-fab {
  position: fixed;
  bottom: max(0.85rem, env(safe-area-inset-bottom, 0.85rem));
  z-index: 200;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border);
  background: rgba(10, 10, 10, 0.9);
  color: var(--fg);
  font-family: var(--font);
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.contact-fab {
  left: max(0.85rem, env(safe-area-inset-left, 0.85rem));
  font-size: 0.9rem;
}

.share-fab {
  right: max(0.85rem, env(safe-area-inset-right, 0.85rem));
}

.contact-fab:hover,
.share-fab:hover {
  border-color: #444;
  background: #111;
}

.contact-modal {
  max-width: min(340px, calc(100vw - 2rem));
  gap: 0.65rem;
}

.contact-hint {
  margin: 0;
  text-align: left;
  font-size: 0.6rem;
  line-height: 1.4;
}

.contact-textarea {
  width: 100%;
  min-height: 7rem;
  max-height: 28vh;
  resize: vertical;
  padding: 0.75rem;
  font-family: var(--font);
  font-size: 0.8rem;
  line-height: 1.5;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
}

.contact-honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.share-modal {
  max-width: min(300px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
}

.share-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 2;
  background: #0a0a0a;
  padding-bottom: 0.25rem;
  margin: -0.25rem 0 0;
}

.share-modal-title {
  margin: 0;
  text-align: left;
}

.share-close-x {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  background: #111;
  color: var(--fg);
  font-family: var(--font);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.share-close-x:hover {
  border-color: #555;
  background: #1a1a1a;
}

.share-btn {
  padding: 0.65rem 0.75rem;
  font-size: 0.7rem;
}

.share-tabs {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  margin-bottom: 0.5rem;
}

.share-format-tabs {
  margin-bottom: 0.35rem;
}

.share-tab {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  cursor: pointer;
}

.share-tab.active {
  color: var(--fg);
  border-color: #444;
  background: #111;
}

.share-preview-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  background: #000;
  border: 1px solid var(--border);
  padding: 0.35rem;
  max-height: min(38vh, 320px);
  overflow: hidden;
}

.share-preview {
  display: block;
  width: auto;
  height: 100%;
  max-height: min(36vh, 300px);
  max-width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: contain;
}

.share-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.share-btn-primary {
  border-color: #555;
  background: #1a1a1a;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
}

.share-btn-primary:hover {
  border-color: #777;
  background: #222;
}

.share-btn-muted {
  color: var(--muted);
  font-size: 0.6rem;
}

.share-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  width: 100%;
}

.share-actions-row .share-btn {
  padding: 0.55rem 0.4rem;
  font-size: 0.58rem;
}

.share-status {
  margin: 0;
  text-align: center;
  min-height: 1rem;
}

/* legacy static announcement fallback removed */
