@font-face { font-family: 'Fredoka'; font-weight: 500; font-display: block; src: url('../fonts/fredoka-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Fredoka'; font-weight: 700; font-display: block; src: url('../fonts/fredoka-latin-700-normal.woff2') format('woff2'); }

:root {
  --ink: #3b2414;
  --cream: #fff6e3;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1d1430; font-family: 'Fredoka', 'Arial Rounded MT Bold', system-ui, sans-serif; color: var(--ink); overscroll-behavior: none; touch-action: none; }
#stage { position: fixed; top: 0; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; overflow: hidden; background: #7fd4f5; }
canvas#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: calc(var(--safe-top) + 12px) 16px calc(var(--safe-bottom) + 18px); pointer-events: none; transition: opacity .18s ease; }
.screen.hidden { opacity: 0; visibility: hidden; }
.screen.hidden * { pointer-events: none !important; }
.hidden { display: none; }
.screen.hidden { display: flex; }

/* ---------- Menú ---------- */
.menu-top { display: flex; flex-direction: column; align-items: center; gap: 18px; margin-top: 9vh; }
.logo { text-align: center; transform: rotate(-4deg); line-height: .92; animation: bob 2.4s ease-in-out infinite; }
.logo span { display: block; font-weight: 700; color: #fff; paint-order: stroke fill; -webkit-text-stroke: 10px var(--ink); text-shadow: 0 6px 0 var(--ink); }
.logo-small { font-size: clamp(34px, 11vw, 52px); color: #ffd84a !important; margin-right: 38%; }
.logo-big { font-size: clamp(46px, 15.5vw, 74px); letter-spacing: -1px; }
@keyframes bob { 0%,100% { transform: rotate(-4deg) translateY(0); } 50% { transform: rotate(-3deg) translateY(-8px); } }

.menu-bottom { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 3vh; }
.best-pill { background: rgba(255,246,227,.92); border: 3px solid var(--ink); border-radius: 999px; padding: 4px 16px; font-size: 17px; font-weight: 500; box-shadow: 0 3px 0 var(--ink); }
.best-pill b { font-weight: 700; }
.tap-hint { font-size: clamp(22px, 7vw, 30px); font-weight: 700; color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.hands { display: flex; gap: 46vw; font-size: 38px; }
.hand-ico { display: block; line-height: 0; }
.hand-ico.flip { transform: scaleX(-1); }
.hand { display: flex; flex-direction: column; align-items: center; filter: drop-shadow(0 3px 0 rgba(0,0,0,.35)); }
.hand small { font-size: 14px; font-weight: 700; color: #fff; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; }
.hand:first-child { animation: nudgeL 1s ease-in-out infinite; }
.hand:last-child { animation: nudgeR 1s ease-in-out infinite .5s; }
@keyframes nudgeL { 0%,100% { transform: translateX(0);} 50% { transform: translateX(-7px);} }
@keyframes nudgeR { 0%,100% { transform: translateX(0);} 50% { transform: translateX(7px);} }

#menu.compact .logo { visibility: hidden; }
#menu.compact .menu-top { margin-top: 2vh; }

/* ---------- Botones de esquina ---------- */
.corner { position: absolute; left: 12px; top: calc(var(--safe-top) + 10px); display: flex; gap: 8px; z-index: 5; }
.corner.hidden { display: none; }
.round { width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--ink); background: var(--cream); font-size: 21px; line-height: 1; box-shadow: 0 3px 0 var(--ink); cursor: pointer; pointer-events: auto; padding: 0; font-family: inherit; color: var(--ink); }
.round:active { transform: translateY(3px); box-shadow: none; }
.round.small { width: 38px; height: 38px; font-size: 17px; font-weight: 700; }
.taco-pill { pointer-events: none; position: absolute; right: 12px; top: calc(var(--safe-top) + 14px); background: var(--cream); border: 3px solid var(--ink); border-radius: 999px; padding: 4px 13px 4px 9px; font-size: 18px; box-shadow: 0 3px 0 var(--ink); z-index: 5; }
.taco-pill b { font-weight: 700; }
.taco-pill.bump { animation: bump .25s ease; }
@keyframes bump { 50% { transform: scale(1.22); } }

/* ---------- Paneles ---------- */
#over, #shop, #board { justify-content: center; background: rgba(29,20,48,.45); }
#over { justify-content: flex-start; padding-top: calc(var(--safe-top) + 17vh); }   /* anclado arriba: "Otra vez" siempre queda en el mismo lugar */
.badges { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 12px; min-height: 30px; }
#shop, #board { padding-top: calc(var(--safe-top) + 60px); }   /* deja libre la fila del contador de tacos */
#shop:not(.hidden), #over:not(.hidden), #board:not(.hidden) { pointer-events: auto; }   /* el fondo oscuro ya no deja pasar toques al juego */
.panel { pointer-events: auto; width: min(100%, 360px); background: var(--cream); border: 4px solid var(--ink); border-radius: 26px; box-shadow: 0 8px 0 var(--ink); padding: 18px 16px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; animation: pop .28s cubic-bezier(.2,1.5,.4,1); }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.phrase { font-size: 30px; font-weight: 700; color: #e5393f; text-align: center; transform: rotate(-3deg); }
.record { background: #ffd84a; border: 3px solid var(--ink); border-radius: 999px; padding: 2px 14px; font-weight: 700; font-size: 15px; animation: pulse .7s ease-in-out infinite; }
.record.hidden { display: none; }
.score-row { display: flex; gap: 10px; width: 100%; }
.score-box { flex: 1; background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 6px 4px 8px; text-align: center; }
.score-box small { display: block; font-size: 13px; font-weight: 500; opacity: .7; }
.score-box b { font-size: 38px; font-weight: 700; line-height: 1; }
.score-box i { font-style: normal; font-weight: 700; font-size: 16px; margin-left: 2px; }
.earned { font-size: 19px; font-weight: 700; }
.medal { font-size: 15px; font-weight: 700; min-height: 0; }
.medal:empty { display: none; }
.medal::before { content: ''; display: inline-block; width: 15px; height: 15px; border-radius: 50%; border: 2.5px solid var(--ink); margin-right: 6px; vertical-align: -3px; background: #cd7f32; }
.medal.medalSilver::before { background: #cfd6de; } .medal.medalGold::before { background: #ffd84a; } .medal.medalDiamond::before { background: #7fe3ff; border-radius: 3px; transform: rotate(45deg); } .medal.medalCosmic::before { background: linear-gradient(135deg, #ff6bd6, #7fe3ff); border-radius: 3px; transform: rotate(45deg); }

.btn { pointer-events: auto; width: 100%; border: 3px solid var(--ink); border-radius: 16px; padding: 12px 10px; font-family: inherit; font-size: 20px; font-weight: 700; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.28); box-shadow: 0 5px 0 var(--ink); cursor: pointer; }
.btn:active { transform: translateY(5px); box-shadow: none; }
.btn em { font-style: normal; background: rgba(0,0,0,.2); border-radius: 999px; padding: 1px 9px; margin-left: 4px; font-size: 16px; }
.btn-green { background: #39b54a; font-size: 24px; padding: 14px 10px; }
.btn-gold { background: #f7a81b; }
.btn-blue { background: #2d9cdb; font-size: 17px; }
.btn-pink { background: #e9559b; font-size: 17px; }
.btn-small { width: auto; font-size: 17px; padding: 8px 14px; border-radius: 13px; box-shadow: 0 4px 0 var(--ink); }
.btn-row { display: flex; gap: 10px; width: 100%; }
.btn.hidden { display: none; }
.round.hidden { display: none; }
.btn.dim { filter: grayscale(.7); opacity: .7; }
.btn[disabled] { filter: grayscale(.8); opacity: .6; }

/* ---------- Tienda ---------- */
.panel-tall { max-height: calc(100% - 20px); overflow: hidden; }
.panel-head { display: flex; width: 100%; align-items: center; justify-content: space-between; }
.panel-head h2 { margin: 0; font-size: 26px; }
.vip { width: 100%; display: flex; align-items: center; gap: 8px; background: linear-gradient(135deg, #ffe27a, #ffb938); border: 3px solid var(--ink); border-radius: 16px; padding: 9px 10px; }
.vip.hidden { display: none; }
.vip.owned { background: linear-gradient(135deg, #c8f5cf, #8fe09b); }
.vip-text { flex: 1; line-height: 1.15; }
.vip-text b { font-size: 18px; display: block; }
.vip-text small { font-size: 12.5px; font-weight: 500; }
.vip-ask { width: 100%; background: #fff4cf; border: 3px solid var(--ink); border-radius: 16px; padding: 9px 10px; text-align: center; }
.vip-ask.hidden { display: none; }
.vip-ask p { margin: 0 0 9px; font-size: 14px; font-weight: 600; line-height: 1.2; }
.vip-ask-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.grid { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; overflow-y: auto; touch-action: pan-y; padding: 2px 2px 6px; }
.skin { background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 4px 2px 7px; text-align: center; cursor: pointer; position: relative; pointer-events: auto; }
.skin canvas { width: 100%; aspect-ratio: 1; display: block; }
.skin b { display: block; font-size: 13.5px; line-height: 1.1; }
.skin small { display: block; font-size: 13px; font-weight: 700; color: #a2611a; margin-top: 2px; }
.skin.locked canvas { opacity: .82; }
.skin .lock { position: absolute; top: 5px; right: 6px; font-style: normal; font-size: 15px; }
.skin.selected { background: #d9f7de; border-color: #1f8f33; box-shadow: 0 0 0 3px #39b54a inset; }
.grid .sec { grid-column: 1 / -1; font-size: 17px; font-weight: 700; text-align: left; margin: 6px 2px -2px; line-height: 1.15; }
.grid .sec:first-child { margin-top: 0; }
.grid .sec small { display: block; font-size: 12.5px; font-weight: 500; opacity: .75; }
.skin .badge { position: absolute; top: 5px; left: 6px; font-style: normal; font-size: 10.5px; font-weight: 700; color: #fff; background: #e9559b; border: 2px solid var(--ink); border-radius: 8px; padding: 0 5px; line-height: 1.35; }
.skin .badge.count { background: #39b54a; font-size: 12px; }
.skin.selected small { color: #1f8f33; }
.links { display: flex; gap: 14px; justify-content: center; }
.link.hidden { display: none; }
.link { pointer-events: auto; background: none; border: none; font-family: inherit; font-size: 14px; font-weight: 500; text-decoration: underline; color: var(--ink); opacity: .7; padding: 4px; cursor: pointer; }

.toast { overflow-wrap: anywhere; pointer-events: none; position: absolute; left: 50%; bottom: calc(var(--safe-bottom) + 90px); transform: translateX(-50%); background: var(--ink); color: #fff; font-weight: 500; font-size: 16px; line-height: 1.2; text-align: center; padding: 9px 18px; border-radius: 18px; z-index: 20; white-space: normal; width: max-content; max-width: 92%; }
.toast.hidden { display: none; }

/* solo para capturas de tienda (?shot=N) */
.shot-caption { position: absolute; left: 50%; bottom: 5%; transform: translateX(-50%) rotate(-2deg); width: 88%; text-align: center; background: #ffd84a; border: 4px solid var(--ink); border-radius: 22px; box-shadow: 0 7px 0 var(--ink); padding: 12px 10px; font-size: clamp(22px, 7vw, 32px); font-weight: 700; line-height: 1.1; z-index: 30; }

/* íconos propios */
.ico { height: 1.15em; width: auto; vertical-align: -0.22em; }
.taco-pill .ico { height: 1.3em; }
.ico-face { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
#btnShop { overflow: hidden; padding: 0; }
#btnSound, #btnFull, #btnBoard { display: flex; align-items: center; justify-content: center; }
#btnFull.hidden, #btnBoard.hidden { display: none; }
#btnBoard.nudge { animation: pulse .9s ease-in-out infinite; background: #ffd84a; }
/* tabla de récords */
#board input { user-select: text; -webkit-user-select: text; touch-action: manipulation; }
.lb-form { width: 100%; background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 10px; display: flex; flex-direction: column; gap: 6px; text-align: center; }
.lb-form.hidden { display: none; }
.lb-form b { font-size: 16px; line-height: 1.15; } .lb-form small { font-size: 12px; font-weight: 500; opacity: .75; line-height: 1.2; }
.lb-form .lb-err { color: #c62828; opacity: 1; font-weight: 700; } .lb-form .lb-err:empty { display: none; }
.lb-form-row { display: flex; gap: 8px; align-items: center; }
.lb-form-row input { flex: 1; min-width: 0; font-family: inherit; font-size: 17px; font-weight: 700; color: var(--ink); background: var(--cream); border: 3px solid var(--ink); border-radius: 12px; padding: 8px 10px; outline: none; }
.chips, .seg { flex-shrink: 0; }   /* con 20 renglones en la lista, estos no deben aplastarse */
.chips { width: 100%; display: flex; gap: 6px; overflow-x: auto; touch-action: pan-x; padding: 2px 1px 4px; scrollbar-width: none; } .chips::-webkit-scrollbar { display: none; }
.chip { pointer-events: auto; flex: none; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: inherit; font-size: 14px; font-weight: 700; color: var(--ink); background: #fff; border: 2.5px solid var(--ink); border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.chip.on { background: #ffd84a; } .chip.add { border-style: dashed; background: transparent; }
.seg { display: flex; width: 100%; border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; }
.seg button { pointer-events: auto; flex: 1; font-family: inherit; font-size: 14px; font-weight: 700; color: var(--ink); background: #fff; border: none; padding: 6px 4px; cursor: pointer; } .seg button.on { background: var(--ink); color: #fff; }
.lb-list { width: 100%; min-height: 72px; flex: 1 1 auto; overflow-y: auto; touch-action: pan-y; display: flex; flex-direction: column; gap: 4px; padding: 1px; }
.lb-row { display: flex; align-items: center; gap: 8px; background: #fff; border: 2.5px solid var(--ink); border-radius: 12px; padding: 5px 10px; font-size: 15px; }
.lb-row.me { background: #d9f7de; border-color: #1f8f33; }
.lb-row .pos { width: 26px; text-align: center; font-weight: 700; flex: none; } .lb-row .nick { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; } .lb-row b { flex: none; }
.lb-note { text-align: center; font-size: 14px; font-weight: 500; opacity: .75; padding: 18px 8px; } .lb-note.retry { pointer-events: auto; cursor: pointer; text-decoration: underline; }
.lb-me { font-size: 14px; font-weight: 700; text-align: center; } .lb-me:empty { display: none; }
#board .links { flex-wrap: wrap; gap: 2px 12px; }
#boardForm:not(.hidden) ~ .lb-me, #boardForm:not(.hidden) ~ .links { display: none; }   /* con el formulario abierto sobra espacio para lo importante */
@media (max-width: 340px) { .corner { left: 8px; gap: 4px; } .corner .round { width: 42px; height: 42px; } }
.btn.nudge { animation: pulse .9s ease-in-out infinite; }
.btn.nudge:active { animation: none; }
@media (max-height: 600px) { #over { padding-top: calc(var(--safe-top) + 64px); } #over .panel { gap: 8px; padding-bottom: 12px; } }   /* pantallas bajitas: que el link del panel siempre salga en la captura */
.over-url { font-size: 13px; font-weight: 700; opacity: .72; letter-spacing: .2px; margin-top: -2px; }
.over-url:empty { display: none; }

@media (prefers-reduced-motion: reduce) { .logo, .tap-hint, .hand, .record, .btn.nudge, #btnBoard.nudge { animation: none !important; } }
