/* ===== Reset & tokens ================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0f1117;
  --surface:  #1a1d27;
  --surface2: #22263a;
  --border:   #2e3348;
  --accent:   #6c63ff;
  --accent2:  #00d4aa;
  --danger:   #ff4d6d;
  --text:     #e4e6f1;
  --muted:    #6b7280;
  --radius:   10px;
  --mono:     'JetBrains Mono', 'Fira Code', monospace;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ===== Utility ========================================================= */
.hidden   { display: none !important; }
.muted    { color: var(--muted); }
.mono     { font-family: var(--mono); }

button {
  cursor: pointer;
  font: inherit;
  border: none;
  border-radius: var(--radius);
  transition: background .15s, opacity .15s;
}
button:hover { opacity: .85; }
button:disabled { opacity: .4; cursor: default; }

input, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  outline: none;
  width: 100%;
  transition: border-color .15s;
}
input:focus, textarea:focus { border-color: var(--accent); }

/* ===== Landing (marketing page) ======================================== */
html.in-room #landing { display: none; }   /* avoid content flash on room URLs */
html.in-room .ignlab-footer { display: none !important; }  /* footer is homepage-only */

#landing {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px 80px;
}

/* Hero */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 22px;
  padding: clamp(64px, 12vh, 130px) 0 80px;
}

.hero-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 14px;
  letter-spacing: .3px;
}

.hero h1 {
  font-size: clamp(30px, 5.5vw, 54px);
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1.1;
  max-width: 760px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  color: var(--text);
  opacity: .8;
  font-size: clamp(15px, 2.2vw, 18px);
  line-height: 1.6;
  max-width: 580px;
}

.btn-hero {
  font-size: 16px;
  padding: 15px 36px;
  border-radius: 999px;
  box-shadow: 0 4px 30px rgba(108,99,255,.45);
}

.hero-note { font-size: 12px; }

/* Generic landing section */
.lp-section {
  padding: 48px 0;
  border-top: 1px solid var(--border);
}
.lp-section h2 {
  font-size: clamp(22px, 3.5vw, 30px);
  font-weight: 800;
  letter-spacing: -.5px;
  text-align: center;
  margin-bottom: 36px;
}

/* Feature cards */
.lp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 18px;
}
.lp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px 24px;
  transition: border-color .2s, transform .2s;
}
.lp-card:hover { border-color: var(--accent); transform: translateY(-3px); }
.lp-icon { font-size: 30px; margin-bottom: 12px; }
.lp-card h3 { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.lp-card p  { color: var(--muted); font-size: 14px; line-height: 1.6; }

/* Steps */
.lp-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}
.lp-step { display: flex; gap: 16px; align-items: flex-start; }
.lp-step-n {
  flex-shrink: 0;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  border-radius: 50%;
}
.lp-step h3 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.lp-step p  { color: var(--muted); font-size: 14px; line-height: 1.55; }

/* Benefits */
.lp-benefits {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  max-width: 760px;
  margin: 0 auto;
}
.lp-benefits li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.55;
}
.lp-benefits strong { color: var(--text); }

/* FAQ */
.lp-faq { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.lp-faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 18px;
}
.lp-faq summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  padding: 14px 0;
  list-style: none;
}
.lp-faq summary::-webkit-details-marker { display: none; }
.lp-faq summary::after { content: '+'; float: right; color: var(--accent); font-size: 18px; }
.lp-faq details[open] summary::after { content: '−'; }
.lp-faq details p { color: var(--muted); font-size: 14px; line-height: 1.6; padding: 0 0 16px; }

/* Recent workspaces */
.recent-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  max-width: 760px;
  margin: 0 auto;
}
.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  text-decoration: none;
  color: var(--text);
  transition: border-color .15s, transform .15s;
}
.recent-item:hover { border-color: var(--accent); transform: translateY(-2px); }
.recent-name { font-weight: 600; font-size: 14px; }
.recent-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.recent-host {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* Footer */
.lp-footer { text-align: center; padding-top: 48px; border-top: 1px solid var(--border); }
.lp-footer p { font-size: 13px; margin: 4px 0; }
.lp-footer a { color: var(--accent2); text-decoration: none; }
.lp-footer a:hover { text-decoration: underline; }

/* ===== Modal (nickname entry) ========================================== */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px;
  width: min(420px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-box h2 { font-size: 22px; font-weight: 700; }
.modal-box p  { color: var(--muted); font-size: 13px; }

#btn-join {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 10px;
}

/* ===== Avatar picker (in join modal) =================================== */
.avatar-pick { display: flex; flex-direction: column; gap: 8px; }
.avatar-pick-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
}
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}
.avatar-opt {
  padding: 3px;
  background: var(--surface2);
  border: 2px solid transparent;
  border-radius: 10px;
  line-height: 0;
  transition: border-color .15s, transform .1s, box-shadow .15s;
}
.avatar-opt:hover { border-color: var(--border); transform: translateY(-2px); opacity: 1; }
.avatar-opt.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(108, 99, 255, .35);
}
.avatar-opt svg { display: block; width: 100%; height: auto; border-radius: 6px; }
.pixav { image-rendering: pixelated; }

/* ===== App shell ======================================================= */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== Top bar ========================================================= */
#topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

#topbar .logo {
  font-size: 15px;
  font-weight: 800;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.5px;
}

#room-link {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  transition: border-color .15s;
}
#room-link:hover { border-color: var(--accent); color: var(--text); }

#nick-badge {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
}
#nick-badge span {
  color: var(--accent2);
  font-weight: 600;
}

/* Presence dots */
#presence {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.presence-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px 2px 3px;
  color: var(--accent2);
}
.presence-chip svg { width: 18px; height: 18px; border-radius: 4px; display: block; }
.presence-chip.self { border-color: var(--accent); }

/* ===== Feature tabs ===================================================== */
#tab-bar {
  display: flex;
  gap: 4px;
  padding: 10px 20px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  padding: 8px 18px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  border-radius: 0;
}
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ===== Content area ===================================================== */
#content {
  flex: 1;
  padding: 24px 20px;
  overflow-y: auto;
}

/* ===== Section headers ================================================== */
.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.section-header h2 {
  font-size: 18px;
  font-weight: 700;
}

/* ===== Button variants ================================================== */
.btn-primary   { background: var(--accent);  color: #fff; font-weight: 600; padding: 8px 18px; }
.btn-secondary { background: var(--surface2); color: var(--text); font-weight: 500; padding: 8px 18px; border: 1px solid var(--border); }
.btn-danger    { background: var(--danger);  color: #fff; font-weight: 600; padding: 8px 18px; }
.btn-ghost     { background: transparent; color: var(--muted); padding: 6px 12px; border: 1px solid var(--border); }
.btn-sm        { padding: 5px 12px; font-size: 12px; }

/* ===== Poker tab ======================================================= */
#poker-task-row {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
#poker-task-row input { flex: 1; min-width: 200px; }

.system-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
}
.system-toggle button {
  padding: 7px 20px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}
.system-toggle button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Vote cards row — styled like little playing cards */
#vote-cards {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.vote-card {
  position: relative;
  width: 60px;
  height: 86px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(160deg, var(--surface2), var(--surface));
  color: var(--text);
  cursor: pointer;
  transition: transform .18s cubic-bezier(.3,1.6,.5,1), border-color .18s, box-shadow .18s, background .18s;
  animation: vote-pop-in .35s cubic-bezier(.3,1.6,.5,1) backwards;
  animation-delay: calc(var(--i, 0) * 40ms);
}
@keyframes vote-pop-in {
  from { opacity: 0; transform: translateY(10px) scale(.85); }
  to   { opacity: 1; transform: translateY(0)    scale(1);   }
}
.vote-card .vc-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  font-family: var(--mono);
}
.vote-card .vc-pip {
  position: absolute;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--muted);
  line-height: 1;
}
.vote-card .vc-tl { top: 6px;    left: 7px;  }
.vote-card .vc-br { bottom: 6px; right: 7px; transform: rotate(180deg); }
.vote-card:hover {
  border-color: var(--accent);
  transform: translateY(-6px) rotate(-2deg);
  box-shadow: 0 10px 24px rgba(108,99,255,.28);
}
.vote-card.selected {
  border-color: var(--accent);
  background: linear-gradient(160deg, var(--accent), #564fe0);
  color: #fff;
  transform: translateY(-8px);
  box-shadow: 0 12px 28px rgba(108,99,255,.45);
  animation: vote-bounce .4s cubic-bezier(.3,1.7,.4,1);
}
.vote-card.selected .vc-pip { color: rgba(255,255,255,.8); }
@keyframes vote-bounce {
  0%   { transform: translateY(-8px) scale(1);    }
  40%  { transform: translateY(-14px) scale(1.12); }
  100% { transform: translateY(-8px) scale(1);    }
}

/* Team members grid — 3D flip cards */
#team-grid {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  perspective: 1200px;
}
.team-card {
  width: 104px;
  height: 142px;
  background: transparent;
  border: none;
  padding: 0;
  animation: card-deal .45s cubic-bezier(.2,.9,.3,1.2) backwards;
  animation-delay: calc(var(--i, 0) * 70ms);
}
@keyframes card-deal {
  from { opacity: 0; transform: translateY(24px) rotate(-8deg) scale(.8); }
  to   { opacity: 1; transform: translateY(0)    rotate(0)     scale(1);  }
}
.tc-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .6s cubic-bezier(.4,1.5,.4,1);
  transition-delay: calc(var(--i, 0) * 80ms);
}
/* Only cards that actually voted flip to reveal a value. */
#team-grid.revealed .team-card.voted .tc-inner { transform: rotateY(180deg); }

.tc-front, .tc-back {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--border);
}
/* Front = face-down card back (the patterned side). */
.tc-front {
  background:
    repeating-linear-gradient(45deg, rgba(108,99,255,.12) 0 8px, transparent 8px 16px),
    linear-gradient(160deg, var(--surface2), var(--surface));
}
.team-card.voted .tc-front {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(108,99,255,.35);
  animation: ready-pulse 1.8s ease-in-out infinite;
}
.team-card.empty .tc-front {
  border-style: dashed;
  opacity: .5;
}
.team-card.empty .tc-emblem { opacity: .3; filter: grayscale(1); }
@keyframes ready-pulse {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(108,99,255,.30); }
  50%      { box-shadow: inset 0 0 0 1px rgba(108,99,255,.65), 0 0 16px rgba(108,99,255,.30); }
}
.tc-emblem { font-size: 30px; line-height: 0; }
.tc-emblem svg { width: 44px; height: 44px; border-radius: 9px; display: block; }

/* Back = the revealed value. */
.tc-back {
  transform: rotateY(180deg);
  background: linear-gradient(160deg, var(--surface), #14202a);
  border-color: var(--accent2);
}
.tc-back .tc-value {
  font-size: 38px;
  font-weight: 800;
  font-family: var(--mono);
  color: var(--accent2);
  line-height: 1;
}
.tc-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.poker-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* New-ticket glow when the host sends a ticket to the team. */
.task-flash { animation: task-flash 1.2s ease-out; border-radius: var(--radius); }
@keyframes task-flash {
  0%   { box-shadow: 0 0 0 0 rgba(108,99,255,.65); }
  100% { box-shadow: 0 0 0 14px rgba(108,99,255,0); }
}

#poker-avg {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--accent2);
  font-weight: 700;
}

/* ===== Reveal verdict =================================================== */
.verdict {
  margin-top: 18px;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--border);
  display: inline-block;
  animation: verdict-in .4s cubic-bezier(.3,1.5,.4,1);
}
@keyframes verdict-in {
  from { opacity: 0; transform: translateY(8px) scale(.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1);  }
}
.verdict.consensus {
  color: #021a14;
  background: linear-gradient(135deg, var(--accent2), #00b894);
  border-color: var(--accent2);
}
.verdict.near {
  color: #1a1606;
  background: linear-gradient(135deg, #ffd166, #f4b942);
  border-color: #ffd166;
}
.verdict.spread {
  color: var(--text);
  background: var(--surface2);
  border-color: var(--border);
}

/* ===== Poker history ===================================================== */
#poker-history {
  margin-top: 36px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}
.ph-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}
.ph-hint {
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  opacity: .8;
}
.ph-entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: border-color .15s, transform .15s, background .15s;
}
.ph-entry.clickable { cursor: pointer; }
.ph-entry.clickable:hover {
  border-color: var(--accent);
  background: var(--surface2);
  transform: translateY(-2px);
}
.ph-reopen {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  opacity: 0;
  transition: opacity .15s;
}
.ph-del {
  font-size: 12px;
  font-weight: 700;
  color: var(--danger);
  white-space: nowrap;
  opacity: 0;
  transition: opacity .15s, border-color .15s;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 1px 6px;
  line-height: 1.4;
}
.ph-entry.clickable:hover .ph-reopen,
.ph-entry.clickable:hover .ph-del { opacity: 1; }
.ph-del:hover { border-color: var(--danger); opacity: 1 !important; }

#poker-task[readonly] { opacity: .55; cursor: default; }
.ph-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.ph-task {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.ph-avg {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent2);
  white-space: nowrap;
}
.ph-votes {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.ph-vote {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  min-width: 52px;
}
.ph-nick {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 2px;
  white-space: nowrap;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ph-val {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 800;
  color: var(--accent);
}

/* ===== Retro tab — sticky-note board =================================== */
.retro-hint { font-size: 12px; }

/* Toolbar: piles + tools */
.retro-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.retro-piles { display: flex; gap: 14px; }

/* A pile = a stacked-paper button you pull a fresh note off. */
.pile {
  position: relative;
  width: 96px;
  height: 70px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-weight: 700;
  font-size: 12px;
  color: #2a2310;
  cursor: grab;
  touch-action: none;
  transition: transform .12s ease, box-shadow .12s ease;
}
.pile::before,
.pile::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: inherit;
  border: 1px solid rgba(0,0,0,.18);
  z-index: -1;
}
.pile::before { transform: translate(3px, 3px) rotate(2.5deg); }
.pile::after  { transform: translate(6px, 6px) rotate(-2deg); }
.pile:hover   { transform: translateY(-2px); opacity: 1; }
.pile:active  { cursor: grabbing; }
.pile-emoji   { font-size: 20px; line-height: 1; }
.pile-label   { letter-spacing: .2px; }
.pile-well    { background: #b8e6a0; }
.pile-stumble { background: #ffb3b8; }
.pile-actions { background: #ffe08a; }

.retro-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.size-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}
.size-toggle .st-label { font-size: 11px; color: var(--muted); padding: 0 6px 0 8px; }
.size-toggle button {
  width: 26px;
  height: 24px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
}
.size-toggle button.active { background: var(--accent); color: #fff; }
.retro-dots {
  font-size: 12px;
  color: var(--accent2);
  font-weight: 600;
  white-space: nowrap;
}
.retro-dots.spent { color: var(--danger); }
#retro-clear { padding: 6px 12px; font-size: 12px; }

/* Scrollable viewport over a large canvas */
.retro-viewport {
  position: relative;
  height: calc(100vh - 210px);
  min-height: 360px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(160deg, #15171f, #11131b);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  /* Firefox */
  scrollbar-width: thin;
  scrollbar-color: rgba(108,99,255,.35) transparent;
}
/* Webkit (Chrome, Edge, Safari) */
.retro-viewport::-webkit-scrollbar { width: 8px; height: 8px; }
.retro-viewport::-webkit-scrollbar-track { background: transparent; }
.retro-viewport::-webkit-scrollbar-thumb {
  background: rgba(108,99,255,.35);
  border-radius: 999px;
}
.retro-viewport::-webkit-scrollbar-thumb:hover { background: rgba(108,99,255,.65); }
.retro-viewport::-webkit-scrollbar-corner { background: transparent; }
/* The large board canvas — wider/taller than the viewport so the team can
   spread out and pan left/right by dragging empty space. */
.retro-canvas {
  position: relative;
  width: 2400px;
  height: 1300px;
  cursor: grab;
  background:
    radial-gradient(circle at center, rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(160deg, #15171f, #11131b);
  background-size: 22px 22px, 100% 100%;
}
.retro-canvas.panning { cursor: grabbing; }
/* Zone guides: three equal columns split by two vertical lines */
.retro-zones {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  pointer-events: none;
  z-index: 0;
}
.retro-zones .rz {
  position: relative;
  border-right: 1px dashed rgba(255,255,255,.12);
}
.retro-zones .rz:last-child { border-right: none; }
.retro-zones .rz-well    { background: rgba(120,200,110,.05); }
.retro-zones .rz-stumble { background: rgba(255,110,120,.05); }
.retro-zones .rz-actions { background: rgba(255,200,70,.05); }
.rz-label {
  position: absolute;
  top: 10px; left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  opacity: .8;
}

.retro-empty {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  font-size: 13px;
  text-align: center;
  pointer-events: none;
  z-index: 1;
}

/* A sticky note */
.snote {
  position: absolute;
  width: 168px;
  min-height: 150px;
  padding: 8px 10px 6px;
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #2a2310;
  box-shadow: 0 6px 14px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.25);
  transform: rotate(var(--tilt, -1.5deg));
  transition: left .25s ease, top .25s ease, transform .12s ease, box-shadow .12s ease;
  animation: note-pop .18s cubic-bezier(.2,.9,.3,1.3);
  will-change: left, top;
  z-index: 2;
}
.snote.size-lg { width: 222px; min-height: 200px; }
.snote.size-xs { width: 122px; min-height: 92px; padding: 6px 8px 5px; gap: 2px; }
.snote.size-xs .sn-text { min-height: 46px; font-size: 12px; line-height: 1.25; }
.snote.size-xs .sn-head svg { width: 18px; height: 18px; }
.snote.size-xs .sn-author { display: none; }
.snote.size-xs .sn-foot { padding-top: 2px; }
.snote.kind-well    { background: #c8efb2; }
.snote.kind-stumble { background: #ffc2c6; }
.snote.kind-actions { background: #ffe79a; }
@keyframes note-pop { from { opacity: 0; transform: rotate(var(--tilt,-1.5deg)) scale(.85); } to { opacity: 1; } }

.snote.dragging {
  transition: none;
  transform: rotate(0deg) scale(1.04);
  box-shadow: 0 16px 30px rgba(0,0,0,.45);
  cursor: grabbing;
  z-index: 999 !important;
}

/* Note header = drag grip + avatar + tools */
.sn-head {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: grab;
  touch-action: none;
  min-height: 22px;
}
.sn-head svg { width: 22px; height: 22px; border-radius: 4px; display: block; flex-shrink: 0; }
/* The whole grip (incl. children the press may land on) must not pan-scroll,
   or touch devices fire pointercancel mid-drag and the drop is lost. */
.pile, .pile *, .sn-head, .sn-head * { touch-action: none; }
.sn-author { font-size: 10px; font-weight: 700; color: rgba(0,0,0,.5); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sn-tools { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.snote:hover .sn-tools { opacity: 1; }
.sn-tools button {
  width: 20px; height: 20px;
  border-radius: 5px;
  background: rgba(0,0,0,.08);
  color: rgba(0,0,0,.6);
  font-size: 12px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.sn-tools button:hover { background: rgba(0,0,0,.18); opacity: 1; }

/* Editable text */
.sn-text {
  flex: 1 1 auto;
  width: 100%;
  min-height: 84px;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  color: #221c0c;
  font-family: 'Segoe Print', 'Comic Sans MS', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.35;
  overflow: hidden;
}
.snote.size-lg .sn-text { min-height: 132px; }
.sn-text::placeholder { color: rgba(0,0,0,.35); }
.sn-text[readonly] { cursor: default; }

/* Vote footer */
.sn-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px dashed rgba(0,0,0,.18);
}
.sn-vote-btn {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: rgba(0,0,0,.1);
  color: #2a2310;
  font-weight: 800;
  font-size: 13px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.sn-vote-btn:hover { background: rgba(0,0,0,.2); opacity: 1; }
.sn-vote-btn:disabled { opacity: .3; cursor: not-allowed; }
.sn-yours { font-size: 10px; font-weight: 700; color: rgba(0,0,0,.55); min-width: 26px; text-align: center; }
.sn-total {
  margin-left: auto;
  font-size: 12px;
  font-weight: 800;
  color: #2a2310;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.sn-total.has-votes { color: #1f6f3a; }

/* Ghost note dragged out of a pile */
.snote.ghost {
  position: fixed;
  margin: 0;
  pointer-events: none;
  opacity: .9;
  transform: rotate(-3deg) scale(1.02);
  z-index: 1000;
  transition: none;
}

@media (max-width: 560px) {
  .retro-toolbar { flex-direction: column; align-items: stretch; }
  .pile { width: 84px; height: 62px; }
  .retro-canvas { min-height: 72vh; }
}

/* ===== Hangman tab ====================================================== */
.hm-layout {
  display: flex;
  gap: 40px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.hm-left {
  flex-shrink: 0;
  width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.gallows-svg {
  width: 100%;
  color: var(--text);
  opacity: .9;
}
.hm-wrong-count {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--muted);
  font-weight: 600;
}
.hm-wrong-count.hm-danger { color: var(--danger); }

.hm-right { flex: 1; min-width: 260px; }
.hm-hint {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent2);
  background: rgba(0,212,170,.1);
  border: 1px solid rgba(0,212,170,.3);
  border-radius: 999px;
  padding: 3px 12px;
  margin-bottom: 18px;
  letter-spacing: .3px;
}

.hm-word {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
  min-height: 58px;
  align-items: flex-end;
}
.hm-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 50px;
  border-bottom: 3px solid var(--text);
  font-size: 24px;
  font-weight: 800;
  font-family: var(--mono);
  color: var(--accent2);
  text-transform: uppercase;
  animation: letter-pop .2s cubic-bezier(.3,1.5,.4,1);
}
@keyframes letter-pop {
  from { transform: scale(.6); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}
.hm-letter.blank { border-bottom-color: var(--border); }
.hm-letter.miss  { color: var(--danger); border-bottom-color: var(--danger); }
.hm-placeholder  {
  font-size: 28px;
  font-weight: 800;
  font-family: var(--mono);
  color: var(--muted);
  letter-spacing: 10px;
  opacity: .3;
  align-self: center;
}

.hm-turn {
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.hm-turn.your-turn {
  background: rgba(108,99,255,.12);
  border-color: var(--accent);
  color: var(--accent);
}
.hm-turn.their-turn {
  background: rgba(255,255,255,.04);
  border-color: var(--border);
  color: var(--muted);
}

.hm-result {
  font-size: 16px;
  font-weight: 700;
  padding: 13px 18px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  animation: verdict-in .4s cubic-bezier(.3,1.5,.4,1);
}
.hm-won {
  background: rgba(0,212,170,.1);
  border: 1px solid var(--accent2);
  color: var(--accent2);
}
.hm-lost {
  background: rgba(255,77,109,.08);
  border: 1px solid var(--danger);
  color: var(--danger);
}

.hm-keyboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 22px;
}
.hm-key-row { display: flex; gap: 5px; }
.hm-key {
  width: 38px;
  height: 44px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  font-family: var(--mono);
  transition: background .12s, border-color .12s, transform .1s;
  flex-shrink: 0;
}
.hm-key:hover:not([disabled]) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: translateY(-2px);
  opacity: 1;
}
.hm-key.correct {
  background: rgba(0,212,170,.18);
  border-color: var(--accent2);
  color: var(--accent2);
  opacity: .8;
}
.hm-key.wrong {
  background: rgba(255,77,109,.12);
  border-color: var(--danger);
  color: var(--danger);
  opacity: .65;
  text-decoration: line-through;
}
.hm-key.guessed  { opacity: .25; }
.hm-key.inactive { opacity: .35; cursor: default; }

.hm-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

@media (max-width: 560px) {
  .hm-layout { gap: 20px; }
  .hm-left { width: 110px; }
  .hm-key  { width: 30px; height: 36px; font-size: 11px; }
  .hm-letter { width: 32px; height: 42px; font-size: 18px; }
}

/* ===== Kanban tab ======================================================= */
#kanban-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.kanban-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 300px;
}

.kanban-col h3 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.kanban-count {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  padding: 1px 7px;
  color: var(--muted);
  font-weight: 600;
}

.kanban-add-row { display: flex; gap: 6px; }
.kanban-add-row input { font-size: 13px; padding: 6px 10px; }
.kanban-add-row button {
  padding: 6px 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  border-radius: var(--radius);
  flex-shrink: 0;
}

.kanban-cards { display: flex; flex-direction: column; gap: 8px; flex: 1; }

.kanban-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  animation: fadein .2s ease;
}
.kanban-card .kc-text { flex: 1; word-break: break-word; }

.kc-actions { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.kc-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, color .15s;
}
.kc-btn:hover { border-color: var(--accent); color: var(--text); }
.kc-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

/* ===== Sprint Sketch ==================================================== */
.sk-waiting { padding: 40px 0; text-align: center; font-size: 15px; }

.sk-host-controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}
.sk-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  white-space: nowrap;
}
.sk-mode-row, .sk-prompt-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sk-mode-toggle { display: flex; gap: 6px; flex-wrap: wrap; }
.sk-mode-toggle button {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  transition: background .15s, color .15s, border-color .15s;
}
.sk-mode-toggle button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.sk-prompt-row input { flex: 1; min-width: 200px; }
.sk-btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

.sk-game { display: flex; flex-direction: column; gap: 12px; }

.sk-prompt-banner {
  background: linear-gradient(135deg, rgba(108,99,255,.18), rgba(0,212,170,.1));
  border: 1px solid rgba(108,99,255,.3);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  letter-spacing: .2px;
}

.sk-meta-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  min-height: 32px;
}
.sk-turn-info {
  font-size: 13px;
  font-weight: 600;
}
.sk-turn-info.your-turn { color: var(--accent2); }
.sk-turn-info.their-turn { color: var(--muted); }

.sk-timer {
  font-size: 13px;
  font-weight: 800;
  font-family: var(--mono);
  color: var(--accent2);
  background: rgba(0,212,170,.1);
  border: 1px solid rgba(0,212,170,.25);
  border-radius: 999px;
  padding: 2px 12px;
  min-width: 70px;
  text-align: center;
}
.sk-timer.urgent { color: var(--danger); background: rgba(255,77,109,.1); border-color: rgba(255,77,109,.3); }

.sk-canvas-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #1e1e2e;
  width: 100%;
  aspect-ratio: 5 / 3;
}
#sk-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}
#sk-canvas.not-my-turn { cursor: not-allowed; }

.sk-canvas-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15,17,23,.7);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  pointer-events: none;
  backdrop-filter: blur(2px);
}

.sk-palette {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}
.sk-colors { display: flex; gap: 6px; flex-wrap: wrap; }
.sk-color {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
  transition: transform .1s, border-color .1s;
}
.sk-color:hover { transform: scale(1.2); opacity: 1; }
.sk-color.active { border-color: #fff; transform: scale(1.15); }

.sk-brush-row { display: flex; align-items: center; gap: 8px; }
#sk-brush-size { width: 80px; }
.sk-eraser-btn { font-size: 12px; padding: 4px 12px; }
.sk-eraser-btn.active { background: var(--accent); color: #fff; }

.sk-reveal {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sk-reveal-header {
  text-align: center;
  padding: 6px 0;
}
.sk-reveal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.sk-reveal-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.sk-reveal-canvas {
  width: 100%;
  height: auto;
  border-radius: 6px;
  display: block;
  background: #1e1e2e;
}
.sk-reveal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sk-reveal-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

@media (max-width: 600px) {
  .sk-palette { gap: 8px; }
  .sk-canvas-wrap { aspect-ratio: 4 / 3; }
  .sk-reveal-grid { grid-template-columns: 1fr; }
}

/* ===== Toast ============================================================ */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 18px;
  font-size: 13px;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  animation: fadein .2s ease;
}
.toast.ok     { border-left: 3px solid var(--accent2); }
.toast.error  { border-left: 3px solid var(--danger); }

/* ===== Responsive tweaks ================================================ */
@media (max-width: 540px) {
  #topbar { padding: 10px 14px; }
  #content { padding: 16px 12px; }
  #tab-bar { padding: 8px 12px 0; overflow-x: auto; }
  .tab-btn { font-size: 12px; padding: 8px 12px; white-space: nowrap; }
}
