/* ─────────────── Reset & base ─────────────── */
* {
  box-sizing: border-box;
  margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; /* evita doble-tap zoom */
}
html, body {
  height: 100%;
  overflow: hidden;
  touch-action: pan-x pan-y;
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: 'Quicksand', system-ui, sans-serif;
  font-weight: 600;
  color: #6b3a5b;
  background:
    radial-gradient(circle at 15% 8%, #ffb3d9 0%, transparent 40%),
    radial-gradient(circle at 85% 92%, #e6a8ff 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, #fff0fa 0%, transparent 65%),
    linear-gradient(135deg, #ffd6ec 0%, #ffb8d9 45%, #e2a8ff 100%);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior: none;
  user-select: none;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(circle at 25% 35%, rgba(255,255,255,0.4) 0, transparent 1.5px),
    radial-gradient(circle at 75% 65%, rgba(255,255,255,0.3) 0, transparent 1.5px),
    radial-gradient(circle at 55% 25%, rgba(255,210,235,0.6) 0, transparent 2px);
  background-size: 60px 60px, 80px 80px, 100px 100px;
  opacity: 0.7;
}
body[data-theme="machote"]::before { display: none; }

/* Decorative floating sparkles */
.sparkles {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden;
}
.sparkles span {
  position: absolute;
  font-size: 30px;
  color: #ff8ec3;
  opacity: 0.7;
  filter: drop-shadow(0 2px 8px rgba(255, 105, 180, 0.5));
  animation: float 9s ease-in-out infinite;
}
.sparkles span:nth-child(1)  { top: 6%;  left: 10%; font-size: 32px; animation-delay: 0s; }
.sparkles span:nth-child(2)  { top: 18%; right: 8%; font-size: 28px; animation-delay: 1.0s; color: #d076ff;}
.sparkles span:nth-child(3)  { top: 42%; left: 4%;  font-size: 26px; animation-delay: 2.0s; color: #ff5fa2;}
.sparkles span:nth-child(4)  { top: 30%; right: 24%; font-size: 22px; animation-delay: 3.0s; color: #c869ff;}
.sparkles span:nth-child(5)  { bottom: 32%; right: 6%; font-size: 30px; animation-delay: 4.0s; color: #ff5fa2;}
.sparkles span:nth-child(6)  { bottom: 18%; left: 14%; font-size: 26px; animation-delay: 5.0s; color: #ff3d88;}
.sparkles span:nth-child(7)  { top: 55%; right: 18%; font-size: 24px; animation-delay: 6.0s; color: #d076ff;}
.sparkles span:nth-child(8)  { top: 38%; left: 78%; font-size: 28px; animation-delay: 7.0s; color: #ff96c1;}
.sparkles span:nth-child(9)  { bottom: 8%;  left: 38%; font-size: 22px; animation-delay: 8.0s; color: #ff3d88;}
.sparkles span:nth-child(10) { top: 12%; left: 58%; font-size: 20px; animation-delay: 2.5s; color: #c869ff;}
.sparkles span:nth-child(11) { bottom: 48%; left: 8%; font-size: 24px; animation-delay: 5.5s; color: #ffba3d;}
.sparkles span:nth-child(12) { bottom: 6%;  right: 28%; font-size: 26px; animation-delay: 6.5s; }
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg) scale(1); opacity: 0.5; }
  50%      { transform: translateY(-24px) rotate(20deg) scale(1.12); opacity: 0.9; }
}
body[data-theme="machote"] .sparkles span {
  filter: none;
}

/* ─────────────── App layout ─────────────── */
#app {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.screen { display: none; flex-direction: column; flex: 1; min-height: 0; padding: 20px 16px; }
.screen.active { display: flex; }

/* ─────────────── Pantalla selección ─────────────── */
#screen-select {
  justify-content: safe center;
  align-items: center;
  gap: 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: 16px;
  padding-bottom: 16px;
}

.title-wrap { text-align: center; position: relative; }
.title {
  font-family: 'Pacifico', cursive;
  font-size: clamp(2.8rem, 11vw, 3.8rem);
  background: linear-gradient(135deg, #ff3d88 0%, #ff5fa2 30%, #c869ff 70%, #9d4edd 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 6px rgba(255, 61, 136, 0.4));
  animation: titleGlow 3.5s ease-in-out infinite;
  position: relative;
  display: inline-block;
}
.title::before,
.title::after {
  content: '✿';
  position: absolute;
  top: 50%;
  font-size: 1.4rem;
  color: #ff5fa2;
  opacity: 0.85;
  filter: drop-shadow(0 2px 6px rgba(255, 95, 162, 0.6));
  animation: deco 3s ease-in-out infinite;
}
.title::before { left: -36px; transform: translateY(-50%) rotate(-15deg); }
.title::after  { right: -36px; transform: translateY(-50%) rotate(15deg); animation-delay: 1.5s; }
@keyframes titleGlow {
  0%, 100% { filter: drop-shadow(0 3px 6px rgba(255, 61, 136, 0.4)); }
  50%      { filter: drop-shadow(0 3px 10px rgba(200, 105, 255, 0.55)); }
}
@keyframes deco {
  0%, 100% { transform: translateY(-50%) rotate(-15deg) scale(1); }
  50%      { transform: translateY(-50%) rotate(15deg)  scale(1.2); }
}
.title .rosita {
  display: inline-block;
  transform: rotate(-3deg);
  animation: wobble 4s ease-in-out infinite;
}
@keyframes wobble {
  0%, 100% { transform: rotate(-3deg); }
  50%      { transform: rotate(3deg); }
}
.subtitle {
  margin-top: 12px;
  font-size: 1.02rem;
  color: #b04880;
  font-weight: 700;
  letter-spacing: 0.3px;
  min-height: 2.6em;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
body[data-theme="machote"] .title::before,
body[data-theme="machote"] .title::after { display: none; }
body[data-theme="machote"] .title {
  animation: none;
  filter: none;
}
body[data-theme="machote"] .title .rosita { animation: none; }

/* Length picker (selector animado) */
.length-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 360px;
}
.length-arrow {
  width: 46px; height: 46px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #fff 0%, #ffdcec 100%);
  backdrop-filter: blur(8px);
  color: #c84d8b;
  font-size: 28px;
  font-weight: 700;
  cursor: pointer;
  box-shadow:
    0 6px 16px rgba(255, 95, 162, 0.3),
    inset 0 -2px 0 rgba(255, 95, 162, 0.15);
  transition: transform 0.15s, background 0.2s;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
  padding-bottom: 4px;
}
.length-arrow:active { transform: scale(0.9); background: linear-gradient(135deg, #ffd1e8 0%, #ffb8d9 100%); }
.length-arrow:disabled { opacity: 0.35; cursor: default; }

.length-track-viewport {
  flex: 1;
  overflow: hidden;
  position: relative;
  border-radius: 28px;
  height: 160px;
  background: linear-gradient(135deg, rgba(255,220,238,0.85) 0%, rgba(248,200,255,0.75) 100%);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 143, 195, 0.45);
  box-shadow:
    inset 0 2px 10px rgba(255, 105, 180, 0.2),
    inset 0 -2px 6px rgba(200, 105, 255, 0.15),
    0 14px 36px rgba(255, 95, 162, 0.28);
}
.length-track-viewport::before,
.length-track-viewport::after {
  content: '';
  position: absolute; top: 0; bottom: 0; width: 32px;
  pointer-events: none; z-index: 2;
}
.length-track-viewport::before { left: 0;  background: linear-gradient(90deg, rgba(255,214,236,0.95), transparent); }
.length-track-viewport::after  { right: 0; background: linear-gradient(-90deg, rgba(255,214,236,0.95), transparent); }

.length-track {
  display: flex;
  height: 100%;
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  will-change: transform;
}
.length-item {
  flex: 0 0 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transform: scale(0.7);
  opacity: 0.4;
  transition: all 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}
.length-item.active {
  transform: scale(1);
  opacity: 1;
}
.length-item span {
  font-family: 'Pacifico', cursive;
  font-size: 5.2rem;
  background: linear-gradient(135deg, #ff3d88 0%, #ff5fa2 40%, #c869ff 80%, #9d4edd 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1;
  filter: drop-shadow(0 4px 10px rgba(255, 61, 136, 0.4));
}
.length-item small {
  font-size: 0.95rem;
  color: #b04880;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 700;
}

/* Tira de stats (chips bajo el subtítulo) */
.stats-strip {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 360px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.stats-strip:active .stats-chip {
  transform: scale(0.97);
  box-shadow: 0 2px 6px rgba(255, 95, 162, 0.18);
}
.stats-chip {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 7px 4px;
  background: linear-gradient(135deg, rgba(255,255,255,0.92) 0%, rgba(255,230,243,0.92) 100%);
  border-radius: 14px;
  border: 2px solid rgba(255, 143, 195, 0.55);
  box-shadow: 0 4px 12px rgba(255, 95, 162, 0.22);
  transition: transform 0.15s, box-shadow 0.2s;
}
.chip-value {
  font-family: 'Pacifico', cursive;
  font-size: 1.5rem;
  background: linear-gradient(135deg, #ff3d88 0%, #c869ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.chip-label {
  font-size: 0.68rem;
  color: #b04880;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
  margin-top: 1px;
}

/* Pastilla de stats (debajo del theme switch) */
.stats-pill {
  border: none;
  background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(255,220,236,0.95) 100%);
  color: #c84d8b;
  font-family: 'Quicksand', sans-serif;
  font-weight: 800;
  font-size: 0.9rem;
  padding: 10px 22px;
  border-radius: 50px;
  cursor: pointer;
  box-shadow:
    0 6px 16px rgba(255, 95, 162, 0.28),
    inset 0 -2px 0 rgba(255, 95, 162, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  letter-spacing: 0.4px;
  transition: transform 0.15s, box-shadow 0.2s;
  min-width: 210px;
}
.stats-pill:active { transform: scale(0.96); }

/* Mode toggle (Libre / Diaria) */
.mode-toggle {
  display: flex;
  gap: 6px;
  width: 100%;
  max-width: 360px;
  background: rgba(255,255,255,0.92);
  padding: 6px;
  border-radius: 50px;
  box-shadow:
    inset 0 2px 6px rgba(255, 105, 180, 0.15),
    0 6px 18px rgba(255, 95, 162, 0.22);
}
.mode-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: #c84d8b;
  font-family: 'Quicksand', sans-serif;
  font-weight: 800;
  font-size: 0.98rem;
  padding: 10px 8px;
  border-radius: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.mode-btn:active { transform: scale(0.96); }
.mode-btn.active {
  background: linear-gradient(135deg, #ff3d88 0%, #ff5fa2 50%, #c869ff 100%);
  color: white;
  box-shadow:
    0 6px 16px rgba(255, 61, 136, 0.45),
    inset 0 -2px 0 rgba(0,0,0,0.08);
  text-shadow: 0 1px 4px rgba(157, 78, 221, 0.3);
}

/* Daily stamp sobre cada length-item */
.daily-stamp {
  position: absolute;
  top: 12px;
  right: 20px;
  transform: rotate(-14deg);
  font-family: 'Pacifico', cursive;
  font-weight: 900;
  font-size: 1.4rem;
  padding: 6px 14px;
  border-radius: 10px;
  letter-spacing: 1px;
  background: rgba(255,255,255,0.55);
  pointer-events: none;
  z-index: 3;
  opacity: 0.92;
  text-shadow: 0 1px 0 rgba(255,255,255,0.6);
  border: 3px solid currentColor;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.4);
}
.daily-stamp.won { color: #4dc78f; }
.daily-stamp.lost { color: #e63946; }
.length-item.locked span { opacity: 0.45; filter: grayscale(0.3); }

/* Countdown — reserva su slot siempre para que toggling Libre/Diaria no mueva nada */
.countdown {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  color: #b04880;
  font-size: 0.8rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: -10px;
  min-height: 22px;
  font-weight: 700;
}
.countdown[hidden] {
  display: flex;
  visibility: hidden;
}
.countdown-time {
  font-family: 'Quicksand', sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  color: #c84d8b;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}

/* Disabled play button */
.play-btn:disabled,
.play-btn[disabled] {
  background: rgba(180, 160, 175, 0.55);
  color: rgba(255,255,255,0.85);
  cursor: not-allowed;
  box-shadow: 0 4px 10px rgba(150, 130, 145, 0.25);
  transform: none;
}
.play-btn:disabled:active { transform: none; }

/* Play button */
.play-btn {
  border: none;
  background: linear-gradient(135deg, #ff3d88 0%, #ff5fa2 50%, #c869ff 100%);
  color: white;
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  padding: 18px 28px;
  border-radius: 50px;
  cursor: pointer;
  min-width: 260px;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  box-shadow:
    0 12px 28px rgba(255, 61, 136, 0.5),
    inset 0 -3px 0 rgba(0,0,0,0.1),
    inset 0 2px 0 rgba(255,255,255,0.25);
  transition: transform 0.15s, box-shadow 0.2s;
  letter-spacing: 0.7px;
  position: relative;
  overflow: hidden;
  text-shadow: 0 2px 6px rgba(157, 78, 221, 0.4);
}
.play-btn::before {
  content: '';
  position: absolute;
  top: 0; left: -75%;
  width: 50%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
  transform: skewX(-20deg);
  animation: shimmer 2.8s infinite;
  pointer-events: none;
}
@keyframes shimmer {
  0%   { left: -75%; }
  60%  { left: 130%; }
  100% { left: 130%; }
}
.play-btn:active {
  transform: scale(0.96) translateY(2px);
  box-shadow: 0 6px 12px rgba(255, 95, 162, 0.4);
}
.play-btn .heart {
  display: inline-block;
  animation: heartBeat 1.1s ease-in-out infinite;
  transform-origin: center;
}
@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  20%      { transform: scale(1.3); }
  40%      { transform: scale(1); }
  60%      { transform: scale(1.2); }
  80%      { transform: scale(1); }
}

/* Theme switch (debajo del botón Jugar) */
.theme-switch {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 360px;
}
.theme-btn {
  flex: 1;
  border: 2px solid transparent;
  background: rgba(255,255,255,0.65);
  backdrop-filter: blur(8px);
  color: #a06080;
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 12px 10px;
  border-radius: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(255, 105, 180, 0.15);
  transition: transform 0.15s, border-color 0.2s, background 0.2s, color 0.2s;
}
.theme-btn:active { transform: scale(0.96); }
.theme-btn .theme-emoji { font-size: 1.1rem; }
.theme-btn.active {
  border-color: #ff5fa2;
  background: rgba(255,255,255,0.95);
  color: #c84d8b;
  box-shadow: 0 6px 18px rgba(255, 95, 162, 0.3);
}

/* ─────────────── Pantalla de juego ─────────────── */
#screen-game { gap: 12px; }

.game-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 4px 8px;
}
.game-title {
  font-family: 'Pacifico', cursive;
  font-size: 1.6rem;
  background: linear-gradient(135deg, #ff5fa2 0%, #c869ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: normal;
}
.back-btn, .restart-btn {
  width: 40px; height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.75);
  color: #c84d8b;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(255, 105, 180, 0.18);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  padding-bottom: 3px;
}
.back-btn:active, .restart-btn:active { transform: scale(0.92); }
.restart-btn { font-size: 20px; padding-bottom: 0; }

/* Board */
.board-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 6px 0;
}
.board {
  display: grid;
  gap: 6px;
  width: 100%;
}
.row {
  display: grid;
  gap: 6px;
}
.cell {
  aspect-ratio: 1;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255,255,255,0.85) 0%, rgba(255,230,243,0.85) 100%);
  border: 2px solid #ffb6d9;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: clamp(1rem, 4.5vw, 1.8rem);
  color: #6b3a5b;
  text-transform: uppercase;
  transition: transform 0.15s, border-color 0.2s, background 0.2s;
  box-shadow: 0 2px 6px rgba(255, 105, 180, 0.1);
}
.cell.filled {
  border-color: #ff8ec3;
  transform: scale(1.05);
  animation: pop 0.2s ease;
}
.cell.selected {
  border-color: #c869ff;
  box-shadow: 0 0 0 3px rgba(200, 105, 255, 0.25);
}
@keyframes pop {
  0% { transform: scale(0.85); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1.05); }
}

/* Cell states after submit */
.cell.flip { animation: flip 0.55s ease forwards; }
@keyframes flip {
  0%   { transform: rotateX(0deg); }
  45%  { transform: rotateX(90deg); }
  55%  { transform: rotateX(90deg); }
  100% { transform: rotateX(0deg); }
}
.cell.correct {
  background: linear-gradient(135deg, #6ed8a8, #4dc78f);
  border-color: #4dc78f;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.cell.present {
  background: linear-gradient(135deg, #ffd86b, #ffba3d);
  border-color: #ffba3d;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.cell.absent {
  background: #d6c0cc;
  border-color: #c0a8b6;
  color: white;
}

/* Message */
.message {
  min-height: 24px;
  text-align: center;
  color: #c84d8b;
  font-weight: 700;
  font-size: 0.95rem;
  transition: opacity 0.2s;
}
.message.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* Keyboard */
.keyboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: env(safe-area-inset-bottom, 8px);
}
.kb-row {
  display: flex;
  justify-content: center;
  gap: 4px;
}
.key {
  flex: 1;
  min-width: 0;
  height: 52px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(180deg, #fff 0%, #ffe6f3 100%);
  color: #6b3a5b;
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  box-shadow:
    0 3px 0 rgba(255, 95, 162, 0.28),
    0 4px 10px rgba(255, 105, 180, 0.2);
  transition: transform 0.08s, box-shadow 0.08s, background 0.2s;
  text-transform: uppercase;
}
.key:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(255, 105, 180, 0.2);
}
.key.wide {
  flex: 1.6;
  font-size: 1.5rem;
  line-height: 1;
  background: linear-gradient(135deg, #ffb6d9, #ff8ec3);
  color: white;
}
.key.enter {
  background: linear-gradient(135deg, #ff5fa2, #c869ff);
  color: white;
  font-size: 1.6rem;
}
.key.correct { background: linear-gradient(135deg, #6ed8a8, #4dc78f); color: white; }
.key.present { background: linear-gradient(135deg, #ffd86b, #ffba3d); color: white; }
.key.absent { background: #d6c0cc; color: white; opacity: 0.85; }

/* ─────────────── Stats ─────────────── */
.stats-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 4px 24px;
  -webkit-overflow-scrolling: touch;
}
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}
.stat-card {
  background: rgba(255,255,255,0.85);
  border-radius: 18px;
  padding: 16px 12px;
  text-align: center;
  box-shadow: 0 4px 14px rgba(255, 105, 180, 0.15);
}
.stat-card-wide { grid-column: 1 / -1; }
.stat-value {
  font-family: 'Pacifico', cursive;
  font-size: 2.2rem;
  background: linear-gradient(135deg, #ff5fa2 0%, #c869ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.1;
}
.stat-label {
  font-size: 0.85rem;
  color: #a06080;
  margin-top: 4px;
  letter-spacing: 0.5px;
}

.section-title {
  font-family: 'Pacifico', cursive;
  font-size: 1.25rem;
  background: linear-gradient(135deg, #ff5fa2 0%, #c869ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 8px 4px 12px;
  font-weight: normal;
}

.ranking, .breakdown, .averages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

/* Promedio de intentos */
.avg-row {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.85);
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(255, 105, 180, 0.1);
  gap: 10px;
}
.avg-len {
  width: 72px;
  color: #6b3a5b;
  font-size: 0.95rem;
}
.avg-bar {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: #ffe4f1;
  overflow: hidden;
  position: relative;
}
.avg-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.avg-bar-fill.good { background: linear-gradient(90deg, #6ed8a8, #4dc78f); }
.avg-bar-fill.mid  { background: linear-gradient(90deg, #ffd86b, #ffba3d); }
.avg-bar-fill.bad  { background: linear-gradient(90deg, #ff9a9a, #e63946); }
.avg-value {
  font-family: 'Pacifico', cursive;
  font-size: 1.3rem;
  line-height: 1;
  min-width: 54px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.avg-value small {
  font-family: 'Quicksand', sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  opacity: 0.55;
  margin-left: 1px;
}
.avg-value.good { color: #4dc78f; }
.avg-value.mid  { color: #d99820; }
.avg-value.bad  { color: #e63946; }
.rank-row, .bd-row {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.85);
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(255, 105, 180, 0.1);
}
.rank-pos {
  width: 28px;
  font-family: 'Pacifico', cursive;
  font-size: 1.1rem;
  color: #c84d8b;
}
.rank-pos.gold { color: #ffba3d; }
.rank-label, .bd-label {
  flex: 1;
  color: #6b3a5b;
  font-size: 0.95rem;
}
.rank-value, .bd-value {
  color: #c84d8b;
  font-size: 0.95rem;
}
.bd-bar {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: #ffe4f1;
  margin: 0 12px;
  overflow: hidden;
  position: relative;
}
.bd-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, #ff5fa2, #c869ff);
  border-radius: 4px;
  transition: width 0.5s ease;
}
.bd-letters {
  width: 56px;
  color: #6b3a5b;
  font-size: 0.9rem;
}
.empty-msg {
  text-align: center;
  color: #a06080;
  padding: 20px;
  font-size: 0.95rem;
  background: rgba(255,255,255,0.6);
  border-radius: 14px;
}

/* ─────────────── Modal ─────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(107, 58, 91, 0.4);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 24px;
  animation: fadeIn 0.3s ease;
}
.modal-overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: white;
  border-radius: 28px;
  padding: 32px 28px 24px;
  text-align: center;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(200, 100, 200, 0.35);
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.modal-emoji { font-size: 4rem; margin-bottom: 6px; }
.modal-title {
  font-family: 'Pacifico', cursive;
  font-size: 2rem;
  background: linear-gradient(135deg, #ff5fa2 0%, #c869ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 8px;
  font-weight: normal;
}
.modal-text { color: #8a5570; font-size: 1rem; margin-bottom: 24px; }
.modal-text strong { color: #c84d8b; letter-spacing: 1px; }
.modal-actions { display: flex; gap: 10px; }
.btn-primary, .btn-secondary {
  flex: 1;
  border: none;
  padding: 14px 18px;
  border-radius: 50px;
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s;
}
.btn-primary {
  background: linear-gradient(135deg, #ff5fa2 0%, #c869ff 100%);
  color: white;
  box-shadow: 0 6px 16px rgba(255, 95, 162, 0.35);
}
.btn-secondary {
  background: #ffd1e8;
  color: #c84d8b;
}
.btn-primary:active, .btn-secondary:active { transform: scale(0.95); }

/* ─────────────── Responsive tweaks ─────────────── */
@media (min-width: 481px) {
  body { padding: 20px 0; }
}

@media (max-height: 700px) {
  .key { height: 46px; font-size: 0.95rem; }
  .length-track-viewport { height: 140px; }
  .length-item span { font-size: 4.2rem; }
}

@media (max-height: 600px) {
  .key { height: 40px; font-size: 0.9rem; }
  .title { font-size: 2.2rem; }
  #screen-select { gap: 24px; }
}

/* ─────────────── Tema MACHOTE 🍺 ─────────────── */
body[data-theme="machote"] {
  color: #d8dee9;
  background:
    radial-gradient(circle at 20% 10%, #2a3441 0%, transparent 50%),
    radial-gradient(circle at 80% 90%, #3a2418 0%, transparent 50%),
    linear-gradient(135deg, #0f1419 0%, #1a2230 50%, #2d1810 100%);
}

/* Sparkles fuera */
body[data-theme="machote"] .sparkles { display: none; }

/* Títulos */
body[data-theme="machote"] .title,
body[data-theme="machote"] .game-title,
body[data-theme="machote"] .modal-title,
body[data-theme="machote"] .section-title,
body[data-theme="machote"] .stat-value,
body[data-theme="machote"] .length-item span {
  font-family: 'Black Ops One', 'Oswald', sans-serif;
  background: linear-gradient(135deg, #ff8800 0%, #e63946 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 4px 16px rgba(255, 136, 0, 0.3);
  letter-spacing: 1px;
}
body[data-theme="machote"] .title .rosita { transform: none; }
body[data-theme="machote"] .length-item span {
  filter: none;
  text-shadow: 0 4px 16px rgba(255, 136, 0, 0.3);
}
body[data-theme="machote"] .length-item small { color: #8a9aab; }
body[data-theme="machote"] .subtitle { color: #8a9aab; }
body[data-theme="machote"] .subtitle {
  color: #8a9aab;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-size: 0.85rem;
}

/* Length picker */
body[data-theme="machote"] .length-track-viewport {
  background: rgba(20, 30, 40, 0.6);
  border: 1px solid rgba(255, 136, 0, 0.2);
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.4),
    0 10px 30px rgba(0, 0, 0, 0.5);
}
body[data-theme="machote"] .length-track-viewport::before { background: linear-gradient(90deg, rgba(15,20,25,0.95), transparent); }
body[data-theme="machote"] .length-track-viewport::after  { background: linear-gradient(-90deg, rgba(15,20,25,0.95), transparent); }
body[data-theme="machote"] .length-item small {
  color: #8a9aab;
  font-family: 'Oswald', sans-serif;
  letter-spacing: 3px;
}
body[data-theme="machote"] .length-arrow {
  background: rgba(40, 50, 60, 0.8);
  color: #ff8800;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
body[data-theme="machote"] .length-arrow:active { background: #2a3441; }

/* Play button */
body[data-theme="machote"] .play-btn {
  background: linear-gradient(135deg, #ff8800 0%, #e63946 100%);
  font-family: 'Oswald', sans-serif;
  text-transform: uppercase;
  letter-spacing: 2px;
  border-radius: 8px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  box-shadow:
    0 10px 24px rgba(230, 57, 70, 0.45),
    inset 0 -3px 0 rgba(0,0,0,0.25);
}

/* Stats strip + pill */
body[data-theme="machote"] .stats-chip {
  background: linear-gradient(135deg, rgba(30,40,50,0.9) 0%, rgba(40,50,60,0.9) 100%);
  border-color: rgba(255, 136, 0, 0.35);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}
body[data-theme="machote"] .chip-value {
  font-family: 'Black Ops One', 'Oswald', sans-serif;
  background: linear-gradient(135deg, #ff8800 0%, #e63946 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
body[data-theme="machote"] .chip-label {
  color: #8a9aab;
  font-family: 'Oswald', sans-serif;
  letter-spacing: 1.5px;
}
body[data-theme="machote"] .stats-pill {
  background: linear-gradient(135deg, rgba(30,40,50,0.95) 0%, rgba(40,50,60,0.95) 100%);
  color: #ff8800;
  font-family: 'Oswald', sans-serif;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.45),
    inset 0 -2px 0 rgba(0, 0, 0, 0.25);
}

/* Mode toggle */
body[data-theme="machote"] .mode-toggle {
  background: rgba(245, 245, 248, 0.95);
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.15),
    0 6px 18px rgba(0, 0, 0, 0.35);
}
body[data-theme="machote"] .mode-btn {
  color: #2a3441;
  font-family: 'Oswald', sans-serif;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 700;
}
body[data-theme="machote"] .mode-btn .mode-emoji { display: none; }
body[data-theme="machote"] .mode-btn[data-mode="libre"]::before  { content: '💪'; font-size: 1.05rem; }
body[data-theme="machote"] .mode-btn[data-mode="diaria"]::before { content: '🔥'; font-size: 1.05rem; }
body[data-theme="machote"] .mode-btn.active {
  background: linear-gradient(135deg, #ff8800 0%, #e63946 100%);
  box-shadow: 0 4px 12px rgba(230, 57, 70, 0.4);
}

/* Daily stamp */
body[data-theme="machote"] .daily-stamp {
  font-family: 'Black Ops One', 'Oswald', sans-serif;
  background: rgba(20, 30, 40, 0.55);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 0 2px rgba(40, 50, 60, 0.5);
}
body[data-theme="machote"] .daily-stamp.won { color: #6aa83d; }
body[data-theme="machote"] .daily-stamp.lost { color: #ff8800; }

/* Countdown */
body[data-theme="machote"] .countdown { color: #8a9aab; font-family: 'Oswald', sans-serif; }
body[data-theme="machote"] .countdown-time {
  font-family: 'Black Ops One', 'Oswald', sans-serif;
  background: linear-gradient(135deg, #ff8800 0%, #e63946 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Disabled play button */
body[data-theme="machote"] .play-btn:disabled,
body[data-theme="machote"] .play-btn[disabled] {
  background: rgba(60, 60, 70, 0.7);
  color: rgba(200, 200, 200, 0.7);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

/* Theme switch */
body[data-theme="machote"] .theme-btn {
  background: rgba(40, 50, 60, 0.6);
  color: #8a9aab;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
body[data-theme="machote"] .theme-btn.active {
  border-color: #ff8800;
  background: rgba(40, 50, 60, 0.95);
  color: #ff8800;
  box-shadow: 0 6px 18px rgba(255, 136, 0, 0.35);
}

/* Header buttons */
body[data-theme="machote"] .back-btn,
body[data-theme="machote"] .restart-btn {
  background: rgba(40, 50, 60, 0.8);
  color: #ff8800;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Board */
body[data-theme="machote"] .cell {
  background: rgba(30, 40, 50, 0.7);
  border-color: #3a4858;
  color: #e0e6ef;
  font-family: 'Oswald', sans-serif;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}
body[data-theme="machote"] .cell.filled {
  border-color: #ff8800;
}
body[data-theme="machote"] .cell.selected {
  border-color: #ffaa44;
  box-shadow: 0 0 0 3px rgba(255, 170, 68, 0.25);
}
body[data-theme="machote"] .cell.correct {
  background: linear-gradient(135deg, #4a7c2e, #6aa83d);
  border-color: #6aa83d;
}
body[data-theme="machote"] .cell.present {
  background: linear-gradient(135deg, #c97c1a, #e69528);
  border-color: #e69528;
}
body[data-theme="machote"] .cell.absent {
  background: #2a3441;
  border-color: #1f2832;
  color: #5a6878;
}

/* Mensaje */
body[data-theme="machote"] .message { color: #ff8800; text-transform: uppercase; letter-spacing: 1px; }

/* Teclado */
body[data-theme="machote"] .key {
  background: rgba(50, 60, 75, 0.95);
  color: #e0e6ef;
  font-family: 'Oswald', sans-serif;
  border-radius: 4px;
  box-shadow:
    0 3px 0 rgba(0, 0, 0, 0.5),
    0 4px 10px rgba(0, 0, 0, 0.3);
}
body[data-theme="machote"] .key.wide {
  background: linear-gradient(135deg, #4a5868, #3a4858);
}
body[data-theme="machote"] .key.enter {
  background: linear-gradient(135deg, #ff8800, #e63946);
}
body[data-theme="machote"] .key.correct { background: linear-gradient(135deg, #4a7c2e, #6aa83d); }
body[data-theme="machote"] .key.present { background: linear-gradient(135deg, #c97c1a, #e69528); }
body[data-theme="machote"] .key.absent { background: #2a3441; color: #5a6878; }

/* Stats */
body[data-theme="machote"] .stat-card,
body[data-theme="machote"] .rank-row,
body[data-theme="machote"] .bd-row,
body[data-theme="machote"] .avg-row {
  background: rgba(30, 40, 50, 0.85);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}
body[data-theme="machote"] .avg-len { color: #d8dee9; }
body[data-theme="machote"] .avg-bar { background: #1a2230; }
body[data-theme="machote"] .avg-value {
  font-family: 'Black Ops One', 'Oswald', sans-serif;
}
body[data-theme="machote"] .avg-value.good { color: #6aa83d; }
body[data-theme="machote"] .avg-value.mid  { color: #ff8800; }
body[data-theme="machote"] .avg-value.bad  { color: #e63946; }
body[data-theme="machote"] .avg-bar-fill.good { background: linear-gradient(90deg, #4a7c2e, #6aa83d); }
body[data-theme="machote"] .avg-bar-fill.mid  { background: linear-gradient(90deg, #c97c1a, #ff8800); }
body[data-theme="machote"] .avg-bar-fill.bad  { background: linear-gradient(90deg, #a02a30, #e63946); }
body[data-theme="machote"] .stat-label { color: #8a9aab; }
body[data-theme="machote"] .rank-label,
body[data-theme="machote"] .bd-label,
body[data-theme="machote"] .bd-letters { color: #d8dee9; }
body[data-theme="machote"] .rank-value,
body[data-theme="machote"] .bd-value { color: #ff8800; }
body[data-theme="machote"] .rank-pos { color: #ff8800; font-family: 'Oswald', sans-serif; }
body[data-theme="machote"] .rank-pos.gold { color: #ffd700; }
body[data-theme="machote"] .bd-bar { background: #1a2230; }
body[data-theme="machote"] .bd-bar-fill { background: linear-gradient(90deg, #ff8800, #e63946); }
body[data-theme="machote"] .empty-msg {
  color: #8a9aab;
  background: rgba(30, 40, 50, 0.6);
}

/* Modal */
body[data-theme="machote"] .modal-overlay { background: rgba(0, 0, 0, 0.6); }
body[data-theme="machote"] .modal {
  background: #1a2230;
  border: 1px solid rgba(255, 136, 0, 0.2);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}
body[data-theme="machote"] .modal-text { color: #b0bac8; }
body[data-theme="machote"] .modal-text strong { color: #ff8800; }
body[data-theme="machote"] .btn-primary {
  background: linear-gradient(135deg, #ff8800 0%, #e63946 100%);
  box-shadow: 0 6px 16px rgba(230, 57, 70, 0.35);
  font-family: 'Oswald', sans-serif;
  text-transform: uppercase;
  letter-spacing: 1px;
}
body[data-theme="machote"] .btn-secondary {
  background: #2a3441;
  color: #ff8800;
  font-family: 'Oswald', sans-serif;
  text-transform: uppercase;
  letter-spacing: 1px;
}
