:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1a1d23;
  --muted: #6b7280;
  --border: #e2e4e9;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --card-selected: #eef2ff;
  --success: #15803d;
  --outlier-low: #2563eb;
  --outlier-low-bg: #eff6ff;
  --outlier-high: #d97706;
  --outlier-high-bg: #fffbeb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1d2026;
    --text: #e8e9ec;
    --muted: #9aa0ab;
    --border: #2c303a;
    --accent: #6366f1;
    --accent-text: #ffffff;
    --card-selected: #2a2a55;
    --success: #4ade80;
    --outlier-low: #60a5fa;
    --outlier-low-bg: #1e2a47;
    --outlier-high: #fbbf24;
    --outlier-high-bg: #3a2e10;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

.app-header {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
}

.app-header h1 { margin: 0 0 0.25rem; font-size: 1.75rem; }
.tagline { margin: 0; color: var(--muted); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.panel h2 { margin-top: 0; font-size: 1.05rem; }

label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.35rem; }

input[type="text"] {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

button {
  font-size: 0.95rem;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  margin-top: 0.75rem;
}

button.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }

button.flash { outline: 2px solid var(--success); }

.share-row { display: flex; gap: 0.5rem; }
.share-row input { flex: 1; }
.share-row button { margin-top: 0; white-space: nowrap; }

.participants { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }

.participant {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: var(--bg);
}

.participant.outlier-low {
  background: var(--outlier-low-bg);
  box-shadow: inset 3px 0 0 var(--outlier-low);
}
.participant.outlier-high {
  background: var(--outlier-high-bg);
  box-shadow: inset 3px 0 0 var(--outlier-high);
}
.participant.outlier-low .participant-card { color: var(--outlier-low); }
.participant.outlier-high .participant-card { color: var(--outlier-high); }

.participant-card {
  font-weight: 600;
  min-width: 2rem;
  text-align: center;
}

.deck { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.card {
  margin-top: 0;
  width: 3.25rem;
  height: 4.25rem;
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 1.1rem;
  font-weight: 600;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.card:hover { transform: translateY(-3px); }
/* :hover never fires on touch, so give taps their own press feedback. */
.card:active { transform: scale(0.95); background: var(--card-selected); }

.card.selected {
  background: var(--card-selected);
  border-color: var(--accent);
  color: var(--accent);
}

.controls { display: flex; gap: 0.75rem; }
.controls button { margin-top: 0; }

.stats { transition: opacity 200ms ease, transform 200ms ease; }
.stats.just-revealed { opacity: 0.4; transform: scale(0.98); }

.footnote { color: var(--muted); font-size: 0.8rem; text-align: center; }

code { background: var(--bg); padding: 0.1rem 0.4rem; border-radius: 4px; }

.chat-log {
  list-style: none;
  margin: 0 0 0.75rem;
  /* Top padding gives the hover picker's negative offset (see
     .chat-react-picker) headroom to sit in without being clipped by
     overflow-y: auto — padding is inside the scroll box's own clip
     edge, unlike a plain negative margin/offset with no padding would
     be. This is what actually fixes the picker-gets-clipped bug; the
     hover mechanism itself was never the problem. */
  padding: 1rem 0 0;
  max-height: 14rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-hint { margin: -0.25rem 0 0.5rem; color: var(--muted); font-size: 0.75rem; }

.chat-message {
  position: relative;
  background: var(--bg);
  border-radius: 8px;
  padding: 0.4rem 2.2rem 0.4rem 0.6rem; /* right space reserved for .react-toggle */
  font-size: 0.9rem;
}

.chat-message-self { border-left: 3px solid var(--accent); }

.chat-meta { display: block; color: var(--muted); font-size: 0.75rem; margin-bottom: 0.15rem; }

.chat-text { word-break: break-word; }
.chat-text a { color: var(--accent); }

.chat-reactions:not(:empty) { display: block; margin-top: 0.3rem; }

/* Always-visible, works identically on mouse and touch (no :hover or
   long-press dependency). Hover on .chat-message is kept as a bonus
   quick-reveal for desktop mouse users — see .chat-react-picker below —
   but this button is the guaranteed way in on every device. */
.react-toggle {
  position: absolute;
  top: 0.3rem;
  right: 0.4rem;
  margin-top: 0;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 50%;
}

.react-toggle:hover { background: var(--panel); color: var(--text); }

.reaction-chip {
  display: inline-block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
  margin-right: 0.25rem;
  font-size: 0.8rem;
}

/* Reveal-to-react: hidden by default, shown on hover (mouse), keyboard
   focus, or a long-press (touch — see wireLongPress in render.js, which
   toggles .picker-open since touch has no real :hover state). */
.chat-react-picker {
  position: absolute;
  top: -0.9rem;
  right: 0.4rem;
  display: flex;
  gap: 0.2rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.chat-message:hover .chat-react-picker,
.chat-message.picker-open .chat-react-picker,
.chat-react-picker:focus-within {
  opacity: 1;
  pointer-events: auto;
}

.react-btn {
  margin-top: 0;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
}

.react-btn:hover, .react-btn:active { background: var(--bg); }

.chat-form { display: flex; gap: 0.5rem; }
.chat-form input { flex: 1; }
.chat-form button { margin-top: 0; white-space: nowrap; }
