:root {
  --bg: #0b0d10;
  --panel: #14181d;
  --line: #262d35;
  --text: #e7edf3;
  --muted: #94a3b2;
  --accent: #7ee787;
  --accent-2: #58a6ff;
  --danger: #ff7b72;
  --radius: 14px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #17202a 0%, var(--bg) 60%);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

h1 {
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

.sub { color: var(--muted); margin: 0 0 28px; font-size: 0.95rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.panel + .panel { margin-top: 16px; }

label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }

input[type="text"], input[type="number"], textarea, .drop {
  width: 100%;
  background: #0e1216;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
}

textarea { min-height: 84px; resize: vertical; }

input:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 1px;
}

.drop {
  border-style: dashed;
  text-align: center;
  padding: 28px 16px;
  cursor: pointer;
  color: var(--muted);
}

.drop.over { border-color: var(--accent); color: var(--text); }

button {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--line);
  background: #1b2128;
  color: var(--text);
  border-radius: 10px;
  padding: 12px 18px;
  cursor: pointer;
}

button:hover:not(:disabled) { border-color: #3a4552; }
button:disabled { opacity: 0.5; cursor: default; }

button.primary { background: var(--accent); color: #08130c; border-color: transparent; }
button.ghost { background: transparent; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.grow { flex: 1 1 200px; }

.hud {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-variant-numeric: tabular-nums;
}

.hud b { font-weight: 700; }
.hud .clock.low { color: var(--danger); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.terms { font-size: clamp(1.1rem, 4vw, 1.6rem); letter-spacing: 0.06em; }

.cipher {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(0.95rem, 3.6vw, 1.25rem);
  line-height: 1.7;
  word-break: break-word;
}

.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }

.claims { margin: 0 0 16px; padding-left: 18px; line-height: 1.8; }

.cell {
  width: 100%;
  aspect-ratio: 1;
  background: #0e1216;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
}
.cell.on { background: var(--accent); border-color: var(--accent); }
.cell.clue { background: transparent; border: none; cursor: default; color: var(--muted); font-size: 0.7rem; display: grid; place-items: center; white-space: pre-line; line-height: 1.15; }

.sudoku { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; max-width: 320px; margin: 0 auto; }
.sudoku input {
  aspect-ratio: 1; text-align: center; padding: 0; border-radius: 6px;
  font-size: 1.1rem; -moz-appearance: textfield;
}
.sudoku input::-webkit-outer-spin-button, .sudoku input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.sudoku input.given { background: #1b2128; color: var(--accent-2); font-weight: 700; }

canvas { display: block; margin: 0 auto; max-width: 100%; border-radius: 10px; background: #0e1216; }

.pad { display: grid; grid-template-columns: repeat(3, 56px); gap: 8px; justify-content: center; margin-top: 14px; }
.pad button { padding: 14px 0; }
.pad .spacer { visibility: hidden; }


.simon { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; max-width: 320px; margin: 0 auto; }
.simon button { aspect-ratio: 1; border-radius: 12px; }
.simon button.lit { filter: brightness(2.2); }
.s0 { background: #2f81f7; } .s1 { background: #db61a2; } .s2 { background: #e3b341; } .s3 { background: #3fb950; }

.target { position: relative; height: 240px; border: 1px solid var(--line); border-radius: 10px; background: #0e1216; }
.target button { position: absolute; width: 64px; height: 64px; border-radius: 50%; background: var(--accent); border: none; }

.bar { position: relative; height: 56px; border: 1px solid var(--line); border-radius: 10px; background: #0e1216; overflow: hidden; }
.bar .zone { position: absolute; top: 0; bottom: 0; background: rgba(126,231,135,0.25); border-left: 1px solid var(--accent); border-right: 1px solid var(--accent); }
.bar .needle { position: absolute; top: 0; bottom: 0; width: 3px; background: var(--danger); }

.hint { color: var(--muted); font-size: 0.9rem; margin: 0 0 14px; }
.big { font-size: clamp(1.3rem, 4vw, 1.8rem); margin: 0 0 8px; }
.ok { color: var(--accent); }
.bad { color: var(--danger); }
.center { text-align: center; }

.link {
  display: flex; gap: 8px; align-items: center; background: #0e1216;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; word-break: break-all;
}
.link code { font-size: 0.9rem; }

footer { color: var(--muted); font-size: 0.8rem; text-align: center; margin-top: 28px; }

/* ------------------------------------------------------------- juegos nuevos */

.palette { --c0: #2f81f7; --c1: #db61a2; --c2: #e3b341; --c3: #3fb950; --c4: #a371f7; --c5: #f0883e; --c6: #56d4dd; }
.c0 { background: #2f81f7; } .c1 { background: #db61a2; } .c2 { background: #e3b341; }
.c3 { background: #3fb950; } .c4 { background: #a371f7; } .c5 { background: #f0883e; } .c6 { background: #56d4dd; }

/* taquín */
.tiles { display: grid; gap: 6px; max-width: 340px; margin: 0 auto; }
.tile {
  aspect-ratio: 1; display: grid; place-items: center; font-size: 1.3rem; font-weight: 700;
  background: #1b2128; border: 1px solid var(--line); border-radius: 10px;
}
.tile.blank { background: transparent; border-style: dashed; }

/* Torres de Hanói */
.pegs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 460px; margin: 0 auto; }
.peg {
  height: 190px; display: flex; align-items: flex-end; padding: 8px 6px;
  background: #0e1216; border: 1px solid var(--line); border-radius: 10px;
}
.peg.picked { border-color: var(--accent); }
.peg .stack { display: flex; flex-direction: column-reverse; gap: 3px; width: 100%; align-items: center; }
.disc {
  height: 18px; border-radius: 9px; background: var(--accent-2); color: #08130c;
  font-size: 0.7rem; font-weight: 700; display: grid; place-items: center;
}

/* tubos de colores */
.tubes { display: grid; grid-template-columns: repeat(auto-fit, minmax(42px, 1fr)); gap: 8px; max-width: 460px; margin: 0 auto; }
.tube { padding: 5px; background: #0e1216; border: 1px solid var(--line); border-radius: 0 0 14px 14px; }
.tube.picked { border-color: var(--accent); }
.tube .liquid { display: flex; flex-direction: column; gap: 3px; }
.seg { height: 26px; border-radius: 4px; display: block; }
.seg.empty { background: #161c22; }

/* Mastermind */
.guesses { display: flex; flex-direction: column; gap: 8px; }
.guess { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.guess .mono { font-size: 0.85rem; color: var(--muted); }
.chip { width: 30px; height: 30px; border-radius: 50%; display: inline-block; border: 1px solid var(--line); }
.chip.empty { background: #161c22; }
.chipbtn { height: 46px; border-radius: 10px; border: 1px solid var(--line); }

/* ahorcado */
.keyboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(42px, 1fr)); gap: 6px; margin-top: 14px; }
.key { padding: 12px 0; font-weight: 700; }
.key.ok { background: rgba(126, 231, 135, 0.18); border-color: var(--accent); }
.key.bad { background: rgba(255, 123, 114, 0.18); border-color: var(--danger); }

/* memorama */
.memo { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 360px; margin: 0 auto; }
.card { aspect-ratio: 1; font-size: 1.6rem; background: #1b2128; }
.card.up { background: #0e1216; border-color: var(--accent-2); }
.card.matched { background: rgba(126, 231, 135, 0.15); border-color: var(--accent); opacity: 1; }

/* buscaminas */
.mines { display: grid; gap: 3px; max-width: 380px; margin: 0 auto; }
.mine {
  aspect-ratio: 1; padding: 0; font-weight: 700; font-size: 0.9rem;
  background: #1b2128; border: 1px solid var(--line); border-radius: 4px;
}
.mine.open { background: #0e1216; display: grid; place-items: center; color: var(--muted); }
.mine.flag { color: var(--danger); }
.mine.n1 { color: #58a6ff; } .mine.n2 { color: #3fb950; } .mine.n3 { color: #e3b341; }
.mine.n4, .mine.n5, .mine.n6, .mine.n7, .mine.n8 { color: var(--danger); }
