/* ============================================================
   Luisorama de Luisa y Lucía — estilos
   Temas: rosa suave (Lucía) / morado claro (Luisa)
   ============================================================ */

:root {
  --radius: 20px;
  --card-radius: 16px;
  --shadow: 0 6px 16px rgba(80, 50, 90, .14);
  --shadow-lg: 0 14px 34px rgba(80, 50, 90, .22);
  --font: "Comic Sans MS", "Chalkboard SE", "Comic Neue", "Baloo 2", "Trebuchet MS", system-ui, sans-serif;

  /* Tema neutro por defecto (portal) */
  --bg1: #fbf1ff; --bg2: #eef0ff;
  --primary: #c9a7e9; --primary-d: #9b6fd4; --primary-dd: #7a4fc0;
  --accent: #f3e6ff; --ink: #4a3a63; --on-primary: #fff;
  --card-front: #ffffff;
  --back-1: #cdb6ee; --back-2: #ac8fe2;
}

/* Tema Lucía — rosa suave */
body[data-theme="lucia"] {
  --bg1: #fff2f8; --bg2: #ffd9ea;
  --primary: #ffb0d0; --primary-d: #f06aa0; --primary-dd: #d94f86;
  --accent: #ffe3f0; --ink: #7a2f57; --on-primary: #fff;
  --back-1: #ffb3d1; --back-2: #ff8fb8;
}

/* Tema Luisa — morado claro */
body[data-theme="luisa"] {
  --bg1: #f4eeff; --bg2: #e1d3fb;
  --primary: #c3aef0; --primary-d: #9670da; --primary-dd: #7a52c5;
  --accent: #ece2ff; --ink: #4d3680; --on-primary: #fff;
  --back-1: #c9b6ee; --back-2: #a98fe0;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1), var(--bg2)) fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, .55);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid rgba(255, 255, 255, .6);
}
.topbar .title {
  margin: 0; font-size: clamp(1.1rem, 3.5vw, 1.6rem);
  color: var(--primary-dd); text-align: center; flex: 1;
}
.btn-icon {
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; color: var(--primary-dd);
  background: #fff; border: 2px solid var(--primary);
  padding: 8px 14px; border-radius: 999px; font: inherit; font-size: .95rem;
  box-shadow: var(--shadow); white-space: nowrap; cursor: pointer;
}
.btn-icon:hover { background: var(--accent); }

main { padding: 18px 14px 40px; max-width: 1000px; margin: 0 auto; }

/* ---------- Pantalla de inicio ---------- */
.setup-card {
  background: rgba(255, 255, 255, .82);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 26px 22px; max-width: 560px; margin: 18px auto; text-align: center;
}
.setup-title { margin: 0 0 4px; font-size: clamp(1.4rem, 5vw, 2rem); color: var(--primary-dd); }
.setup-sub { margin: 0 0 16px; color: var(--ink); opacity: .85; }
.setup-label { margin: 18px 0 10px; font-size: 1.15rem; color: var(--ink); }

.choice-row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.choice-row.small .choice { min-width: 90px; padding: 10px 14px; font-size: 1rem; }
.choice {
  font: inherit; cursor: pointer;
  background: #fff; color: var(--primary-dd);
  border: 3px solid transparent; border-radius: 16px;
  padding: 14px 22px; font-size: 1.25rem; font-weight: bold;
  box-shadow: var(--shadow); transition: transform .08s, background .15s, border-color .15s;
  min-width: 84px;
}
.choice:hover { transform: translateY(-2px); }
.choice[aria-pressed="true"] {
  background: var(--accent); border-color: var(--primary-d);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, .04), var(--shadow);
}
.big-choice { line-height: 1.4; font-size: 1.8rem; padding: 16px 26px; }
.big-choice br + * { font-size: 1rem; }

.best-line { margin: 16px 0 0; min-height: 1.4em; color: var(--primary-dd); }

.btn-play {
  margin-top: 22px; font: inherit; font-weight: bold; cursor: pointer;
  color: var(--on-primary);
  background: linear-gradient(145deg, var(--primary), var(--primary-d));
  border: none; border-radius: 999px; padding: 16px 40px;
  font-size: 1.4rem; box-shadow: var(--shadow-lg);
  transition: transform .1s;
}
.btn-play.small { font-size: 1.1rem; padding: 12px 26px; margin-top: 12px; }
.btn-play:hover { transform: scale(1.04); }
.btn-play:active { transform: scale(.98); }

/* ---------- Barra de estado (HUD) ---------- */
.hud {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  justify-content: center;
  background: rgba(255, 255, 255, .72); border-radius: 999px;
  padding: 10px 16px; box-shadow: var(--shadow); margin: 0 auto 18px; max-width: 720px;
}
.hud-item { display: inline-flex; align-items: center; gap: 6px; font-size: 1.15rem; font-weight: bold; color: var(--primary-dd); }
.hud-emoji { font-size: 1.3rem; }
.hud-btns { display: flex; gap: 8px; margin-left: auto; }
.btn-small {
  font: inherit; cursor: pointer; color: var(--primary-dd);
  background: #fff; border: 2px solid var(--primary); border-radius: 999px;
  padding: 8px 14px; font-size: .95rem; box-shadow: var(--shadow);
}
.btn-small:hover { background: var(--accent); }
.btn-small.wide { display: block; width: 100%; margin-top: 12px; }

/* ---------- Tablero ---------- */
.board {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(var(--cmin, 96px), 1fr));
  max-width: 860px; margin: 0 auto;
}
.board.sz-sm { --cmin: 100px; }
.board.sz-md { --cmin: 84px; }
.board.sz-lg { --cmin: 70px; }

.card {
  aspect-ratio: 1 / 1; border: none; background: none; padding: 0; cursor: pointer;
  perspective: 700px;
}
.card-inner {
  position: relative; width: 100%; height: 100%; display: block;
  transition: transform .42s cubic-bezier(.4, .8, .3, 1.2);
  transform-style: preserve-3d;
}
.card.flipped .card-inner, .card.matched .card-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute; inset: 0; -webkit-backface-visibility: hidden; backface-visibility: hidden;
  border-radius: var(--card-radius); display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow); overflow: hidden;
}
.card-back { background: linear-gradient(145deg, var(--back-1), var(--back-2)); }
.back-mark { color: rgba(255, 255, 255, .9); font-size: 2rem; text-shadow: 0 2px 3px rgba(0,0,0,.12); }
.card-front {
  transform: rotateY(180deg); background: var(--card-front);
  border: 3px solid var(--primary); padding: 6px;
}
.card.matched .card-front { border-color: var(--primary-d); box-shadow: 0 0 0 4px var(--accent), var(--shadow); }
.card.matched { cursor: default; }

.word-img { width: 86%; height: 86%; object-fit: contain; pointer-events: none; }
.emoji-img { font-size: 2.8rem; line-height: 1; }
.word-text {
  font-weight: bold; color: var(--primary-dd); text-align: center;
  line-height: 1.05; word-break: break-word; padding: 2px;
  font-size: clamp(.75rem, 2.6vw, 1.2rem);
}
.sz-sm .word-text { font-size: clamp(.9rem, 3vw, 1.35rem); }
.sz-lg .word-text { font-size: clamp(.62rem, 2vw, .95rem); }

.pulse { animation: pulse .5s ease; }
@keyframes pulse {
  0% { transform: scale(1); } 40% { transform: scale(1.08); } 100% { transform: scale(1); }
}

/* ---------- Overlay de victoria ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(60, 40, 70, .45); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 18px;
  animation: fade .25s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.win-box {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 28px 26px; text-align: center; max-width: 420px; width: 100%;
  animation: pop .35s cubic-bezier(.3, 1.4, .5, 1);
}
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.win-title { margin: 0 0 8px; color: var(--primary-dd); font-size: 1.8rem; }
.stars { display: flex; justify-content: center; gap: 8px; margin: 8px 0 6px; }
.star { font-size: 3rem; }
.star.on { color: #ffc83d; animation: starpop .4s backwards; }
.star.off { color: #e6e0ec; }
@keyframes starpop { from { transform: scale(0) rotate(-40deg); } to { transform: scale(1) rotate(0); } }
.win-stats { color: var(--ink); font-size: 1.1rem; }

/* ---------- Confeti ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti-bit { position: absolute; top: -40px; animation: fall linear forwards; }
@keyframes fall {
  to { transform: translateY(108vh) rotate(540deg); opacity: .9; }
}

/* ---------- Configuración: pestañas y paneles ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 6px auto 0; max-width: 720px; padding: 0 14px; }
.tab {
  font: inherit; cursor: pointer; color: var(--primary-dd);
  background: rgba(255, 255, 255, .7); border: 2px solid transparent; border-radius: 999px;
  padding: 10px 16px; font-size: 1rem; box-shadow: var(--shadow);
}
.tab.active { background: #fff; border-color: var(--primary-d); }

.panel {
  background: rgba(255, 255, 255, .85); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 18px; margin: 16px auto; max-width: 640px;
}
.panel-title { margin: 0 0 12px; color: var(--primary-dd); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.pref-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px dashed rgba(120, 90, 130, .2); }
.pref-row.pref-stack { display: block; border-bottom: none; padding-bottom: 4px; }
.pref-label { font-size: 1.1rem; }

.switch {
  width: 60px; height: 34px; border-radius: 999px; border: none; cursor: pointer;
  background: #d9cfe4; position: relative; transition: background .2s; flex: none;
}
.switch.on { background: var(--primary-d); }
.switch .knob { position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch.on .knob { left: 30px; }

.danger-zone { margin-top: 18px; padding-top: 14px; border-top: 2px solid rgba(217, 79, 134, .25); }
.btn-danger {
  font: inherit; cursor: pointer; color: #fff; background: #e8638c; border: none;
  border-radius: 999px; padding: 12px 20px; font-size: 1rem; box-shadow: var(--shadow);
}
.btn-danger:hover { filter: brightness(.95); }
.hint { color: var(--ink); opacity: .75; font-size: .92rem; margin: 0 0 10px; }

.btn-add {
  font: inherit; cursor: pointer; color: var(--on-primary);
  background: linear-gradient(145deg, var(--primary), var(--primary-d)); border: none;
  border-radius: 999px; padding: 10px 18px; font-size: 1rem; box-shadow: var(--shadow);
}

/* Lista de palabras */
.word-list { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.word-row {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border-radius: 14px; padding: 8px 12px; box-shadow: var(--shadow);
}
.thumb { width: 46px; height: 46px; object-fit: contain; flex: none; }
.emoji-thumb { font-size: 2rem; width: 46px; text-align: center; flex: none; }
.emoji-thumb.big { font-size: 3rem; }
.word-texts { display: flex; flex-direction: column; line-height: 1.25; }
.w-en { font-weight: bold; }
.w-fr { opacity: .8; }
.badge-new { font-size: .72rem; background: var(--accent); color: var(--primary-dd); padding: 2px 8px; border-radius: 999px; }
.word-actions { margin-left: auto; display: flex; gap: 6px; }
.btn-mini { font: inherit; cursor: pointer; background: var(--accent); border: none; border-radius: 10px; padding: 8px 10px; font-size: 1.1rem; }
.btn-mini:hover { filter: brightness(.96); }

/* Editor modal */
.editor-box {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 22px; width: 100%; max-width: 460px; max-height: 88vh; overflow: auto;
}
.editor-title { margin: 0 0 14px; color: var(--primary-dd); }
.field-label { display: block; margin: 12px 0 4px; font-weight: bold; }
.field {
  width: 100%; font: inherit; padding: 10px 12px; border-radius: 12px;
  border: 2px solid var(--primary); background: #fff; color: var(--ink);
}
.field:focus { outline: none; border-color: var(--primary-d); box-shadow: 0 0 0 3px var(--accent); }
.editor-preview { display: flex; justify-content: center; margin: 8px 0; }
.editor-preview .thumb { width: 80px; height: 80px; }
.editor-preview .emoji-thumb { font-size: 3.4rem; width: auto; }
.icon-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 6px;
  max-height: 220px; overflow: auto; margin-top: 10px; padding: 4px;
  background: var(--accent); border-radius: 12px;
}
.icon-pick { background: #fff; border: 2px solid transparent; border-radius: 10px; padding: 4px; cursor: pointer; }
.icon-pick img { width: 100%; height: 44px; object-fit: contain; display: block; pointer-events: none; }
.icon-pick.sel { border-color: var(--primary-d); background: var(--accent); }
.emoji-wrap { margin-top: 10px; }
.editor-acts { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* Progreso */
.prog-line { font-size: 1.1rem; margin: 4px 0 10px; }
.best-table { display: flex; flex-direction: column; gap: 6px; }
.best-cell { background: #fff; border-radius: 10px; padding: 8px 12px; box-shadow: var(--shadow); }

/* ============================================================
   Portal (página de inicio)
   ============================================================ */
.portal { text-align: center; padding-top: 6px; }
.portal-hero h1 { font-size: clamp(1.8rem, 6vw, 2.8rem); margin: 8px 0 2px; color: #8a5cc4; }
.portal-hero p { color: #6c5a82; margin: 0 0 22px; font-size: 1.1rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; max-width: 820px; margin: 0 auto; }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; color: #fff; border-radius: var(--radius);
  padding: 34px 20px; box-shadow: var(--shadow-lg); min-height: 180px;
  transition: transform .12s; position: relative; overflow: hidden;
}
.tile:hover { transform: translateY(-4px) scale(1.02); }
.tile .tile-emoji { font-size: 3.4rem; }
.tile .tile-name { font-size: 1.7rem; font-weight: bold; }
.tile .tile-sub { font-size: 1rem; opacity: .95; }
.tile-lucia { background: linear-gradient(150deg, #ffc1dd, #ff8fb8); }
.tile-luisa { background: linear-gradient(150deg, #cdb6ee, #a98fe0); }
.tile-config { background: linear-gradient(150deg, #b9c6e6, #8aa0cf); }
.portal-foot { margin-top: 26px; color: #7a6a8c; font-size: .9rem; }

/* ---------- Reproductor de música ---------- */
.music-fab {
  position: fixed; right: 16px; bottom: 16px; z-index: 30;
  width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer;
  font-size: 1.7rem; color: var(--on-primary);
  background: linear-gradient(145deg, var(--primary), var(--primary-d));
  box-shadow: var(--shadow-lg); transition: transform .1s;
}
.music-fab:hover, .music-fab.active { transform: scale(1.06); }
.music-panel {
  position: fixed; right: 16px; bottom: 84px; z-index: 45;
  width: 280px; max-width: calc(100vw - 32px);
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 14px; display: none;
  animation: pop .25s cubic-bezier(.3, 1.4, .5, 1);
}
.music-panel.open { display: block; }
.music-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.music-title { font-weight: bold; color: var(--primary-dd); font-size: 1.15rem; }
.music-close { background: var(--accent); border: none; border-radius: 50%; width: 30px; height: 30px; cursor: pointer; font-size: .9rem; color: var(--primary-dd); }
.mood-row { display: flex; gap: 8px; margin-bottom: 10px; }
.mood-btn { flex: 1; font: inherit; cursor: pointer; background: #fff; color: var(--primary-dd); border: 2px solid var(--accent); border-radius: 12px; padding: 8px; font-size: .95rem; }
.mood-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--primary-d); }
.track-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.track-item { display: flex; align-items: center; gap: 8px; font: inherit; text-align: left; cursor: pointer; background: var(--accent); border: 2px solid transparent; border-radius: 12px; padding: 9px 10px; color: var(--ink); }
.track-item:hover { filter: brightness(.98); }
.track-item.active { border-color: var(--primary-d); background: #fff; box-shadow: var(--shadow); }
.track-ic { font-size: 1.1rem; color: var(--primary-dd); width: 1.3em; text-align: center; flex: none; }
.track-nm { font-size: .95rem; }
.music-controls { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 12px; }
.mctrl { font: inherit; cursor: pointer; background: #fff; border: 2px solid var(--primary); color: var(--primary-dd); border-radius: 50%; width: 44px; height: 44px; font-size: 1.1rem; box-shadow: var(--shadow); }
.mctrl.big { width: 56px; height: 56px; font-size: 1.5rem; background: linear-gradient(145deg, var(--primary), var(--primary-d)); color: var(--on-primary); border: none; }
.mctrl:hover { filter: brightness(.97); }
.vol-row { display: flex; align-items: center; gap: 10px; }
.vol-ic { font-size: 1.1rem; }
.vol { flex: 1; accent-color: var(--primary-d); height: 6px; }

@media (max-width: 480px) {
  .topbar .title { font-size: 1rem; }
  .btn-icon { padding: 7px 10px; font-size: .85rem; }
}
