@font-face { font-family: 'PS2P'; src: url('../assets/fonts/PressStart2P.ttf'); font-display: block; }

:root {
  --ink: #141c26; --panel: #2b3b4c; --panel2: #3d5266; --txt: #f4f1e8; --dim: #8fa4b6;
  --blue: #2d8cff; --blue-d: #194f9c; --red: #f0545c; --red-d: #96303a;
  --orange: #ffa62b; --orange-d: #a8620e; --gold: #ffd34d; --gold-d: #a47c10;
  --gray: #5c7184; --gray-d: #34434f;
  --back: url(../assets/cards/card_back.png);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #0e3b2c; color: var(--txt);
  font-family: 'PS2P', monospace; font-size: 8px; line-height: 1.5;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

#bg { position: fixed; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
#stage { position: absolute; transform-origin: 0 0; overflow: hidden; }
#board { position: absolute; inset: 0; }
#spark, #fx { position: absolute; left: 0; top: 0; pointer-events: none; image-rendering: pixelated; }
#spark { z-index: 5000; }
#fx { z-index: 4000; }

/* ---------- HUD ---------- */
#hud {
  position: absolute; left: 0; right: 0; top: 0; height: 18px; z-index: 6000;
  display: flex; justify-content: space-between; align-items: center; padding: 0 8px;
  background: rgba(10, 16, 22, .6); box-shadow: 0 2px 0 rgba(0, 0, 0, .35);
}
.stat { display: flex; gap: 5px; align-items: baseline; }
.stat i { font-style: normal; color: var(--dim); }
.stat b { font-weight: 400; color: var(--gold); text-shadow: 1px 1px 0 #000a; }

/* ---------- Cartas ---------- */
.card { position: absolute; left: 0; top: 0; width: 42px; height: 60px;
  transition: transform .2s cubic-bezier(.2, .9, .3, 1); will-change: transform; }
.card .in {
  width: 100%; height: 100%; background-repeat: no-repeat; background-size: 64px 64px;
  background-position: -11px -2px; image-rendering: pixelated; transform-origin: 50% 0;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .32)); transition: transform .12s;
}
.card.mv { cursor: grab; }
.card.mv:hover .in { transform: translateY(-2px); }
.card.drag { transition: none; cursor: grabbing; }
.card.drag .in { filter: drop-shadow(0 6px 0 rgba(0, 0, 0, .28)); }
#board.noanim .card { transition: none !important; }
.card.hint .in { animation: glow .45s steps(2) infinite; }
@keyframes glow {
  0% { filter: drop-shadow(0 0 0 #ffd34d) drop-shadow(1px 0 0 #ffd34d) drop-shadow(-1px 0 0 #ffd34d) drop-shadow(0 -1px 0 #ffd34d); }
  100% { filter: brightness(1.18) drop-shadow(1px 0 0 #fff) drop-shadow(-1px 0 0 #fff) drop-shadow(0 -1px 0 #fff); }
}

.slot { position: absolute; left: 0; top: 0; width: 42px; height: 60px; z-index: 0;
  border: 1px dashed rgba(255, 255, 255, .22); background: rgba(0, 0, 0, .2); border-radius: 2px; }
.slot.stock { cursor: pointer; }
.slot i { position: absolute; left: 16px; top: 25px; width: 9px; height: 9px; background-size: 9px 9px;
  image-rendering: pixelated; opacity: .35; }
.slot.stock.recycle i { opacity: .9; }
.slot.found img { position: absolute; left: 12px; top: 22px; width: 16px; height: 16px; image-rendering: pixelated; opacity: .32; }
.slot.hint { border-color: var(--gold); animation: slotglow .45s steps(2) infinite; }
@keyframes slotglow { 0% { background: rgba(255, 211, 77, .12); } 100% { background: rgba(255, 211, 77, .35); } }

/* ---------- Botones ---------- */
.btn {
  --c: var(--gray); --cd: var(--gray-d);
  position: relative; border: 0; padding: 6px 7px 5px; color: #fff; background: var(--c);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, .45); letter-spacing: 0;
  box-shadow: -1px 0 0 var(--c), 1px 0 0 var(--c), 0 -1px 0 var(--c),
              0 3px 0 var(--cd), -1px 2px 0 var(--cd), 1px 2px 0 var(--cd), 0 4px 0 rgba(0, 0, 0, .35);
  margin-bottom: 4px;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(2px); box-shadow: -1px 0 0 var(--c), 1px 0 0 var(--c), 0 -1px 0 var(--c), 0 1px 0 var(--cd), 0 2px 0 rgba(0, 0, 0, .35); }
.btn.blue { --c: var(--blue); --cd: var(--blue-d); }
.btn.red { --c: var(--red); --cd: var(--red-d); }
.btn.orange { --c: var(--orange); --cd: var(--orange-d); color: #2a1600; text-shadow: none; }
.btn.gold { --c: var(--gold); --cd: var(--gold-d); color: #2a1f00; text-shadow: none; }
.btn.gray { --c: var(--gray); --cd: var(--gray-d); }
.btn.dis { opacity: .4; pointer-events: none; }
.btn.big { padding: 9px 14px 8px; font-size: 10px; min-width: 120px; }
.btn.pulse { animation: pulse .5s steps(2) infinite; }
@keyframes pulse { 50% { filter: brightness(1.3); } }

#bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 30px; z-index: 6000;
  display: flex; justify-content: center; align-items: center; gap: 6px; padding: 4px 6px 0;
  background: rgba(10, 16, 22, .6); box-shadow: 0 -2px 0 rgba(0, 0, 0, .35);
}
#bar .btn { margin-bottom: 4px; }

#toast {
  position: absolute; left: 50%; bottom: 40px; transform: translate(-50%, 6px); z-index: 7000;
  background: var(--ink); color: var(--gold); padding: 6px 8px; opacity: 0; pointer-events: none; white-space: nowrap;
  box-shadow: 0 0 0 1px var(--panel2), 0 3px 0 1px #000a; transition: opacity .15s, transform .15s;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Overlays / paneles ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 8000; display: none; flex-direction: column;
  align-items: center; justify-content: center; background: rgba(8, 14, 20, .78); text-align: center;
}
.overlay.on { display: flex; }
.overlay.light { background: rgba(8, 14, 20, .5); }
#title { background: rgba(8, 14, 20, .93); gap: 0; }
.panel {
  background: var(--panel); padding: 10px 12px 6px; max-width: 94%; width: 250px;
  box-shadow: 0 0 0 1px var(--panel2) inset, 0 0 0 2px var(--ink), 0 -2px 0 2px var(--ink), 0 2px 0 2px var(--ink), 0 6px 0 2px rgba(0, 0, 0, .45);
}
.panel.small { width: 200px; }
.panel h2 { margin: 0 0 8px; font-size: 10px; font-weight: 400; color: var(--txt); text-shadow: 2px 2px 0 #000a; }
.panel h2.gold { color: var(--gold); font-size: 14px; text-shadow: 0 2px 0 #b3361f, 0 4px 0 rgba(0, 0, 0, .4); margin: 4px 0 8px; }
.panel p { margin: 0 0 8px; }
.dim { color: var(--dim); margin: 6px 0 4px; font-size: 7px; }
.col { display: flex; flex-direction: column; align-items: stretch; gap: 4px; margin: 6px 0; }
.title .col, #title .col { align-items: center; }
#title .col .btn { min-width: 120px; }
.row { display: flex; gap: 10px; justify-content: center; margin: 8px 0 4px; }

#opts { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.opt {
  display: flex; justify-content: space-between; align-items: center; padding: 6px 7px; border: 0; color: var(--txt);
  background: var(--ink); text-align: left; box-shadow: 0 0 0 1px var(--panel2);
}
.opt b { font-weight: 400; color: var(--gold); }
.opt:hover { background: #1d2a38; }
.how { list-style: none; margin: 0 0 8px; padding: 0; text-align: left; font-size: 7px; line-height: 1.7; }
.how li { padding: 3px 0 3px 10px; position: relative; }
.how li::before { content: ''; position: absolute; left: 0; top: 7px; width: 4px; height: 4px; background: var(--gold); }
.res { width: 100%; margin: 0 0 8px; border-collapse: collapse; text-align: left; }
.res td { padding: 3px 0; border-bottom: 1px dashed rgba(255, 255, 255, .15); }
.res td:last-child { text-align: right; color: var(--gold); }

/* título */
.hero { display: flex; align-items: flex-end; justify-content: center; gap: 4px; height: 76px; margin-top: -6px; }
.hero.small { height: 52px; margin-bottom: 2px; }
.logo { width: 64px; height: 64px; image-rendering: pixelated; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .4)); }
.hero.small .logo { width: 32px; height: 32px; }
.bob { animation: bob 1.4s steps(5) infinite; }
@keyframes bob { 50% { transform: translateY(-5px); } }
.jk { width: 42px; height: 60px; background: url(../assets/cards/card_joker_red.png) -11px -2px / 64px 64px no-repeat;
  image-rendering: pixelated; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .4)); }
.jk.l { transform: rotate(-14deg) translateX(8px); }
.jk.r { transform: rotate(14deg) translateX(-8px); background-image: url(../assets/cards/card_joker_black.png); }
.hero.small .jk { transform: scale(.7) rotate(-14deg); }
.hero.small .jk.r { transform: scale(.7) rotate(14deg); }
h1 { margin: 6px 0 2px; font-size: 20px; font-weight: 400; color: var(--gold); letter-spacing: 1px;
  text-shadow: 0 2px 0 #b3361f, 0 4px 0 #6b1d12, 0 7px 0 rgba(0, 0, 0, .4); }
h1 span { display: inline-block; animation: wave 1.6s steps(4) infinite; }
@keyframes wave { 50% { transform: translateY(-3px); } }
.sub { color: var(--dim); margin: 0 0 10px; letter-spacing: 1px; }
.mini-back { display: none; }

/* ---------- Pantalla ---------- */
#loading { position: absolute; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; background: #0e1b17; color: var(--gold); }
#crt { position: fixed; inset: 0; pointer-events: none; z-index: 99999; display: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, .13) 0, rgba(0, 0, 0, .13) 1px, transparent 1px, transparent 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .45) 100%); }
body.crt #crt { display: block; }
