/* ─────────────────────────────────────────────────────────────
   Design System — Refinement Poker
   ───────────────────────────────────────────────────────────── */
:root {
  --blue:        #3B82F6;
  --blue-light:  #DBEAFE;
  --blue-dark:   #1D4ED8;
  --blue-hover:  #4078ED;
  --gray-50:     #F9FAFB;
  --gray-100:    #F3F4F6;
  --gray-200:    #E5E7EB;
  --gray-300:    #D1D5DB;
  --gray-400:    #9CA3AF;
  --gray-500:    #6B7280;
  --gray-700:    #374151;
  --gray-900:    #111827;
  --green:       #22C55E;
  --red:         #EF4444;
  --white:       #FFFFFF;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:   0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.05);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius-sm); border: none;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all .15s;
  text-decoration: none; white-space: nowrap;
}
.btn-primary {
  background: var(--blue); color: var(--white);
}
.btn-primary:hover { background: var(--blue-hover); }
.btn-secondary {
  background: var(--white); color: var(--gray-700);
  border: 1.5px solid var(--gray-200);
}
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-300); }
.btn-ghost {
  background: transparent; color: var(--blue); padding: 6px 12px;
}
.btn-ghost:hover { background: var(--blue-light); }
.btn-lg { padding: 14px 32px; font-size: 16px; border-radius: var(--radius); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); width: 38px; height: 38px; }
.btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.btn:disabled { cursor: not-allowed; }

/* ── Form fields ─────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--gray-700); margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font);
  background: var(--white); color: var(--gray-900);
  transition: border-color .15s;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.field textarea { resize: vertical; min-height: 80px; }
.field-row { display: flex; gap: 12px; }

/* ── Toggle switch ───────────────────────────────────────────── */
.toggle-wrap {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 0; border-bottom: 1px solid var(--gray-100);
}
.toggle-wrap:last-child { border-bottom: none; }
.toggle-info { flex: 1; }
.toggle-info strong { display: block; font-size: 14px; font-weight: 600; color: var(--gray-900); }
.toggle-info span { font-size: 12px; color: var(--gray-500); }
.toggle {
  position: relative; width: 44px; height: 24px; flex-shrink: 0; margin-top: 1px;
}
.toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.toggle input:focus-visible + .toggle-slider { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 24px; }
.toggle-slider {
  position: absolute; inset: 0; background: var(--gray-300);
  border-radius: 24px; cursor: pointer; transition: background .2s;
}
.toggle-slider::before {
  content: ''; position: absolute; width: 18px; height: 18px;
  left: 3px; top: 3px; background: var(--white); border-radius: 50%;
  transition: transform .2s; box-shadow: var(--shadow);
}
.toggle input:checked + .toggle-slider { background: var(--blue); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--white); border-radius: var(--radius);
  padding: 28px; width: 100%; max-width: 480px;
  box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto;
}
.modal-title {
  font-size: 18px; font-weight: 700; margin-bottom: 20px; color: var(--gray-900);
}
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.modal-subtitle  { font-size: 14px; color: var(--gray-500); margin-bottom: 16px; }
.modal-hint      { font-size: 12px; color: var(--gray-400); margin-top: 8px; }
.modal-input-row { display: flex; gap: 8px; }
.invite-link-input {
  flex: 1; padding: 10px 12px; border: 1.5px solid var(--gray-200);
  border-radius: 8px; font-size: 13px; background: var(--gray-50); color: var(--gray-700);
}
.room-code-display { letter-spacing: 2px; }
.required-mark { color: var(--red); }

/* ── Card ────────────────────────────────────────────────────── */
.card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px;
}

/* ── Toast ───────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--gray-900); color: var(--white);
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; z-index: 9999;
  opacity: 0; transition: opacity .3s; pointer-events: none;
}
#toast.show { opacity: 1; }

/* ── Link ────────────────────────────────────────────────────── */
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Field inline error ──────────────────────────────────────── */
.field-error { margin-top: 6px; color: var(--red); font-size: 13px; }

/* ── Utils ───────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-sm { font-size: 13px; }
.text-gray { color: var(--gray-500); }
.mt-4 { margin-top: 16px; }
.mt-2 { margin-top: 8px; }
.w-full { width: 100%; }

/* ─────────────────────────────────────────────────────────────
   HOME PAGE
   ───────────────────────────────────────────────────────────── */
.home-wrapper {
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.home-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 32px; background: var(--white);
  border-bottom: 1px solid var(--gray-200);
}
.home-header .logo-icon {
  width: 36px; height: 36px; background: linear-gradient(135deg, #60A5FA, #2563EB);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  color: white; font-size: 18px;
}
.home-header .logo-text {
  font-size: 18px; font-weight: 700; color: var(--gray-900);
}
.home-main {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 40px 20px;
}
.home-box {
  width: 100%; max-width: 460px;
}
.home-tabs {
  display: flex; background: var(--gray-100); border-radius: var(--radius);
  padding: 4px; margin-bottom: 24px;
}
.home-tab {
  flex: 1; padding: 10px; border: none; background: transparent;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  cursor: pointer; color: var(--gray-500); transition: all .15s;
}
.home-tab.active {
  background: var(--white); color: var(--gray-900);
  box-shadow: var(--shadow);
}
.home-panel { display: none; }
.home-panel.active { display: block; }

.adv-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 0 4px;
  border-bottom: 2px solid var(--gray-200);
  cursor: pointer; user-select: none;
}
.adv-toggle-row:hover .adv-toggle-label { color: var(--blue-dark); }
.adv-toggle-label {
  font-size: 13px; font-weight: 500; color: var(--blue);
  transition: color .15s;
}
.adv-toggle-chevron {
  color: var(--gray-400);
  transition: transform .2s ease, color .15s;
  flex-shrink: 0;
}
.adv-toggle-row.open .adv-toggle-chevron { transform: rotate(180deg); }
.advanced-section {
  padding-top: 16px; margin-top: 8px;
}

/* ── Minhas salas ─────────────────────────────────────────── */
.my-room-card {
  border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm);
  padding: 14px; margin-bottom: 12px; background: var(--white);
  transition: border-color .15s;
}
.my-room-card:hover { border-color: var(--gray-300); }
.my-room-card-header {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  margin-bottom: 4px;
}
.my-room-card-name {
  font-size: 15px; font-weight: 600; color: var(--gray-900);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.my-room-card-date {
  font-size: 12px; color: var(--gray-400); flex-shrink: 0;
}
.my-room-card-code {
  font-size: 12px; color: var(--gray-500); margin-bottom: 12px;
  letter-spacing: 1px; font-family: 'Consolas', monospace;
}
.my-room-card-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.my-room-card-actions .btn { padding: 6px 12px; font-size: 13px; }
.btn-danger {
  background: var(--white); color: var(--red);
  border: 1.5px solid var(--gray-200);
}
.btn-danger:hover { background: var(--red); color: var(--white); border-color: var(--red); }

#my-rooms-list { padding-right: 4px; }
#my-rooms-list::-webkit-scrollbar { width: 6px; }
#my-rooms-list::-webkit-scrollbar-thumb {
  background: var(--gray-300); border-radius: 3px;
}
#my-rooms-list::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

.empty-state {
  text-align: center; color: var(--gray-500); font-size: 14px;
  padding: 40px 20px; line-height: 1.6;
}

/* ─────────────────────────────────────────────────────────────
   ROOM PAGE
   ───────────────────────────────────────────────────────────── */
.room-wrapper {
  display: flex; flex-direction: column; height: 100vh; overflow: hidden;
}

/* Header */
.room-header {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; height: 60px; background: var(--white);
  border-bottom: 1px solid var(--gray-200); flex-shrink: 0; z-index: 100;
  position: relative;
}
.room-header .logo-icon {
  width: 32px; height: 32px; background: linear-gradient(135deg, #60A5FA, #2563EB);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  color: white; font-size: 16px; flex-shrink: 0;
}
.room-header .logo-text {
  font-size: 15px; font-weight: 700; color: var(--gray-900);
}
.room-name-badge {
  margin-left: 20px; margin-right: 12px;
  display: inline-block; line-height: 1;
  font-size: 14px; font-weight: 700; color: var(--blue-dark);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 400px;
  background: var(--blue-light);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 20px;
  padding: 6px 12px;
}
.room-header-right {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
}
.btn-invite {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px; border: 1.5px solid var(--blue);
  border-radius: var(--radius-sm); background: var(--white);
  color: var(--blue); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .15s;
}
.btn-invite:hover { background: var(--blue-light); }
.btn-sidebar-toggle {
  width: 36px; height: 36px; border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm); background: var(--white);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--gray-500); transition: all .15s;
}
.btn-sidebar-toggle:hover { border-color: var(--blue); color: var(--blue); }
.btn-sidebar-toggle.btn-appearing { opacity: 0; }

/* Room body */
.room-body {
  flex: 1; display: flex; overflow: hidden; position: relative;
}

/* Main area (mesa) */
.room-main {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; position: relative;
}

/* Mesa de poker */
.poker-table {
  grid-row: 3;
  flex: 1; min-height: 0; position: relative; display: flex;
  align-items: center; justify-content: center;
  padding: 20px;
  overflow: hidden;
}

/* Área central da mesa — min-height garante mesmo tamanho para todos os participantes */
.table-center {
  background: var(--blue-light); border-radius: 24px;
  padding: 20px 56px; text-align: center;
  min-width: 300px; max-width: 420px;
  min-height: 130px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  position: relative; z-index: 10;
}
.table-center-msg {
  font-size: 15px; font-weight: 500; color: var(--gray-700); margin-bottom: 10px;
}
.table-center-msg a { color: var(--blue); font-weight: 600; }
.table-center .btn { margin: 0 auto; width: 100%; }
.countdown-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--blue-light); border-radius: 24px;
  font-size: 72px; font-weight: 800; color: var(--blue);
  z-index: 20;
}
.countdown-pop { animation: countdown-pop .9s ease-out forwards; }
@keyframes countdown-pop {
  0%   { transform: scale(1.6); opacity: 0; }
  20%  { transform: scale(1);   opacity: 1; }
  80%  { transform: scale(1);   opacity: 1; }
  100% { transform: scale(.6);  opacity: 0; }
}

/* Players ao redor da mesa */
.players-ring {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}

.player-slot {
  position: absolute;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 80px;
}
.player-card {
  width: 52px; height: 72px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; transition: all .4s ease;
  position: relative;
}
/* Não votou */
.player-card.empty {
  background: var(--gray-200);
}
/* Votou (oculto) */
.player-card.voted {
  background: var(--blue);
}
/* Revelado */
.player-card.revealed {
  background: var(--white); border: 2px solid var(--blue);
  color: var(--blue); box-shadow: var(--shadow-md);
}
/* Eu mesmo — não votei: cinza com borda tracejada para identificar meu slot */
.player-card.me-empty {
  background: var(--gray-100); border: 2px dashed var(--gray-300);
  color: var(--gray-400);
}
/* Espectador: fundo cinza com borda tracejada, com ícone SVG */
.player-card.spectator-card {
  background: var(--gray-100); border: 2px dashed var(--gray-300);
  color: var(--gray-400); font-size: 18px;
}
.spectator-icon {
  width: 36px; height: auto; display: block;
}
/* Moderador que não vota: fundo cinza com borda tracejada, com coroa */
.player-card.moderator-card {
  background: var(--gray-100); border: 2px dashed var(--gray-300);
  color: var(--gray-400); font-size: 20px;
}
.moderator-icon {
  width: 36px; height: auto; display: block;
}
.mod-badge {
  width: 14px; height: 14px; vertical-align: middle; margin-right: 3px;
}
/* Eu mesmo — votei: azul sólido como os outros */
.player-card.me-voted {
  background: var(--blue); border: 2px solid var(--blue-dark);
}
.player-name {
  font-size: 12px; font-weight: 500; color: var(--gray-700);
  display: flex; align-items: center; justify-content: center;
  text-align: center; white-space: nowrap; overflow: hidden; max-width: 80px;
}
/* Nome do jogador atual — verde, com "(Você)" em linha separada */
.player-name-me {
  color: #4078ED; font-weight: 700;
  white-space: normal; line-height: 1.4;
  display: flex; flex-direction: column; align-items: center;
  overflow: visible; text-overflow: unset;
}
.you-label {
  font-size: 10px; font-weight: 500;
  color: #4078ED; opacity: 0.75; line-height: 1.2;
}
/* Deck de cartas (barra inferior) */
.deck-bar {
  flex-shrink: 0; padding: 14px 20px;
  background: var(--white); border-top: 1px solid var(--gray-200);
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
}
.deck-card {
  width: 52px; height: 72px; border-radius: 8px;
  border: 2px solid var(--blue); background: var(--white);
  color: var(--blue); font-size: 16px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .15s; user-select: none;
}
.deck-card:hover {
  background: var(--blue); color: var(--white);
  transform: translateY(-6px); box-shadow: var(--shadow-md);
}
.deck-card.selected {
  background: var(--blue); color: var(--white);
  transform: translateY(-8px); box-shadow: var(--shadow-lg);
}
.deck-card.disabled {
  opacity: .4; cursor: not-allowed; pointer-events: none;
}

/* Results panel */
.results-panel {
  flex-shrink: 0;
  padding: 16px 20px; background: var(--white);
  border-top: 1px solid var(--gray-200);
  display: flex; align-items: flex-end; gap: 12px;
  flex-wrap: wrap; justify-content: center;
  min-height: 120px;
}
.results-panel.hidden { display: none; }

@keyframes results-enter {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
#results-panel.entering {
  animation: results-enter 0.5s ease forwards;
}

.vote-bar-group {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.vote-bar-track {
  width: 52px; display: flex; align-items: flex-end; height: 80px;
}
.vote-bar {
  width: 52px; background: var(--blue); border-radius: 6px 6px 0 0;
  transition: height .4s ease;
}
.vote-bar-card {
  width: 52px; height: 38px; border-radius: 6px; border: 2px solid var(--blue);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: var(--blue);
}
.vote-bar-count {
  font-size: 12px; color: var(--gray-500); font-weight: 500;
}

/* Agreement meter */
.agreement-meter {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  margin-left: 24px;
}
.agreement-gauge {
  position: relative; width: 72px; height: 72px;
}
.agreement-gauge svg { transform: rotate(-90deg); }
.agreement-gauge .gauge-bg { fill: none; stroke: var(--gray-200); stroke-width: 6; }
.agreement-gauge .gauge-fill {
  fill: none; stroke: var(--green); stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 188; /* 2πr where r=30 */
  stroke-dashoffset: 188;
  transition: stroke-dashoffset .8s ease;
}
.agreement-gauge .gauge-icon {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; transform: rotate(0deg);
}
.agreement-label {
  font-size: 11px; color: var(--gray-500); font-weight: 500;
}
.agreement-pct {
  font-size: 13px; font-weight: 700; color: var(--gray-700);
}

.average-badge {
  background: var(--blue-light); color: var(--blue);
  border-radius: var(--radius); padding: 16px 24px;
  font-size: 28px; font-weight: 800; margin-left: 24px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  align-self: center;
  min-width: 90px;
}
.average-badge span { font-size: 13px; font-weight: 500; color: var(--gray-500); }

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: 300px; flex-shrink: 0; background: var(--white);
  border-left: 1px solid var(--gray-200);
  display: flex; flex-direction: column;
  transition: width .25s, opacity .25s;
  overflow: hidden;
}
.sidebar.closed { width: 0; opacity: 0; }
.sidebar.sidebar--no-transition { transition: none; }
.sidebar-inner { width: 300px; display: flex; flex-direction: column; height: 100%; }

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--gray-100);
  flex-shrink: 0;
}
.sidebar-title { font-size: 14px; font-weight: 700; color: var(--gray-900); display: inline-flex; align-items: center; gap: 8px; }

.sidebar-stories {
  flex: 1; overflow-y: auto; padding: 8px;
}
.story-item {
  border-radius: var(--radius-sm); padding: 10px 12px;
  cursor: pointer; transition: background .12s;
  border: 1.5px solid var(--gray-200); margin-bottom: 4px;
}
.story-item:hover { background: var(--gray-50); }
.story-item.story-item--readonly { cursor: default; }
.story-item.story-item--readonly:hover { background: transparent; }
.story-item.story-item--readonly.active { background: transparent; border-color: var(--gray-200); }
.story-item.story-item--readonly.active:hover { background: transparent; }
.story-item.story-item--readonly.active .story-item-title { color: var(--gray-900); }
.story-item.active {
  background: var(--blue-light); border-color: var(--blue);
}
.story-item--estimated {
  border-left: 3px solid var(--green);
  padding-left: 10px;
}
/* Non-moderadores: borda verde sempre visível, mesmo na story ativa */
.story-item.story-item--readonly.story-item--estimated,
.story-item.story-item--readonly.story-item--estimated.active {
  border-left: 3px solid var(--green);
  padding-left: 10px;
}
.story-item-header {
  display: flex; align-items: center; justify-content: space-between;
}
.drag-handle {
  cursor: grab; color: var(--gray-400); font-size: 16px;
  padding: 0 2px 0 0; user-select: none; flex-shrink: 0;
}
.drag-handle:active { cursor: grabbing; }
.story-item-title-row {
  display: flex; align-items: center; gap: 6px; margin-top: 4px;
}
.story-item-title {
  font-size: 13px; font-weight: 600; color: var(--gray-900);
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.story-item.active .story-item-title { color: var(--blue); }
.story-item-estimate {
  font-size: 11px; font-weight: 700; background: var(--blue);
  color: white; border-radius: 4px; padding: 1px 6px; flex-shrink: 0;
}
.story-link-icon {
  font-size: 13px; color: var(--gray-400); text-decoration: none;
  flex-shrink: 0;
  width: 24px; height: 24px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.story-link-icon:hover { background: var(--gray-100); color: var(--blue); text-decoration: none; }
.story-item-desc {
  font-size: 12px; color: var(--gray-500); margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; white-space: pre-wrap; overflow-wrap: break-word;
}

.story-actions {
  display: flex; gap: 4px; flex-shrink: 0;
}
.story-action-btn {
  width: 24px; height: 24px; border: none; background: transparent;
  border-radius: 4px; cursor: pointer; color: var(--gray-400);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; transition: all .12s;
}
.story-action-btn:hover { background: var(--gray-100); color: var(--gray-700); }

.sidebar-footer {
  padding: 12px; border-top: 1px solid var(--gray-100); flex-shrink: 0;
}

/* Voting view — Grid garante que rodapé (deck/results) sempre apareça */
.voting-view {
  display: grid;
  grid-template-rows: auto auto 1fr auto;  /* linha 1 = room bar, linha 2 = story card, linha 3 = mesa, linha 4 = rodapé */
  flex: 1;                                  /* ocupa room-main */
  min-height: 0;
  overflow: hidden;
}

/* Room info bar — linha 1 do grid */
.room-info-bar {
  grid-row: 1;
  height: 34px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  flex-shrink: 0;
}

/* Story card — linha 2 do grid */
.story-card {
  grid-row: 2;
  padding: 12px 20px;
  background: var(--blue-light);
  overflow: hidden;
}
.story-card-title {
  font-size: 15px; font-weight: 700; color: var(--blue-dark); margin-bottom: 4px;
}
.story-card-desc {
  font-size: 13px; color: var(--gray-700); line-height: 1.5; margin-bottom: 6px;
  white-space: pre-wrap; overflow-wrap: break-word;
  max-height: 10.5em; overflow-y: auto;
}
.story-card-link {
  font-size: 13px; color: var(--blue); font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  width: 24px; height: 24px;
  border-radius: 4px; transition: background .12s;
}
.story-card-link:hover { background: var(--gray-100); text-decoration: none; }

/* Rodapé do grid — deck-bar e results-panel ficam na linha 4 */
.results-panel,
.deck-bar {
  grid-row: 4;
}

/* Lobby view */
.lobby-view {
  flex: 1; overflow-y: auto; padding: 24px;
}
.lobby-title {
  font-size: 20px; font-weight: 700; margin-bottom: 4px; color: var(--gray-900);
}
.lobby-subtitle { font-size: 14px; color: var(--gray-500); margin-bottom: 20px; }
.lobby-steps {
  display: flex; align-items: flex-start; margin-bottom: 28px;
}
.lobby-step {
  display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 72px;
}
.lobby-step-circle {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.lobby-step-label { font-size: 11px; white-space: nowrap; }
.lobby-step-line {
  flex: 1; height: 2px; margin-top: 13px; background: var(--gray-200);
}
.lobby-step-line--done { background: var(--blue); }
.lobby-step--done .lobby-step-circle  { background: var(--blue); color: white; }
.lobby-step--done .lobby-step-label   { color: var(--gray-500); }
.lobby-step--active .lobby-step-circle { background: var(--blue); color: white; }
.lobby-step--active .lobby-step-label  { color: var(--blue); font-weight: 600; }
.lobby-step--pending .lobby-step-circle {
  background: var(--gray-100); color: var(--gray-400); border: 2px solid var(--gray-200);
}
.lobby-step--pending .lobby-step-label { color: var(--gray-400); }
.lobby-section-title {
  font-size: 16px; font-weight: 700; color: var(--gray-900);
  margin-bottom: 10px; margin-top: 24px;
}
.lobby-story-card {
  background: var(--white); border: 1.5px solid var(--gray-200);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.lobby-story-title {
  font-size: 15px; font-weight: 700; color: var(--gray-900); margin-bottom: 6px;
}
.lobby-story-desc { font-size: 13px; color: var(--gray-500); margin-bottom: 8px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: break-word; }
.lobby-story-link {
  font-size: 13px; color: var(--blue); display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  width: 24px; height: 24px;
  border-radius: 4px; transition: background .12s;
}
.lobby-story-link:hover { background: var(--gray-100); text-decoration: none; }

/* Waiting state */
.waiting-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; flex: 1; color: var(--gray-400);
}
.waiting-state .robot { font-size: 48px; }

/* ─────────────────────────────────────────────────────────────
   Responsive
   ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .sidebar { width: 100%; position: fixed; inset: 0; z-index: 200; }
  .sidebar.closed { display: none; }
  .deck-card { width: 44px; height: 62px; font-size: 14px; }
  .player-card { width: 44px; height: 60px; font-size: 16px; }
  .home-header { padding: 12px 16px; }
  .room-header { padding: 0 12px; }
}
