/* Crucigrama MexcoParts — estilo móvil primero, letra grande, sin dependencias */
:root {
  --ink: #1c1f24;
  --paper: #f5f2ea;
  --card: #ffffff;
  --line: #d8d2c4;
  --brand: #ff6b1a;
  --brand-deep: #d94f00;
  --steel: #2e4a63;
  --ok: #1f9d55;
  --err: #e03131;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
}

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: var(--ink); color: #fff;
  padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  position: sticky; top: 0; z-index: 30;
}
.brand { font-size: 1.1rem; letter-spacing: .2px; }
.brand .logo { margin-right: 2px; }
.brand .name { font-weight: 700; }
.brand b { color: var(--brand); font-weight: 700; }
.badge {
  font-size: .72rem; background: #3a4048; color: #ffd7bd;
  padding: 4px 9px; border-radius: 999px; white-space: nowrap;
}

/* ---------- barra de navegación del sitio ---------- */
.sitebar {
  flex-basis: 100%;
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 8px;
}
.sitebar a {
  color: #e8eef4; text-decoration: none; font-size: .86rem; font-weight: 600;
  padding: 5px 11px; border-radius: 999px; background: #2b3037; white-space: nowrap;
}
.sitebar a:hover { background: #3a4048; }
.sitebar a.active { background: var(--brand); color: #fff; }

main { max-width: 560px; margin: 0 auto; padding: 12px 12px 40px; }

/* ---------- barra de pista ---------- */
.cluebar {
  display: flex; align-items: stretch; gap: 8px;
  background: var(--card); border: 2px solid var(--ink);
  border-radius: var(--radius); padding: 8px; margin-bottom: 12px;
  box-shadow: 0 3px 0 rgba(28,31,36,.85);
}
.cluebar .nav {
  flex: 0 0 46px; font-size: 1.6rem; line-height: 1;
  background: var(--paper); border: 2px solid var(--line);
  border-radius: 10px; color: var(--ink); font-weight: 700;
  cursor: pointer;
}
.cluebar .nav:active { background: #e9e3d5; }
.clue { flex: 1; align-self: center; min-width: 0; }
.cluenum {
  display: inline-block; background: var(--brand); color: #fff;
  font-weight: 800; font-size: .95rem; border-radius: 8px;
  padding: 2px 8px; margin-right: 6px; vertical-align: 2px;
}
#clueDesc { font-size: 1.06rem; font-weight: 600; line-height: 1.3; }

/* ---------- tablero ---------- */
.boardwrap { display: flex; justify-content: center; margin: 4px 0 14px; }
.board {
  --cols: 11;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: 3px;
  width: 100%;
  max-width: calc(var(--cols) * 34px);
  touch-action: manipulation;
}
.cell {
  position: relative; aspect-ratio: 1 / 1; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.cell.void { background: transparent; }
.cell.playable {
  background: var(--card); border: 2px solid var(--ink);
  cursor: pointer;
}
.cell.playable .num {
  position: absolute; top: 1px; left: 3px;
  font-size: clamp(.5rem, 2.6vw, .68rem); font-weight: 700; color: var(--steel);
}
.cell.playable .let {
  font-size: clamp(.95rem, 5vw, 1.35rem); font-weight: 800; color: var(--ink);
  text-transform: uppercase;
}
.cell.hl { background: #ffe9d4; }
.cell.sel { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand) inset; background: #fff3e6; }
.cell.err { animation: shake .5s; border-color: var(--err); background: #ffe3e3; }
.cell.err .let { color: var(--err); }
.cell.ok { background: #e6f6ec; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* ---------- botones ---------- */
.tools { display: flex; gap: 8px; margin-bottom: 16px; }
.btn {
  flex: 1; padding: 13px 10px; border-radius: var(--radius);
  font-size: 1rem; font-weight: 700; border: 2px solid var(--ink);
  background: var(--card); color: var(--ink); cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand-deep); color: #fff; }
.btn.ghost { background: transparent; border-style: dashed; }

/* ---------- pistas ---------- */
.clues { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cluecol { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.cluecol h3 { margin: 2px 0 8px; font-size: .95rem; color: var(--steel); }
.cluecol ul { list-style: none; margin: 0; padding: 0; }
.cluecol li {
  font-size: .92rem; line-height: 1.35; padding: 7px 6px; border-radius: 8px;
  cursor: pointer; display: flex; gap: 7px; align-items: baseline;
}
.cluecol li b { color: var(--brand-deep); min-width: 1.1em; text-align: right; }
.cluecol li.active { background: #fff0e0; outline: 1.5px solid var(--brand); }
.cluecol li.wdone b { color: var(--ok); }
.cluecol li.wdone { color: #6b7469; }

.foot { text-align: center; font-size: .8rem; color: #8b8577; margin-top: 22px; }

/* ---------- victoria ---------- */
.win {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(28,31,36,.55); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.win.hidden { display: none; }
.wincard {
  background: var(--card); border-radius: 20px; padding: 26px 22px;
  text-align: center; max-width: 360px; width: 100%;
  border: 3px solid var(--ink); box-shadow: 0 10px 0 rgba(28,31,36,.35);
  animation: pop .35s ease-out;
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.wemoji { font-size: 3rem; }
.wincard h2 { margin: 6px 0 4px; }
.wtime { font-size: 1.15rem; font-weight: 700; color: var(--brand-deep); margin: 4px 0 10px; }
.wincard .small { font-size: .85rem; color: #6f6a5e; margin-bottom: 16px; }

/* confeti */
.cft { position: fixed; top: -12px; z-index: 49; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall {
  to { transform: translateY(110dvh) rotate(560deg); opacity: .9; }
}

/* ---------- barra para escribir (abre el teclado del celular) ---------- */
.writebar { margin: 0 0 14px; }
#kbd {
  display: block; width: 100%; -webkit-appearance: none; appearance: none;
  font: inherit; font-size: 16px; font-weight: 700; letter-spacing: .5px; /* 16px: evita el zoom en iOS */
  padding: 12px 14px; border-radius: var(--radius);
  border: 2px dashed var(--steel); background: var(--card); color: var(--ink);
  text-transform: uppercase;
}
#kbd::placeholder { text-transform: none; color: #8b8577; font-weight: 600; }
#kbd:focus {
  border-style: solid; border-color: var(--brand-deep);
  outline: 3px solid var(--brand); outline-offset: 1px; background: #fff8f2;
}

@media (min-width: 430px) {
  .board { max-width: calc(var(--cols) * 38px); }
}

/* ---------- menú de temas (v2) ---------- */
.hidden { display: none !important; }
.menutitle { font-size: 1.45rem; margin: 6px 2px 2px; }
.menusub { font-size: .92rem; color: #6f6a5e; margin: 0 2px 14px; }
.levelGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.levelcard {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius);
  padding: 12px 12px 10px; cursor: pointer; text-align: left;
  box-shadow: 0 3px 0 rgba(28,31,36,.85);
  font: inherit; color: var(--ink);
}
.levelcard:active { transform: translateY(1px); box-shadow: 0 2px 0 rgba(28,31,36,.85); }
.levelcard .lvemoji { font-size: 1.6rem; line-height: 1; }
.levelcard .lvtitle { font-weight: 800; font-size: 1rem; line-height: 1.15; }
.levelcard .lvstatus { font-size: .78rem; font-weight: 700; color: #8b8577; }
.levelcard.done { border-color: var(--ok); }
.levelcard.done .lvstatus { color: var(--ok); }
.levelcard.doing .lvstatus { color: var(--brand-deep); }

.gamebar { display: flex; align-items: center; gap: 10px; margin: 2px 0 10px; }
.backbtn {
  font: inherit; font-weight: 700; font-size: .92rem;
  background: var(--card); border: 2px solid var(--ink); border-radius: 10px;
  padding: 7px 10px; cursor: pointer; color: var(--ink);
}
.backbtn:active { background: #e9e3d5; }
.gametitle { font-weight: 800; font-size: 1.05rem; }

#btnNext { display: block; width: 100%; margin-bottom: 8px; }
.winrow { display: flex; gap: 8px; }

/* ===== Modo embebido (?embed=1, iframe de la Zona de retos) ===== */
body.embed .top { display: none; }
body.embed .foot { display: none; }
body.embed .backbtn { display: none; }
body.embed #btnBackWin { display: none; }
body.embed .gamebar { justify-content: center; }
body.embed .boardwrap { margin: 2px 0 8px; }
body.embed .clues { margin-top: 6px; }
body.embed #wrap { padding: 4px 2px 0; }

/* ===== Reto con tiempo + cupón ===== */
.timer { font-weight: 800; font-size: 1.05rem; color: #1f9d55; font-variant-numeric: tabular-nums; margin-left: auto; }
.timer.urgente { color: #c22; }
.cuponarea { margin: 10px 0 4px; }
.cuponarea .btn { width: 100%; }
.cuponmsg { font-size: .95rem; margin: 8px 0 0; }
.cuponcodigo {
  display: inline-block;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 2px;
  background: #fdf6e3;
  border: 2px dashed #d94f00;
  border-radius: 10px;
  padding: 8px 16px;
  color: #d94f00;
  margin: 6px 0;
}
