/* ===== RESET ===== */
*,
*::after,
*::before {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

/* ===== THEME ===== */
:root {
  --gap: 14px;
  --board-padding: 16px;
  --card-radius: 16px;

  --board-width: min(860px, 92vw);
  --ui-max: min(900px, 94vw);

  --card-min: 150px;
  --card-max: 210px;

  --font:
    ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  --title: clamp(22px, 2.4vw, 34px);
  --text: clamp(14px, 1.3vw, 18px);
  --small: clamp(12px, 1vw, 14px);

  --glass: rgba(255, 255, 255, 0.12);
  --glass-strong: rgba(255, 255, 255, 0.18);
  --stroke: rgba(255, 255, 255, 0.25);
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
  --shadow-soft: 0 8px 22px rgba(0, 0, 0, 0.22);
  --gold: #fdd257;

  --ink: rgba(255, 255, 255, 0.92);
  --ink-dim: rgba(255, 255, 255, 0.72);

  /* Ajuste para: Topbar + Footerbar + Crédito */
  --ui-offset: 300px;

  /* ✅ FEEDBACK accesible */
  --fb-text: #ffffff;
  --fb-bg: rgba(10, 12, 18, 0.82);
  --fb-border: rgba(255, 255, 255, 0.26);

  --fb-ok-accent: #00e5a8;
  --fb-bad-accent: #ff5c7a;

  --fb-shadow: 0 20px 55px rgba(0, 0, 0, 0.45);
}

body {
  font-family: var(--font);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background-image:
    radial-gradient(
      1100px 800px at 20% 10%,
      rgba(168, 235, 18, 0.25),
      transparent 55%
    ),
    radial-gradient(
      900px 700px at 85% 20%,
      rgba(0, 191, 114, 0.25),
      transparent 55%
    ),
    radial-gradient(
      800px 600px at 50% 90%,
      rgba(0, 135, 147, 0.22),
      transparent 55%
    ),
    linear-gradient(to right top, #051937, #004d7a, #008793, #00bf72, #a8eb12);
  background-attachment: fixed;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: -40px;
  background:
    radial-gradient(
      circle at 30% 40%,
      rgba(255, 255, 255, 0.08),
      transparent 35%
    ),
    radial-gradient(
      circle at 70% 60%,
      rgba(255, 255, 255, 0.06),
      transparent 35%
    );
  filter: blur(18px);
  animation: floaty 10s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}

@keyframes floaty {
  from {
    transform: translate3d(-8px, -6px, 0);
    opacity: 0.9;
  }
  to {
    transform: translate3d(10px, 8px, 0);
    opacity: 1;
  }
}

.app {
  width: 100%;
  min-height: 100vh;
  display: grid;
  /* ✅ topbar / tablero / footerbar / crédito */
  grid-template-rows: auto 1fr auto auto;
  place-items: center;
  gap: 14px;
  position: relative;
  z-index: 1;
}

.topbar {
  width: var(--ui-max);
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--glass-strong), var(--glass));
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.badge {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(
    135deg,
    rgba(253, 210, 87, 0.95),
    rgba(255, 183, 3, 0.9)
  );
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.22);
  display: grid;
  place-items: center;
  color: #4b2b00;
  font-weight: 900;
  letter-spacing: -0.02em;
  user-select: none;
}

.brandText {
  min-width: 0;
}

.brandText h1 {
  font-size: var(--title);
  line-height: 1.05;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brandText p {
  margin-top: 2px;
  font-size: var(--small);
  color: var(--ink-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.9);
  font-weight: 800;
  font-size: var(--small);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.18);
}

.pill strong {
  color: var(--gold);
}

.progress {
  width: 160px;
  height: 10px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00ff99, #fdd257);
  transition: width 0.4s ease;
}

#playground {
  width: var(--board-width);
  padding: var(--board-padding);
  display: grid;
  gap: var(--gap);
  border-radius: 22px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.17),
    rgba(255, 255, 255, 0.1)
  );
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow);

  grid-template-columns: repeat(4, 1fr);
  justify-content: center;
  align-content: center;

  max-height: calc(100vh - var(--ui-offset));
  overflow: auto;

  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.35) transparent;

  animation: boardIn 0.6s ease-out both;
}

@keyframes boardIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#playground::-webkit-scrollbar {
  width: 10px;
}
#playground::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 999px;
}
#playground::-webkit-scrollbar-track {
  background: transparent;
}

.card {
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
  user-select: none;

  /* ✅ aquí guardamos el personaje dinámico */
  --img: none;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  transition: transform 0.7s cubic-bezier(0.2, 0.9, 0.2, 1);
  transform-style: preserve-3d;

  aspect-ratio: 99 / 140;
  max-width: min(var(--card-max), 100%);
  min-width: min(var(--card-min), 100%);
  border-radius: var(--card-radius);
}

.flip {
  transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--card-radius);
  overflow: hidden;
}

.flip-card-front {
  background-image: url("./assets/carta.png");
  background-size: cover;
  background-position: center;
  border: 2px solid rgba(253, 210, 87, 0.95);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  transform: translateZ(0);
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    filter 0.18s ease;
}

.flip-card-front::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    120deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.1) 35%,
    rgba(255, 255, 255, 0) 70%
  );
  transform: translateX(-40%);
  transition: transform 0.5s ease;
}

.card:hover .flip-card-front {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.28);
  filter: brightness(1.02);
}
.card:hover .flip-card-front::after {
  transform: translateX(40%);
}

.card:active .flip-card-front {
  transform: scale(0.96);
}

.flip-card-back {
  transform: rotateY(180deg);
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  background-color: rgba(255, 255, 255, 0.95);
  border: 2px solid rgba(20, 20, 20, 0.18);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.18);

  /* ✅ IMAGEN DINÁMICA */
  background-image: var(--img);
}

@keyframes rotate-center {
  0% {
    transform: rotate(0);
    opacity: 1;
  }
  100% {
    transform: rotate(360deg);
    opacity: 0;
  }
}
.rotate {
  animation: rotate-center 0.95s ease-in-out both;
}

.footerbar {
  width: var(--ui-max);
  display: flex;
  margin-bottom: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--glass-strong), var(--glass));
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.btnRow {
  display: flex;
  gap: 10px;
  align-items: center;
}

button {
  min-height: 44px;
}

.startButton {
  appearance: none;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 0.01em;
  padding: 12px 16px;
  font-size: var(--text);
  white-space: nowrap;
  color: #4b2b00;
  background: linear-gradient(
    135deg,
    rgba(253, 210, 87, 0.98),
    rgba(255, 183, 3, 0.95)
  );
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.22);
  transform: translateZ(0);
  transition:
    transform 0.15s ease,
    filter 0.15s ease;
}

.startButton:hover {
  transform: translateY(-2px);
  filter: brightness(1.03);
}

.ghostButton {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.18);
  color: rgba(255, 255, 255, 0.92);
  border-radius: 14px;
  cursor: pointer;
  padding: 12px 16px;
  font-size: var(--text);
  font-weight: 800;
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.18);
  transition:
    transform 0.15s ease,
    background 0.15s ease;
}

.ghostButton:hover {
  transform: translateY(-2px);
  background: rgba(0, 0, 0, 0.24);
}

.muteBtn {
  display: none;
}

.muteBtn + label {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  cursor: pointer;
  user-select: none;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.18);
  transition:
    transform 0.15s ease,
    background 0.15s ease;
}
.muteBtn + label:hover {
  transform: translateY(-2px);
  background: rgba(0, 0, 0, 0.24);
}

.muteBtn + label::before {
  content: "";
  width: 22px;
  height: 22px;
  background: rgba(255, 255, 255, 0.95);
  -webkit-mask: url("https://i.ibb.co/8xG9vgT/sound-mute-01.png") center /
    contain no-repeat;
  mask: url("https://i.ibb.co/8xG9vgT/sound-mute-01.png") center / contain
    no-repeat;
}

.muteBtn:checked + label::before {
  -webkit-mask: url("https://i.ibb.co/h7w6rmR/sound-mute-02.png") center /
    contain no-repeat;
  mask: url("https://i.ibb.co/h7w6rmR/sound-mute-02.png") center / contain
    no-repeat;
}

/* ===== COMBO centrado ===== */
#combo {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.24));
}

.bounceIn {
  animation: bounceIn 1s both;
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale3d(0.3, 0.3, 0.3);
  }
  60% {
    opacity: 1;
    transform: translate(-50%, -50%) scale3d(1.05, 1.05, 1.05);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale3d(1, 1, 1);
  }
}

/* ===== FEEDBACK ===== */
#feedback {
  position: fixed;
  top: 58%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;

  max-width: min(520px, 92vw);
  width: max-content;

  padding: 14px 16px;
  border-radius: 16px;

  background: var(--fb-bg);
  color: var(--fb-text);
  border: 2px solid var(--fb-border);
  box-shadow: var(--fb-shadow);

  display: flex;
  align-items: center;
  gap: 12px;

  font-size: clamp(16px, 1.8vw, 22px);
  font-weight: 900;
  letter-spacing: -0.01em;

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

#feedback .icon {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 22px;
  flex: 0 0 auto;

  background: rgba(255, 255, 255, 0.14);
  border: 2px solid rgba(255, 255, 255, 0.22);
}

#feedback .msg {
  line-height: 1.2;
}

#feedback.show {
  opacity: 1;
  transform: translate(-50%, -54%);
}

#feedback.ok {
  border-left: 8px solid var(--fb-ok-accent);
}
#feedback.bad {
  border-left: 8px solid var(--fb-bad-accent);
}

#feedback::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 20px;
  background: radial-gradient(
    300px 160px at 50% 50%,
    rgba(255, 255, 255, 0.08),
    transparent 60%
  );
  z-index: -1;
}

@media (prefers-reduced-motion: reduce) {
  #feedback {
    transition: none;
  }
  #playground {
    animation: none;
  }
}

/* ===== OVERLAYS ===== */
.start-screen,
#finishScreen,
#nameScreen {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(
      900px 700px at 20% 10%,
      rgba(255, 255, 255, 0.1),
      transparent 50%
    ),
    rgba(0, 0, 0, 0.72);
  z-index: 999;
  display: block;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.modalCard {
  position: absolute;
  width: min(640px, 94vw);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.16),
    rgba(255, 255, 255, 0.1)
  );
}

.modalInner {
  padding: 18px 18px 16px;
  color: rgba(255, 255, 255, 0.94);
}

.modalTitle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 1000;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.modalBody {
  font-size: clamp(14px, 1.4vw, 18px);
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.86);
}

.modalActions {
  padding: 14px 18px 18px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
}

.finishHero {
  width: min(260px, 55vw);
  display: block;
  margin: 0 auto 2px;
  filter: drop-shadow(0 16px 20px rgba(0, 0, 0, 0.24));
  border-radius: 18px;
}

.finishGrid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.finishStats {
  display: grid;
  gap: 10px;
  margin-top: 6px;
}

.finishStats .pill {
  justify-content: space-between;
  width: 100%;
}

.verse {
  margin-top: 10px;
  padding: 12px 12px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.88);
  font-size: var(--text);
  line-height: 1.35;
}
.verse strong {
  color: var(--gold);
}

.exitBtn {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: rgba(255, 60, 60, 0.92);
  color: #fff;
  font-weight: 1000;
  border: 0;
  box-shadow: 0 16px 20px rgba(0, 0, 0, 0.22);
}

/* ✅ Crédito debajo de footerbar (no fijo, no se sobrepone) */
.dev-credit {
  width: var(--ui-max);
  margin: 10px 0 14px;
  padding: 10px 14px;
  border-radius: 999px;

  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;

  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.14),
    rgba(255, 255, 255, 0.08)
  );
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);

  color: rgba(255, 255, 255, 0.88);
  font-size: clamp(12px, 1.1vw, 14px);
  letter-spacing: 0.02em;
}

.dev-credit strong {
  color: var(--gold);
  font-weight: 1000;
}

.dev-credit .dot {
  opacity: 0.75;
}

/* ===== Inputs bonitos para nombre ===== */
.nameRow {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}
.nameInput {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.22);
  color: rgba(255, 255, 255, 0.95);
  font-size: clamp(16px, 1.6vw, 18px);
  outline: none;
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.18);
}
.nameInput::placeholder {
  color: rgba(255, 255, 255, 0.6);
}
.nameHint {
  font-size: var(--small);
  color: rgba(255, 255, 255, 0.75);
}

@media (max-width: 520px) {
  :root {
    --board-width: 96vw;
    --gap: 12px;
    --board-padding: 12px;
    --card-min: 92px;
    --card-max: 132px;
    --ui-offset: 330px;
  }
  .progress {
    width: 120px;
  }
}
