/* Repelentes v13 · tema oscuro, pensado primero para el móvil.
   Paleta Canary Options: azul #1688B4, amarillo #E3BB32, naranja #E17B46,
   verde #77A56B, coral #D15B63, violeta #8174B3, gris #8B929B. */
:root{
  --bg:#0f1a22;--bg-2:#132430;--card:#182b37;--card-2:#203645;--card-3:#28414f;
  --line:#2d4655;--line-2:#3b5768;--ink:#eef4f2;--soft:#c3d0d5;--muted:#8B929B;
  --blue:#1688B4;--blue-2:#2aa3d2;--yellow:#E3BB32;--orange:#E17B46;--green:#77A56B;--coral:#D15B63;--violet:#8174B3;
  --font:system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;
  --radius:14px;--tap:48px;
}
*{box-sizing:border-box}
html{background:var(--bg)}
body{margin:0;min-height:100dvh;background:radial-gradient(130% 520px at 50% -120px,#1d3a4c 0%,#0f1a2200 100%) no-repeat,var(--bg);color:var(--ink);font-family:var(--font);font-size:15px;line-height:1.4;-webkit-text-size-adjust:100%;padding-bottom:env(safe-area-inset-bottom)}
button,select{font:inherit;color:inherit}
button{cursor:pointer;border:0;background:none;-webkit-tap-highlight-color:transparent;touch-action:manipulation}
button:disabled{cursor:not-allowed}
:focus-visible{outline:3px solid var(--blue-2);outline-offset:3px}
a{color:inherit;text-decoration:none}

/* Cabecera */
.awning{height:8px;background:repeating-linear-gradient(90deg,var(--orange) 0 28px,#a9502a 28px 56px)}
.topbar{max-width:1100px;margin:0 auto;padding:12px 16px;display:flex;justify-content:space-between;align-items:center}
.wordmark{font:900 26px/0.9 "Arial Black",Arial,sans-serif;letter-spacing:-1.5px;color:var(--orange);transform:rotate(-2deg);display:block;text-shadow:0 2px 0 #00000055}
.brand-sub{display:block;font:800 7px/1 var(--font);letter-spacing:3px;color:var(--soft);margin-top:6px;text-align:center}
.header-tools{display:flex;gap:8px}
.icon-button{width:44px;height:44px;border-radius:50%;background:var(--card);border:1px solid var(--line);display:grid;place-items:center;font-size:19px;font-weight:800;color:var(--ink)}
.icon-button svg{width:21px;height:21px}
.icon-button[aria-pressed="true"]{border-color:var(--blue);color:var(--blue-2)}

/* Distribución: una columna en el móvil */
.layout{max-width:1100px;margin:0 auto;padding:4px 12px 12px;display:flex;flex-direction:column;gap:12px}
.customer-column{display:contents}
.play-column{display:contents}

/* Cliente */
.customer-card{order:1;display:grid;grid-template-columns:78px minmax(0,1fr);background:var(--card);border:1px solid var(--line);border-radius:var(--radius);overflow:hidden}
.customer-art{position:relative;overflow:hidden;background:#dfe6dc}
.customer-art>svg{position:absolute;left:-58px;bottom:0;width:190px;height:136px}
.customer-body{padding:10px 12px 11px;min-width:0}
.customer-info{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap}
h1{font-size:18px;line-height:1.1;margin:0;letter-spacing:-.3px}
.customer-info p{margin:0;font-size:12px;color:var(--muted)}
.speech{margin:5px 0 8px;font-size:14px;font-weight:600;color:var(--soft);line-height:1.35}
.patience-top{display:flex;justify-content:space-between;font-size:11px;color:var(--muted);margin-bottom:5px;text-transform:uppercase;letter-spacing:.8px;font-weight:700}
.patience-top strong{color:var(--ink)}
.patience-meter{display:flex;gap:3px}
.patience-meter span{flex:1;height:7px;border-radius:4px;background:var(--green);transition:background .3s}
.patience-meter span.urgent{background:var(--coral)}
.patience-meter span.empty{background:var(--card-3)}

/* Leyenda */
.legend{order:4;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:12px}
.legend>div{display:flex;flex-direction:column;gap:6px;align-items:flex-start}
.legend p{margin:0}
.legend strong{display:block;font-size:13px}
.legend span:not(.chip){display:block;font-size:12px;color:var(--muted);margin-top:2px;line-height:1.35}
.legend .legend-note{grid-column:1/-1;font-size:12px;color:var(--muted);border-top:1px solid var(--line);padding-top:9px}
.legend .legend-note b{color:var(--ink)}

/* Nivel */
.level-bar{order:2;display:flex;align-items:center;gap:10px}
.level-bar label{font-size:12px;font-weight:800;color:var(--muted);text-transform:uppercase;letter-spacing:1px}
.level-bar select{flex:1;min-width:0;height:var(--tap);background:var(--card) 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' fill='none' stroke='%23c3d0d5' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 14px center;border:1px solid var(--line-2);border-radius:12px;padding:0 36px 0 14px;font-size:15px;font-weight:700;appearance:none;-webkit-appearance:none;color:var(--ink)}
.level-bar select option{background:var(--card);color:var(--ink)}

/* Tablero */
.board{order:3;background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:14px 12px 12px;box-shadow:0 10px 30px #0006}
.board-head{display:flex;justify-content:space-between;align-items:center;gap:8px}
.board-head h2{font-size:17px;margin:0;letter-spacing:-.3px;white-space:nowrap}
.board-pills{display:flex;gap:5px;justify-content:flex-end}
.pill{font-size:11px;font-weight:800;letter-spacing:.4px;padding:5px 9px;border-radius:999px;white-space:nowrap;border:1px solid}
.pill[hidden]{display:none}
.pill.attempt{background:var(--card-2);border-color:var(--line-2);color:var(--soft)}
.pill.attempt.urgent{background:#D15B6326;border-color:var(--coral);color:#ff9aa1}
.pill.possible{background:#8174B326;border-color:var(--violet);color:#c4bbf2}
.pill.possible.one{background:var(--violet);color:#fff;animation:pop .3s ease-out}
.board-rules{font-size:13px;color:var(--muted);margin:6px 0 12px}
.section-title{font-size:11px;font-weight:800;letter-spacing:1px;color:var(--muted);margin:0 0 7px}

.result-banner{display:flex;justify-content:space-between;align-items:center;gap:10px;background:#77A56B26;border:1px solid var(--green);border-radius:12px;padding:10px 12px;margin-bottom:12px;font-size:14px;font-weight:700}
.result-banner.lost{background:#E17B4622;border-color:var(--orange)}
.result-banner[hidden]{display:none}
.result-banner button{font-size:14px;font-weight:800;color:var(--blue-2);text-decoration:underline;text-underline-offset:3px;min-height:40px;white-space:nowrap}

/* Pistas */
.chip{display:inline-flex;align-items:center;justify-content:center;gap:3px;border:1.5px solid;border-radius:9px;font-weight:900;font-variant-numeric:tabular-nums;min-width:34px;height:32px;padding:0 6px;font-size:16px}
.chip i{font-style:normal;font-size:14px}
.chip small{display:block;font-size:9px;font-weight:700;letter-spacing:.4px;text-transform:uppercase;opacity:.85}
.exact{background:#77A56B2e;border-color:var(--green);color:#b6e3a9}
.misplaced{background:#E3BB322b;border-color:var(--yellow);color:#ffd96b}
.absent{background:#D15B632b;border-color:var(--coral);color:#ffa3a9}

/* Compras anteriores */
.attempts{margin-bottom:12px}
.attempts[hidden]{display:none}
.attempt{display:grid;grid-template-columns:20px minmax(0,1fr) auto 36px;align-items:center;gap:6px;padding:6px 6px 6px 4px;border-radius:11px}
.attempt+.attempt{margin-top:3px}
.attempt-no{font-size:12px;font-weight:800;color:var(--muted);text-align:center}
.attempt-products{display:grid;grid-template-columns:repeat(var(--size,4),minmax(0,1fr));gap:4px;max-width:260px}
.mini{display:block;min-width:0}
.mini .product-art{width:100%;height:auto;max-height:44px;display:block}
.attempt .chips{display:flex;gap:3px}
.attempt .chip{min-width:32px;height:30px;font-size:15px;padding:0 4px}
.attempt .chip i{font-size:12px}
.attempt.latest{background:var(--card-2);border:1px solid var(--line-2);padding:8px 6px 8px 4px;margin-top:6px;grid-template-columns:20px minmax(0,1fr) 36px;row-gap:7px}
.attempt.latest .attempt-products{max-width:none}
.attempt.latest .mini .product-art{max-height:58px}
.attempt.latest .chips{grid-column:2;grid-row:2;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
.attempt.latest .reuse{grid-column:3;grid-row:1/3}
.attempt.latest .chip{height:40px;font-size:20px;gap:6px}
.attempt.latest .chip small{font-size:11px}
.reuse{width:36px;height:36px;border-radius:50%;font-size:19px;color:var(--soft);background:var(--card-3)}
.reuse:disabled{opacity:.3}

/* Compra actual */
.current-purchase{background:var(--bg-2);border:1px solid var(--line);border-radius:12px;padding:10px}
.slots{display:grid;grid-template-columns:repeat(var(--size,4),minmax(0,1fr));gap:6px}
.slot{position:relative;min-width:0;min-height:92px;border-radius:11px;border:2px dashed var(--line-2);background:var(--card);display:flex;flex-direction:column;align-items:center;justify-content:center;padding:16px 2px 6px;transition:transform .12s,border-color .12s,background .12s}
.slot.filled{border-style:solid;border-color:var(--line-2);background:var(--card-2)}
.slot.selected{border:2px solid var(--blue-2);background:#1688B424;box-shadow:0 0 0 3px #1688B433}
.slot:active:not(:disabled){transform:scale(.96)}
.slot-number{position:absolute;top:4px;left:7px;font-size:11px;font-weight:800;color:var(--muted)}
.slot.selected .slot-number{color:var(--blue-2)}
.slot-plus{font-size:30px;line-height:1;color:var(--line-2);font-weight:300}
.slot.selected .slot-plus{color:var(--blue-2)}
.slot .product-art{width:44px;height:50px}
.product-name{display:block;font-size:11px;font-weight:700;margin-top:3px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--soft)}
.slot.hinted{border:2px solid var(--yellow)!important;background:#E3BB3224!important}
.slot.hinted::before{content:'💡';position:absolute;top:2px;right:5px;font-size:12px}
.slots[data-size="5"] .slot .product-art{width:38px;height:44px}
.slots[data-size="6"] .slot .product-art{width:32px;height:38px}
.slots[data-size="6"] .product-name{font-size:9px}

/* Estantería */
.shelf-section{margin-top:12px}
.shelf-head{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-bottom:8px}
.tabs{display:flex;background:var(--bg-2);border:1px solid var(--line);border-radius:12px;padding:3px;gap:3px}
.tab{min-height:38px;padding:0 12px;border-radius:9px;font-size:14px;font-weight:800;color:var(--muted)}
.tab[aria-pressed="true"]{background:var(--card-3);color:var(--ink);box-shadow:0 1px 0 #ffffff14 inset}
#tab-note[aria-pressed="true"]{background:var(--violet);color:#fff}
.shelf-hint{font-size:12px;color:var(--muted);text-align:right}
.shelf{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:7px}
.shelf[data-n="6"]{grid-template-columns:repeat(3,minmax(0,1fr))}
.shelf-product{position:relative;min-width:0;min-height:84px;border-radius:12px;background:var(--card-2);border:1.5px solid var(--line-2);display:flex;flex-direction:column;align-items:center;justify-content:center;padding:7px 2px 6px;transition:transform .1s,background .12s,border-color .12s}
.shelf-product:active:not(:disabled){transform:scale(.94);background:var(--card-3)}
.shelf-product .product-art{width:44px;height:50px}
.shelf-product:disabled{opacity:.45}
.shelf.noting .shelf-product{border-style:dashed;border-color:var(--violet)}
.note-badge{position:absolute;top:-6px;right:-6px;width:22px;height:22px;border-radius:50%;display:none;place-items:center;font-size:13px;font-weight:900;color:#fff;border:2px solid var(--card)}
.note-1 .note-badge{display:grid;background:var(--green)}
.note-2 .note-badge{display:grid;background:var(--coral)}
.shelf-product.note-1{border-color:var(--green);background:#77A56B1f}
.shelf-product.note-2{border-color:#D15B6399;background:#D15B6314}
.shelf.noting .shelf-product.note-1{border-style:solid;border-color:var(--green)}
.shelf.noting .shelf-product.note-2{border-style:solid;border-color:var(--coral)}
.note-2 .product-art{opacity:.35;filter:grayscale(.85)}
.slot.note-1{border-color:var(--green)}
.slot.note-2{border-color:#D15B6399}
.slot.note-1.selected,.slot.note-2.selected{border-color:var(--blue-2)}
.mini.note-2 .product-art{opacity:.3}

/* Acciones */
.purchase-controls{display:grid;grid-template-columns:auto auto minmax(0,1fr);gap:7px;margin-top:12px}
.ghost-button{min-height:var(--tap);padding:0 12px;border-radius:12px;border:1px solid var(--line-2);font-size:14px;font-weight:700;color:var(--soft);background:transparent}
.ghost-button:disabled{opacity:.35}
.ghost-button[hidden]{display:none}
.hint-button{min-height:var(--tap);padding:0 12px;border-radius:12px;border:1.5px solid var(--yellow);background:#E3BB321f;color:#ffd96b;font-size:14px;font-weight:800;white-space:nowrap}
.hint-button:disabled{opacity:.35}
.primary-button{min-height:var(--tap);padding:0 16px;border-radius:12px;background:var(--blue);color:#fff;font-size:16px;font-weight:800;box-shadow:0 3px 0 #0c5a79;display:flex;align-items:center;justify-content:center;text-align:center;line-height:1.15;transition:transform .1s,background .12s}
.primary-button:active:not(:disabled){transform:translateY(2px);box-shadow:0 1px 0 #0c5a79}
.primary-button:disabled{background:var(--card-3);color:var(--muted);box-shadow:none}
.secondary-button{min-height:var(--tap);padding:0 16px;border-radius:12px;background:var(--card-3);color:var(--ink);font-size:14px;font-weight:700;border:1px solid var(--line-2)}
.selection-status{font-size:12px;color:var(--muted);text-align:center;margin:9px 0 0;min-height:16px}

/* Marcador */
.bottom-bar{order:5;display:flex;justify-content:space-between;align-items:center;gap:10px;padding:2px 2px 0}
.score-summary{display:flex;gap:14px;font-size:14px;color:var(--soft)}
.score-summary b{color:var(--ink);font-size:16px;margin-left:2px}
.bottom-bar .ghost-button{font-size:13px}
footer{max-width:1100px;margin:8px auto 0;padding:16px;color:var(--muted);font-size:12px;text-align:center}
footer b{color:var(--soft)}

/* Aviso flotante */
.toast{position:fixed;z-index:60;left:50%;bottom:calc(16px + env(safe-area-inset-bottom));transform:translate(-50%,16px);width:max-content;max-width:calc(100vw - 24px);background:#0b141b;color:var(--ink);border:1px solid var(--line-2);box-shadow:0 10px 40px #000a;border-radius:12px;padding:12px 16px;font-size:14px;font-weight:700;text-align:center;opacity:0;pointer-events:none;transition:.2s}
.toast.visible{opacity:1;transform:translate(-50%,0)}

/* Ventanas */
dialog{background:var(--card);color:var(--ink);border:1px solid var(--line-2);border-radius:18px;box-shadow:0 30px 80px #000c;padding:20px;width:calc(100% - 24px);max-width:520px;max-height:90dvh;overflow:auto}
dialog::backdrop{background:#050b10b3;backdrop-filter:blur(3px)}
.modal-header{display:flex;justify-content:space-between;align-items:center;gap:10px}
.eyebrow{font-size:11px;font-weight:800;letter-spacing:1.2px;color:var(--orange)}
.modal-header .close-dialog{font-size:28px;line-height:1;color:var(--soft);min-width:40px;min-height:40px}
dialog h2{font-size:25px;line-height:1.15;margin:12px 0 8px;letter-spacing:-.5px}
dialog p{font-size:15px;color:var(--soft);line-height:1.55}
dialog p b{color:var(--ink)}
dialog>.primary-button{width:100%;margin-top:10px}
.help-steps{padding-left:20px;color:var(--soft);font-size:15px;line-height:1.55}
.help-steps li{margin:6px 0}
.help-steps strong{color:var(--ink)}
.help-example{background:var(--bg-2);border:1px solid var(--line);border-radius:12px;padding:12px;margin:12px 0}
.help-example>strong{font-size:13px}
.example-pills{display:flex;gap:6px;margin-top:8px}
.help-example p{font-size:14px;margin:8px 0 0}
.keyboard-hint{display:none}
.dialog-actions{display:flex;gap:8px;justify-content:flex-end;margin-top:16px;flex-wrap:wrap}
.dialog-actions button{flex:1 1 140px}
.result-stars{font-size:34px;letter-spacing:4px;color:var(--yellow);margin-top:8px;text-shadow:0 2px 12px #E3BB3255}
.result-stars:empty{display:none}
.result-record{font-weight:800;color:#c4bbf2!important;margin:0}
.result-record:empty{display:none}
#result-dialog .section-title{margin-top:14px}
.solution{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:6px}
.solution>div{display:flex;flex-direction:column;align-items:center;background:var(--bg-2);border:1px solid var(--line);border-radius:10px;padding:8px 2px}
.solution .product-art{width:40px;height:46px}
.solution span{font-size:11px;font-weight:700;color:var(--soft);margin-top:4px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.daily-box{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;background:#8174B326;border:1px solid var(--violet);border-radius:12px;padding:10px 12px;margin-top:14px}
.daily-box[hidden]{display:none}
.share-button{min-height:var(--tap);padding:0 16px;border-radius:12px;background:var(--violet);color:#fff;font-size:15px;font-weight:800;box-shadow:0 3px 0 #574c8a}
#countdown{font-size:13px;font-weight:800;color:#c4bbf2;font-variant-numeric:tabular-nums}

/* Demostración guiada */
#guided-tour[hidden]{display:none}
.tour-shade{position:fixed;inset:0;background:#03080cb8;z-index:100}
.tour-target{position:relative!important;z-index:101!important;outline:3px solid var(--blue-2);outline-offset:4px;border-radius:var(--radius)}
.tour-panel{position:fixed;left:50%;bottom:calc(10px + env(safe-area-inset-bottom));transform:translateX(-50%);z-index:103;width:min(560px,calc(100% - 20px));max-height:50dvh;overflow:auto;background:var(--card);border:1.5px solid var(--blue);border-radius:16px;box-shadow:0 20px 60px #000c;padding:14px 16px;color:var(--ink)}
.tour-panel:focus{outline:none}
.tour-top,.tour-actions{display:flex;justify-content:space-between;align-items:center;gap:10px}
.tour-top span{font-size:11px;font-weight:800;letter-spacing:1px;color:var(--muted)}
.tour-top button{font-size:13px;font-weight:700;color:#ff9aa1;min-height:40px;padding:0 4px}
.tour-panel h2{font-size:20px;margin:6px 0}
.tour-panel p{font-size:15px;line-height:1.5;color:var(--soft);margin:6px 0 12px}
.tour-actions button{flex:1}
.tour-actions button:disabled{opacity:.35}

/* Confeti y animaciones */
.confetti{position:fixed;inset:0;pointer-events:none;z-index:70;overflow:hidden}
.confetti i{position:absolute;top:-30px;width:8px;height:14px;border-radius:2px;animation:fall 2.5s ease-in forwards}
@keyframes fall{to{transform:translate(var(--dx),110vh) rotate(650deg)}}
@keyframes pop{from{transform:scale(.85);opacity:.4}to{transform:scale(1);opacity:1}}
@keyframes arrive{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}
.attempt.latest{animation:arrive .3s ease-out}

/* 5 y 6 huecos en el móvil: los productos ocupan la fila y las pistas van debajo */
@media(max-width:819px){
  .attempts[data-size="5"] .attempt,.attempts[data-size="6"] .attempt{grid-template-columns:20px minmax(0,1fr) 36px;row-gap:5px}
  .attempts[data-size="5"] .attempt-products,.attempts[data-size="6"] .attempt-products{max-width:none}
  .attempts[data-size="5"] .attempt .chips,.attempts[data-size="6"] .attempt .chips{grid-column:2;grid-row:2}
  .attempts[data-size="5"] .attempt .reuse,.attempts[data-size="6"] .attempt .reuse{grid-column:3;grid-row:1/3}
  .attempts[data-size="5"] .attempt:not(.latest) .chip,.attempts[data-size="6"] .attempt:not(.latest) .chip{height:26px;font-size:14px}
}
/* Pantallas muy estrechas */
@media(max-width:360px){
  .layout{padding-left:8px;padding-right:8px}
  .board-head{flex-wrap:wrap}
  .board-pills{flex-wrap:wrap;justify-content:flex-start}
  .pill{font-size:10px;padding:4px 7px}
  .board{padding:12px 8px 10px}
  .attempt{grid-template-columns:16px minmax(0,1fr) auto 32px;gap:4px}
  .attempt .chip{min-width:28px;font-size:13px}
  .attempt.latest .chip{font-size:17px;gap:3px}
  .attempt.latest .chip small{font-size:9px}
  .reuse{width:32px;height:32px}
  .tab{padding:0 9px;font-size:13px}
  .shelf-hint{display:none}
  .purchase-controls{grid-template-columns:auto auto minmax(0,1fr);gap:5px}
  .ghost-button,.hint-button{padding:0 9px;font-size:13px}
  .primary-button{font-size:14px;padding:0 10px}
}

/* Tableta y ordenador: cliente a la izquierda, tablero a la derecha */
@media(min-width:820px){
  .awning{height:10px}
  .topbar{padding:18px 24px}
  .wordmark{font-size:34px}
  .brand-sub{font-size:8px}
  .layout{display:grid;grid-template-columns:280px minmax(0,640px);justify-content:center;gap:24px;padding:8px 24px 24px;align-items:start}
  .play-column{display:flex;flex-direction:column;gap:14px;min-width:0}
  .customer-column{display:flex;flex-direction:column;gap:14px}
  .customer-card{display:block}
  .customer-art{height:190px}
  .customer-art>svg{position:static;width:100%;height:100%}
  .customer-body{padding:14px 16px 16px}
  h1{font-size:22px}
  .speech{font-size:16px;margin:8px 0 12px}
  .legend{grid-template-columns:1fr;gap:10px}
  .legend>div{flex-direction:row;align-items:center;gap:10px}
  .board{padding:18px 18px 14px}
  .slot{min-height:112px}
  .slot .product-art,.shelf-product .product-art{width:52px;height:60px}
  .shelf-product{min-height:96px}
  .shelf-product:hover:not(:disabled){border-color:var(--blue-2)}
  .slot:hover:not(:disabled){border-color:var(--blue-2)}
  .keyboard-hint{display:block;font-size:13px!important;color:var(--muted)!important}
  .mini .product-art{max-height:52px}
}

@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important}.confetti{display:none}}
