/* ================================================================ misiones diarias y cofre de bienvenida (missions.js) */

/* ---------------------------------------------------------------- pantalla de misiones */
.mt-missions .ms-timer { flex: none; display: inline-flex; align-items: center; gap: 10px; margin-top: 1.6vh; padding: 8px 14px; font-size: 9px; letter-spacing: 1px;
  color: #c9d3ee; text-shadow: 2px 2px 0 #000; background: rgba(0,0,0,.55); border: 2px solid #2d3b66; box-shadow: 0 0 0 2px #000; }
.ms-timer svg { width: 16px; height: 16px; flex: none; }
.ms-list { flex: 1 1 auto; min-height: 0; width: min(920px, 94vw); box-sizing: border-box; margin: 2.2vh auto 0; padding: 6px 10px 10px;
  display: flex; flex-direction: column; gap: clamp(10px, 1.8vh, 18px); overflow-y: auto; }

.ms-card { --ic: #ffd84a; position: relative; display: grid; grid-template-columns: 64px minmax(0, 1fr) auto 150px; align-items: center; gap: 18px;
  padding: 14px 18px; cursor: pointer; background: linear-gradient(#1a2552, #0d1330); border: 2px solid #2d3b66;
  box-shadow: 0 0 0 3px #000, 0 6px 0 #000; transition: transform .12s, border-color .12s;
  animation: ms-in .42s cubic-bezier(.3,1.4,.5,1) backwards; animation-delay: calc(var(--k, 0) * 70ms); }
@keyframes ms-in { from { opacity: 0; transform: translateX(-40px); } }
.ms-card.sel { border-color: #ffd84a; transform: translateX(6px); box-shadow: 0 0 0 3px #000, 0 6px 0 #000, 0 0 22px rgba(255,216,74,.25); }
.ms-card.sel::before { content: ""; position: absolute; left: -22px; top: 50%; width: 10px; height: 14px; margin-top: -7px; background: #ffd84a;
  clip-path: polygon(0 0, 100% 50%, 0 100%); animation: ms-arrow .6s steps(2) infinite; }
@keyframes ms-arrow { 50% { transform: translateX(4px); } }
.ms-card.st-ready { border-color: #7dff8a; background: linear-gradient(#1d3a3a, #0d1f22); }
.ms-card.st-ready.sel { border-color: #c9ffd0; }
.ms-card.st-claimed { opacity: .55; filter: saturate(.5); }
.ms-card.st-claimed.sel { opacity: .8; }

.ms-ico { width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; color: var(--ic); background: #05070f;
  box-shadow: 0 0 0 2px #000, inset 0 0 0 2px color-mix(in srgb, var(--ic) 45%, transparent); }
.ms-ico svg { width: 32px; height: 32px; filter: drop-shadow(2px 2px 0 rgba(0,0,0,.7)); }
.ms-bonus .ms-ico svg { width: 40px; height: auto; }
.ms-body { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ms-name { font-weight: normal; font-size: clamp(9px, .95vw, 13px); line-height: 1.6; color: #fff; text-shadow: 2px 2px 0 #000; }
.ms-tag { align-self: flex-start; font-style: normal; font-size: 7px; letter-spacing: 1px; color: #1a1a1a; background: #ffd84a; padding: 4px 6px; box-shadow: 0 0 0 2px #000; }
.ms-bar { position: relative; height: 16px; background: #05070f; box-shadow: 0 0 0 2px #000, inset 0 0 0 2px #1d2850; overflow: hidden; }
.ms-bar s { display: block; height: 100%; text-decoration: none; transition: width .5s cubic-bezier(.3,1,.5,1);
  background: repeating-linear-gradient(90deg, var(--ic) 0 10px, color-mix(in srgb, var(--ic) 72%, #000) 10px 12px);
  box-shadow: inset 0 3px 0 rgba(255,255,255,.35), inset 0 -3px 0 rgba(0,0,0,.25); }
.ms-card.st-ready .ms-bar s, .ms-card.st-claimed .ms-bar s { background: repeating-linear-gradient(90deg, #7dff8a 0 10px, #4fc95c 10px 12px); }
.ms-bar em { position: absolute; inset: 0; font-style: normal; font-size: 8px; line-height: 16px; text-align: center; color: #fff; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000; }

.ms-rw { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; white-space: nowrap; }
.ms-rw > span { display: inline-flex; align-items: center; gap: 7px; text-shadow: 2px 2px 0 #000; }
.ms-rw-coins { font-size: 13px; color: #ffd84a; }
.ms-rw-coins svg { width: 20px; height: 20px; }
.ms-rw-box { font-size: 11px; color: #7fd0ff; }
.ms-rw-box svg { width: 24px; height: auto; }
.ms-rw-xp { font-size: 8px; color: #c084fc; }
.ms-rw b { font-weight: normal; }
.ms-act { display: flex; justify-content: center; }
.ms-act .big-btn { font-size: 10px; padding: 12px 14px; background: #7dff8a; box-shadow: 0 5px 0 #2a8a3a, 0 8px 0 #000; animation: ms-pulse 1s ease-in-out infinite; }
.ms-act .big-btn:hover, .ms-act .big-btn:focus { background: #c9ffd0; }
@keyframes ms-pulse { 50% { filter: brightness(1.15); transform: translateY(-2px); } }
.ms-state { display: inline-flex; align-items: center; gap: 8px; font-size: 9px; color: #7dff8a; text-shadow: 2px 2px 0 #000; }
.ms-state svg { width: 16px; height: auto; }
.ms-state.todo { color: #9fb3e6; }

.ms-bonus { border-color: #b38f00; background: linear-gradient(#3a2a0c, #1a1206); }
.ms-bonus.sel { border-color: #ffd84a; }
.ms-bonus.st-ready { border-color: #ffd84a; background: linear-gradient(#4a3510, #241806); animation: ms-in .42s cubic-bezier(.3,1.4,.5,1) backwards, ms-gold 1.4s ease-in-out infinite; animation-delay: calc(var(--k, 0) * 70ms), 0s; }
@keyframes ms-gold { 50% { box-shadow: 0 0 0 3px #000, 0 6px 0 #000, 0 0 30px rgba(255,216,74,.45); } }
.ms-card.just { animation: ms-just .8s ease-out; }
@keyframes ms-just { 0% { transform: scale(1.04); filter: brightness(2); } 100% { transform: none; filter: none; } }
.ms-shake { animation: ms-shake .35s; }
@keyframes ms-shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }

@media (max-width: 760px) {
  .ms-card { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px 12px; padding: 12px; }
  .ms-ico { width: 40px; height: 40px; }
  .ms-ico svg { width: 24px; height: 24px; }
  .ms-act { grid-column: 1 / -1; }
  .ms-card.sel::before { display: none; }
  .mt-missions .mt-wallet { position: static; justify-content: center; margin-top: 8px; }
  .mt-missions .mt-top { flex-direction: column; padding-top: 60px; }
  .mt-missions .mt-help { padding-right: 60px; padding-left: 60px; }
}
@media (prefers-reduced-motion: reduce) {
  .ms-card, .ms-act .big-btn, .ms-bonus.st-ready { animation: none !important; }
}

/* ---------------------------------------------------------------- cofre de bienvenida (encima de la pantalla final) */
.wc-ov { position: fixed; inset: 0; z-index: 85; display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: radial-gradient(circle at 50% 45%, rgba(40,28,90,.9), rgba(3,5,14,.94) 70%); animation: mt-fade .25s; font-family: "Press Start 2P", monospace; }
.wc-ov.out { opacity: 0; transition: opacity .2s; }
.wc-box { position: relative; display: flex; flex-direction: column; align-items: center; gap: clamp(10px, 2.2vh, 22px); max-width: 94vw; padding: 12px; }
.wc-title { margin: 0; font-weight: normal; font-size: clamp(14px, 2.2vw, 30px); letter-spacing: 2px; text-align: center; color: #ffd84a;
  text-shadow: 2px 2px 0 #b3261e, 4px 4px 0 #000; animation: wc-title 1.6s ease-in-out infinite; }
@keyframes wc-title { 50% { transform: translateY(-4px); } }

.wc-rays { position: absolute; left: 50%; top: 46%; width: 160vmax; height: 160vmax; transform: translate(-50%, -50%); pointer-events: none; opacity: 0;
  background: repeating-conic-gradient(from 0deg, rgba(255,216,74,.32) 0 7deg, transparent 7deg 20deg);
  -webkit-mask: radial-gradient(circle, #000 0, rgba(0,0,0,.6) 12%, transparent 36%); mask: radial-gradient(circle, #000 0, rgba(0,0,0,.6) 12%, transparent 36%);
  animation: mt-spin 16s linear infinite; transition: opacity .4s; }
.wc-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.st-open .wc-flash { animation: wc-flash .45s ease-out; }
@keyframes wc-flash { 0% { opacity: .9; } 100% { opacity: 0; } }
.st-open .wc-rays, .st-reveal .wc-rays, .st-done .wc-rays { opacity: 1; }

/* escena: el cofre abajo y la carta que sale de él */
.wc-scene { position: relative; width: min(420px, 90vw); height: clamp(280px, 52vh, 440px); }
.wc-chest { position: absolute; left: 50%; bottom: 0; width: min(170px, 46vw); transform: translateX(-50%); }
.wc-svg { display: block; width: 100%; height: auto; filter: drop-shadow(4px 6px 0 rgba(0,0,0,.6)); }
.wc-lid { position: relative; z-index: 2; transform-origin: 10% 100%; transition: transform .35s cubic-bezier(.3,1.6,.5,1); }
.wc-base { position: relative; z-index: 1; margin-top: -1px; }
.wc-glow { position: absolute; left: 8%; right: 8%; top: 30%; height: 30%; z-index: 0; opacity: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 60%, #fff6b0, #ffd84a 35%, rgba(255,181,71,0) 70%); filter: blur(4px); transition: opacity .3s; }
.st-drop .wc-chest { animation: wc-drop .5s cubic-bezier(.3,1.5,.5,1) backwards; }
@keyframes wc-drop { from { transform: translate(-50%, -120%) scale(.6); opacity: 0; } }
.st-shake .wc-chest { animation: wc-shake .16s steps(2) infinite; }
.st-shake2 .wc-chest { animation: wc-shake2 .1s steps(2) infinite; }
@keyframes wc-shake { 0% { transform: translateX(-50%) rotate(-3deg); } 100% { transform: translateX(-50%) rotate(3deg); } }
@keyframes wc-shake2 { 0% { transform: translate(-54%, -2px) rotate(-5deg); } 100% { transform: translate(-46%, 1px) rotate(5deg); } }
.st-shake2 .wc-glow { opacity: .7; top: 34%; height: 8%; }
.st-open .wc-lid, .st-reveal .wc-lid, .st-done .wc-lid { transform: translate(-115%, -130%) rotate(-28deg); }
.st-open .wc-glow, .st-reveal .wc-glow, .st-done .wc-glow { opacity: 1; top: 18%; height: 40%; }
.st-done .wc-glow { animation: wc-glow 1.4s ease-in-out infinite; }
@keyframes wc-glow { 50% { opacity: .6; } }

.wc-card { position: absolute; left: 50%; bottom: 74px; z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 10px;
  transform: translate(-50%, 45%) scale(.15); opacity: 0; pointer-events: none;
  transition: transform .55s cubic-bezier(.25,1.5,.45,1), opacity .2s; }
.st-reveal .wc-card, .st-done .wc-card { transform: translate(-50%, 0) scale(1); opacity: 1; }
.wc-card img { width: min(250px, 62vw); image-rendering: pixelated; display: block;
  box-shadow: 0 0 0 3px #000, 0 0 0 6px #ffb547, 0 0 0 9px #000, 0 0 40px rgba(255,216,74,.6); background: #05070f; }
.st-done .wc-card img { animation: wc-card 2s ease-in-out infinite; }
@keyframes wc-card { 50% { box-shadow: 0 0 0 3px #000, 0 0 0 6px #ffd84a, 0 0 0 9px #000, 0 0 60px rgba(255,216,74,.85); } }
.wc-card b { font-weight: normal; font-size: clamp(14px, 1.8vw, 22px); color: #fff; letter-spacing: 2px; text-shadow: 2px 2px 0 #b3261e, 4px 4px 0 #000; white-space: nowrap; }
.wc-card i { font-style: normal; font-size: 8px; letter-spacing: 1px; color: #1a1a1a; background: var(--cc, #ffd84a); padding: 4px 7px; box-shadow: 0 0 0 2px #000; }
.wc-coins { display: inline-flex; }
.wc-coins svg { width: 64px; height: 64px; filter: drop-shadow(3px 3px 0 rgba(0,0,0,.6)); }
.wc-coins svg + svg { margin-left: -24px; }
.wc-card.coins b { color: #ffd84a; }

/* texto y botones: aparecen al final */
.wc-info { display: flex; flex-direction: column; align-items: center; gap: 14px; opacity: 0; transform: translateY(12px); transition: opacity .3s, transform .3s; pointer-events: none; }
.st-done .wc-info { opacity: 1; transform: none; pointer-events: auto; }
.wc-new { margin: 0; font-size: clamp(11px, 1.2vw, 15px); color: #7dff8a; letter-spacing: 2px; text-shadow: 2px 2px 0 #000; }
.wc-note { margin: 0; max-width: min(560px, 90vw); display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 8px; line-height: 2; color: #c9d3ee;
  text-align: center; padding: 10px 14px; background: rgba(0,0,0,.45); border: 1px dashed #4c5a8a; }
.wc-note.saved { color: #7dff8a; border-color: #2a8a3a; }
.wc-note svg { width: 16px; height: auto; flex: none; }
.wc-btns { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.wc-btns .big-btn { font-size: 12px; padding: 13px 24px; }
.wc-btns .big-btn:focus-visible, .wc-btns .big-btn:focus { outline: 3px solid #fff; outline-offset: 4px; }
.wc-skip { position: absolute; bottom: -18px; left: 0; right: 0; margin: 0; text-align: center; font-size: 7px; color: #6a789e; letter-spacing: 1px; animation: wc-blink 1s steps(2) infinite; }
.st-done .wc-skip { display: none; }
@keyframes wc-blink { 50% { opacity: 0; } }

@media (max-height: 560px) {
  .wc-scene { height: 52vh; }
  .wc-card img { width: min(180px, 50vw); }
  .wc-chest { width: min(150px, 40vw); }
}
@media (prefers-reduced-motion: reduce) {
  .wc-rays, .wc-title, .st-done .wc-card img, .st-done .wc-glow { animation: none; }
}
