/* ══════════════════════════════════════════════
   THE BLACK LOTUS — rediseño (B: mano 8×2 + dock · D: inicio)
══════════════════════════════════════════════ */

:root {
  --bg:        #0e0619;
  --table:     #120a22;
  --surface:   #170d29;
  --card-back: #1d1135;
  --line:      #2e1f4d;
  --line-2:    #3a2861;
  --violet:    #8b5cf6;
  --violet-dk: #3b1d73;
  --gold:      #e2c26b;
  --gold-lt:   #f3dc9a;
  --gold-bg:   #241a05;
  --text:      #efe8fa;
  --dim:       #b1a6c6;
  --win:       #6ee7b7;
  --win-bg:    #0f2a22;
  --lose:      #fca5a5;
  --lose-bg:   #2d1215;
  --lose-line: #7a3b3b;
  --radius:    12px;

  --font-display: 'Cinzel', Georgia, serif;
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* medidas del layout de escritorio */
  --topbar-h: 76px;
  --dock-h:   120px;
  --gap:      20px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  overflow: hidden;
}

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ── Botones comunes ── */
.icon-btn {
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--text);
  transition: border-color .2s, background .2s;
}
.icon-btn:hover { border-color: var(--violet); background: rgba(139,92,246,.08); }

.btn-gold {
  height: 48px; padding: 0 24px;
  border: none; border-radius: 14px;
  background: var(--gold); color: #1a1205;
  font-weight: 700; font-size: 16px;
  transition: background .2s, transform .1s;
}
.btn-gold:hover  { background: var(--gold-lt); }
.btn-gold:active { transform: scale(.98); }
.btn-lg { height: 56px; font-size: 17px; }

.btn-link {
  height: 44px; border: none; background: transparent;
  color: var(--dim); font-size: 15px; text-decoration: underline;
}
.btn-link:hover { color: var(--text); }

.btn-ghost {
  height: 44px; padding: 0 32px;
  border: 1px solid var(--line-2); border-radius: 999px;
  background: transparent; color: var(--text); font-weight: 600;
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }

/* sonido: mostrar el icono que toca */
.ico-sound-off { display: none; }
body.muted .ico-sound-on  { display: none; }
body.muted .ico-sound-off { display: block; }

/* ══════════════════════════════════════════════
   INICIO (D)
══════════════════════════════════════════════ */
.splash {
  position: fixed; inset: 0; z-index: 200;
  display: flex; justify-content: center;
  overflow-y: auto;
  background: radial-gradient(ellipse at 50% 30%, #1d1035 0%, var(--bg) 65%);
  transition: opacity .5s ease;
}
.splash.leaving { opacity: 0; pointer-events: none; }

.splash-inner {
  width: 100%; max-width: 440px; min-height: 100%;
  padding: max(20px, env(safe-area-inset-top)) 24px max(32px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center;
}

.splash-top { align-self: stretch; display: flex; justify-content: flex-end; }

.splash-fan {
  position: relative;
  width: 300px; height: 280px;
  margin-top: 8px;
  flex-shrink: 0;
}
.splash-fan img {
  position: absolute; object-fit: cover; border-radius: 10px;
  pointer-events: none;
}
.fan-left, .fan-right { top: 36px; width: 140px; height: 200px; opacity: .75; }
.fan-left  { left: 22px;  transform: rotate(-12deg); }
.fan-right { right: 22px; transform: rotate(12deg); }
.fan-center {
  left: 70px; top: 6px; width: 160px; height: 228px;
  border-radius: 12px; border: 2px solid var(--gold);
  box-shadow: 0 0 40px rgba(226,194,107,.35);
  animation: floatCard 4s ease-in-out infinite;
}
@keyframes floatCard { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.splash-title {
  margin-top: 4px;
  font-family: var(--font-display); font-weight: 700;
  font-size: 34px; letter-spacing: .06em; line-height: 1.1;
  color: var(--gold); text-align: center;
}
.splash-subtitle { margin-top: 8px; font-size: 16px; color: var(--dim); text-align: center; }

.splash-steps {
  list-style: none; align-self: stretch;
  margin-top: 24px;
  display: flex; flex-direction: column; gap: 10px;
}
.splash-steps li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); font-size: 15px;
}
.step-num {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--line); color: var(--gold); font-weight: 700; font-size: 14px;
}

.splash-actions {
  margin-top: auto; padding-top: 24px;
  align-self: stretch;
  display: flex; flex-direction: column; gap: 10px;
}

/* ══════════════════════════════════════════════
   JUEGO (B)
══════════════════════════════════════════════ */
.game {
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  animation: fadeIn .4s ease;
}

/* ── Barra superior ── */
.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  padding: 0 48px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand {
  font-family: var(--font-display); font-weight: 700;
  font-size: 20px; letter-spacing: .12em; color: var(--gold);
}
.topbar-stats { display: flex; align-items: center; gap: 40px; }
.stat { display: flex; flex-direction: column; align-items: flex-end; }
.stat-label { font-size: 12px; color: var(--dim); }
.stat-value { font-size: 18px; font-weight: 700; }
.stat-value.big { font-size: 28px; color: #fff; line-height: 1.1; }
.mult { color: var(--gold); font-weight: 600; }

.stat-value.bump { animation: bump .5s ease; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* menú */
.menu-wrap { position: relative; }
.menu-panel {
  position: absolute; right: 0; top: 52px; z-index: 50;
  min-width: 260px; padding: 6px;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0,0,0,.5);
}
.menu-item {
  min-height: 44px; padding: 0 14px;
  text-align: left; border: none; border-radius: 8px;
  background: transparent; font-size: 15px;
}
.menu-item:hover { background: rgba(139,92,246,.12); }
.menu-item.danger { color: var(--lose); }
.menu-item.danger.confirm { background: var(--lose-bg); font-weight: 700; }

/* ── Mesa ── */
.table {
  flex: 1; min-height: 0; position: relative;
  padding: 48px 48px 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px;
  background: var(--table);
}

/* alto disponible para cada carta en la mano 8×2 */
.board {
  --card-h: calc((100dvh - var(--topbar-h) - var(--dock-h) - 96px - 44px - var(--gap)) / 2);
  width: min(100%, calc(var(--card-h) * 5 / 7 * 8 + 7 * var(--gap)), 1400px);
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: var(--gap);
}

.table-hint { font-size: 14px; color: var(--dim); text-align: center; }

/* ── Carta ── */
.card {
  position: relative;
  aspect-ratio: 5 / 7;
  padding: 0; border: none; background: none;
  perspective: 900px;
  transition: transform .35s ease;
}
.card-inner {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.3,.7,.3,1);
}
.card.flipped .card-inner { transform: rotateY(180deg); }

.card-face {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: var(--radius); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}

.card-back {
  background: var(--card-back);
  border: 1px solid var(--line-2);
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.card-back svg { width: 50%; height: auto; }
.card:not(.played):hover .card-back,
.card:not(.played):focus-visible .card-back {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(226,194,107,.2);
}
.card:not(.played):hover { transform: translateY(-4px); }
.card:focus-visible { outline: none; }

.card-front {
  transform: rotateY(180deg);
  background: #000;
  border: 2px solid var(--ring, var(--line-2));
}
.card-front img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }

.card.played { cursor: zoom-in; }
.card.result-win  { --ring: var(--win); }
.card.result-lose { --ring: var(--lose); }
.card.result-gold { --ring: var(--gold); }

/* la última carta revelada se levanta */
.card.latest { transform: translateY(-10px) scale(1.04); z-index: 2; }
.card.latest .card-front { box-shadow: 0 0 0 4px rgba(226,194,107,.22), 0 18px 40px rgba(0,0,0,.5); }
.card.latest.result-win  .card-front { box-shadow: 0 0 0 4px rgba(110,231,183,.2),  0 18px 40px rgba(0,0,0,.5); }
.card.latest.result-lose .card-front { box-shadow: 0 0 0 4px rgba(252,165,165,.2), 0 18px 40px rgba(0,0,0,.5); }

.board.busy .card:not(.played) { pointer-events: none; }

/* ── Toast de resultado (sustituye al modal) ── */
.toast {
  position: absolute; top: 14px; left: 50%; z-index: 10;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 12px;
  padding: 10px 22px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line-2);
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  white-space: nowrap;
  animation: toastIn .3s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast.out { animation: toastOut .3s ease forwards; }
@keyframes toastOut { to { opacity: 0; transform: translate(-50%, -10px); } }

.toast-title { font-family: var(--font-display); font-weight: 700; font-size: 16px; }
.toast-text  { font-size: 15px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; }
.toast-delta { font-size: 18px; font-weight: 700; }

.toast.win  { border-color: rgba(110,231,183,.5); }
.toast.win  .toast-title, .toast.win .toast-delta { color: var(--win); }
.toast.lose { border-color: rgba(252,165,165,.5); }
.toast.lose .toast-title, .toast.lose .toast-delta { color: var(--lose); }
.toast.gold { background: var(--gold-bg); border-color: var(--gold); }
.toast.gold .toast-title { color: var(--gold-lt); }
.toast.gold .toast-text  { color: #e6d7b0; }

/* ── Dock inferior ── */
.dock {
  height: var(--dock-h); flex-shrink: 0;
  padding: 0 48px max(0px, env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 32px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.dock-label { font-size: 13px; color: var(--dim); font-weight: 500; }

.dock-bet { display: flex; flex-direction: column; gap: 8px; }
.bet-buttons { display: flex; gap: 8px; }
.bet-btn {
  min-width: 64px; height: 48px; padding: 0 12px;
  border-radius: 10px; border: 1px solid var(--line-2);
  background: transparent; color: var(--text);
  font-weight: 600; font-size: 16px;
  transition: border-color .2s, background .2s;
}
.bet-btn:hover { border-color: var(--violet); }
.bet-btn.active { border-color: var(--violet); background: var(--violet-dk); color: #fff; }
.bet-btn.bet-all { border-color: var(--lose-line); color: var(--lose); }
.bet-btn.bet-all.active { background: var(--lose-bg); border-color: var(--lose); }
.bet-btn:disabled { opacity: .35; cursor: not-allowed; }

.dock-divider { width: 1px; height: 64px; background: var(--line-2); }

.dock-odds { display: flex; gap: 28px; }
.odd { display: flex; flex-direction: column; gap: 2px; }
.odd-value { font-size: 26px; font-weight: 700; }
.odd-value.win  { color: var(--win); }
.odd-value.lose { color: var(--lose); }
.odd-value.gold { color: var(--gold); }

.dock-progress { margin-left: auto; width: 260px; display: flex; flex-direction: column; gap: 8px; }
.progress-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--dim); }
.progress-head span:last-child { color: var(--text); font-weight: 600; }
.progress-segs { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 3px; }
.progress-segs span { height: 10px; border-radius: 2px; background: var(--line); transition: background .3s; }
.progress-segs span.win  { background: var(--win); }
.progress-segs span.lose { background: var(--lose); }
.progress-segs span.gold { background: var(--gold); }

/* ══════════════════════════════════════════════
   OVERLAYS (fin, sin fichas, info, zoom)
══════════════════════════════════════════════ */
.overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(8, 3, 16, .9);
  animation: fadeIn .25s ease;
  overflow-y: auto;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.panel {
  width: min(480px, 100%);
  display: flex; flex-direction: column; gap: 18px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--gold); border-radius: 20px;
  box-shadow: 0 0 60px rgba(226,194,107,.15);
  text-align: center;
  animation: scaleIn .3s ease;
}
.panel.panel-lose { border-color: var(--lose-line); box-shadow: 0 0 60px rgba(252,165,165,.12); }
@keyframes scaleIn { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.panel-title { font-family: var(--font-display); font-weight: 700; font-size: 26px; color: var(--gold); }
.panel-title.lose { color: var(--lose); }
.panel-text { font-size: 15px; line-height: 1.5; color: var(--dim); }

.panel-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.panel-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel-stat {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 6px; border-radius: 10px; background: var(--bg);
}
.panel-stat span:last-child { font-size: 22px; font-weight: 700; }

.panel-balance {
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px; border-radius: 12px; background: var(--bg);
}
.balance-value { font-size: 36px; font-weight: 700; color: #fff; }
.balance-diff { font-size: 15px; font-weight: 600; }
.balance-diff.positive { color: var(--win); }
.balance-diff.negative { color: var(--lose); }

.info-list { list-style: none; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.info-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px; background: var(--bg);
}
.info-list img { width: 40px; height: 56px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.info-list .info-body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.info-list .info-name { font-weight: 700; font-size: 15px; }
.info-list .info-desc { font-size: 13px; color: var(--dim); }
.info-list .info-prob { font-weight: 700; color: var(--gold); font-size: 15px; }

.overlay.zoom { cursor: zoom-out; }
.zoom-box { display: flex; flex-direction: column; align-items: center; gap: 16px; cursor: default; animation: scaleIn .25s ease; }
.zoom-box img {
  max-height: 78vh; max-width: 88vw;
  border-radius: 14px;
  box-shadow: 0 0 60px rgba(226,194,107,.35);
}

/* ══════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════ */

/* Inicio en pantallas grandes: centrado en vertical */
@media (min-width: 700px) and (min-height: 700px) {
  .splash { align-items: center; }
  .splash-inner { min-height: 0; margin: auto 0; }
  .splash-actions { margin-top: 0; padding-top: 32px; }
}

/* Pantallas medianas: el dock se compacta */
@media (max-width: 1180px) {
  .topbar, .dock { padding-left: 24px; padding-right: 24px; }
  .table { padding: 48px 24px 0; }
  .dock { gap: 20px; }
  .dock-odds { gap: 18px; }
  .odd-value { font-size: 22px; }
  .bet-btn { min-width: 52px; }
  .dock-progress { width: 180px; }
  .odd-event { display: none; }
}

/* Tablet en vertical y móvil: tablero 4×4 y panel de apuesta abajo */
@media (max-width: 860px) and (min-height: 521px), (orientation: portrait) and (max-width: 1024px) {
  :root { --topbar-h: 68px; --dock-h: 186px; --gap: 8px; }

  .topbar { padding: 0 16px; }
  .brand { display: none; }
  .topbar-stats { flex: 1; justify-content: space-between; gap: 12px; }
  .stat-balance { order: -1; align-items: flex-start; }
  .stat-streak {
    flex-direction: row; align-items: center; gap: 6px;
    margin-left: auto;
    height: 36px; padding: 0 12px; border-radius: 999px;
    background: var(--gold-bg); border: 1px solid #6b5520;
  }
  .stat-streak .stat-label { color: var(--gold-lt); }
  .stat-streak .stat-value { font-size: 14px; color: var(--gold-lt); }

  .table { padding: 56px 16px 0; gap: 10px; justify-content: flex-start; }
  .board {
    --card-h: calc((100dvh - var(--topbar-h) - var(--dock-h) - 56px - 30px - 3 * var(--gap)) / 4);
    width: min(100%, calc(var(--card-h) * 5 / 7 * 4 + 3 * var(--gap)));
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .card-face { border-radius: 8px; }
  .card.latest { transform: scale(1.06); }
  .table-hint { font-size: 12px; }
  .hint-extra { display: none; }

  .toast { top: 10px; padding: 8px 16px; gap: 8px; }
  .toast-title { font-size: 15px; }
  .toast-text { display: none; }
  .toast-delta { font-size: 16px; }

  .dock {
    flex-direction: column; align-items: stretch; justify-content: center;
    gap: 12px;
    padding: 14px 16px max(16px, env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0;
  }
  .dock-divider { display: none; }
  .dock-progress { order: -1; width: 100%; margin: 0; gap: 6px; }
  .progress-segs span { height: 6px; }
  .dock-odds { justify-content: space-between; gap: 8px; }
  .odd { flex-direction: row; align-items: baseline; gap: 6px; }
  .odd-value { font-size: 18px; }
  .dock-bet .dock-label { display: none; }
  .bet-buttons { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
  .bet-btn { min-width: 0; padding: 0; font-size: 15px; }

  .panel { padding: 22px 18px; }
  .panel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Móvil en horizontal (poca altura): mantener la mano 8×2, todo más compacto */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --topbar-h: 52px; --dock-h: 76px; --gap: 8px; }
  .topbar, .dock { padding-left: 16px; padding-right: 16px; }
  .stat-value.big { font-size: 20px; }
  .table { padding: 8px 16px 0; gap: 6px; }
  .board {
    --card-h: calc((100dvh - var(--topbar-h) - var(--dock-h) - 16px - 20px - var(--gap)) / 2);
    width: min(100%, calc(var(--card-h) * 5 / 7 * 8 + 7 * var(--gap)));
  }
  .table-hint { display: none; }
  .dock { gap: 14px; }
  .dock-bet .dock-label, .dock-divider, .dock-progress, .odd-event { display: none; }
  .bet-btn { height: 44px; min-width: 48px; }
  .odd-value { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
