/* ==========================================================================
   MODO MULTIPLAYER (salas 2 a 4) — design system do perfil (profile.css).
   Esta folha é autocontida: cartas, barra, ampulheta, modal e avisos ficam aqui.
   Cores sólidas (sem degradê). Espaços: 18px entre cards; 14px dentro; 10px entre itens.
   ========================================================================== */

/* ---------- Estrutura ---------- */
.room { display: flex; flex-direction: column; gap: 18px; padding-bottom: 60px; }
.room [hidden] { display: none !important; }
.room-game { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.room .pf-panel { gap: 14px; min-width: 0; }
.room .pf-panel__head { margin: 0; }
.room .pf-panel__head h2 { font-size: 19px; }
.room .pf-note, .room .pf-lead { margin: 0; }
.room .pf-alert { margin: 0; }
.room-back { align-self: flex-start; font-size: 14px; font-weight: 800; color: var(--pf-leaf); text-decoration: none; }
.room-back:hover { color: var(--pf-forest); text-decoration: underline; text-underline-offset: 3px; }

/* Regras: chips sobre a faixa verde do cabeçalho */
.room-rules { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.room-rule { display: inline-flex; align-items: center; min-height: 30px; padding: 4px 12px; border-radius: 999px; background: var(--pf-white); color: var(--pf-forest); font-size: 13px; font-weight: 800; }

/* Listas de pessoas (lobby e comunidade) */
.room-players, .mp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.room-player, .mp-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 20px; background: var(--pf-cream); border: 1px solid var(--pf-line); flex-wrap: wrap; }
.room-player.is-me { border-color: var(--pf-leaf); }
.room-player.is-declined, .room-player.is-left { opacity: .6; }
.room-player__avatar, .room-score__avatar, .pf-person__avatar {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--pf-ochre); color: var(--pf-ink); font-weight: 800;
}
.room-player__body, .room-score__body, .mp-row__body { display: flex; flex-direction: column; min-width: 0; flex: 1 1 200px; color: var(--pf-ink); text-decoration: none; }
.room-player__nick, .room-score__nick { color: var(--pf-ink); font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-player__state, .room-score__tags, .mp-row__body small { color: var(--pf-muted); font-size: 12px; font-weight: 700; line-height: 1.4; }
.mp-row__body b { font-weight: 800; overflow-wrap: anywhere; }
.room-actions, .mp-row__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.room-actions form, .mp-row__actions form { margin: 0; }

/* Placar: um cartão por jogador */
.room-scores { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.room-score { display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; column-gap: 10px; align-items: center; padding: 14px; border-radius: 22px; background: var(--pf-white); border: 1px solid var(--pf-line); }
.room-score.is-turn { border: 2px solid var(--pf-leaf); background: var(--pf-leaf-soft); }
.room-score.is-left { opacity: .55; }
.room-score__avatar { grid-row: span 2; width: 36px; height: 36px; font-size: 15px; }
.room-score__body { grid-column: 2; grid-row: 1; flex: none; }
.room-score__points { grid-column: 3; grid-row: 1; color: var(--pf-forest); font-size: 26px; font-weight: 800; line-height: 1; }
.room-score__meta { grid-column: 2 / span 2; grid-row: 2; color: var(--pf-muted); font-size: 12px; font-weight: 700; }
.room-score__tags { display: block; min-height: 1em; }

/* Barra de vez */
.room .duel__bar { display: flex; align-items: center; gap: 12px; }
.room .duel__bar-avatar { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--pf-leaf); color: var(--pf-white); font-weight: 800; font-size: 18px; }
.room .duel__bar.is-mine .duel__bar-avatar { background: var(--pf-ochre); color: var(--pf-ink); }
.room .duel__bar-main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.room .duel__bar-main b { color: var(--pf-ink); font-size: 17px; font-weight: 800; }
.room .duel__bar-main small { color: var(--pf-muted); font-size: 13px; font-weight: 700; }
.room .duel__bar-round { font-size: 12px; font-weight: 800; color: var(--pf-forest); background: var(--pf-leaf-soft); border-radius: 999px; padding: 6px 12px; white-space: nowrap; }

/* Tempo (ampulheta + barra) */
.room .duel__timer-row { display: flex; align-items: center; gap: 12px; }
.room .duel__hourglass { flex: 0 0 auto; width: 30px; height: 40px; }
.room .duel__hourglass svg { width: 100%; height: 100%; display: block; }
.room .duel__hourglass-frame { fill: none; stroke: var(--pf-forest); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.room .duel__hourglass-sand { fill: var(--pf-ochre); }
.room .duel__hourglass-sand--top { transform-origin: 20px 8px; }
.room .duel__hourglass-sand--bottom { transform-origin: 20px 44px; }
.room .duel__hourglass-drip { fill: var(--pf-ochre); }
.room .duel__timer { position: relative; flex: 1 1 auto; height: 30px; border-radius: 999px; background: #efe9d8; overflow: hidden; }
.room .duel__timer-fill { position: absolute; inset: 0 auto 0 0; background: var(--pf-leaf); border-radius: 999px; }
.room .duel__timer-text { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; font-weight: 800; color: var(--pf-ink); }
.room .duel__timer.is-mine .duel__timer-fill { background: var(--pf-forest); }
.room .duel__timer.is-low .duel__timer-fill { background: var(--pf-urucum); }

/* Cargas */
.room .duel__charges { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 800; color: var(--pf-muted); }
.room .duel__pip { width: 14px; height: 14px; border-radius: 50%; background: #efe9d8; border: 1px solid var(--pf-line); display: inline-block; }
.room .duel__pip.is-on { background: var(--pf-ochre); border-color: var(--pf-ochre); }

/* Poderes */
.room .duel__powers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.room .duel__power { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px; border-radius: 20px; border: 1px solid var(--pf-line); background: var(--pf-cream); color: var(--pf-ink); cursor: pointer; text-align: left; font: inherit; min-width: 0; }
.room .duel__power:disabled { cursor: default; opacity: .6; }
.room .duel__power.is-ready { border-color: var(--pf-leaf); background: var(--pf-leaf-soft); }
.room .duel__power.is-active { border-color: var(--pf-ochre); background: var(--pf-ochre-soft); }
.room .duel__power-text b { display: block; font-size: 15px; font-weight: 800; }
.room .duel__power-text small { display: block; font-size: 12px; font-weight: 700; color: var(--pf-muted); line-height: 1.4; margin-top: 2px; }
.room .duel__power-state { font-size: 12px; font-weight: 800; color: var(--pf-leaf); }
.room .duel__veil { margin: 0; font-size: 13px; font-weight: 700; color: var(--pf-muted); }
.room .duel__toast { margin: 0; min-height: 1.2em; font-size: 14px; font-weight: 800; color: var(--pf-leaf); }
.room .duel__hint { text-align: center; }

/* ---------- Tabuleiro e cartas (cores sólidas) ---------- */
.room-board-card { padding: 16px; }
.room .duel__board { display: grid; grid-template-columns: repeat(var(--duel-cols, 4), minmax(0, 1fr)); gap: 10px; width: 100%; margin: 0; }
.room .mcard { position: relative; width: 100%; aspect-ratio: 3 / 4; height: auto; padding: 0; border: 0; background: none; cursor: pointer; perspective: 900px; }
.room .mcard:disabled { cursor: default; }
.room .mcard__inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .5s ease, opacity .35s; }
.room .mcard.is-open .mcard__inner { transform: rotateY(180deg); }
.room .mcard.is-matched .mcard__inner { opacity: .75; }
.room .mcard__face { position: absolute; inset: 0; border-radius: 14px; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; box-sizing: border-box; }
.room .mcard__back { display: flex; align-items: center; justify-content: center; background: var(--pf-forest); border: 3px solid var(--pf-ochre); }
.room .mcard__back::after { content: ''; position: absolute; inset: 6px; border-radius: 10px; border: 1.5px solid var(--pf-ochre); opacity: .5; }
.room .mcard__mark { width: 48%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: var(--pf-leaf); border: 2px solid var(--pf-ochre); overflow: hidden; }
.room .mcard__mark img { width: 80%; height: 80%; object-fit: contain; }
.room .mcard__front { transform: rotateY(180deg); display: flex; flex-direction: column; gap: 6px; padding: 6px; background: var(--pf-white); border: 2px solid var(--pf-line); }
.room .mcard__front .media { flex: 1 1 auto; min-height: 0; width: 100%; border-radius: 9px; object-fit: cover; }
.room .mcard__label { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; text-align: center; min-height: 2.4em; padding: 6px; border-radius: 10px; background: var(--pf-forest); color: var(--pf-ochre); font-size: 11px; font-weight: 800; line-height: 1.2; text-transform: uppercase; letter-spacing: .02em; overflow: hidden; }
.room .mcard.is-revealed .mcard__front { border-color: var(--pf-urucum); }
.room .mcard.is-matched .mcard__front { border: 3px solid var(--pf-leaf); background: var(--pf-leaf-soft); }
.room .mcard.is-matched .mcard__label { background: var(--pf-leaf); color: var(--pf-white); }
.room .mcard.is-matched .mcard__front::after { content: '✓'; position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--pf-leaf); color: var(--pf-white); font-size: 14px; font-weight: 800; border: 2px solid var(--pf-white); }
.room .mcard.is-matched { cursor: default; }

/* ---------- História, fim ---------- */
.room .duel__story { gap: 6px; border-color: var(--pf-ochre); background: var(--pf-ochre-soft); }
.room .duel__story-tag { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--pf-urucum); }
.room .duel__story b { font-size: 18px; color: var(--pf-ink); }
.room .duel__story p { margin: 0; font-size: 15px; line-height: 1.55; color: var(--pf-ink); }
.room .duel__end { align-items: center; text-align: center; }
.room .duel__end-tag { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--pf-leaf); }
.room .duel__end-title { font-size: 26px; font-weight: 800; color: var(--pf-forest); }
.room .duel__end-score { margin: 0; color: var(--pf-muted); font-size: 15px; }
.room .duel__end-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--pf-leaf-soft); color: var(--pf-forest); font-size: 24px; font-weight: 800; }
.room .duel__end.is-loss .duel__end-icon { background: var(--pf-urucum-soft); color: var(--pf-urucum); }
.room .duel__end.is-draw .duel__end-icon { background: var(--pf-ochre-soft); color: var(--pf-ink); }
.room-final { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 340px; }
.room-final__row { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 18px; background: var(--pf-cream); border: 1px solid var(--pf-line); }
.room-final__row.is-me { background: var(--pf-leaf-soft); border-color: var(--pf-leaf-soft); }
.room-final__pos { color: var(--pf-forest); font-weight: 800; }
.room-final__nick { color: var(--pf-ink); font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-final__pts { color: var(--pf-muted); font-weight: 700; font-size: 14px; }

/* ---------- Aviso discreto (canto superior) ---------- */
.duel__notice { position: fixed; left: 50%; top: 84px; transform: translateX(-50%); z-index: 80; width: min(420px, calc(100vw - 28px)); pointer-events: none; }
.duel__notice[hidden] { display: none !important; }
.duel__notice-card { display: flex; flex-direction: column; gap: 4px; padding: 14px 18px; border-radius: 22px; background: var(--pf-white); border: 1px solid var(--pf-line); border-left: 8px solid var(--pf-leaf); box-shadow: 0 24px 40px -18px oklch(14% 0.05 152 / .75); }
.duel__notice-tag { font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--pf-muted); }
.duel__notice-title { font-size: 17px; color: var(--pf-forest); }
.duel__notice-sub { font-size: 14px; color: var(--pf-ink); line-height: 1.4; }
.duel__notice-card.is-start { background: var(--pf-forest); border-left-color: var(--pf-ochre); }
.duel__notice-card.is-start .duel__notice-title, .duel__notice-card.is-start .duel__notice-sub, .duel__notice-card.is-start .duel__notice-tag { color: var(--pf-white); }
.duel__notice-card.is-turn, .duel__notice-card.is-erro, .duel__notice-card.is-tempo { border-left-color: var(--pf-urucum); }
.duel__notice-card.is-combo, .duel__notice-card.is-end { border-left-color: var(--pf-ochre); }

/* ---------- Modal: vez e poderes de outros ---------- */
.duel-modal { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 20px; }
.duel-modal__backdrop { position: absolute; inset: 0; background: rgba(24, 61, 43, .55); }
.duel-modal__card { position: relative; width: min(380px, 100%); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 28px 24px; border-radius: 28px; background: var(--pf-white); border: 1px solid var(--pf-line); box-shadow: 0 30px 60px -24px oklch(14% 0.05 152 / .8); }
.duel-modal__card.is-turn { border-color: var(--pf-leaf); }
.duel-modal__card.is-trava { border-color: var(--pf-urucum); }
.duel-modal__card.is-dobro { border-color: var(--pf-ochre); }
.duel-modal__card.is-veu { border-color: var(--pf-blue); }
.duel-modal__icon { width: 72px; height: 72px; border-radius: 50%; display: block; background: var(--pf-leaf); }
.duel-modal__icon.is-trava { background: var(--pf-urucum); }
.duel-modal__icon.is-dobro { background: var(--pf-ochre); }
.duel-modal__icon.is-veu { background: var(--pf-blue); }
.duel-modal__icon.is-par, .duel-modal__icon.is-combo { background: var(--pf-ochre); }
.duel-modal__tag { font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--pf-muted); }
.duel-modal__title { margin: 0; font-size: 22px; line-height: 1.2; color: var(--pf-forest); }
.duel-modal__text { margin: 0; font-size: 15px; line-height: 1.5; color: var(--pf-ink); }
.duel-modal__btn { margin-top: 8px; min-height: 46px; padding: 10px 28px; border-radius: 999px; border: 0; font: inherit; font-weight: 800; font-size: 15px; color: var(--pf-white); background: var(--pf-forest); cursor: pointer; }
.duel-modal__btn:focus-visible { outline: 3px solid var(--pf-ochre); outline-offset: 3px; }

/* ---------- Chat ---------- */
.room-chat .pf-panel__head h2 { font-size: 19px; }
.room-chat__list { display: flex; flex-direction: column; gap: 10px; max-height: 280px; min-height: 120px; overflow-y: auto; padding: 4px 2px; }
.room-chat__empty { margin: auto; color: var(--pf-muted); text-align: center; font-size: 14px; }
.room-chat__msg { align-self: flex-start; max-width: 85%; background: var(--pf-cream); border: 1px solid var(--pf-line); border-radius: 18px 18px 18px 6px; padding: 10px 14px; }
.room-chat__msg.is-mine { align-self: flex-end; background: var(--pf-leaf-soft); border-color: var(--pf-leaf-soft); border-radius: 18px 18px 6px 18px; }
.room-chat__head2 { display: flex; gap: 8px; align-items: baseline; color: var(--pf-forest); font-size: 12px; font-weight: 800; }
.room-chat__head2 small { color: var(--pf-muted); font-weight: 700; }
.room-chat__text { margin: 2px 0 0; color: var(--pf-ink); font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.room-chat__form { display: flex; gap: 10px; }
.room-chat__form input { flex: 1 1 auto; min-width: 0; min-height: 48px; padding: 12px 18px; border-radius: 999px; border: 2px solid var(--pf-line); background: var(--pf-white); font: inherit; font-size: 16px; color: var(--pf-ink); outline: none; }
.room-chat__form input:focus { border-color: var(--pf-leaf); }
.room-chat__form .pf-btn { flex: 0 0 auto; }

/* ---------- Criar sala e comunidade ---------- */
.mp-form { display: flex; flex-direction: column; gap: 18px; }
.mp-group { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.mp-group legend { padding: 0; margin-bottom: 4px; color: var(--pf-forest); font-weight: 800; font-size: 16px; }
.mp-group legend small { color: var(--pf-muted); font-weight: 700; }
.mp-people-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.mp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.mp-field { display: flex; flex-direction: column; gap: 6px; color: var(--pf-ink); font-weight: 800; font-size: 13px; min-width: 0; }
.mp-field select { min-height: 48px; padding: 10px 14px; border-radius: 16px; border: 2px solid var(--pf-line); background: var(--pf-white); font: inherit; font-weight: 700; color: var(--pf-ink); width: 100%; }
.mp-field select:focus { outline: none; border-color: var(--pf-leaf); }
.mp-check { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 6px 16px; border-radius: 999px; background: var(--pf-white); border: 2px solid var(--pf-line); color: var(--pf-ink); font-weight: 800; font-size: 14px; cursor: pointer; align-self: flex-start; }
.mp-check input { width: 18px; height: 18px; accent-color: var(--pf-leaf); margin: 0; }
.mp-check:has(input:checked) { background: var(--pf-leaf-soft); border-color: var(--pf-leaf); }
.mp-submit { display: flex; }
.mp-submit .pf-btn { width: 100%; }
.room-search-row { display: flex; }
.room-search-row .pf-search { width: 100%; }

@media (min-width: 640px) { .mp-submit .pf-btn { width: auto; } }
@media (max-width: 640px) {
  .room .duel__powers { grid-template-columns: 1fr; }
  .mp-grid { grid-template-columns: 1fr; }
  .room-scores { grid-template-columns: 1fr 1fr; }
  .room-chat__list { max-height: 240px; }
  .room-actions .pf-btn, .mp-row__actions .pf-btn { flex: 1 1 auto; }
}
