:root {
  --kraft: #c6a472;
  --kraft-dark: #a8854f;
  --paper: #efe4cb;
  --paper-2: #e4d5b2;
  --ink: #1d1a17;
  --ink-soft: #4a4136;
  --yellow: #f6e33d;
  --teal: #2e9c95;
  --rust: #c4553a;
  --marker: "Permanent Marker", "Comic Sans MS", cursive;
  --hand: "Kalam", "Segoe Print", cursive;
  --sans: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background-color: var(--kraft);
  /* Grano de papel kraft. */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .25 0 0 0 0 .17 0 0 0 0 .08 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='600'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.004 .06' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 .3 0 0 0 0 .2 0 0 0 0 .1 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='600' height='600' filter='url(%23f)' opacity='.25'/%3E%3C/svg%3E");
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
button { font-family: inherit; color: inherit; }
[hidden] { display: none !important; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
::selection { background: var(--yellow); }

/* ---------- Piezas reutilizables ---------- */
.marker { font-family: var(--marker); font-weight: 400; letter-spacing: .02em; }
.hand { font-family: var(--hand); }
.hl {
  background: var(--yellow);
  padding: 0 .12em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  border-radius: 3px 14px 5px 12px / 12px 4px 14px 5px;
}
.ink { display: block; width: 100%; height: 100%; overflow: visible; }

/* Botón tipo pegatina: amarillo, borde de tinta, sombra dura y un poco torcido. */
.sticker {
  display: inline-flex; align-items: center; gap: .5em;
  font-family: var(--marker); font-size: 17px; letter-spacing: .04em; text-decoration: none;
  background: var(--yellow); color: var(--ink);
  border: 2.5px solid var(--ink); border-radius: 3px;
  padding: 12px 22px; cursor: pointer; position: relative;
  box-shadow: 3px 4px 0 rgba(29, 26, 23, .85);
  transform: rotate(-1.2deg);
  transition: transform .1s ease, box-shadow .1s ease;
}
.sticker:hover { transform: rotate(-.4deg) translate(-1px, -1px); box-shadow: 5px 6px 0 rgba(29, 26, 23, .85); }
.sticker:active { transform: rotate(-1deg) translate(2px, 3px); box-shadow: 1px 1px 0 rgba(29, 26, 23, .85); }
.taped::after {
  content: ""; position: absolute; top: -12px; right: -14px; width: 46px; height: 18px;
  background: rgba(238, 226, 190, .75); transform: rotate(28deg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}

/* Botones de herramienta: texto a mano subrayado, sin cajas de colores. */
.btn {
  border: 2px solid var(--ink); background: var(--paper); cursor: pointer;
  font-family: var(--hand); font-weight: 700; font-size: 16px; line-height: 1;
  padding: 8px 14px 6px; border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform .08s ease, box-shadow .08s ease, background .12s;
}
.btn:hover { background: #fff6dc; }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.btn.on { background: var(--yellow); }
.btn.small { padding: 6px 12px 4px; font-size: 15px; }
.btn.primary { background: var(--yellow); }
.btn:disabled { opacity: .45; cursor: default; }

.link-u {
  font-family: var(--marker); font-size: 16px; letter-spacing: .03em; text-decoration: none;
  border-bottom: 3px solid var(--teal); padding-bottom: 2px; display: inline-block;
}

/* Sello circulado "RESUELTO" a mano. */
.stamp {
  display: inline-block; font-family: var(--hand); font-weight: 700; font-size: 13px;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink);
  border: 2.5px solid var(--teal); border-radius: 50% 46% 52% 48% / 55% 50% 48% 52%;
  padding: 3px 12px 1px; transform: rotate(-4deg);
}

/* ---------- Barra superior ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  width: 100%; max-width: 1180px; margin: 0 auto; padding: 22px 24px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-logo { width: 40px; height: 40px; flex: none; }
.brand-name { font-family: var(--marker); font-size: 24px; letter-spacing: .03em; }
.brand-name span { color: #1f5f5b; }
.topnav { display: flex; align-items: center; gap: 22px; }
.topnav a:not(.sticker) {
  font-family: var(--hand); font-weight: 700; font-size: 18px; text-decoration: none;
  border-bottom: 2.5px solid transparent;
}
.topnav a:not(.sticker):hover, .topnav a.active { border-bottom-color: var(--ink); }
.topnav .sticker { font-size: 14px; padding: 8px 14px; }

main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 18px 24px 48px; outline: none; }
.footer {
  max-width: 1180px; width: 100%; margin: 0 auto; padding: 18px 24px 34px;
  font-family: var(--hand); font-size: 16px; color: var(--ink-soft);
  border-top: 2px dashed rgba(29, 26, 23, .35);
}
.footer span { display: block; font-size: 14px; }

/* ---------- Portada ---------- */
.hero { display: grid; grid-template-columns: 1fr 1.08fr; gap: 28px; align-items: center; padding-top: 18px; }
.hero h1 {
  font-family: var(--marker); font-weight: 400; font-size: clamp(42px, 6.4vw, 78px);
  line-height: 1.16; margin: 0 0 24px; letter-spacing: .01em;
}
.hero h1 .hl { padding: 0 .08em; margin-left: -.08em; }
.hero p.lead { font-size: 20px; line-height: 1.55; color: var(--ink-soft); margin: 0 0 30px; max-width: 30em; }
.hero p.lead b { color: var(--ink); }
.hero-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 24px; }
.hero-actions .sticker { font-size: 19px; padding: 16px 26px; }
.brands { margin-top: 36px; font-family: var(--hand); font-size: 18px; color: var(--ink-soft); display: flex; flex-wrap: wrap; gap: 6px 14px; }
.brands i { font-style: normal; opacity: .6; }

/* Dibujo anotado */
.diagram { position: relative; aspect-ratio: 1 / .92; }
.diagram > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.diagram .cube-art { position: absolute; left: 34%; top: 18%; width: 38%; height: auto; aspect-ratio: 1; }
.note-text {
  position: absolute; font-family: var(--hand); font-weight: 700; font-size: clamp(15px, 1.55vw, 19px);
  line-height: 1.32; width: 34%;
}
.note-text .num {
  display: inline-grid; place-items: center; width: 1.45em; height: 1.45em; border: 2.5px solid var(--ink);
  border-radius: 50%; font-size: .85em; margin-right: 4px; vertical-align: .05em;
}
.note-text a.ref {
  display: inline; font-family: var(--sans); font-weight: 800; font-size: 13px; text-decoration: none;
  border-bottom: 2px solid var(--ink); line-height: 2;
}
.note-text .stamp { margin-left: 6px; font-size: 11px; }
.pin {
  position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%;
  border: 2.5px solid var(--ink); background: var(--paper); display: grid; place-items: center;
  font-family: var(--hand); font-weight: 700; font-size: 20px; text-decoration: none;
  box-shadow: 2px 3px 0 rgba(29, 26, 23, .5); transition: transform .12s ease;
}
.pin:hover { transform: scale(1.12) rotate(-6deg); }
.pin.yellow { background: var(--yellow); }
.diagram .caption {
  position: absolute; right: 2%; bottom: -2%; font-family: var(--hand); font-style: italic;
  font-size: 15px; color: var(--ink-soft);
}

/* ---------- Secciones ---------- */
.section-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 64px 0 22px; flex-wrap: wrap; }
.section-title h2 { font-family: var(--marker); font-weight: 400; font-size: 34px; margin: 0; line-height: 1; }
.section-title small { font-family: var(--hand); font-size: 17px; color: var(--ink-soft); }

/* Tarjetas de papel con cinta */
.paper {
  background: var(--paper); border: 2px solid var(--ink); position: relative;
  box-shadow: 4px 5px 0 rgba(29, 26, 23, .25);
}
.tape::before {
  content: ""; position: absolute; top: -11px; left: 50%; width: 70px; height: 20px; margin-left: -35px;
  background: rgba(240, 230, 200, .72); transform: rotate(-3deg); box-shadow: 0 1px 2px rgba(0, 0, 0, .1);
}

.daily-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px; }
.daily-card {
  text-decoration: none; padding: 20px 18px 16px; display: grid; grid-template-columns: 64px 1fr;
  gap: 4px 14px; align-items: center; transition: transform .12s ease;
}
.daily-card:nth-child(odd) { transform: rotate(-1deg); }
.daily-card:nth-child(even) { transform: rotate(.8deg); }
.daily-card:hover { transform: rotate(0) translateY(-3px); }
.daily-card .art { width: 64px; height: 64px; grid-row: span 2; }
.daily-card h3 { margin: 0; font-family: var(--marker); font-weight: 400; font-size: 20px; line-height: 1.1; }
.daily-card .state { font-family: var(--hand); font-weight: 700; font-size: 15px; color: var(--ink-soft); }

.filters { display: flex; gap: 18px; }
.filters button {
  background: none; border: 0; cursor: pointer; font-family: var(--hand); font-weight: 700; font-size: 18px;
  padding: 0 2px 2px; border-bottom: 3px solid transparent;
}
.filters button.on { border-bottom-color: var(--teal); }

.games-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px 26px; }
.game-card { text-decoration: none; display: flex; flex-direction: column; transition: transform .12s ease; }
.game-card:nth-child(3n+1) { transform: rotate(-.8deg); }
.game-card:nth-child(3n+2) { transform: rotate(.6deg); }
.game-card:nth-child(3n) { transform: rotate(-.3deg); }
.game-card:hover { transform: rotate(0) translateY(-4px); }
.game-art {
  height: 170px; display: grid; place-items: center; border-bottom: 2px solid var(--ink);
  background:
    repeating-linear-gradient(0deg, transparent 0 23px, rgba(46, 156, 149, .18) 23px 24px),
    var(--paper);
}
.game-art .ink { width: 120px; height: 120px; }
.game-info { padding: 14px 18px 18px; }
.game-info .kind {
  font-family: var(--hand); font-weight: 700; font-size: 13px; letter-spacing: .1em; text-transform: uppercase;
  color: #1f5f5b;
}
.game-info h3 { margin: 2px 0 6px; font-family: var(--marker); font-weight: 400; font-size: 23px; line-height: 1.1; }
.game-info p { margin: 0; color: var(--ink-soft); font-size: 15px; line-height: 1.45; }

/* ---------- Pantalla de juego ---------- */
.game-head { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 14px 20px; margin: 6px 0 18px; }
.game-title { display: flex; align-items: center; gap: 16px; }
.game-title .art { width: 58px; height: 58px; flex: none; }
.game-title h1 { margin: 0; font-family: var(--marker); font-weight: 400; font-size: clamp(28px, 4vw, 40px); line-height: 1.05; }
.game-title .sub { font-family: var(--hand); font-size: 17px; color: var(--ink-soft); }
.back { font-family: var(--hand); font-weight: 700; font-size: 17px; text-decoration: none; border-bottom: 2px solid var(--ink); }
.hud { display: flex; gap: 12px; }
.hud-item {
  background: var(--paper); border: 2px solid var(--ink); padding: 6px 14px 4px; text-align: center; min-width: 84px;
  box-shadow: 3px 3px 0 rgba(29, 26, 23, .25);
}
.hud-item:first-child { transform: rotate(-1.5deg); }
.hud-item:last-child { transform: rotate(1.2deg); }
.hud-item b { display: block; font-family: var(--marker); font-weight: 400; font-size: 24px; font-variant-numeric: tabular-nums; }
.hud-item span { font-family: var(--hand); font-weight: 700; font-size: 13px; color: var(--ink-soft); }
.game-bar { display: flex; flex-wrap: wrap; gap: 10px 12px; margin-bottom: 22px; align-items: center; }
.game-bar .spacer { flex: 1; }
.select {
  appearance: none; background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%231d1a17' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--ink); border: 2px solid var(--ink); border-radius: 4px; padding: 7px 34px 5px 12px;
  font-family: var(--hand); font-weight: 700; font-size: 16px; box-shadow: 2px 2px 0 var(--ink);
}
.stage { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* Lienzo 3D sobre una hoja de papel cuadriculado */
.canvas3d {
  width: 100%; height: min(70vh, 620px); overflow: hidden; touch-action: none; position: relative;
  border: 2px solid var(--ink); box-shadow: 5px 6px 0 rgba(29, 26, 23, .25);
  background:
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(46, 156, 149, .16) 31px 32px),
    repeating-linear-gradient(90deg, transparent 0 31px, rgba(46, 156, 149, .16) 31px 32px),
    var(--paper);
}
.canvas3d canvas { display: block; width: 100%; height: 100%; }
.canvas-hint {
  position: absolute; bottom: 12px; right: 16px; font-family: var(--hand); font-style: italic; font-size: 15px;
  color: var(--ink-soft); pointer-events: none; text-align: right; max-width: 90%;
}

/* ---------- Sudoku ---------- */
.sudoku {
  display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); grid-template-rows: repeat(9, minmax(0, 1fr));
  width: min(92vw, 520px); aspect-ratio: 1;
  background: var(--paper); border: 3.5px solid var(--ink); user-select: none;
  box-shadow: 5px 6px 0 rgba(29, 26, 23, .25);
}
.sudoku .cell {
  border: 0; border-right: 1px solid rgba(29, 26, 23, .35); border-bottom: 1px solid rgba(29, 26, 23, .35);
  background: transparent; font-size: clamp(18px, 4.6vw, 28px);
  display: grid; place-items: center; cursor: pointer; padding: 0; position: relative;
  min-width: 0; min-height: 0; overflow: hidden; line-height: 1;
}
.sudoku .cell:nth-child(9n) { border-right: 0; }
.sudoku .cell.bR { border-right: 3px solid var(--ink); }
.sudoku .cell.bB { border-bottom: 3px solid var(--ink); }
.sudoku .cell.given { font-family: var(--sans); font-weight: 800; color: var(--ink); }
.sudoku .cell.user { font-family: var(--hand); font-weight: 700; color: #1f5f5b; font-size: clamp(20px, 5vw, 31px); }
.sudoku .cell.peer { background: rgba(46, 156, 149, .1); }
.sudoku .cell.same { background: rgba(246, 227, 61, .45); }
.sudoku .cell.sel { background: var(--yellow); }
.sudoku .cell.bad { color: var(--rust); text-decoration: line-through; text-decoration-thickness: 2px; }
.sudoku .notes {
  display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; height: 100%;
  font-family: var(--hand); font-size: clamp(9px, 1.7vw, 12px); color: var(--ink-soft); padding: 2px;
}
.sudoku .notes span { display: grid; place-items: center; }
.numpad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 7px; width: min(92vw, 520px); }
.numpad .btn { justify-content: center; font-family: var(--marker); font-weight: 400; font-size: 22px; padding: 10px 0 8px; border-radius: 4px; }
.numpad .btn.full { opacity: .3; }

/* ---------- Nonograma ---------- */
.nono { display: grid; user-select: none; touch-action: none; padding: 14px; }
.nono .clue-col, .nono .clue-row { font-family: var(--hand); font-weight: 700; font-size: 15px; display: flex; gap: 4px; line-height: 1.1; }
.nono .clue-col { flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: 6px; }
.nono .clue-row { justify-content: flex-end; align-items: center; padding-right: 8px; }
.nono .clue-ok { color: var(--teal); text-decoration: line-through; }
.nono .ncell {
  width: var(--cs); height: var(--cs); background: #fbf5e6; border: 1px solid rgba(29, 26, 23, .3); cursor: pointer;
  display: grid; place-items: center; color: var(--teal); font-weight: 800; font-size: calc(var(--cs) * .6);
}
.nono .ncell.fill { background: var(--ink); border-color: var(--ink); }
.nono .ncell.x::after { content: "×"; font-family: var(--hand); }
.nono .ncell.tR { border-right: 2.5px solid var(--ink); }
.nono .ncell.tB { border-bottom: 2.5px solid var(--ink); }

/* ---------- Luces ---------- */
.lights { display: grid; gap: 12px; width: min(88vw, 420px); aspect-ratio: 1; padding: 18px; }
.light {
  border: 2.5px solid var(--ink); border-radius: 50%; cursor: pointer; background: #fbf5e6;
  box-shadow: inset 0 -5px 0 rgba(29, 26, 23, .12); transition: background .12s, transform .08s;
  position: relative;
}
.light.on {
  background: var(--yellow);
  box-shadow: 0 0 0 4px rgba(246, 227, 61, .45), inset 0 -5px 0 rgba(29, 26, 23, .12);
}
.light.on::after {
  content: ""; position: absolute; inset: 22% 50% 50% 22%; border-top: 3px solid #fff8b8; border-left: 3px solid #fff8b8;
  border-radius: 40% 0 0 0;
}
.light:active { transform: scale(.92); }

/* ---------- Piezas compartidas: teclado numérico y rondas ---------- */
.quiz { display: flex; flex-direction: column; align-items: center; gap: 18px; width: min(100%, 640px); }
.quiz.wide { width: 100%; }
.quiz-q { font-family: var(--marker); font-size: clamp(22px, 3.4vw, 30px); text-align: center; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.entry { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.entry-display {
  min-width: 170px; text-align: center; font-family: var(--marker); font-size: 36px; padding: 6px 20px 2px;
  background: #fbf5e6; border: 2.5px solid var(--ink); box-shadow: 3px 3px 0 rgba(29,26,23,.25);
}
.entry-display.good { background: rgba(46,156,149,.3); }
.entry-display.bad { background: rgba(196,85,58,.3); }
.entry-display.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
.entry-pad { display: grid; grid-template-columns: repeat(3, 64px); gap: 8px; }
.entry-pad .btn { justify-content: center; font-size: 20px; padding: 10px 0 8px; border-radius: 4px; }
.entry-pad .key-ok, .entry-pad .key-del { font-size: 15px; }
.entry-pad .wide { grid-column: span 3; }
.rounds { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.rounds span { width: 26px; height: 26px; border: 2px solid var(--ink); border-radius: 50%; background: #fbf5e6; }
.rounds span.done { background: var(--teal); }
.rounds span.now { background: var(--yellow); }
.rounds.compact span { width: 16px; height: 16px; border-width: 1.6px; }

/* ---------- Binario ---------- */
.binario { display: grid; aspect-ratio: 1; background: #fbf5e6; border: 3px solid var(--ink); box-shadow: 5px 6px 0 rgba(29,26,23,.25); user-select: none; touch-action: manipulation; }
.bcell { border: 0; border-right: 1px solid rgba(29,26,23,.3); border-bottom: 1px solid rgba(29,26,23,.3); background: transparent; cursor: pointer; font-family: var(--marker); font-size: clamp(16px, 3.6vw, 26px); padding: 0; aspect-ratio: 1; }
.bcell.one { background: var(--yellow); }
.bcell.zero { background: rgba(46,156,149,.25); }
.bcell.given { font-family: var(--sans); font-weight: 800; cursor: default; }
.bcell.given.one { background: #e8cf2a; }
.bcell.given.zero { background: rgba(46,156,149,.45); }
.bcell.bad { color: var(--rust); box-shadow: inset 0 0 0 3px var(--rust); }

/* ---------- Rascacielos ---------- */
.sky { display: grid; gap: 4px; user-select: none; }
.sky-clue { display: grid; place-items: center; font-family: var(--hand); font-weight: 700; font-size: clamp(16px, 3.4vw, 22px); }
.sky-clue.ok { color: var(--teal); text-decoration: line-through; }
.sky-clue.bad { color: var(--rust); }
.sky-cell { position: relative; aspect-ratio: 1; border: 2px solid var(--ink); background: #fbf5e6; cursor: pointer; padding: 0; overflow: hidden; font-family: var(--marker); font-size: clamp(16px, 3.6vw, 26px); }
.sky-cell b { position: relative; font-weight: 400; }
.sky-cell .tower { position: absolute; left: 18%; right: 18%; bottom: 0; height: calc(var(--h) * 86%); background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M-2 2l4-4M0 8l8-8M6 10l4-4' stroke='%232e9c95' stroke-width='2.4'/%3E%3C/svg%3E"); border: 1.5px solid var(--ink); border-bottom: 0; opacity: .7; }
.sky-cell.given { background: var(--paper-2); cursor: default; }
.sky-cell.sel { background: var(--yellow); }
.sky-cell.bad b { color: var(--rust); }
.sky-key { min-width: 46px; justify-content: center; font-family: var(--marker); font-weight: 400; font-size: 20px; }

/* ---------- Buscaminas ---------- */
.mine-count { font-size: 18px; font-weight: 700; }
.mines { display: grid; border: 3px solid var(--ink); background: var(--ink); gap: 1px; user-select: none; box-shadow: 5px 6px 0 rgba(29,26,23,.25); }
.mcell { aspect-ratio: 1; border: 0; padding: 0; cursor: pointer; background: var(--paper-2); box-shadow: inset -2px -2px 0 rgba(29,26,23,.25), inset 2px 2px 0 #fff6dc; display: grid; place-items: center; font-family: var(--hand); font-weight: 700; font-size: clamp(13px, 2.6vw, 20px); }
.mcell.open { background: #fbf5e6; box-shadow: none; cursor: default; }
.mcell.boom { background: var(--rust); }
.mcell .mflag { width: 72%; height: 72%; }
.mcell .n1 { color: var(--teal); } .mcell .n2 { color: var(--ink); } .mcell .n3 { color: var(--rust); }
.mcell .n4 { color: #2c4f8a; } .mcell .n5, .mcell .n6, .mcell .n7, .mcell .n8 { color: #7a2f1d; }

/* ---------- Fontanería ---------- */
.pipes { display: grid; background: #fbf5e6; border: 3px solid var(--ink); box-shadow: 5px 6px 0 rgba(29,26,23,.25); user-select: none; touch-action: manipulation; }
.pcell { aspect-ratio: 1; border: 0; padding: 0; background: transparent; cursor: pointer; border-right: 1px dashed rgba(29,26,23,.2); border-bottom: 1px dashed rgba(29,26,23,.2); }
.pcell svg { width: 100%; height: 100%; display: block; transition: transform .16s ease; }
.pcell .water { stroke: #d9c9a3; transition: stroke .2s; }
.pcell .tap { fill: var(--paper); }
.pcell.wet .water { stroke: var(--teal); }
.pcell.wet .tap { fill: var(--teal); }

/* ---------- Sopa de letras ---------- */
.sopa-wrap { display: flex; gap: 28px; align-items: flex-start; flex-wrap: wrap; justify-content: center; }
.sopa-box { position: relative; width: min(92vw, 540px); aspect-ratio: 1; background: #fbf5e6; border: 3px solid var(--ink); box-shadow: 5px 6px 0 rgba(29,26,23,.25); }
.sopa { position: absolute; inset: 0; display: grid; user-select: none; touch-action: none; }
.scell { display: grid; place-items: center; font-family: var(--hand); font-weight: 700; font-size: clamp(14px, 3.2vw, 24px); cursor: pointer; }
.sopa-marks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.sopa-marks .mark { stroke: var(--yellow); stroke-width: .72; stroke-linecap: round; opacity: .9; }
.sopa-marks .mark:nth-of-type(even) { stroke: rgba(46,156,149,.55); }
.sopa-marks .mark.live { stroke: rgba(29,26,23,.18); }
.sopa-list { min-width: 200px; padding: 6px 4px; }
.sopa-list .kind { font-family: var(--hand); font-weight: 700; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: #1f5f5b; }
.sopa-list h3 { font-family: var(--marker); font-weight: 400; font-size: 24px; margin: 2px 0 12px; }
.sopa-word { font-family: var(--hand); font-weight: 700; font-size: 20px; padding: 2px 0; }
.sopa-word.found { text-decoration: line-through; text-decoration-color: var(--teal); text-decoration-thickness: 3px; opacity: .55; }

/* ---------- Código secreto ---------- */
.code-wrap { display: flex; gap: 22px; align-items: flex-start; justify-content: center; flex-wrap: wrap; }
.code-board { padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; }
.code-row { display: flex; align-items: center; gap: 12px; padding: 3px 6px; border-bottom: 1.5px dashed rgba(29,26,23,.25); }
.code-row.now { background: rgba(246,227,61,.45); }
.row-n { font-family: var(--hand); font-weight: 700; width: 20px; color: var(--ink-soft); }
.slots { display: flex; gap: 6px; }
.slot { width: 34px; height: 34px; padding: 0; border: 0; background: none; display: grid; place-items: center; cursor: pointer; }
.slot.empty { border: 2px dashed rgba(29,26,23,.35); border-radius: 50%; width: 30px; height: 30px; margin: 2px; }
.fbs { display: grid; gap: 3px; min-width: 34px; }
.fb { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid rgba(29,26,23,.2); display: block; }
.fb.exact { background: var(--ink); border-color: var(--ink); }
.fb.near { border: 2px solid var(--ink); }
.code-palette { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 14px; background: var(--paper); border: 2px solid var(--ink); box-shadow: 4px 5px 0 rgba(29,26,23,.25); transform: rotate(1deg); }
.code-color { border: 0; background: none; padding: 4px; cursor: pointer; transition: transform .1s; }
.code-color:hover { transform: scale(1.12) rotate(-6deg); }

/* ---------- Memoria ---------- */
.memory { display: grid; gap: 12px; perspective: 900px; }
.mcard { aspect-ratio: 3 / 4; border: 0; padding: 0; background: none; cursor: pointer; position: relative; transform-style: preserve-3d; transition: transform .35s ease; transform: rotate(var(--tilt)); }
.mcard .face { position: absolute; inset: 0; backface-visibility: hidden; border: 2.5px solid var(--ink); box-shadow: 3px 4px 0 rgba(29,26,23,.25); display: grid; place-items: center; }
.mcard .back { background: repeating-linear-gradient(45deg, var(--kraft-dark) 0 6px, var(--kraft) 6px 12px); }
.mcard .back::after { content: ""; width: 34%; aspect-ratio: 1; border-radius: 50%; background: var(--yellow); border: 2.5px solid var(--ink); }
.mcard .front { background: #fbf5e6; transform: rotateY(180deg); }
.mcard .front svg { width: 70%; height: 70%; }
.mcard.up { transform: rotate(var(--tilt)) rotateY(180deg); }
.mcard.match .front { background: rgba(46,156,149,.25); }

/* ---------- La Balanza ---------- */
.scales { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; width: 100%; }
.scale-card { padding: 8px 6px 2px; }
.scale-card:nth-child(odd) { transform: rotate(-.8deg); }
.scale-card:nth-child(even) { transform: rotate(.7deg); }
.scale { width: 100%; display: block; }
.shape-inline { width: 30px; height: 30px; }

/* ---------- ¿Qué sigue? y Cálculo ---------- */
.seq { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; justify-content: center; font-family: var(--marker); font-size: clamp(26px, 5vw, 44px); }
.seq i { font-style: normal; color: var(--ink-soft); }
.seq .term.ask { background: var(--yellow); border: 2.5px solid var(--ink); padding: 0 14px; transform: rotate(-2deg); display: inline-block; }
.seq .term.ask.shown { background: rgba(46,156,149,.35); }
.rule { min-height: 28px; font-size: 19px; text-align: center; max-width: 34em; }
.calc-op { font-family: var(--marker); font-size: clamp(40px, 9vw, 72px); line-height: 1.1; text-align: center; }
.calc-op span { color: var(--teal); }

/* ---------- Laberinto ---------- */
.arrows-pad { display: grid; grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(2, 50px); gap: 6px; }
.arrows-pad .btn { justify-content: center; font-size: 22px; border-radius: 6px; }
.arrows-pad .arrow-up { grid-column: 2; grid-row: 1; }
.arrows-pad .arrow-left { grid-column: 1; grid-row: 2; }
.arrows-pad .arrow-down { grid-column: 2; grid-row: 2; }
.arrows-pad .arrow-right { grid-column: 3; grid-row: 2; }

.game-info .kind .stamp { font-size: 10px; margin-left: 6px; letter-spacing: .06em; }

.pocket { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; padding: 8px 16px; background: var(--paper); border: 2px dashed var(--ink); min-height: 50px; }
.pocket-label { font-family: var(--marker); font-size: 17px; }
.pocket-empty { font-family: var(--hand); color: var(--ink-soft); }
.canvas-hint.speaking { background: var(--yellow); color: var(--ink); font-style: normal; font-weight: 700; padding: 6px 12px; border: 2px solid var(--ink); left: 50%; right: auto; transform: translateX(-50%); text-align: center; width: max-content; max-width: 92%; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(29, 26, 23, .55); display: grid; place-items: center;
  z-index: 50; padding: 16px; animation: fade .18s ease;
}
.modal-card {
  width: min(480px, 100%); max-height: 85vh; overflow: auto; padding: 34px 30px 26px;
  background: var(--paper); border: 2.5px solid var(--ink); box-shadow: 7px 8px 0 rgba(29, 26, 23, .45);
  transform: rotate(-.8deg); position: relative;
}
.modal-card::before {
  content: ""; position: absolute; top: -12px; left: 50%; width: 90px; height: 22px; margin-left: -45px;
  background: rgba(240, 230, 200, .8); transform: rotate(2deg);
}
.modal-card h2 { margin: 0 0 12px; font-family: var(--marker); font-weight: 400; font-size: 32px; line-height: 1.05; }
.modal-card p, .modal-card li { line-height: 1.55; color: var(--ink-soft); }
.modal-card b { color: var(--ink); }
.modal-card ul { padding-left: 20px; }
.modal-actions { display: flex; gap: 14px; justify-content: flex-end; align-items: center; margin-top: 22px; flex-wrap: wrap; }
.modal-actions .sticker { font-size: 15px; padding: 10px 18px; }
.win-stats { display: flex; gap: 14px; margin: 18px 0 8px; }
.win-note { font-family: var(--hand); font-weight: 700; font-size: 18px; color: var(--ink); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Logros ---------- */
.stats-head { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 34px; }
.stat-note { padding: 18px 22px 14px; min-width: 170px; }
.stat-note:nth-child(1) { transform: rotate(-1.5deg); }
.stat-note:nth-child(2) { transform: rotate(1deg); background: var(--yellow); }
.stat-note:nth-child(3) { transform: rotate(-.5deg); }
.stat-note b { display: block; font-family: var(--marker); font-weight: 400; font-size: 48px; line-height: 1; }
.stat-note span { font-family: var(--hand); font-weight: 700; font-size: 16px; }
.stats-wrap { display: grid; grid-template-columns: 360px 1fr; gap: 34px; align-items: start; }
.stats-wrap h3 { font-family: var(--marker); font-weight: 400; font-size: 24px; margin: 0 0 14px; }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; padding: 16px; }
.calendar div {
  aspect-ratio: 1; display: grid; place-items: center; font-family: var(--hand); font-weight: 700; font-size: 14px;
  border: 1.5px solid rgba(29, 26, 23, .3); border-radius: 50%;
}
.calendar .lvl1 { border: 2.5px solid var(--teal); }
.calendar .lvl2 { background: rgba(46, 156, 149, .35); border: 2.5px solid var(--teal); }
.calendar .lvl3 { background: var(--yellow); border: 2.5px solid var(--ink); }
.stats-table { width: 100%; border-collapse: collapse; }
.stats-table th, .stats-table td { padding: 12px 14px; text-align: left; border-bottom: 1.5px dashed rgba(29, 26, 23, .35); }
.stats-table th { font-family: var(--hand); font-weight: 700; font-size: 14px; color: var(--ink-soft); }
.stats-table td:first-child { font-family: var(--marker); font-size: 17px; }
.stats-table .lv { font-family: var(--hand); color: var(--ink-soft); }

.loading { text-align: center; font-family: var(--hand); font-size: 20px; padding: 80px 0; }

/* ---------- Móvil ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .daily-grid { grid-template-columns: repeat(2, 1fr); }
  .games-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-wrap { grid-template-columns: 1fr; }
  .diagram { aspect-ratio: auto; display: flex; flex-direction: column; gap: 16px; }
  .diagram > svg.arrows { display: none; }
  .diagram .cube-art { position: relative; left: auto; top: auto; width: min(70%, 300px); margin: 0 auto; order: -1; }
  .note-text { position: static; width: auto !important; }
  .pin { display: none; }
  .diagram .caption { position: static; }
}
@media (max-width: 560px) {
  .entry-pad { grid-template-columns: repeat(3, 58px); }
  .code-palette { grid-template-columns: repeat(4, 1fr); transform: none; }
  .sopa-list { min-width: 0; width: 100%; display: flex; flex-wrap: wrap; gap: 4px 14px; }
  .sopa-list .kind, .sopa-list h3 { width: 100%; }
  .topbar { padding: 16px 16px 6px; flex-wrap: wrap; }
  main { padding: 12px 16px 40px; }
  .footer { padding: 16px; }
  .brand-name { font-size: 20px; }
  .brand-logo { width: 34px; height: 34px; }
  .topnav { gap: 14px; }
  .topnav a:not(.sticker) { font-size: 16px; }
  .topnav .taped::after { display: none; }
  .daily-grid, .games-grid { grid-template-columns: 1fr; }
  .section-title { margin-top: 48px; }
  .hud-item { min-width: 70px; padding: 5px 10px 3px; }
  .numpad { gap: 4px; }
  .numpad .btn { font-size: 18px; }
  .nono { padding: 4px; }
  .nono .clue-col, .nono .clue-row { font-size: 12px; gap: 3px; }
}
