:root {
  --indigo: #1e1b4b;
  --indigo-deep: #14121f;
  --violet: #5b4b9a;
  --gold: #e8b44a;
  --gold-bright: #f5d27c;
  --gold-dark: #a9762a;
  --cream: #f3e6c4;
  --parchment: #f3e4c0;
  --ink: #2a2138;
  --crimson: #9e2b3a;
  --teal: #6fb7b0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--indigo-deep);
  color: var(--cream);
  font-family: "Alegreya Sans", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}

body { height: 100dvh; }

button { font: inherit; color: inherit; }

#backdrop {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--indigo-deep);
  z-index: 0;
}

#sky {
  position: absolute;
  inset: 0;
  background-image: url("assets/cielo_nocturno.webp");
  background-size: cover;
  background-position: 50% 42%;
  background-repeat: no-repeat;
  filter: brightness(1.14) saturate(1.1);
}

#moonglow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 82% 24%, rgba(255, 226, 150, 0.34), rgba(232, 180, 74, 0.12) 24%, transparent 54%),
    radial-gradient(circle at 18% 8%, rgba(112, 92, 190, 0.18), transparent 46%);
  mix-blend-mode: screen;
  pointer-events: none;
}

#stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.star {
  position: absolute;
  border-radius: 50%;
  background: #ffe9ad;
  box-shadow: 0 0 6px rgba(255, 221, 147, 0.9), 0 0 14px rgba(232, 180, 74, 0.45);
  animation: twinkle 4.6s ease-in-out infinite alternate;
}

@keyframes twinkle {
  0% { opacity: 0.18; transform: scale(0.7); }
  55% { opacity: 0.95; transform: scale(1.08); }
  100% { opacity: 0.35; transform: scale(0.85); }
}

#columnsFar {
  position: absolute;
  left: -8%;
  right: -8%;
  top: 21%;
  height: 48%;
  background-image: url("assets/columnas_flotantes.webp");
  background-repeat: repeat-x;
  background-size: auto 100%;
  background-position: 0 50%;
  opacity: 0.3;
  filter: saturate(0.62) brightness(1.02) contrast(0.9) blur(2.2px);
  will-change: transform;
  pointer-events: none;
}

#columns {
  position: absolute;
  left: -6%;
  right: -6%;
  top: 31%;
  height: 38%;
  background-image: url("assets/columnas_flotantes.webp");
  background-repeat: repeat-x;
  background-size: auto 100%;
  background-position: 0 50%;
  opacity: 0.86;
  filter: saturate(0.92) brightness(0.98) contrast(1) blur(0.3px);
  will-change: transform;
  pointer-events: none;
}

#mist {
  position: absolute;
  left: 0;
  right: 0;
  top: 26%;
  height: 46%;
  background:
    linear-gradient(to bottom, rgba(30, 27, 75, 0.03), rgba(60, 50, 116, 0.24) 52%, rgba(30, 27, 75, 0.08)),
    radial-gradient(ellipse at 50% 60%, rgba(112, 92, 190, 0.2), transparent 70%);
  pointer-events: none;
}

#haze {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 42%;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(112, 92, 190, 0.28), transparent 62%),
    linear-gradient(to top, rgba(20, 18, 31, 0.38), rgba(20, 18, 31, 0));
  pointer-events: none;
}

#backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 45%, transparent 58%, rgba(15, 12, 30, 0.32) 100%);
  pointer-events: none;
}

#game {
  position: fixed;
  inset: 0;
  z-index: 2;
}

#game canvas {
  display: block;
  margin: 0 auto;
}

#ui {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

#ui button { pointer-events: auto; }

.hidden { display: none !important; }

.screen {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.title-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  gap: clamp(6px, 1.4vh, 14px);
  padding: max(2.2vh, 10px) max(10px, env(safe-area-inset-right)) max(2.4vh, 12px) max(10px, env(safe-area-inset-left));
  background: linear-gradient(to bottom, rgba(16, 13, 34, 0.28), rgba(16, 13, 34, 0.04) 38%, rgba(16, 13, 34, 0.42));
  overflow-y: auto;
  overflow-x: hidden;
  pointer-events: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.title-logo {
  text-align: center;
  margin-top: max(6px, env(safe-area-inset-top));
  filter: drop-shadow(0 8px 22px rgba(0, 0, 0, 0.6));
}

.crest {
  display: block;
  width: clamp(30px, 5.4vh, 46px);
  height: auto;
  margin: 0 auto 2px;
  color: var(--gold);
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}

.title-kicker {
  margin: 0;
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: clamp(9px, 1.35vh, 12px);
  letter-spacing: 0.34em;
  color: var(--gold);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.title-logo h1 {
  margin: 0.06em 0 0.08em;
  font-family: "Young Serif", serif;
  font-weight: 400;
  font-size: clamp(27px, 6.1vh, 66px);
  line-height: 0.98;
  color: var(--cream);
  letter-spacing: 0.01em;
  text-shadow: 0 2px 0 #6b4a18, 0 0 30px rgba(232, 180, 74, 0.45), 0 8px 26px rgba(0, 0, 0, 0.7);
}

.title-tag {
  margin: 0;
  font-size: clamp(11px, 1.8vh, 16px);
  letter-spacing: 0.08em;
  color: #ded1ea;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.parchment {
  position: relative;
  color: var(--ink);
  border: 2px solid var(--gold-dark);
  border-radius: 16px;
  background:
    radial-gradient(ellipse at 18% 0%, rgba(255, 255, 255, 0.55), transparent 55%),
    radial-gradient(ellipse at 82% 102%, rgba(158, 43, 58, 0.08), transparent 62%),
    linear-gradient(158deg, #f8eed7 0%, #f1e2bd 46%, #e6d0a2 100%);
  box-shadow:
    0 22px 60px rgba(0, 0, 0, 0.6),
    0 2px 0 rgba(255, 248, 226, 0.7) inset,
    0 0 42px rgba(140, 100, 40, 0.22) inset;
}

.gold-corners::before {
  content: "";
  position: absolute;
  inset: 7px;
  pointer-events: none;
  border-radius: 10px;
  background:
    linear-gradient(var(--gold-dark), var(--gold-dark)) left top / 16px 2px no-repeat,
    linear-gradient(var(--gold-dark), var(--gold-dark)) left top / 2px 16px no-repeat,
    linear-gradient(var(--gold-dark), var(--gold-dark)) right top / 16px 2px no-repeat,
    linear-gradient(var(--gold-dark), var(--gold-dark)) right top / 2px 16px no-repeat,
    linear-gradient(var(--gold-dark), var(--gold-dark)) left bottom / 16px 2px no-repeat,
    linear-gradient(var(--gold-dark), var(--gold-dark)) left bottom / 2px 16px no-repeat,
    linear-gradient(var(--gold-dark), var(--gold-dark)) right bottom / 16px 2px no-repeat,
    linear-gradient(var(--gold-dark), var(--gold-dark)) right bottom / 2px 16px no-repeat;
  opacity: 0.85;
}

.select-card::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(169, 118, 42, 0.34);
  border-radius: 10px;
  pointer-events: none;
}

.select-card {
  width: min(980px, 100%);
  padding: clamp(10px, 1.8vh, 20px) clamp(12px, 2.6vw, 30px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(5px, 1vh, 10px);
  pointer-events: auto;
}

.pick-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  width: 100%;
}

.select-card h2 {
  margin: 0;
  font-family: "Young Serif", serif;
  font-weight: 400;
  font-size: clamp(16px, 2.5vh, 25px);
  letter-spacing: 0.05em;
  color: #3b2a54;
  text-align: center;
  line-height: 1.1;
}

.pick-summary {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0 7px;
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: clamp(10px, 1.5vh, 13px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b4a18;
  text-align: center;
}

.pick-summary i {
  font-style: normal;
  color: var(--gold-dark);
  opacity: 0.8;
}

.pick-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  min-width: 0;
}

.mode-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(84, 62, 34, 0.12);
  border: 1px solid rgba(84, 62, 34, 0.18);
}

.mode-tab {
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: #7a6242;
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: clamp(10px, 1.5vh, 13px);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: clamp(4px, 0.7vh, 7px) clamp(12px, 2.2vw, 22px);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.mode-tab.selected {
  color: #f5e6c2;
  background: linear-gradient(180deg, #4a3a76, #2d2552);
  border-color: rgba(232, 180, 74, 0.55);
  box-shadow: 0 2px 0 rgba(60, 40, 12, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.duel-row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: clamp(8px, 1.6vw, 16px);
  width: 100%;
  padding: 3px 2px 7px;
}

.duel-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: clamp(6px, 1.2vw, 12px);
  flex: 1 1 0;
  min-width: 0;
  max-width: 300px;
  padding: clamp(6px, 1vh, 9px) clamp(8px, 1.4vw, 14px);
  border: 1.5px solid rgba(120, 88, 40, 0.55);
  border-radius: 12px;
  background: linear-gradient(160deg, rgba(255, 251, 238, 0.65), rgba(238, 220, 183, 0.55));
  color: #3b2a54;
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.duel-card:hover { border-color: rgba(120, 88, 40, 0.9); }

.duel-card.selected {
  border-color: var(--gold);
  background: linear-gradient(160deg, rgba(255, 251, 238, 0.92), rgba(238, 214, 160, 0.85));
  box-shadow: 0 0 0 2px rgba(232, 180, 74, 0.55), 0 8px 18px rgba(60, 35, 10, 0.22);
  transform: translateY(-1px);
}

.duel-card img {
  width: clamp(42px, 8vh, 62px);
  aspect-ratio: 1;
  object-fit: contain;
  flex: none;
  filter: drop-shadow(0 3px 5px rgba(60, 30, 10, 0.35));
}

.duel-card-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.duel-card-name {
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: clamp(10px, 1.55vh, 13px);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1.1;
}

.duel-card-tag {
  font-size: clamp(9px, 1.35vh, 11px);
  line-height: 1.15;
  color: #7a6440;
}

@media (max-aspect-ratio: 4/5) {
  .duel-card { width: 100%; max-width: none; flex: none; }
  .duel-row { flex-direction: column; align-items: stretch; }
}

/* HUD del duelo */
#duelHud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
  pointer-events: none;
}

.duel-band {
  width: min(900px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(4px, 1vw, 14px);
  padding: clamp(4px, 0.8vh, 7px) clamp(9px, 1.6vw, 18px);
  border: 1px solid rgba(232, 180, 74, 0.4);
  border-bottom-color: rgba(232, 180, 74, 0.65);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(34, 30, 84, 0.93), rgba(21, 19, 47, 0.86));
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.42), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
}

.duel-side {
  display: flex;
  align-items: center;
  gap: clamp(4px, 0.8vw, 9px);
  min-width: 0;
}

.duel-side.right { justify-content: flex-end; }

.duel-portrait {
  width: clamp(30px, 5.4vh, 44px);
  aspect-ratio: 1;
  flex: none;
  display: grid;
  place-items: center;
}

.duel-portrait img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.duel-side-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.duel-side.right .duel-side-text { align-items: flex-end; }

.duel-name {
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: clamp(10px, 1.8vh, 15px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 30vw;
}

.duel-pips {
  display: flex;
  align-items: center;
  gap: 3px;
}

.duel-pips i {
  display: block;
  width: clamp(7px, 1.3vh, 10px);
  height: clamp(7px, 1.3vh, 10px);
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 7px rgba(232, 180, 74, 0.7);
  transition: opacity 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.duel-pips i.off {
  background: rgba(255, 255, 255, 0.16);
  box-shadow: none;
  transform: scale(0.78);
  opacity: 0.7;
}

.duel-allies {
  display: flex;
  align-items: center;
  gap: 1px;
  margin-top: 1px;
  line-height: 0;
}

.duel-allies img {
  width: clamp(13px, 2.1vh, 18px);
  height: clamp(13px, 2.1vh, 18px);
  object-fit: contain;
  opacity: 0.94;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
}

.duel-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  flex: none;
}

.duel-tag {
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: clamp(8px, 1.25vh, 10px);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  white-space: nowrap;
}

.duel-timer {
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: clamp(15px, 2.5vh, 22px);
  letter-spacing: 0.05em;
  color: var(--cream);
  line-height: 1;
}

.duel-attack {
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid rgba(232, 180, 74, 0.9);
  background: radial-gradient(circle at 35% 30%, #41397a, #221d48 70%);
  box-shadow: 0 0 0 2px rgba(20, 16, 40, 0.55), 0 7px 14px rgba(0, 0, 0, 0.5);
}

#touch.duel .duel-attack { display: flex; }

.duel-attack img {
  width: 66%;
  height: 66%;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
}

@media (max-width: 430px) {
  .duel-tag { display: none; }
  .duel-name { font-size: 10px; }
}


.pick-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 0 5px;
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: clamp(9px, 1.35vh, 11px);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #7a6440;
}

.pick-hint {
  font-style: normal;
  letter-spacing: 0.05em;
  text-transform: none;
  font-weight: 500;
  color: #9a835c;
  opacity: 0.9;
}

.flex-break {
  display: none;
}

.cast-row {
  display: flex;
  align-items: flex-start;
  gap: clamp(4px, 0.9vw, 10px);
  width: 100%;
  padding: 4px 2px 6px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
}

.cast-row::-webkit-scrollbar,
.level-row::-webkit-scrollbar {
  display: none;
}

.picker {
  flex: 0 0 auto;
  width: clamp(58px, 8.6vh, 84px);
  padding: 2px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #493867;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  filter: saturate(0.72) brightness(0.86);
  opacity: 0.7;
  transition: transform 0.16s ease, filter 0.16s ease, opacity 0.16s ease;
}

.picker .portrait-wrap {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
}

.picker img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 5px 8px rgba(60, 30, 10, 0.3));
}

.picker .portrait-wrap::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(232, 180, 74, 0);
  transition: box-shadow 0.16s ease;
}

.picker-name {
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: clamp(8px, 1.25vh, 11px);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.05;
  text-align: center;
  max-width: 100%;
  min-height: 2.1em;
  max-height: 2.15em;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.picker-tag {
  display: none;
}

.picker.selected {
  transform: translateY(-2px) scale(1.04);
  filter: none;
  opacity: 1;
}

.picker.selected .portrait-wrap::after {
  box-shadow: 0 0 0 2px var(--gold), 0 0 22px rgba(232, 180, 74, 0.7);
}

.picker.selected .picker-name {
  color: #2f2345;
}

.level-row {
  display: flex;
  gap: clamp(4px, 0.7vw, 8px);
  width: 100%;
  padding: 3px 2px 6px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
}

.level-card {
  position: relative;
  flex: 0 0 auto;
  width: clamp(76px, 11.6vh, 104px);
  aspect-ratio: 1.24;
  padding: 4px 5px 5px;
  border: 1.5px solid rgba(120, 88, 40, 0.6);
  border-radius: 10px;
  background-color: #1c1836;
  background-size: cover;
  background-position: 50% 50%;
  overflow: hidden;
  cursor: pointer;
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  text-align: left;
  color: var(--cream);
  box-shadow: 0 4px 10px rgba(40, 25, 10, 0.28);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
  filter: saturate(0.86) brightness(0.92);
}

.level-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(9, 7, 20, 0.9) 8%, rgba(9, 7, 20, 0.42) 52%, rgba(9, 7, 20, 0.12) 100%);
  pointer-events: none;
}

.level-card .lv-num,
.level-card .lv-name {
  position: relative;
  z-index: 1;
}

.level-card .lv-num {
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: clamp(8px, 1.15vh, 10px);
  letter-spacing: 0.14em;
  color: var(--gold-bright);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.level-card .lv-name {
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: clamp(8px, 1.25vh, 11px);
  line-height: 1.02;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.level-card .lv-done {
  position: absolute;
  z-index: 2;
  top: 4px;
  right: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold-bright);
  box-shadow: 0 0 8px rgba(245, 210, 124, 0.9);
  display: none;
}

.level-card.done .lv-done { display: block; }

.level-card:hover {
  filter: none;
}

.level-card.selected {
  transform: translateY(-2px);
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 2px var(--gold), 0 0 22px rgba(232, 180, 74, 0.5);
  filter: none;
}

.level-card.locked {
  cursor: not-allowed;
  filter: saturate(0.16) brightness(0.5);
}

.level-card.locked:hover { filter: saturate(0.24) brightness(0.56); }

.level-card.locked .lv-name {
  color: #b9a9cf;
  letter-spacing: 0.08em;
}

.level-card.locked .lv-done { display: none; }

.level-card .lv-lock {
  position: absolute;
  left: 50%;
  top: 37%;
  z-index: 3;
  width: 36%;
  max-width: 44px;
  aspect-ratio: 428 / 597;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.6));
}

.level-card .lv-lock img {
  width: 100%;
  height: auto;
  display: block;
}


.locked-slot {
  position: relative;
  width: clamp(34px, 6.2vh, 54px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1.5px solid rgba(120, 88, 40, 0.55);
  background: radial-gradient(circle at 34% 28%, #42396f, #171531 72%);
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.7), 0 4px 10px rgba(40, 25, 10, 0.25);
  margin-bottom: clamp(14px, 2.4vh, 24px);
}

.locked-slot .silhouette {
  position: absolute;
  bottom: 12%;
  width: 54%;
  height: 46%;
  border-radius: 50% 50% 42% 42% / 62% 62% 34% 34%;
  background: rgba(0, 0, 0, 0.5);
}

.locked-slot .silhouette::before {
  content: "";
  position: absolute;
  top: -30%;
  left: 27%;
  width: 46%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
}

.locked-slot img {
  position: relative;
  width: 47%;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6));
}

.locked-note {
  margin: -2px 0 0;
  font-size: clamp(10px, 1.5vh, 13px);
  font-style: italic;
  color: #7a6440;
  letter-spacing: 0.02em;
}

.howto {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 16px;
  width: 100%;
  padding: 5px 12px;
  border-radius: 10px;
  border: 1px solid rgba(120, 90, 50, 0.28);
  background: rgba(255, 250, 235, 0.5);
  font-size: clamp(10px, 1.5vh, 14px);
  color: #4a3a2a;
}

.howto span { white-space: nowrap; }

.key {
  display: inline-block;
  min-width: 1.35em;
  padding: 0 4px;
  border: 1px solid #9a7a45;
  border-bottom-width: 3px;
  border-radius: 5px;
  background: #fbf3df;
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: 0.92em;
  line-height: 1.5;
  text-align: center;
  color: #3b2a54;
}

.select-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 18px;
  width: 100%;
}

.btn {
  pointer-events: auto;
  cursor: pointer;
  border-radius: 999px;
  border: 2px solid #6b4a18;
  padding: clamp(8px, 1.3vh, 12px) clamp(18px, 3vw, 34px);
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: clamp(13px, 2vh, 18px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s ease;
}

.btn.gold {
  color: #241c3f;
  border-color: #6b4a18;
  background: linear-gradient(180deg, #f7d98c 0%, #ecc163 42%, #d79c33 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.65), 0 5px 0 #6b4a18, 0 12px 24px rgba(0, 0, 0, 0.32);
}

.btn.gold:hover { filter: brightness(1.05); }

.btn.gold:active {
  transform: translateY(4px);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 1px 0 #6b4a18;
}

.btn.gold:disabled {
  cursor: default;
  opacity: 0.7;
  filter: saturate(0.6);
}

.btn.ghost {
  color: #4a3318;
  border: 1.5px solid rgba(90, 60, 28, 0.5);
  background: rgba(255, 250, 235, 0.42);
  box-shadow: none;
  padding: clamp(6px, 1vh, 10px) clamp(14px, 2.2vw, 24px);
}

.btn.ghost:hover { background: rgba(255, 250, 235, 0.75); }

.best-line {
  margin: 0;
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: clamp(11px, 1.7vh, 14px);
  letter-spacing: 0.08em;
  color: #6b4a18;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
  pointer-events: none;
}

.hud-band {
  position: relative;
  width: min(1120px, 100%);
  display: flex;
  align-items: center;
  gap: clamp(5px, 1.1vw, 16px);
  padding: clamp(5px, 0.95vh, 9px) clamp(12px, 2vw, 24px);
  border: 2px solid #e2ad3e;
  border-radius: 999px;
  background:
    radial-gradient(ellipse at 50% -20%, rgba(150, 128, 232, 0.35), transparent 62%),
    linear-gradient(180deg, rgba(58, 50, 122, 0.97), rgba(27, 24, 64, 0.95));
  box-shadow:
    inset 0 0 0 1px rgba(255, 235, 180, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.12),
    inset 0 -2px 0 rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(82, 52, 12, 0.6),
    0 10px 26px rgba(0, 0, 0, 0.5),
    0 0 30px rgba(232, 180, 74, 0.16);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
}

.hud-band::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(232, 180, 74, 0.34);
  border-radius: 999px;
  pointer-events: none;
}

#bossHud {
  width: min(560px, 100%);
  pointer-events: none;
}

.boss-band {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(7px, 1.4vw, 13px);
  padding: clamp(4px, 0.8vh, 7px) clamp(12px, 2vw, 20px);
  border: 1.5px solid rgba(232, 180, 74, 0.62);
  border-radius: 999px;
  background:
    radial-gradient(ellipse at 50% -20%, rgba(215, 86, 100, 0.3), transparent 66%),
    linear-gradient(180deg, rgba(48, 24, 62, 0.95), rgba(24, 15, 40, 0.9));
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(255, 235, 180, 0.12);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.boss-flag {
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: clamp(8px, 1.25vh, 10px);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #ff9a8a;
}

.boss-name {
  font-family: "Young Serif", serif;
  font-size: clamp(13px, 1.9vh, 17px);
  letter-spacing: 0.08em;
  color: #ffd76a;
  text-transform: uppercase;
}


.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: clamp(5px, 1vw, 12px);
  flex: 1 1 0;
  min-width: 0;
}

.hud-right { justify-content: flex-end; }

.hud-portrait {
  width: clamp(38px, 6.4vh, 52px);
  aspect-ratio: 1;
  flex: none;
  display: grid;
  place-items: center;
  padding: 1px;
  border: 2px solid var(--gold);
  border-radius: 50%;
  background: radial-gradient(circle at 36% 28%, #352d6c, #14122a 72%);
  box-shadow: 0 0 0 2px rgba(80, 50, 12, 0.62), 0 0 12px rgba(232, 180, 74, 0.3), inset 0 0 9px rgba(0, 0, 0, 0.55);
}

.hud-portrait img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 5px rgba(232, 180, 74, 0.36)) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.55));
}

.hearts {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-wrap: nowrap;
}

.hearts img {
  width: clamp(14px, 2.3vh, 22px);
  height: auto;
  filter: drop-shadow(0 0 5px rgba(190, 55, 72, 0.3)) drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6));
  transition: opacity 0.15s ease;
}

.hearts img.empty {
  filter: grayscale(1) brightness(0.55);
  opacity: 0.4;
}

.stat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: clamp(13px, 2.1vh, 20px);
  letter-spacing: 0.04em;
  color: var(--cream);
  white-space: nowrap;
}

.stat img {
  width: clamp(19px, 3.2vh, 28px);
  height: auto;
  filter: drop-shadow(0 0 5px rgba(232, 180, 74, 0.4));
}

.hud-left .stat,
.hud-right .stat {
  padding: 2px 10px 2px 6px;
  border: 1px solid rgba(232, 180, 74, 0.34);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(16, 13, 38, 0.5), rgba(10, 8, 24, 0.36));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.hud-center {
  display: flex;
  align-items: center;
  gap: clamp(4px, 0.8vw, 9px);
  flex: none;
}

.hud-center .lbl {
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: clamp(10px, 1.8vh, 15px);
  letter-spacing: 0.18em;
  color: var(--gold-bright);
  white-space: nowrap;
  text-shadow: 0 0 8px rgba(232, 180, 74, 0.42), 0 1px 2px rgba(0, 0, 0, 0.7);
}

.diamond {
  display: block;
  width: 6px;
  height: 6px;
  background: var(--gold-bright);
  transform: rotate(45deg);
  opacity: 0.95;
  box-shadow: 0 0 6px rgba(232, 180, 74, 0.6);
}

.clock {
  width: clamp(15px, 2.4vh, 19px);
  height: auto;
  color: var(--gold-bright);
  filter: drop-shadow(0 0 4px rgba(232, 180, 74, 0.45));
}

#pauseBtn {
  width: clamp(32px, 5.4vh, 43px);
  aspect-ratio: 1;
  flex: none;
  padding: 1px;
  border: 2px solid var(--gold);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #3b3475, #1a1739 72%);
  box-shadow: 0 0 0 2px rgba(80, 50, 12, 0.55), 0 0 12px rgba(232, 180, 74, 0.24);
  cursor: pointer;
}

#pauseBtn img { width: 100%; height: 100%; display: block; }

#pauseBtn:active { transform: scale(0.92); }

#touch { position: absolute; inset: 0; pointer-events: none; }

.touch-left,
.touch-right {
  position: absolute;
  bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  gap: clamp(6px, 1.4vw, 12px);
  pointer-events: none;
}

.touch-left { left: max(10px, env(safe-area-inset-left)); }
.touch-right { right: max(10px, env(safe-area-inset-right)); }

.tbtn {
  pointer-events: auto;
  width: clamp(56px, 10.5vh, 86px);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: none;
  filter: drop-shadow(0 7px 12px rgba(0, 0, 0, 0.45));
  transition: transform 0.08s ease, filter 0.08s ease;
}

.tbtn img { width: 100%; height: 100%; display: block; }

.tbtn.active {
  transform: scale(0.92);
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.55)) brightness(1.16);
}

.screen.center {
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(ellipse at 50% 45%, rgba(20, 16, 42, 0.35), rgba(12, 10, 24, 0.78));
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.modal {
  width: min(560px, 94vw);
  max-height: 92vh;
  overflow-y: auto;
  padding: clamp(18px, 3.2vh, 34px) clamp(18px, 4vw, 40px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(7px, 1.3vh, 12px);
  text-align: center;
  pointer-events: auto;
}

.modal-title {
  margin: 0;
  font-family: "Young Serif", serif;
  font-weight: 400;
  font-size: clamp(28px, 5.6vh, 46px);
  line-height: 1;
  color: #3b2a54;
}

.modal-title.big { font-size: clamp(34px, 7.4vh, 60px); color: var(--crimson); }

.modal-sub {
  margin: -2px 0 0;
  font-style: italic;
  color: #6b5636;
  font-size: clamp(12px, 1.8vh, 15px);
}

.victory-kicker {
  margin: 0;
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: clamp(9px, 1.4vh, 12px);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--gold-dark);
}

.scales {
  width: clamp(120px, 24vh, 190px);
  height: auto;
  color: var(--gold-dark);
  margin: -2px 0;
}

.win-line {
  margin: 0;
  font-size: clamp(14px, 2.2vh, 18px);
  line-height: 1.3;
  color: #4a3a2a;
  max-width: 40ch;
}

.win-unlock {
  margin: 0;
  padding: 4px 12px;
  border: 1px solid rgba(150, 110, 40, 0.38);
  border-radius: 8px;
  background: rgba(255, 215, 106, 0.2);
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: clamp(11px, 1.8vh, 15px);
  letter-spacing: 0.06em;
  color: #8a5a12;
}

.score-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(10px, 3vw, 30px);
  width: 100%;
  padding: clamp(6px, 1.2vh, 10px) 10px;
  border-top: 1px solid rgba(120, 90, 50, 0.28);
  border-bottom: 1px solid rgba(120, 90, 50, 0.28);
  background: rgba(255, 250, 235, 0.42);
}

.score-row > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 62px;
}

.score-label {
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: clamp(9px, 1.4vh, 12px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #7a6440;
}

.score-value {
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: clamp(20px, 3.6vh, 30px);
  color: #3b2a54;
  letter-spacing: 0.04em;
}

.controls-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(255, 250, 235, 0.45);
  border: 1px solid rgba(120, 90, 50, 0.25);
  font-size: clamp(12px, 1.8vh, 15px);
  color: #4a3a2a;
}

.controls-list > div {
  display: flex;
  align-items: center;
  gap: 5px;
  justify-content: center;
}

.controls-list span { margin-left: 8px; }

.touch-note {
  margin: 0;
  font-size: clamp(11px, 1.6vh, 13px);
  font-style: italic;
  color: #7a6440;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 12px;
  width: 100%;
  margin-top: 2px;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + 96px);
  transform: translate(-50%, 12px);
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid rgba(232, 180, 74, 0.55);
  background: rgba(30, 27, 75, 0.94);
  color: var(--cream);
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: clamp(11px, 1.8vh, 14px);
  letter-spacing: 0.06em;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 40;
  max-width: calc(100vw - 24px);
  white-space: normal;
  text-align: center;
  line-height: 1.2;
}

.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-aspect-ratio: 4/5) {
  #sky { background-position: 82% 44%; }
  #moonglow { background: radial-gradient(circle at 88% 22%, rgba(232, 180, 74, 0.18), rgba(232, 180, 74, 0.05) 26%, transparent 56%); }
  #columns { top: 36%; height: 29%; opacity: 0.42; }
  .hud-band { border-radius: 18px; }
  .hud-center .diamond { display: none; }
  .hud-center .lbl { font-size: 10px; letter-spacing: 0.1em; }
  .cast-row { gap: 4px; }
  .picker { width: clamp(56px, 8.2vh, 72px); }
  .level-card { width: clamp(76px, 10.6vh, 92px); }
}

@media (min-width: 760px) and (min-height: 560px) {
  .pick-hint { display: none; }
}

@media (max-height: 560px) {
  .title-screen { padding-top: max(5px, env(safe-area-inset-top)); padding-bottom: 5px; gap: 5px; }
  .title-logo h1 { font-size: clamp(22px, 6.4vh, 34px); }
  .title-tag { display: none; }
  .crest { width: 24px; }
  .select-card { padding: 8px 14px; gap: 4px; }
  .select-card h2 { font-size: 15px; }
  .picker { width: clamp(54px, 10.4vh, 76px); }
  .picker-tag { display: none; }
  .picker-name { font-size: 8px; min-height: 1.1em; }
  .level-card { width: clamp(70px, 12.4vh, 96px); }
  .howto { font-size: 9px; padding: 2px 8px; }
  .btn { padding: 7px 18px; font-size: 12px; }
}

@media (max-height: 430px) {
  .title-logo { display: none; }
  .title-screen { justify-content: flex-start; }
  .select-card h2 { font-size: 13px; }
  .picker { width: 50px; }
  .picker-name { font-size: 7px; }
  .level-card { width: 64px; }
  .howto { display: none; }
  .pick-summary { font-size: 8px; }
  .modal { gap: 5px; padding: 14px 24px; }
  .modal-title.big { font-size: 32px; }
  .scales { width: 100px; }
}

@media (hover: hover) and (pointer: fine) {
  #touch { display: none !important; }
}

/* Figuras 3D descargables */
.models-panel { width: min(520px, 94vw); }
.models-sub {
  margin: -2px 0 4px;
  font-size: clamp(11px, 1.7vh, 14px);
  font-style: italic;
  color: #6b5636;
  max-width: 46ch;
}
.model-list {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: left;
}
.model-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid rgba(120, 90, 50, 0.32);
  border-radius: 9px;
  background: rgba(255, 250, 235, 0.5);
}
.model-list a {
  color: #3b2a54;
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: clamp(12px, 1.8vh, 15px);
  letter-spacing: 0.03em;
  text-decoration: none;
  border-bottom: 1px solid rgba(158, 43, 58, 0.45);
}
.model-list a:hover { color: var(--crimson); border-bottom-color: var(--crimson); }
.model-list span {
  font-family: "Alegreya Sans SC", sans-serif;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: #7a6440;
}
@media (max-height: 560px) {
  .models-panel { max-height: 94vh; gap: 4px; padding: 10px 18px; }
  .model-list { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
  .model-list li { padding: 4px 8px; font-size: 11px; }
  .models-sub { display: none; }
}

/* Personajes ocultos hasta ganar su nivel */
.picker.locked {
  opacity: 0.55;
  filter: saturate(0.4) brightness(0.8);
}

.picker.locked .portrait-wrap { place-items: center; }

.picker.locked .locked-slot {
  width: 100%;
  height: 100%;
  margin-bottom: 0;
}

.picker .locked-slot .picker-lock {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 34%;
  height: auto;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

.picker .portrait-wrap .picker-lock {
  position: absolute;
  right: 2%;
  bottom: -2%;
  width: 34%;
  height: auto;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

.picker.locked.teased {
  opacity: 0.78;
  filter: saturate(0.66) brightness(0.9);
}

.picker.locked.teased .picker-name {
  color: #58466f;
  letter-spacing: 0.06em;
}

.picker.locked .picker-name {
  color: #6b5a7a;
  letter-spacing: 0.14em;
}

.picker.locked.selected { opacity: 0.85; }
