/* ═══════════════════════════════════════════════════════════════════
   Casino Night — Sistema visual
   Estética: casino elegante (Dirección de Arte).
   UX: videojuego (botones grandes, retratos grandes, muy app).
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --ink:        #0D0D0D;
  --ink-2:      #171310;
  --ink-3:      #211B16;
  --gold:       #C9A227;
  --gold-soft:  #A8842A;
  --gold-line:  rgba(201, 162, 39, 0.42);
  --ivory:      #F5F0E6;
  --ivory-dim:  rgba(245, 240, 230, 0.66);
  --ivory-faint:rgba(245, 240, 230, 0.42);
  --burgundy:   #6E1D25;
  --felt:       #1F5C3A;

  --font-serif:  'Cinzel', Georgia, 'Times New Roman', serif;
  --font-script: 'Courgette', 'Segoe Script', cursive;
  --font-sans:   'Elms Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --radius: 18px;
  --radius-sm: 12px;
  --nav-h: 68px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(201, 162, 39, 0.07), transparent 60%),
    var(--ink);
  color: var(--ivory);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}

.app {
  max-width: 820px;
  margin: 0 auto;
  padding: 18px 16px calc(var(--nav-h) + 28px);
  min-height: 100vh;
}

/* ── Jerarquía tipográfica ─────────────────────────────── */

h1, h2, h3 { font-family: var(--font-serif); font-weight: 700; line-height: 1.15; margin: 0 0 0.5em; }

h1 { font-size: clamp(2rem, 7vw, 3.2rem); letter-spacing: 0.02em; }
h2 { font-size: clamp(1.45rem, 4.5vw, 2rem); }
h3 { font-size: 1.2rem; margin: 1.3em 0 0.55em; }

.view h1 { margin: 0.35em 0 0.7em; text-align: center; }
.card h3:first-child, .fallback-back h3 { margin-top: 0; }

a.card { color: inherit; text-decoration: none; }

.serif { font-family: var(--font-serif); }
.script { font-family: var(--font-script); font-size: 1.7em; color: var(--gold); line-height: 1.2; }
.muted { color: var(--ivory-dim); }
.small { font-size: 0.85rem; }

/* ── Ornamentación ─────────────────────────────────────── */

.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-line), transparent);
  border: 0;
  margin: 22px 0;
}

.logo {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 8.5vw, 3.2rem);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-align: center;
  margin: 6px 0 2px;
}
.logo small { display: block; font-family: var(--font-sans); font-weight: 500; font-size: 0.36em; letter-spacing: 0.28em; text-transform: uppercase; color: var(--gold-soft); margin-top: 8px; }

.tagline {
  text-align: center;
  color: var(--ivory-dim);
  max-width: 30em;
  margin: 10px auto 0;
  font-size: 0.98rem;
}

/* ── Botones (grandes, tipo juego) ─────────────────────── */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 14px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--gold-line);
  background: transparent;
  color: var(--ivory);
  font-family: var(--font-sans);
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s var(--ease), background 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:active { transform: scale(0.97); }

.btn--primary {
  background: linear-gradient(180deg, #D9B44C, #B8902A);
  border-color: #D9B44C;
  color: #151007;
  box-shadow: 0 6px 22px rgba(201, 162, 39, 0.35);
}
.btn--ghost { background: var(--ink-2); }
.btn--danger { border-color: rgba(180, 60, 60, 0.6); color: #E5A0A0; }

.btn-row { display: flex; flex-direction: column; gap: 12px; margin: 18px 0; }
@media (min-width: 600px) {
  .btn-row--2 { flex-direction: row; }
  .btn-row--2 .btn { flex: 1; }
}

/* ── Tarjetas y retratos ───────────────────────────────── */

.card {
  background: linear-gradient(180deg, var(--ink-2), var(--ink-3));
  border: 1px solid var(--gold-line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (min-width: 600px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 760px) { .grid { grid-template-columns: repeat(4, 1fr); } }

.char-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 10px;
  text-align: center;
  background: linear-gradient(180deg, var(--ink-2), var(--ink-3));
  border: 1px solid var(--gold-line);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ivory);
  cursor: pointer;
  transition: transform 0.12s var(--ease), border-color 0.15s;
}
.char-card:active { transform: scale(0.96); }
.char-card .name { font-family: var(--font-serif); font-size: 1.05rem; font-weight: 700; }
.char-card .power { font-size: 0.78rem; color: var(--gold-soft); text-transform: uppercase; letter-spacing: 0.12em; }

.portrait, .avatar-img {
  border-radius: 50%;
  border: 2px solid var(--gold-line);
  background: var(--ink-3);
  object-fit: cover;
}
.portrait { width: min(250px, 62vw); height: min(250px, 62vw); }
.portrait--lg { width: min(220px, 54vw); height: min(220px, 54vw); }

.avatar { width: 64px; height: 64px; border-radius: 50%; flex: none; }
.avatar-sm { width: 46px; height: 46px; }

.avatar-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 25%, var(--ink-3), var(--ink));
  border: 2px solid var(--gold-line);
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--gold);
}

/* ── Badges, chips, listas ─────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--gold-line);
  background: rgba(201, 162, 39, 0.08);
  color: var(--gold-soft);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge--felt { border-color: rgba(31, 92, 58, 0.8); background: rgba(31, 92, 58, 0.16); color: #7FC39A; }
.badge--empty { border-color: var(--ivory-faint); background: transparent; color: var(--ivory-faint); }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.list li { padding-left: 22px; position: relative; }
.list li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 0.62em;
  width: 8px;
  height: 8px;
  transform: rotate(45deg);
  border: 1px solid var(--gold);
}

.row { display: flex; align-items: center; gap: 14px; }
.row--between { justify-content: space-between; }
.flex { display: flex; gap: 12px; }
.flex-col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; }

/* ── Formularios ───────────────────────────────────────── */

label { display: block; font-size: 0.82rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ivory-dim); margin: 16px 0 6px; }

.input, select.input {
  width: 100%;
  min-height: 54px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gold-line);
  background: #0F0C0A;
  color: var(--ivory);
  font-family: var(--font-sans);
  font-size: 1.02rem;
  -webkit-appearance: none;
  appearance: none;
}
select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='10'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%23C9A227' fill='none' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 42px;
}
.input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.18); }

.check-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px dashed var(--gold-line); }
.check-row:last-child { border-bottom: 0; }
.check-row input { width: 22px; height: 22px; accent-color: var(--gold); flex: none; }

/* ── Navegación inferior (muy app) ─────────────────────── */

.nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 820px;
  height: var(--nav-h);
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  background: rgba(13, 13, 13, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--gold-line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 50;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  flex: 1 0 62px;
  min-width: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ivory-dim);
  text-decoration: none;
  font-size: 0.5rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-weight: 600;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
  scroll-snap-align: center;
}
.nav a .ico { font-size: 1.15rem; line-height: 1; display: flex; }
.nav a .ico .ph { font-size: inherit; line-height: 1; }
.nav a.active { color: var(--gold); }
.nav a:active { transform: scale(0.94); }

/* Iconos Phosphor (color plano, heredan el color del texto) */
.btn .ph { font-size: 1.3rem; }
.btn--primary .ph { color: #151007; }
.slider-arrow .ph { font-size: 1.1rem; }
.settings-ico { display: inline-flex; width: 26px; justify-content: center; }
.game-ico { font-size: 1.8rem; color: var(--gold-soft); display: inline-flex; }
.game-big-icon { font-size: 3rem; color: var(--gold-soft); display: inline-flex; }

/* ── Tablas ────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; border: 1px solid var(--gold-line); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; min-width: 460px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid rgba(201, 162, 39, 0.18); }
th { background: rgba(201, 162, 39, 0.1); color: var(--gold-soft); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; }
tr:last-child td { border-bottom: 0; }

/* ── Página de partida ─────────────────────────────────── */

.player-card { display: flex; gap: 14px; align-items: flex-start; }
.player-card .meta { flex: 1; min-width: 0; }
.player-card .meta h3 { margin: 0 0 4px; font-size: 1.15rem; }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

.field-note { font-size: 0.8rem; color: var(--ivory-dim); margin-top: 4px; }

/* ── Modal y toast ─────────────────────────────────────── */

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 5, 0.78);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 90;
  animation: fade 0.2s var(--ease);
}
.modal {
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--ink-2);
  border: 1px solid var(--gold-line);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
  animation: slideUp 0.24s var(--ease);
}
@media (min-width: 600px) {
  .modal-back { align-items: center; padding: 20px; }
  .modal { border-radius: 22px; }
}

#toast-root { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 480px); }
.toast {
  background: var(--ink-2);
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.95rem;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: slideDown 0.22s var(--ease);
}
.toast--err { border-color: rgba(200, 90, 90, 0.7); color: #E8B4B4; }
.toast--ok  { border-color: rgba(127, 195, 154, 0.7); color: #BFE8CF; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideDown { from { transform: translateY(-14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.view { animation: fadeIn 0.22s var(--ease); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Utilidades ────────────────────────────────────────── */

.center { text-align: center; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.avoid-nav { margin-bottom: 10px; }
.spacer { height: 20px; }
.hidden { display: none !important; }
.error-text { color: #E8B4B4; font-size: 0.92rem; margin-top: 8px; }

/* ── Slider de personajes (cartas del casino) ──────────── */

.slider-wrap { position: relative; }

.slider {
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  margin: 0 -16px;
  padding: 6px 0;
}
.slider::-webkit-scrollbar { display: none; }
@media (min-width: 760px) {
  .slider { max-width: 640px; margin-left: auto; margin-right: auto; }
}

.slider-track { display: flex; gap: 14px; }
.slide-spacer { flex: 0 0 auto; }

.slide {
  flex: 0 0 74%;
  scroll-snap-align: center;
  text-decoration: none;
  color: var(--ivory);
}
@media (min-width: 600px) { .slide { flex-basis: 300px; } }

.slide-card {
  display: flex;
  flex-direction: column;
  aspect-ratio: 0.72;
  border-radius: 22px;
  border: 1px solid var(--gold);
  background: linear-gradient(180deg, #1B1612, #120E0B);
  box-shadow:
    0 16px 36px rgba(0, 0, 0, 0.55),
    inset 0 0 0 4px var(--ink),
    inset 0 0 0 5px var(--gold-line);
  overflow: hidden;
  transition: transform 0.15s var(--ease);
}
.slide-card:active { transform: scale(0.98); }

.slide-art { flex: 1; min-height: 0; background: #0F0C0A; }
.slide-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slide-art .slide-fill { width: 100%; height: 100%; border-radius: 0; font-size: 3rem; }

.slide-body {
  padding: 12px 14px 14px;
  text-align: center;
  border-top: 1px solid var(--gold-line);
}
.slide-name { display: block; font-family: var(--font-serif); font-size: 1.25rem; font-weight: 700; }
.slide-phrase {
  display: block;
  font-family: var(--font-script);
  font-size: 1.15rem;
  color: var(--gold);
  margin: 2px 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slide-power {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-soft);
}

/* Carta real (imagen completa 65×90) con volteo 3D */
.card3d { position: relative; aspect-ratio: 0.72; perspective: 1400px; }
.card3d--detail { max-width: 280px; margin: 0 auto; }
.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s var(--ease);
}
.card-inner.card-flip { transform: rotateY(180deg); }
.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 18px;
  overflow: hidden;
}
.card-front { background: #0F0C0A; }
.card-back { transform: rotateY(180deg); background: #0F0C0A; }
.card-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #0F0C0A;
  border: 1px solid var(--gold-line);
  border-radius: 18px;
}

.fallback-front {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #1B1612, #120E0B);
  border: 1px solid var(--gold-line);
  border-radius: 18px;
  overflow: hidden;
}
.fallback-art { flex: 1; min-height: 0; background: #0F0C0A; }
.fallback-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fallback-art .avatar-ph, .fallback-art .slide-fill { width: 100%; height: 100%; border-radius: 0; font-size: 3rem; }
.fallback-meta { padding: 12px 14px 14px; text-align: center; border-top: 1px solid var(--gold-line); }
.fallback-back {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 18px;
  text-align: left;
  background: #0F0C0A;
  border: 1px solid var(--gold-line);
  border-radius: 18px;
}
.fallback-back h3 { font-family: var(--font-serif); color: var(--gold); font-size: 1.3rem; }

.slider-arrow {
  position: absolute;
  top: 42%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(13, 13, 13, 0.72);
  border: 1px solid var(--gold-line);
  color: var(--gold);
  font-size: 1.5rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  -webkit-tap-highlight-color: transparent;
}
.slider-arrow--prev { left: 6px; }
.slider-arrow--next { right: 6px; }
.slider-arrow:active { transform: translateY(-50%) scale(0.93); }

.dot-current {
  margin-top: 10px;
  text-align: center;
  color: var(--gold);
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
}

.slider-dots {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 6px 2px 2px;
}
.slider-dots::-webkit-scrollbar { display: none; }

.dot {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  padding: 0;
  border: 2px solid var(--gold-line);
  background: var(--ink-3);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.dot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dot.active { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.25); }
.dot-ph {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--gold);
  background: var(--ink-3);
}

.slide-actions { display: flex; justify-content: center; margin: 14px 0 6px; min-height: 44px; }
.slide-action { display: none; width: 100%; justify-content: center; }
.slide-action.active { display: flex; }

.btn-sm { min-height: 44px; padding: 10px 22px; font-size: 0.92rem; width: auto; }

.card-front-fallback { background: transparent !important; }
.card-front-fallback::before { display: none; }

/* ── Pizarra ──────────────────────────────────────────── */

.note-form .input { margin-bottom: 4px; }
.note { margin-bottom: 10px; }
.note-text { margin: 0 0 8px; white-space: pre-wrap; word-break: break-word; }
.note-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.note-meta > span { font-size: 0.78rem; color: var(--ivory-dim); display: inline-flex; align-items: center; gap: 4px; }
.note-meta .ph { color: var(--gold-soft); }
.note-del {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--ivory-faint);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}
.note-del:active { color: #E5A0A0; }

.note-media {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gold-line);
  margin-bottom: 10px;
  background: #0F0C0A;
}
.note-media[controls] { object-fit: contain; max-height: 300px; }

.attach-bar { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.attach-info { font-size: 0.78rem; }
.attach-preview { position: relative; margin-top: 10px; }
.attach-preview .note-del { position: absolute; top: 8px; right: 8px; background: rgba(13, 13, 13, 0.8); }

/* Verde tapete solo en contexto de juego */
.felt { color: #7FC39A; }
.entry { color: #7FC39A; font-weight: 600; }
