/* Capas flotantes: avisos, tooltip de carta, bocadillos, victoria, historial, mazo y sonido */
@keyframes popIn { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes ctaBlink { 0%, 100% { opacity: 1; } 50% { opacity: .6; } }
@keyframes checkPop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes winPop { from { transform: translateY(10px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes btnUp { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- toast: píldora de tinta translúcida bajo la barra ---- */
#toast {
  position: fixed; top: 66px; left: 50%; z-index: 70; pointer-events: none;
  transform: translate(-50%, -6px); opacity: 0;
  max-width: min(520px, 92vw); text-align: center;
  display: flex; align-items: center; gap: 8px;
  background: rgba(36,36,36,.86); color: var(--cream); padding: 9px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 400; backdrop-filter: blur(4px);
  box-shadow: 0 10px 26px rgba(20,40,20,.25);
  transition: opacity .2s var(--ease-out), transform .25s var(--ease-out);
}
#toast.visible { opacity: 1; transform: translate(-50%, 0); }
#toast.warn { box-shadow: 0 0 0 1.5px var(--accent-deep), 0 10px 26px rgba(20,40,20,.25); }
#toast.warn::before { /* mano de "alto" en línea fina */
  content: ''; width: 16px; height: 16px; flex: 0 0 auto;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M8 12V6.5a1.5 1.5 0 0 1 3 0V11M11 11V4.5a1.5 1.5 0 0 1 3 0V11M14 11V6a1.5 1.5 0 0 1 3 0v7c0 4-2.5 7-6 7-2.5 0-4-1.2-5.2-3.2L4 13.5a1.4 1.4 0 0 1 2.3-1.6L8 14' fill='none' stroke='%23E8873A' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/></svg>") center / contain no-repeat;
}

/* ---- tooltip de carta ---- */
#cardTip {
  position: fixed; left: 0; top: 0; z-index: 90; pointer-events: none;
  width: 260px; padding: 12px 14px; border-radius: 14px;
  background-image: var(--grain); background-color: var(--cream); color: var(--ink); font-size: 12.5px; line-height: 1.4;
  box-shadow: var(--shadow-soft), 6px 6px 0 rgba(20,40,20,.18);
  border-top: 4px solid var(--ink);
  opacity: 0; transition: opacity .15s var(--ease-out);
}
#cardTip.visible { opacity: 1; }
#cardTip.orange { border-top-color: var(--accent); }
#cardTip b { display: block; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
#cardTip .kind { display: inline-block; margin: 4px 0 7px; font-size: 10px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
  padding: 2px 8px; border-radius: 999px; border: 1px solid var(--ink-line); color: var(--ink-soft); }
#cardTip p { color: var(--ink); }
#cardTip .why { margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--cream-line); color: var(--accent-deep); font-weight: 500; }

/* ---- carta jugada en exhibición: capa fija, sin interacción ---- */
#playShow { position: fixed; inset: 0; pointer-events: none; z-index: 94; }

/* ---- bocadillo de tutorial del modo historia ---- */
#storyTip {
  position: fixed; top: 16vh; left: 50%; transform: translate(-50%, 6px);
  z-index: 70; max-width: min(420px, 86vw);
  background-image: var(--grain); background-color: var(--cream); color: var(--ink);
  font-size: 17px; font-weight: 500; letter-spacing: -.01em; text-align: center;
  padding: 12px 22px; border-radius: 16px;
  box-shadow: var(--shadow-soft), 8px 8px 0 rgba(20,40,20,.2);
  opacity: 0; pointer-events: none; transition: opacity .25s var(--ease-out), transform .25s var(--ease-out);
}
#storyTip::after {
  content: ''; position: absolute; left: 50%; bottom: -8px; width: 16px; height: 16px; margin-left: -8px;
  background: var(--cream); transform: rotate(45deg); border-radius: 3px;
}
#storyTip.visible { opacity: 1; transform: translate(-50%, 0); }

/* ---- victoria / hoyo completado ---- */
#winOverlay {
  position: fixed; inset: 0; z-index: 40; display: none; align-items: center; justify-content: center;
  background: rgba(20,40,20,.55); backdrop-filter: blur(6px);
}
#winOverlay.visible { display: flex; animation: fadeIn .25s var(--ease-out); }
#winOverlay .box {
  position: relative; min-width: min(440px, 92vw); max-width: 92vw;
  background-image: var(--grain); background-color: var(--cream);
  border-radius: 20px; padding: 56px 40px 30px; text-align: center;
  border: 1.5px solid transparent;
  box-shadow: var(--shadow-soft), 14px 14px 0 rgba(20,40,20,.25);
  transition: border-color .25s;
}
#winOverlay.visible .box { animation: winPop .3s var(--ease-out); }
.winIcon {
  position: absolute; left: 50%; top: 0; transform: translate(-50%, -50%);
  width: 76px; height: 76px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--cream);
  box-shadow: 6px 6px 0 var(--shadow);
}
.winIcon .i { width: 36px; height: 36px; }
#winOverlay.lost .winIcon { background: var(--grass-dark); }
#winOverlay .msg { font-size: 30px; font-weight: 500; line-height: 1.1; letter-spacing: -.03em; margin-bottom: 16px; }
#winChips { display: flex; gap: 8px; justify-content: center; margin: -4px 0 18px; flex-wrap: wrap; }
#winChips:empty { display: none; }
.winChip { color: #fff; font-weight: 500; font-size: 14px; border-radius: 999px; padding: 5px 16px; box-shadow: 3px 3px 0 var(--shadow); }
#winStats { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 8px; margin: 0 0 24px; }
#winStats .st {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 1px solid var(--cream-line); border-radius: 14px; padding: 9px 6px 8px; font-size: 11px; color: var(--ink-soft);
}
#winStats .st .i { width: 18px; height: 18px; color: var(--grass-dark); }
#winStats .st b { font-size: 20px; font-weight: 500; color: var(--ink); line-height: 1.1; }
#winOverlay.visible #winStats .st { animation: btnUp .3s var(--ease-out) backwards; }
#winOverlay.visible #winStats .st:nth-child(2) { animation-delay: .04s; }
#winOverlay.visible #winStats .st:nth-child(3) { animation-delay: .08s; }
#winOverlay.visible #winStats .st:nth-child(4) { animation-delay: .12s; }
#winOverlay.visible #winStats .st:nth-child(5) { animation-delay: .16s; }
#winStats:empty { display: none; }
#winBtns button { animation: btnUp .3s var(--ease-out) backwards; }
#winBtns button:nth-child(1) { animation-delay: .15s; }
#winBtns button:nth-child(2) { animation-delay: .2s; }
#winBtns button:nth-child(3) { animation-delay: .25s; }
#winBtns .btn-light { --b-bg: transparent; --b-line: var(--ink-line); }

/* ---- historial (cajón lateral) ---- */
#logPanel {
  position: fixed; right: 0; top: 0; bottom: 0; z-index: 48; width: min(330px, 90vw);
  display: flex; flex-direction: column;
  background-image: var(--grain); background-color: var(--cream);
  box-shadow: -10px 0 30px rgba(20,40,20,.25);
  transform: translateX(105%); transition: transform .3s var(--ease-out);
}
#logPanel.open { transform: translateX(0); }
#logHead { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 12px; border-bottom: 1px solid var(--cream-line); }
#logHead h4 { font-size: 20px; font-weight: 500; letter-spacing: -.02em; }
#logHead .btn-ghost { --b-fg: var(--ink); --b-line: var(--ink-line); }
#logList { flex: 1; overflow: auto; padding: 8px 16px 20px; font-size: 13px; line-height: 1.45; }
#logList div { padding: 7px 0; border-bottom: 1px solid var(--cream-line); color: var(--ink-soft); }
#logList div:first-child { color: var(--ink); font-weight: 500; }

/* ---- popover del mazo ---- */
#deckPop {
  position: absolute; right: calc(100% + 12px); top: 50%; transform: translateY(-50%);
  z-index: 48; width: 250px; cursor: default;
  background-image: var(--grain); background-color: var(--cream); color: var(--ink); border-radius: 16px; padding: 12px 14px;
  box-shadow: var(--shadow-soft), 6px 6px 0 rgba(20,40,20,.18); display: none;
  grid-template-columns: 1fr 1fr; gap: 6px 10px; font-size: 12px; text-align: left;
}
#deckPop.open { display: grid; animation: popIn .2s var(--ease-out); }
#deckPop h5 { grid-column: 1 / -1; font-size: 10px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); }
#deckPop .row { display: flex; align-items: center; gap: 6px; }
#deckPop .hintCard { width: 24px; height: 24px; border-radius: 6px; }
#deckPop .n { margin-left: auto; font-weight: 500; }

/* ---- botones de sonido: barra inferior en menús, arriba a la derecha en partida ---- */
#sfxBtn, #sndCfgBtn {
  position: fixed; bottom: 14px; z-index: 65; width: 36px; height: 36px; padding: 0;
  --b-bg: rgba(241,241,220,.92); --b-fg: var(--ink); --b-line: var(--cream-line);
  backdrop-filter: blur(4px);
}
#sfxBtn { left: 14px; }
#sndCfgBtn { left: 56px; }
body[data-screen="game"] #sfxBtn, body[data-screen="game"] #sndCfgBtn { --b-bg: rgba(241,241,220,.06); --b-fg: var(--cream); --b-line: rgba(241,241,220,.55); backdrop-filter: none; }
body[data-screen="game"] #sfxBtn { top: 14px; bottom: auto; left: auto; right: 58px; }
body[data-screen="game"] #sndCfgBtn { top: 14px; bottom: auto; left: auto; right: 16px; }
#sndPanel {
  position: fixed; left: 14px; bottom: 60px; z-index: 66; width: 230px;
  background-image: var(--grain); background-color: var(--cream); border-radius: 16px; padding: 12px 14px;
  box-shadow: var(--shadow-soft), 6px 6px 0 rgba(20,40,20,.18); display: none; font-size: 12.5px;
}
body[data-screen="game"] #sndPanel { top: 60px; bottom: auto; left: auto; right: 14px; }
@media (max-width: 760px) {
  body[data-screen="game"] #sndCfgBtn { display: none; }
  body[data-screen="game"] #sfxBtn { right: 8px; top: 9px; width: 32px; height: 32px; }
}
#sndPanel.open { display: block; animation: popIn .2s var(--ease-out); }
#sndPanel label { display: flex; align-items: center; gap: 8px; margin: 7px 0; }
#sndPanel label .i { color: var(--ink-soft); }
#sndPanel input[type=range] { flex: 1; accent-color: var(--grass-dark); }
#sndPanel input[type=checkbox] { accent-color: var(--grass-dark); }
#sndPanel .mus { border-top: 1px solid var(--cream-line); padding-top: 9px; margin-top: 9px; }
/* selector de idioma (panel de ajustes) */
#sndPanel .langRow { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 9px 0 2px; padding-top: 9px; border-top: 1px solid var(--cream-line); }
#sndPanel .langBtns { display: flex; gap: 4px; }
#sndPanel .langBtns button { padding: 3px 10px; font-size: 11.5px; }
#sndPanel .langBtns button[aria-pressed="true"] { --b-bg: var(--ink); --b-fg: var(--cream); --b-line: var(--ink); }
