/* ============================================================
   PARCHÍS — classic Spanish cross-board race.
   Prefix: .pcs-  ·  DOM ids: pcs-*
   Reuses the global theme vars from styles.css.
   ============================================================ */

[hidden] { display: none !important; }

#pcs-lobby, #pcs-room { min-height: 100%; }
.pcs-content { max-width: 1100px; margin: 0 auto; padding: 22px 20px 60px; }
.pcs-topbar-actions { margin-left: auto; }

/* ── Header ── */
.pcs-head {
  display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
  background: linear-gradient(135deg, rgba(239,68,68,0.16), rgba(59,130,246,0.10));
  border: 1px solid var(--border-default); border-radius: 20px; padding: 26px 28px; margin-bottom: 26px;
}
.pcs-head-badge {
  display: inline-block; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase;
  color: #ffd0a0; background: rgba(245,185,66,0.14); border: 1px solid rgba(245,185,66,0.3);
  padding: 5px 12px; border-radius: 999px; margin-bottom: 12px;
}
.pcs-head-titles h1 { font-size: 2rem; margin: 0 0 8px; }
.pcs-head-titles p { margin: 0; color: var(--text-secondary); max-width: 660px; line-height: 1.5; font-size: 0.95rem; }

/* ── Buttons ── */
.pcs-btn { border: none; border-radius: 12px; cursor: pointer; font-weight: 700; font-size: 0.92rem; padding: 12px 20px; transition: transform 0.12s ease, filter 0.15s ease; color: var(--text-primary); }
.pcs-btn:hover { transform: translateY(-1px); }
.pcs-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.pcs-btn-primary { background: linear-gradient(135deg, var(--primary-500), var(--accent-500)); }
.pcs-btn-primary:hover { filter: brightness(1.08); }
.pcs-btn-ghost { background: var(--bg-elevated); border: 1px solid var(--border-default); }
.pcs-btn-sm { padding: 8px 14px; font-size: 0.84rem; }
.pcs-btn-block { width: 100%; }
.pcs-create { white-space: nowrap; }

/* ── Rooms list ── */
.pcs-rooms-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.pcs-section-title { font-size: 1.05rem; margin: 0; }
.pcs-count { color: var(--text-muted); font-weight: 600; font-size: 0.9rem; }
.pcs-search { position: relative; }
.pcs-search-ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; fill: none; stroke: var(--text-muted); stroke-width: 2; }
.pcs-search input { background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: 10px; padding: 9px 14px 9px 34px; color: var(--text-primary); font-size: 0.9rem; width: 220px; outline: none; }
.pcs-search input:focus { border-color: var(--primary-400); }

.pcs-rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.pcs-room-card { background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: 16px; overflow: hidden; cursor: pointer; transition: transform 0.14s ease, border-color 0.14s ease; }
.pcs-room-card:hover { transform: translateY(-3px); border-color: var(--primary-400); }
.pcs-room-card-top { height: 92px; display: flex; align-items: center; justify-content: center; position: relative; font-size: 2.6rem; }
.pcs-room-card-emoji { filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4)); }
.pcs-card-state { position: absolute; top: 10px; left: 10px; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; padding: 3px 9px; border-radius: 999px; background: rgba(0,0,0,0.45); color: #ffd43b; border: 1px solid rgba(255,212,59,0.4); }
.pcs-card-open { color: #51cf66; border-color: rgba(81,207,102,0.4); }
.pcs-room-card-body { padding: 14px 16px 16px; }
.pcs-room-card-name { font-weight: 700; font-size: 1rem; margin-bottom: 4px; }
.pcs-room-card-host { color: var(--text-muted); font-size: 0.82rem; margin-bottom: 12px; }
.pcs-room-card-foot { display: flex; align-items: center; justify-content: space-between; }
.pcs-room-card-people { color: var(--text-secondary); font-size: 0.85rem; }
.pcs-room-card-join { color: var(--primary-300); font-weight: 700; font-size: 0.85rem; }
.pcs-room-card-watch { color: #ffd43b; }

.pcs-empty { grid-column: 1 / -1; text-align: center; padding: 48px 20px; color: var(--text-muted); font-size: 0.95rem; }
.pcs-empty-ic { display: block; font-size: 2.2rem; margin-bottom: 10px; }
.pcs-empty-sm { color: var(--text-muted); font-size: 0.85rem; padding: 12px; text-align: center; }

/* ════════════════════════════════════════════ ROOM ════════════════════════════════════════════ */
#pcs-room:not([hidden]) { display: flex; flex-direction: column; height: 100%; }
.pcs-room-top { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--border-subtle); background: var(--bg-surface); }
.pcs-room-back { background: var(--bg-elevated); border: 1px solid var(--border-default); color: var(--text-secondary); border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 600; font-size: 0.86rem; }
.pcs-room-back:hover { color: var(--text-primary); }
.pcs-room-title { display: flex; align-items: center; gap: 12px; }
.pcs-room-emoji { font-size: 1.8rem; }
.pcs-room-name { font-weight: 700; font-size: 1.05rem; }
.pcs-room-meta { color: var(--text-muted); font-size: 0.82rem; }
.pcs-pillbtn { margin-left: auto; background: var(--bg-elevated); border: 1px solid var(--border-default); color: var(--text-secondary); border-radius: 999px; padding: 8px 16px; cursor: pointer; font-weight: 600; font-size: 0.84rem; }
.pcs-pillbtn:hover { color: var(--text-primary); border-color: var(--primary-400); }

.pcs-stage { flex: 1; overflow-y: auto; padding: 20px; }
.pcs-phase { max-width: 720px; margin: 0 auto; }

.pcs-avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.9rem; color: #fff; overflow: hidden; flex: none; }
.pcs-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pcs-avatar-sm { width: 26px; height: 26px; font-size: 0.78rem; }

/* ── Waiting ── */
.pcs-waiting-card { background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: 20px; padding: 32px 28px; text-align: center; max-width: 560px; margin: 20px auto; }
.pcs-waiting-ic { font-size: 3rem; margin-bottom: 6px; }
.pcs-waiting-card h2 { margin: 0 0 6px; }
.pcs-waiting-card > p { color: var(--text-secondary); margin: 0 0 22px; }
.pcs-players { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 24px; }
.pcs-player { display: flex; align-items: center; gap: 8px; background: var(--bg-elevated); border: 1px solid var(--border-default); border-radius: 999px; padding: 6px 14px 6px 6px; }
.pcs-player-name { font-size: 0.88rem; font-weight: 600; }
.pcs-host-tag { font-size: 0.66rem; font-weight: 700; text-transform: uppercase; color: var(--primary-200); margin-left: 4px; }
.pcs-wins { font-size: 0.78rem; color: #ffd43b; }
.pcs-host-wait { color: var(--text-secondary); display: flex; align-items: center; gap: 10px; justify-content: center; }
.pcs-spin { width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--primary-400); border-radius: 50%; display: inline-block; animation: pcs-spin 0.8s linear infinite; }
@keyframes pcs-spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════ PLAYING ════════════════════════════════════════════ */
.pcs-seats { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 14px; }
.pcs-seat { display: flex; align-items: center; gap: 7px; background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: 999px; padding: 5px 12px 5px 6px; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.pcs-seat-turn { border-color: #fff; animation: pcs-seatpulse 1.3s ease-in-out infinite; }
@keyframes pcs-seatpulse { 0%,100% { box-shadow: 0 0 10px rgba(255,255,255,0.2); } 50% { box-shadow: 0 0 20px rgba(255,255,255,0.5); } }
.pcs-seat-disc { width: 16px; height: 16px; border-radius: 50%; flex: none; box-shadow: inset 0 -2px 3px rgba(0,0,0,0.35); }
.pcs-seat-name { font-size: 0.82rem; font-weight: 700; }
.pcs-seat-prog { font-size: 0.74rem; font-weight: 700; color: var(--primary-300); background: var(--bg-elevated); padding: 1px 7px; border-radius: 999px; }
.pcs-seat-spec { color: var(--text-muted); font-size: 0.82rem; font-weight: 700; }
.pcs-wins-sm { font-size: 0.72rem; color: #ffd43b; }

.pcs-turn-banner { text-align: center; font-weight: 800; font-size: 1rem; padding: 9px 14px; border-radius: 12px; background: var(--bg-elevated); border: 1px solid var(--border-default); margin: 0 auto 14px; max-width: 460px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.pcs-turn-mine { color: #51cf66; border-color: rgba(81,207,102,0.5); background: rgba(81,207,102,0.1); animation: pcs-bannerpulse 1.4s ease-in-out infinite; }
@keyframes pcs-bannerpulse { 0%,100% { box-shadow: 0 0 0 rgba(81,207,102,0); } 50% { box-shadow: 0 0 16px rgba(81,207,102,0.4); } }
.pcs-turn-bonus { color: #ffd43b; border-color: rgba(255,212,59,0.6); background: rgba(255,212,59,0.12); animation: pcs-bannerpulse-gold 1s ease-in-out infinite; }
@keyframes pcs-bannerpulse-gold { 0%,100% { box-shadow: 0 0 4px rgba(255,212,59,0.2); } 50% { box-shadow: 0 0 20px rgba(255,212,59,0.6); } }
.pcs-bonus-badge { background: linear-gradient(135deg, #ffd43b, #ff9f1c); color: #3a2400; font-weight: 900; border-radius: 999px; padding: 2px 10px; font-size: 0.95rem; box-shadow: 0 2px 8px rgba(255,159,28,0.5); }
.pcs-turn-spectate { color: var(--text-muted); }
.pcs-turn-disc { width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 -2px 3px rgba(0,0,0,0.35); }
.pcs-die-inline { font-size: 1.3rem; line-height: 1; }

/* ── SVG board (classic cross grid) ── */
.pcs-board-wrap {
  display: flex; justify-content: center; padding: 14px;
  background: radial-gradient(circle at 50% 50%, #20222c, #0d0e14 80%);
  border: 1px solid var(--border-default); border-radius: 22px;
  box-shadow: inset 0 2px 18px rgba(0,0,0,0.55), 0 10px 30px rgba(0,0,0,0.35);
}
#pcs-board { width: 100%; max-width: 560px; height: auto; aspect-ratio: 1 / 1; touch-action: manipulation; overflow: visible; }

/* Track squares */
.pcs-cell { stroke: #0d0f16; stroke-width: 1; }
.pcs-home { stroke: #0d0f16; stroke-width: 1; animation: pcs-homeglow 3s ease-in-out infinite; }
@keyframes pcs-homeglow { 0%,100% { fill-opacity: 0.72; } 50% { fill-opacity: 0.95; } }
.pcs-seg { fill: none; stroke: #4a4f5e; stroke-width: 2; }
/* Corner casas */
.pcs-corner { }
.pcs-jail { }
.pcs-jail-slot { fill: rgba(0,0,0,0.28); stroke: rgba(255,255,255,0.14); stroke-width: 1; }
.pcs-jail-star { font-size: 30px; pointer-events: none; }
/* Centre meta */
.pcs-tri { stroke: #0d0f16; stroke-width: 1; }

/* Glossy pieces. The <g> carries per-piece transform-origin so the movable
   pulse (scale) and the move slide (translate) both pivot at the piece. */
.pcs-piece { will-change: transform; transform-box: view-box; }
.pcs-peg-body { stroke: rgba(0,0,0,0.45); stroke-width: 0.8; filter: drop-shadow(0 1.4px 1.8px rgba(0,0,0,0.6)); }
.pcs-peg-gloss { fill: #fff; opacity: 0.45; pointer-events: none; }
.pcs-piece.pcs-movable { cursor: pointer; animation: pcs-pegpulse 0.9s ease-in-out infinite; }
.pcs-piece.pcs-movable .pcs-peg-body { stroke: #fff; stroke-width: 1; filter: drop-shadow(0 0 3.6px rgba(255,255,255,0.95)); }
@keyframes pcs-pegpulse { 0%,100% { transform: scale(0.96); } 50% { transform: scale(1.15); } }

/* ── Action row (die + roll) ── */
.pcs-action { text-align: center; margin-top: 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pcs-die { min-height: 52px; display: flex; align-items: center; justify-content: center; }
.pcs-die-face { font-size: 3rem; line-height: 1; display: inline-block; filter: drop-shadow(0 3px 6px rgba(0,0,0,0.5)); }
.pcs-die-roll { animation: pcs-dietumble 0.5s linear; color: #fff; }
@keyframes pcs-dietumble { 0% { transform: rotate(0) scale(1); } 100% { transform: rotate(540deg) scale(1.1); } }
.pcs-die-live { color: #ffd43b; }
.pcs-die-settle { color: #ffd43b; filter: drop-shadow(0 0 10px rgba(255,212,59,0.7)); animation: pcs-diesettle 0.5s cubic-bezier(.2,1.4,.4,1); }
@keyframes pcs-diesettle { 0% { transform: scale(1.9) rotate(-20deg); opacity: 0.4; } 60% { transform: scale(0.86) rotate(4deg); } 100% { transform: scale(1) rotate(0); opacity: 1; } }
.pcs-roll { font-size: 1.05rem; padding: 14px 38px; box-shadow: 0 6px 22px rgba(124,92,255,0.45); animation: pcs-rollbob 1.8s ease-in-out infinite; }
@keyframes pcs-rollbob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.pcs-roll:hover { animation: none; }
.pcs-hint { color: var(--text-muted); font-size: 0.86rem; }

/* ── Ended ── */
.pcs-ended-card { background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: 20px; padding: 32px 28px; text-align: center; max-width: 460px; margin: 20px auto; }
.pcs-ended-trophy { font-size: 3.4rem; margin-bottom: 6px; }
.pcs-ended-card h2 { margin: 0 0 6px; font-size: 1.5rem; }
.pcs-ended-card > p { color: var(--text-secondary); margin: 0 0 20px; }
.pcs-leaderboard { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.pcs-lb-row { display: flex; align-items: center; gap: 10px; background: var(--bg-elevated); border-radius: 10px; padding: 7px 12px; }
.pcs-lb-pos { color: var(--text-muted); font-weight: 800; width: 22px; }
.pcs-lb-disc { width: 16px; height: 16px; border-radius: 50%; flex: none; box-shadow: inset 0 -2px 3px rgba(0,0,0,0.35); }
.pcs-lb-name { flex: 1; font-size: 0.88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcs-lb-score { color: #ffd43b; font-weight: 800; font-size: 0.85rem; }

/* ── Confetti ── */
.pcs-confetti { position: fixed; inset: 0; z-index: 9997; pointer-events: none; overflow: hidden; }
@keyframes pcs-fall-conf { 0% { transform: translateY(-12vh) rotate(0); } 100% { transform: translateY(112vh) rotate(720deg); } }
.pcs-confetti i { position: absolute; top: 0; width: 9px; height: 15px; border-radius: 2px; animation-name: pcs-fall-conf; animation-timing-function: linear; animation-iteration-count: 1; }

/* ── Create modal ── */
.pcs-modal { max-width: 480px; position: relative; }
.pcs-modal h3 { margin: 0 0 18px; }
.pcs-modal-close { position: absolute; top: 14px; right: 14px; background: none; border: none; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; }
.pcs-field { margin-bottom: 14px; }
.pcs-row3 { display: grid; grid-template-columns: auto auto 1fr; gap: 12px; align-items: end; }
.pcs-emoji-input { text-align: center; font-size: 1.3rem; width: 64px; }
.pcs-color-input { width: 56px; height: 44px; padding: 4px; cursor: pointer; }
.pcs-field-note { font-size: 0.78rem; color: var(--text-muted); line-height: 1.4; margin-bottom: 14px; }
.pcs-grow { align-self: end; }
.pcs-form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  .pcs-seat-turn, .pcs-turn-mine, .pcs-turn-bonus, .pcs-piece.pcs-movable, .pcs-home,
  .pcs-die-roll, .pcs-die-settle, .pcs-roll, .pcs-piece { animation: none !important; transition: none !important; }
}

@media (max-width: 720px) {
  .pcs-head { padding: 20px; }
  .pcs-head-titles h1 { font-size: 1.5rem; }
  .pcs-search input { width: 100%; }
  .pcs-rooms-head .pcs-search { width: 100%; }
  .pcs-stage { padding: 14px 10px 40px; }
  #pcs-board { max-width: 94vw; }
  .pcs-row3 { grid-template-columns: auto 1fr; }
}

.pcs-room-card-bet { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 10px; padding: 3px 9px; border-radius: 999px; background: rgba(245, 158, 11, 0.16); border: 1px solid rgba(245, 158, 11, 0.34); color: #fcd34d; font-size: 0.76rem; font-weight: 700; }
