/* =====================================================
   40 - Cuarenta Ecuador
   Tema oscuro, mobile-first
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

/* ---------- Variables ---------- */
:root {
  --bg-1:       #0a0a14;
  --bg-2:       #12121f;
  --bg-3:       #1a1a2e;
  --bg-4:       #222238;
  --accent:     #c8a84b;   /* dorado ecuatoriano */
  --accent-l:   #e2c06a;
  --accent-d:   #9a7a2e;
  --red:        #e63946;
  --green:      #2dc653;
  --blue:       #4361ee;
  --text-1:     #f0ece2;
  --text-2:     #a09880;
  --text-3:     #5a5040;
  --border:     rgba(200,168,75,0.15);
  --shadow:     0 8px 32px rgba(0,0,0,0.7);
  --radius:     14px;
  --radius-sm:  8px;
  --radius-lg:  20px;
  --nav-h:      68px;

  /* cartas */
  --card-w:     72px;
  --card-h:     104px;
  --card-w-sm:  52px;
  --card-h-sm:  76px;
  --card-radius:10px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Nunito', -apple-system, sans-serif;
  background: var(--bg-1);
  color: var(--text-1);
  min-height: 100vh; min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input  { font-family: inherit; }

/* ---------- Página ---------- */
.page { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.page-content { flex: 1; overflow-y: auto; padding: 16px 16px calc(var(--nav-h) + 16px); }
.page-content.no-nav { padding-bottom: 24px; }

/* ---------- Splash ---------- */
.splash {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100vh; height: 100dvh;
  background: radial-gradient(ellipse at center, #1a1020 0%, #0a0a14 70%);
  gap: 16px;
}
.splash-emblem {
  width: 110px; height: 110px;
  background: linear-gradient(135deg, #c8a84b, #9a7a2e);
  border-radius: 28px;
  display: flex; align-items: center; justify-content: center;
  font-size: 58px;
  box-shadow: 0 0 40px rgba(200,168,75,0.4);
  animation: pulse-glow 2s ease-in-out infinite;
}
.splash-title {
  font-size: 28px; font-weight: 900;
  background: linear-gradient(135deg, #e2c06a, #c8a84b);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}
.splash-sub { font-size: 13px; color: var(--text-2); letter-spacing: 2px; text-transform: uppercase; }
.splash-dots { display: flex; gap: 8px; margin-top: 8px; }
.splash-dots span {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  animation: bounce 1.2s ease-in-out infinite;
}
.splash-dots span:nth-child(2) { animation-delay: .2s; }
.splash-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes pulse-glow {
  0%,100% { box-shadow: 0 0 30px rgba(200,168,75,0.35); }
  50%      { box-shadow: 0 0 55px rgba(200,168,75,0.65); }
}
@keyframes bounce {
  0%,80%,100% { transform: scale(0.7); opacity: 0.5; }
  40%          { transform: scale(1.2); opacity: 1; }
}

/* ---------- Auth ---------- */
.auth-page {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 20px;
  background: radial-gradient(ellipse at top, #1a1020 0%, #0a0a14 60%);
}
.auth-logo { font-size: 52px; margin-bottom: 6px; }
.auth-title { font-size: 22px; font-weight: 900; color: var(--accent-l); }
.auth-sub   { font-size: 13px; color: var(--text-2); margin-bottom: 28px; }
.auth-form  { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.auth-form h2 { font-size: 20px; font-weight: 800; text-align: center; color: var(--text-1); }

/* ---------- Inputs ---------- */
.input-group { display: flex; flex-direction: column; gap: 4px; }
.input-group label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .icon { position: absolute; left: 14px; font-size: 16px; pointer-events: none; }
.input-wrap input {
  width: 100%; padding: 13px 14px 13px 42px;
  background: var(--bg-3); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-1);
  font-size: 15px; transition: border-color .2s;
}
.input-wrap input:focus { outline: none; border-color: var(--accent); }
.input-wrap .toggle-pass { position: absolute; right: 12px; font-size: 16px; color: var(--text-2); }
.error-msg { font-size: 12px; color: var(--red); min-height: 16px; }

/* ---------- Botones ---------- */
.btn {
  padding: 14px 24px; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 800; text-align: center;
  transition: opacity .15s, transform .1s;
  display: block; width: 100%;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-d));
  color: #0a0a14;
}
.btn-secondary {
  background: var(--bg-3); border: 1.5px solid var(--border); color: var(--text-1);
}
.btn-outline {
  background: transparent; border: 1.5px solid var(--accent); color: var(--accent-l);
}
.btn-danger {
  background: var(--red); color: #fff;
}
.btn-sm { padding: 9px 16px; font-size: 13px; }
.btn:disabled { opacity: .5; pointer-events: none; }

.divider { text-align: center; color: var(--text-3); font-size: 13px; margin: 4px 0; position: relative; }
.divider::before, .divider::after {
  content: ''; position: absolute; top: 50%; width: 42%; height: 1px; background: var(--border);
}
.divider::before { left: 0; }
.divider::after  { right: 0; }

/* ---------- Bottom Nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-h);
  background: var(--bg-2); border-top: 1px solid var(--border);
  display: flex; z-index: 100;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--text-3); transition: color .2s;
}
.nav-item.active { color: var(--accent); }
.nav-icon  { font-size: 22px; }
.nav-label { font-size: 11px; font-weight: 700; }

/* ---------- Cards (Home) ---------- */
.section-title { font-size: 13px; font-weight: 800; color: var(--text-2); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; }
.card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.card-mode {
  background: var(--bg-2); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 18px 16px;
  display: flex; align-items: center; gap: 14px;
  transition: border-color .2s, transform .15s;
}
.card-mode:active { transform: scale(.98); }
.card-mode.highlight { border-color: var(--accent); }
.card-mode-icon { font-size: 36px; flex-shrink: 0; }
.card-mode-body h3 { font-size: 16px; font-weight: 800; }
.card-mode-body p  { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.card-mode-arrow   { margin-left: auto; font-size: 22px; color: var(--text-3); }

.stack { display: flex; flex-direction: column; gap: 12px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.text-sm   { font-size: 13px; }
.text-2    { color: var(--text-2); }

/* ---------- Header ---------- */
.home-header {
  padding: 16px 16px 0;
  display: flex; align-items: center; justify-content: space-between;
}
.home-greeting h2 { font-size: 20px; font-weight: 800; }
.home-greeting p  { font-size: 13px; color: var(--text-2); }

/* ---------- Score banner ---------- */
.score-banner {
  margin: 12px 16px;
  background: linear-gradient(135deg, #1a1020, #120c1c);
  border: 1px solid rgba(200,168,75,0.3);
  border-radius: var(--radius); padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
}
.score-label { font-size: 12px; color: var(--text-2); font-weight: 700; text-transform: uppercase; }
.score-value { font-size: 28px; font-weight: 900; color: var(--accent-l); }

/* ---------- Stats grid ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 8px; text-align: center;
}
.stat-value { font-size: 22px; font-weight: 900; color: var(--accent-l); }
.stat-label { font-size: 11px; color: var(--text-2); font-weight: 700; margin-top: 2px; }
.stat-green .stat-value { color: var(--green); }
.stat-red   .stat-value { color: var(--red); }

/* ---------- Ranking ---------- */
.rank-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.rank-pos { font-size: 18px; font-weight: 900; width: 28px; text-align: center; color: var(--text-2); }
.rank-pos.gold   { color: #ffd700; }
.rank-pos.silver { color: #c0c0c0; }
.rank-pos.bronze { color: #cd7f32; }
.rank-avatar { font-size: 28px; }
.rank-name   { font-weight: 800; font-size: 15px; }
.rank-wins   { font-size: 12px; color: var(--text-2); }
.rank-pts    { margin-left: auto; font-size: 16px; font-weight: 900; color: var(--accent-l); }

/* =====================================================
   NAIPES — diseño SVG profesional
   ===================================================== */

/* Contenedor genérico de carta */
.naipe {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-radius);
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  user-select: none;
}
.naipe:active { transform: scale(.95); }
.naipe.selected {
  transform: translateY(-14px);
  box-shadow: 0 0 0 2px var(--accent), 0 12px 28px rgba(200,168,75,0.4);
}
.naipe.playable:hover { transform: translateY(-8px); }
.naipe.not-playable { opacity: .55; cursor: not-allowed; }
.naipe.sm { width: var(--card-w-sm); height: var(--card-h-sm); }

/* Cara de la carta */
.naipe-face {
  width: 100%; height: 100%;
  background: #fdf8ef;
  border-radius: var(--card-radius);
  border: 1px solid rgba(0,0,0,0.12);
  box-shadow: 0 3px 8px rgba(0,0,0,0.45);
  position: relative; overflow: hidden;
  display: flex; flex-direction: column;
}

/* Esquinas superior-izquierda e inferior-derecha */
.naipe-corner {
  position: absolute;
  display: flex; flex-direction: column; align-items: center;
  line-height: 1;
}
.naipe-corner.tl { top: 5px; left: 6px; }
.naipe-corner.br { bottom: 5px; right: 6px; transform: rotate(180deg); }
.naipe-rank {
  font-size: 15px; font-weight: 900;
  font-family: 'Georgia', serif;
  color: #111;
}
.naipe-suit-sm {
  font-size: 11px;
  margin-top: -1px;
}

/* Centro de la carta */
.naipe-center {
  flex: 1; display: flex; align-items: center; justify-content: center;
}
.naipe-suit-lg { font-size: 36px; }
.naipe.sm .naipe-suit-lg { font-size: 26px; }
.naipe.sm .naipe-rank     { font-size: 12px; }
.naipe.sm .naipe-suit-sm  { font-size: 9px; }

/* Colores por palo */
.suit-red  .naipe-rank,
.suit-red  .naipe-suit-sm { color: #cc2200; }
.suit-black .naipe-rank,
.suit-black .naipe-suit-sm { color: #111; }

/* Figuras (J, Q, K) — fondo decorativo */
.naipe-face.figure {
  background: linear-gradient(160deg, #fdf8ef 60%, #f5e8c8 100%);
}
.naipe-face.figure .naipe-center { font-size: 38px; }
.naipe.sm .naipe-face.figure .naipe-center { font-size: 26px; }

/* Reverso de la carta */
.naipe-back {
  width: 100%; height: 100%;
  border-radius: var(--card-radius);
  box-shadow: 0 3px 8px rgba(0,0,0,0.55);
  background-image: url('../icons/card-back.png');
  background-size: cover;
  background-position: center;
  border: 2px solid rgba(200,168,75,0.4);
}

/* ---------- Mesa de juego ---------- */
.game-table {
  min-height: 100vh; min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  background: radial-gradient(ellipse at center, #0d1a0d 0%, #060d06 100%);
  padding: 0;
  overflow: hidden;
}

.game-top    { padding: 8px 12px; display: flex; align-items: center; gap: 8px; }
.game-center {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 8px;
}
.game-bottom { padding: 8px 12px; }

/* Zona mesa (cartas sobre la mesa) */
.table-zone {
  min-height: 110px;
  background: rgba(0,80,0,0.25);
  border: 1.5px dashed rgba(255,255,255,0.12);
  border-radius: var(--radius);
  padding: 10px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px;
  position: relative;
}
.table-zone-label {
  position: absolute; top: -10px; left: 14px;
  font-size: 10px; font-weight: 800; color: rgba(255,255,255,0.3);
  text-transform: uppercase; letter-spacing: 1px;
  background: #060d06; padding: 0 6px;
}

/* Mano del jugador */
.player-hand {
  display: flex; align-items: flex-end; justify-content: center;
  padding: 8px 4px;
  min-height: calc(var(--card-h) + 24px);
  gap: -8px;
}
.player-hand .naipe { margin-left: -10px; }
.player-hand .naipe:first-child { margin-left: 0; }

/* Info jugador en la mesa */
.player-info {
  display: flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,0.5);
  border-radius: 40px; padding: 6px 14px 6px 6px;
  border: 1px solid var(--border);
}
.player-avatar { font-size: 24px; }
.player-name   { font-size: 13px; font-weight: 800; }
.player-turn   { font-size: 11px; color: var(--accent); font-weight: 700; }

/* Palitos visuales */
.palitos-display { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.palito {
  width: 6px; height: 28px; background: var(--accent);
  border-radius: 3px; box-shadow: 0 0 6px rgba(200,168,75,0.5);
}
.carta-especial {
  width: 32px; height: 44px;
  background: linear-gradient(135deg, var(--accent), var(--accent-d));
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 900; color: #0a0a14;
  box-shadow: 0 0 10px rgba(200,168,75,0.5);
}

/* Score en juego */
.game-score {
  display: flex; gap: 16px; align-items: center;
  background: rgba(0,0,0,0.6); border: 1px solid var(--border);
  border-radius: 40px; padding: 6px 16px;
}
.game-score-team {
  display: flex; flex-direction: column; align-items: center;
}
.game-score-pts   { font-size: 22px; font-weight: 900; color: var(--accent-l); }
.game-score-label { font-size: 10px; color: var(--text-2); font-weight: 700; }
.game-score-sep   { color: var(--text-3); font-size: 18px; }

/* Toast / Notificación de evento */
.toast-container { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: var(--bg-2); border: 1px solid var(--accent);
  border-radius: 40px; padding: 10px 20px;
  font-size: 15px; font-weight: 800; color: var(--accent-l);
  box-shadow: 0 4px 20px rgba(200,168,75,0.3);
  animation: toast-in .3s ease, toast-out .3s ease 1.7s forwards;
  white-space: nowrap;
}
@keyframes toast-in  { from { opacity:0; transform: translateY(-10px); } to { opacity:1; transform: translateY(0); } }
@keyframes toast-out { from { opacity:1; } to { opacity:0; transform: translateY(-10px); } }

/* ---------- Animaciones generales ---------- */
.animate-fade-up { animation: fade-up .4s ease both; }
@keyframes fade-up {
  from { opacity:0; transform:translateY(18px); }
  to   { opacity:1; transform:translateY(0); }
}
.animate-card-deal { animation: card-deal .35s cubic-bezier(.22,1,.36,1) both; }
@keyframes card-deal {
  from { opacity:0; transform: translateY(60px) rotate(-8deg) scale(.8); }
  to   { opacity:1; transform: translateY(0) rotate(0) scale(1); }
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.modal {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px 20px;
  width: 100%; max-width: 360px;
  animation: fade-up .3s ease;
}
.modal h3 { font-size: 20px; font-weight: 900; text-align: center; margin-bottom: 8px; }
.modal p  { font-size: 14px; color: var(--text-2); text-align: center; margin-bottom: 20px; }

/* ---------- Chip de estado ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 40px; padding: 4px 12px;
  font-size: 12px; font-weight: 800;
}
.chip-green  { background: rgba(45,198,83,.15); color: var(--green); }
.chip-red    { background: rgba(230,57,70,.15);  color: var(--red); }
.chip-gold   { background: rgba(200,168,75,.15); color: var(--accent-l); }
.chip-blue   { background: rgba(67,97,238,.15);  color: var(--blue); }

/* ---------- Lobby ---------- */
.player-slot {
  background: var(--bg-3); border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm); padding: 14px;
  display: flex; align-items: center; gap: 12px;
  transition: border-color .2s;
}
.player-slot.filled { border-style: solid; border-color: var(--accent); }
.player-slot.ai     { border-color: rgba(67,97,238,0.4); }
.slot-avatar { font-size: 30px; }
.slot-name   { font-weight: 800; font-size: 15px; }
.slot-label  { font-size: 12px; color: var(--text-2); }
.slot-team-badge {
  margin-left: auto;
  padding: 4px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 800;
}
.team-1 { background: rgba(230,57,70,.2); color: #e63946; }
.team-2 { background: rgba(67,97,238,.2); color: #4361ee; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 4px; }
