:root { --bg: #17171b; --panel: #222228; --text: #f1f1f4; --muted: #9a9aa6; --line: #34343c; --accent: #f1f1f4; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; overflow: hidden; overscroll-behavior: none; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; background: var(--panel); border: 0; border-radius: 14px; padding: 12px 18px; cursor: pointer; }
button:active { filter: brightness(1.25); }
[hidden] { display: none !important; }

#bar { position: fixed; top: 0; left: 0; right: 0; z-index: 5; height: calc(env(safe-area-inset-top) + 52px); padding: env(safe-area-inset-top) 12px 0; display: grid; grid-template-columns: 48px 1fr auto; align-items: center; }
#bar #back { width: 40px; height: 40px; padding: 0; font-size: 26px; line-height: 1; background: rgba(255, 255, 255, .08); border-radius: 12px; }
#title { font-weight: 700; letter-spacing: .3px; text-align: center; }
#hud { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 48px; text-align: right; color: var(--muted); }
#hud b { color: var(--text); }
body[data-screen="menu"] #bar { height: env(safe-area-inset-top); }

#view { position: fixed; inset: 0; padding-top: calc(env(safe-area-inset-top) + 52px); }
body[data-screen="menu"] #view { padding-top: env(safe-area-inset-top); overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* Menú */
.menu { max-width: 560px; margin: 0 auto; padding: 28px 18px calc(env(safe-area-inset-bottom) + 30px); text-align: center; }
.logo { margin: 8px 0 0; font-size: 46px; letter-spacing: 6px; font-weight: 900; }
.tag { margin: 4px 0 14px; color: var(--muted); font-size: 14px; }
.total { display: inline-block; padding: 6px 16px; border-radius: 20px; background: var(--panel); color: var(--muted); margin-bottom: 18px; }
.total b { color: #ffd24a; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card { min-height: 142px; padding: 14px; display: flex; flex-direction: column; justify-content: space-between; text-align: left; border-radius: 20px; color: #fff; text-shadow: 0 1px 6px rgba(0, 0, 0, .35); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); }
.card .cname { font-size: 19px; font-weight: 800; line-height: 1.15; }
.card .cdesc { font-size: 12px; opacity: .92; margin-top: 4px; line-height: 1.25; }
.card .cfoot { display: flex; justify-content: space-between; font-size: 12px; margin-top: 10px; }
.soft { margin-top: 26px; background: none; color: var(--muted); font-size: 13px; }

/* Escenario de juego */
.stage { position: relative; height: 100%; display: flex; flex-direction: column; padding: 4px 14px calc(env(safe-area-inset-bottom) + 14px); }
.stage .hint { text-align: center; color: var(--muted); font-size: 14px; min-height: 22px; margin-bottom: 8px; }
.stage .hint b { color: var(--text); }
.play { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.row-btns { display: flex; justify-content: center; gap: 10px; padding-top: 10px; }
.row-btns button { padding: 10px 16px; font-size: 14px; }
.row-btns button[disabled] { opacity: .4; }

/* Tablero */
.board { display: grid; justify-content: center; touch-action: none; }
.tile { border-radius: 10px; position: relative; transition: transform .12s, box-shadow .12s; }
.tile.locked::after { content: ''; position: absolute; left: 50%; top: 50%; width: 9px; height: 9px; margin: -4.5px; border-radius: 50%; background: rgba(255, 255, 255, .85); box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .35); }
.tile.sel { transform: scale(.88); box-shadow: 0 0 0 3px #fff; z-index: 2; }
.tile.over { transform: scale(1.06); box-shadow: 0 0 0 3px rgba(255, 255, 255, .7); }
.tile.hinted { box-shadow: 0 0 0 2px rgba(255, 255, 255, .55); }
.tile.pop { animation: pop .28s; }
.tile.shake { animation: shake .3s; }
.board.won .tile { animation: win .6s; border-radius: 4px; }
@keyframes pop { 40% { transform: scale(.82); } 100% { transform: scale(1); } }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes win { 50% { transform: scale(1.08); } }

/* Elecciones (distinto, falta, memoria) */
.grid { display: grid; gap: 8px; justify-content: center; }
.swatch { border-radius: 12px; border: 0; padding: 0; transition: transform .1s, opacity .2s; }
.swatch:active { transform: scale(.94); }
.swatch.right { box-shadow: 0 0 0 4px #7dff9a; }
.swatch.wrong { box-shadow: 0 0 0 4px #ff5c6c; opacity: .8; }
.swatch.dim { opacity: .35; }
.lives { color: #ff5c6c; letter-spacing: 2px; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin: 0 auto 12px; width: min(300px, 80%); }
.bar i { display: block; height: 100%; width: 100%; background: #fff; transform-origin: left; }
.big-swatch { width: min(300px, 78vw); aspect-ratio: 1; border-radius: 26px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .1); }
.pair { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; }
.pair .big-swatch { width: min(150px, 38vw); border-radius: 20px; }
.pair figure { margin: 0; text-align: center; font-size: 12px; color: var(--muted); }
.pair figcaption { margin-top: 6px; }
.strip { display: flex; gap: 6px; justify-content: center; }
.strip .cell { border-radius: 10px; }
.strip .cell.q { background: var(--panel); display: grid; place-items: center; font-size: 22px; color: var(--muted); border: 2px dashed var(--line); }

/* Mezclador */
.mixer { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; }
.mixer .pair .big-swatch { width: min(140px, 36vw); }
.slider { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.slider input { -webkit-appearance: none; appearance: none; width: 100%; height: 30px; border-radius: 15px; outline: none; margin: 0; }
.slider input::-webkit-slider-thumb { -webkit-appearance: none; width: 34px; height: 34px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(0, 0, 0, .35); }
.slider input::-moz-range-thumb { width: 34px; height: 34px; border-radius: 50%; background: #fff; border: 0; }
.score { text-align: center; font-size: 28px; font-weight: 800; }

/* Resultado */
#modal { position: fixed; inset: 0; z-index: 20; background: rgba(8, 8, 10, .72); display: grid; place-items: center; padding: 20px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#modal .sheet { background: var(--panel); border-radius: 24px; padding: 22px; width: min(360px, 100%); text-align: center; }
#modal h2 { margin: 0 0 6px; font-size: 22px; }
.bigstars { font-size: 40px; color: #ffd24a; letter-spacing: 6px; }
.newrec { color: #7dff9a; font-weight: 700; margin-top: 2px; }
#modal .stats { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; text-align: left; margin: 14px 4px; font-size: 15px; }
#modal .stats span { color: var(--muted); }
#modal button { display: block; width: 100%; margin-top: 8px; }
#modal button.big { background: #f1f1f4; color: #17171b; font-weight: 700; }
