:root {
  --navy: #1d3a7a;
  --navy-2: #2c5ea8;
  --sky: #4aa3ff;
  --gold: #f2c14e;
  --cream: #fff8ec;
  --ink: #1f2440;
  --muted: #5b6386;
  --pink: #ff7fbf;
  --green: #4cc38a;
  --card: rgba(255, 252, 245, 0.94);
  --glass: rgba(20, 32, 70, 0.42);
  --glass-2: rgba(20, 32, 70, 0.62);
  --radius: 18px;
  --shadow: 0 10px 30px rgba(20, 30, 80, 0.25);
  --font-title: "Baloo 2", system-ui, sans-serif;
  --font: "Nunito", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #9fd3ff; color: var(--ink); font-family: var(--font); }
body { -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
#app { position: fixed; inset: 0; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
kbd { font-family: var(--font-title); }

/* ---------- screens ---------- */
.screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
#loading { background: #f6c9a8 url("../../assets/generated/pantalla-carga.webp") center / cover no-repeat; }
#loading::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255,255,255,0) 40%, rgba(255,240,225,0.65)); }
.loading-card { position: relative; text-align: center; width: min(420px, 100%); margin-top: auto; margin-bottom: 6vh; }
.logo { width: 150px; height: auto; filter: drop-shadow(0 6px 14px rgba(30, 50, 120, .35)); }
.logo.big { width: min(240px, 46vw); }
.bar { height: 14px; border-radius: 99px; background: rgba(255,255,255,.7); overflow: hidden; box-shadow: inset 0 2px 4px rgba(0,0,0,.12); }
.bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--sky), var(--pink)); border-radius: 99px; transition: width .25s; }
#load-text { font-weight: 800; color: var(--navy); margin: 10px 0 0; text-shadow: 0 1px 0 #fff; }

#title { background: linear-gradient(90deg, rgba(40, 70, 160, .10), rgba(40, 70, 160, 0) 40%, rgba(255, 210, 180, .25)); overflow-y: auto; align-items: stretch; }
.title-wrap { display: flex; gap: 32px; align-items: stretch; justify-content: space-between; width: min(1180px, 100%); margin: 0 auto; flex-wrap: wrap; padding: 8px 0; }
.title-left { text-align: left; flex: 1 1 300px; color: #fff; align-self: flex-start; }
.title-left .logo.big { width: min(170px, 34vw); }
.title-left h1 { font-family: var(--font-title); font-size: clamp(40px, 5.5vw, 64px); line-height: .95; margin: 2px 0 6px; color: #fff; text-shadow: 0 4px 0 var(--navy), 0 10px 24px rgba(20, 40, 100, .45); letter-spacing: .5px; }
.tagline { font-weight: 800; font-size: 18px; margin: 0; max-width: 340px; text-shadow: 0 2px 6px rgba(20, 40, 100, .6); }
#avatar-form { align-self: center; }
@media (max-width: 760px) {
  .title-wrap { justify-content: center; gap: 12px; }
  .title-left { text-align: center; flex-basis: 100%; }
  .title-left .tagline { margin: 0 auto; }
  .title-left + form { margin-top: 34vh; }
}
.card { background: var(--card); border-radius: 24px; padding: 20px 22px; box-shadow: var(--shadow); border: 3px solid #fff; }
#avatar-form { flex: 1 1 340px; max-width: 420px; display: flex; flex-direction: column; gap: 10px; }
#avatar-form h2 { font-family: var(--font-title); margin: 0; color: var(--navy); font-size: 28px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 800; color: var(--muted); font-size: 14px; }
.field input { font: inherit; font-size: 18px; color: var(--ink); padding: 10px 14px; border-radius: 12px; border: 2px solid #dfe5f5; background: #fff; outline: none; }
.field input:focus { border-color: var(--sky); }
.swatches, .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px #dfe5f5; padding: 0; }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--navy); transform: scale(1.08); }
.chips button { border: 2px solid #dfe5f5; background: #fff; border-radius: 99px; padding: 6px 12px; font-weight: 800; color: var(--ink); font-size: 14px; }
.chips button[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.hint { font-size: 12.5px; color: var(--muted); text-align: center; margin: 0; }

.btn { border: 0; border-radius: 14px; padding: 10px 18px; font-weight: 800; font-size: 16px; background: #e8edf9; color: var(--navy); box-shadow: 0 4px 0 rgba(29, 58, 122, .25); transition: transform .08s, box-shadow .08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(29, 58, 122, .25); }
.btn.primary { background: linear-gradient(180deg, #5bb4ff, #2f7fe0); color: #fff; box-shadow: 0 5px 0 #1d5bb0; }
.btn.gold { background: linear-gradient(180deg, #ffd56b, #f0a92e); color: #4a2a00; box-shadow: 0 5px 0 #c27c12; }
.btn.big { font-size: 20px; padding: 14px 22px; font-family: var(--font-title); }
.btn.mini { font-size: 14px; padding: 6px 12px; margin-left: 8px; vertical-align: middle; font-family: var(--font); }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; font-weight: 800; }
#hud > * { pointer-events: auto; }
.hud-tl { position: absolute; left: max(12px, env(safe-area-inset-left)); top: max(12px, env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.player-card { display: flex; align-items: center; gap: 8px; background: var(--glass-2); color: #fff; padding: 8px 12px; border-radius: 14px; backdrop-filter: blur(6px); }
.player-card .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; }
.pill { background: rgba(255, 213, 107, .95); color: #5a3a00; padding: 2px 9px; border-radius: 99px; font-size: 14px; }
.pill.gem { background: rgba(126, 249, 255, .92); color: #0d4a5a; }
.quests { pointer-events: auto; width: 238px; background: var(--glass); color: #fff; border-radius: 14px; padding: 6px 12px 9px; backdrop-filter: blur(6px); font-size: 13.5px; }
.quests-head { all: unset; cursor: pointer; display: flex; width: 100%; justify-content: space-between; align-items: baseline; font-family: var(--font-title); font-size: 16px; letter-spacing: .3px; padding: 2px 0 4px; }
.quests-head small { font-family: var(--font); font-size: 12.5px; color: var(--gold); }
.quests-head:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.quests ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.quests li { display: flex; gap: 8px; align-items: flex-start; line-height: 1.25; }
.quests li::before { content: ""; flex: none; width: 12px; height: 12px; margin-top: 2px; border-radius: 4px; border: 2px solid rgba(255, 255, 255, .85); }
.quests li .count { margin-left: auto; color: var(--gold); font-variant-numeric: tabular-nums; }
.quests li.done::before { background: var(--green); border-color: var(--green); }
.quests.collapsed { padding-bottom: 6px; }
.quests.collapsed ul { display: none; }
.online { color: #fff; background: var(--glass); border-radius: 10px; padding: 4px 10px; font-size: 13px; width: fit-content; backdrop-filter: blur(6px); }
.hud-tr { position: absolute; right: max(12px, env(safe-area-inset-right)); top: max(12px, env(safe-area-inset-top)); display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#minimap { width: 150px; height: 150px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .9); box-shadow: var(--shadow); background: #8fd0ff; }
.hud-buttons { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 220px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--glass-2); color: #fff; font-size: 18px; font-weight: 800; backdrop-filter: blur(6px); display: grid; place-items: center; }
.icon-btn:hover { background: rgba(29, 58, 122, .85); }
.icon-btn.off { opacity: .55; }
#minimap { cursor: pointer; }
.icon-btn.on { background: var(--gold); color: var(--navy); }
body.is-touch #btn-run { display: none; }
.emote-menu { display: flex; flex-direction: column; gap: 4px; background: var(--glass-2); padding: 6px; border-radius: 14px; backdrop-filter: blur(6px); }
.emote-menu button { border: 0; background: rgba(255, 255, 255, .12); color: #fff; font-weight: 800; padding: 8px 12px; border-radius: 10px; text-align: left; }
.emote-menu button:hover { background: rgba(255, 255, 255, .25); }

.prompt { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); display: flex; gap: 10px; align-items: center; background: rgba(255, 252, 245, .95); padding: 10px 16px 10px 10px; border-radius: 16px; box-shadow: var(--shadow); color: var(--navy); font-size: 17px; white-space: nowrap; animation: pop .18s ease-out; cursor: pointer; }
.prompt kbd { background: var(--navy); color: #fff; border-radius: 8px; padding: 2px 10px; font-size: 18px; box-shadow: 0 3px 0 #0f234f; }
@keyframes pop { from { transform: translateX(-50%) scale(.85); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

.zone-title { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); font-family: var(--font-title); font-size: clamp(26px, 4vw, 40px); color: #fff; text-shadow: 0 3px 0 var(--navy), 0 8px 20px rgba(0, 0, 0, .35); opacity: 0; transition: opacity .6s; pointer-events: none !important; text-align: center; white-space: nowrap; }
.zone-title small { display: block; font-family: var(--font); font-size: 15px; font-weight: 800; text-shadow: 0 2px 6px rgba(0,0,0,.5); }
.zone-title.show { opacity: 1; }

.game-banner { position: absolute; left: 50%; top: max(12px, env(safe-area-inset-top)); transform: translateX(-50%); background: rgba(255, 252, 245, .95); color: var(--navy); border-radius: 16px; padding: 8px 18px; box-shadow: var(--shadow); display: flex; gap: 14px; align-items: center; font-size: 18px; }
.game-banner .big { font-family: var(--font-title); font-size: 26px; line-height: 1; }
.game-banner button { pointer-events: auto; }

#toasts { position: absolute; left: 50%; top: 84px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none !important; }
.toast { background: rgba(29, 58, 122, .9); color: #fff; padding: 9px 16px; border-radius: 14px; box-shadow: var(--shadow); animation: toast 3.2s forwards; font-size: 15px; }
.toast.good { background: rgba(37, 150, 100, .92); }
.toast.gold { background: linear-gradient(180deg, #ffd56b, #f0a92e); color: #4a2a00; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-8px); } 8% { opacity: 1; transform: none; } 85% { opacity: 1; } 100% { opacity: 0; } }

/* first-visit hints (src/systems/onboarding.js): bottom center on computers, under the quests on touch */
/* the hints and what Nimbo says (player/nimbo.js), stacked: bottom center on a computer, under the player card on a phone */
.talk { position: absolute; left: 50%; bottom: 70px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; width: max-content; max-width: min(640px, calc(100vw - 24px)); pointer-events: none !important; z-index: 1; } /* over the chat lines while he talks */
body:not(.is-touch) .prompt:not(.hidden) ~ .talk { bottom: 184px; } /* never over the E prompt */
.coach { max-width: 100%; background: rgba(29, 58, 122, .9); color: #fff; padding: 10px 16px; border-radius: 14px; box-shadow: var(--shadow); font-size: 15px; line-height: 1.6; text-align: center; animation: talk .35s ease-out; }
.coach kbd { background: #fff; color: var(--navy); border-radius: 6px; padding: 0 6px; margin: 0 1px; font-size: 13px; box-shadow: 0 2px 0 rgba(0, 0, 0, .3); }
@keyframes talk { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.nimbo-say { order: -1; display: flex; gap: 10px; align-items: center; max-width: min(560px, 100%); background: rgba(255, 255, 255, .94); color: var(--navy); padding: 8px 14px 8px 8px; border-radius: 18px; box-shadow: var(--shadow); font-size: 15px; line-height: 1.4; cursor: pointer; pointer-events: auto; animation: talk .35s ease-out; }
.nimbo-say img { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; background: #dff1ff; flex: none; }
.nimbo-say p { margin: 0; }
.nimbo-say b { display: block; font-family: var(--font-title); font-size: 13px; color: #3f86d8; line-height: 1.1; }
body.is-touch .nimbo-say { font-size: 13.5px; padding: 6px 12px 6px 6px; }
body.is-touch .nimbo-say img { width: 36px; height: 36px; }
/* phones: above the chat and the thumbs (portrait), or low between the thumbs (landscape) */
body.is-touch .talk { left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); bottom: calc(env(safe-area-inset-bottom) + 236px); transform: none; width: auto; max-width: none; align-items: flex-start; }
@media (max-height: 500px) { body.is-touch .talk { left: calc(max(12px, env(safe-area-inset-left)) + 250px); right: calc(max(12px, env(safe-area-inset-right)) + 104px); top: max(8px, env(safe-area-inset-top)); bottom: auto; align-items: center; } }
@media (max-height: 500px) { body.is-touch .nimbo-say { font-size: 12.5px; line-height: 1.3; } }
body.is-touch .coach { text-align: left; line-height: 1.35; }
body.is-touch.chat-open .talk { visibility: hidden; } /* typing: the chat log needs the space (his voice goes on) */
/* landscape phones: his caption takes the top band, so the toasts and the place names step below it */
@media (max-height: 500px) {
  body.is-touch #hud:has(.nimbo-say:not(.hidden)) #toasts { top: 104px; }
  body.is-touch #hud:has(.nimbo-say:not(.hidden)) .zone-title { top: 30%; }
}

.chat { position: absolute; left: max(12px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); width: min(360px, calc(100vw - 24px)); display: flex; flex-direction: column; gap: 6px; }
.chat-log { max-height: 160px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 3px; font-size: 14px; mask-image: linear-gradient(180deg, transparent, #000 30%); pointer-events: none; }
.chat-log div { background: var(--glass); color: #fff; padding: 3px 9px; border-radius: 9px; width: fit-content; max-width: 100%; backdrop-filter: blur(4px); font-weight: 700; transition: opacity .8s; }
.chat-log div.old { opacity: 0; }
:is(body.chat-open, .chat:focus-within) .chat-log div.old { opacity: 1; }
.chat-log b { font-weight: 800; }
.chat-log .sys { background: rgba(242, 193, 78, .85); color: #4a2a00; }
#chat-input { width: 100%; font: inherit; font-weight: 700; font-size: 15px; padding: 9px 12px; border-radius: 12px; border: 2px solid rgba(255, 255, 255, .6); background: rgba(20, 32, 70, .55); color: #fff; outline: none; backdrop-filter: blur(6px); }
#chat-input::placeholder { color: rgba(255, 255, 255, .7); }
#chat-input:focus { background: rgba(20, 32, 70, .85); border-color: var(--sky); }

/* touch */
.touch { position: absolute; inset: 0; pointer-events: none !important; }
.touch > * { pointer-events: auto; }
.stick { position: absolute; left: max(22px, env(safe-area-inset-left)); bottom: max(26px, env(safe-area-inset-bottom)); width: 128px; height: 128px; border-radius: 50%; background: rgba(255, 255, 255, .22); border: 3px solid rgba(255, 255, 255, .55); touch-action: none; }
.knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-radius: 50%; background: rgba(255, 255, 255, .85); box-shadow: 0 4px 12px rgba(0, 0, 0, .2); }
.tbtn { position: absolute; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .82); color: var(--navy); font-weight: 800; box-shadow: 0 4px 12px rgba(0, 0, 0, .2); touch-action: none; }
.tbtn.jump { right: max(26px, env(safe-area-inset-right)); bottom: max(34px, env(safe-area-inset-bottom)); width: 76px; height: 76px; font-size: 32px; }
.tbtn.act { right: max(114px, env(safe-area-inset-right)); bottom: max(46px, env(safe-area-inset-bottom)); width: 58px; height: 58px; font-size: 22px; background: rgba(255, 213, 107, .95); }
.tbtn.chatb { right: max(30px, env(safe-area-inset-right)); bottom: max(124px, env(safe-area-inset-bottom)); width: 48px; height: 48px; font-size: 20px; }
.tbtn.run { right: max(98px, env(safe-area-inset-right)); bottom: max(118px, env(safe-area-inset-bottom)); width: 52px; height: 52px; font-size: 24px; }
.tbtn.run.on { background: var(--gold); box-shadow: 0 0 0 3px #fff, 0 4px 12px rgba(0, 0, 0, .2); }
body.is-touch .chat { bottom: 170px; width: min(300px, calc(100vw - 24px)); }
body.is-touch .chat form { display: none; }
body.is-touch.chat-open .chat form { display: block; }
body.is-touch .prompt { bottom: 190px; }
body.is-touch .prompt kbd { display: none; }

/* ---------- modal ---------- */
.modal { position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(20, 30, 70, .35); backdrop-filter: blur(3px); }
.modal-card { position: relative; width: min(880px, 100%); max-height: calc(100% - 8px); overflow-y: auto; background: var(--cream); border-radius: 26px; border: 4px solid #fff; box-shadow: 0 20px 60px rgba(20, 30, 80, .45); padding: 22px; animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(16px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.modal .close { position: absolute; right: 12px; top: 12px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: #e8edf9; color: var(--navy); font-size: 18px; font-weight: 800; z-index: 2; }
.modal h2 { font-family: var(--font-title); color: var(--navy); font-size: 30px; margin: 0 40px 4px 0; line-height: 1.1; }
.modal h3 { font-family: var(--font-title); color: var(--navy); margin: 14px 0 6px; font-size: 21px; }
.modal p { line-height: 1.5; margin: 6px 0; font-weight: 600; color: #333a5c; }
.modal .sub { color: var(--muted); font-weight: 800; margin-top: 0; }
.cover { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 16px; display: block; box-shadow: 0 6px 18px rgba(20, 30, 80, .2); }
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-top: 12px; }
.course-card { background: #fff; border-radius: 18px; overflow: hidden; border: 0; padding: 0; text-align: left; box-shadow: 0 4px 0 rgba(29, 58, 122, .12), 0 8px 18px rgba(20, 30, 80, .12); transition: transform .12s; color: inherit; }
.course-card:hover { transform: translateY(-3px); }
.course-card img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; }
.course-card div { padding: 10px 12px 12px; }
.course-card b { font-family: var(--font-title); font-size: 19px; color: var(--navy); display: block; line-height: 1.15; }
.course-card small { color: var(--muted); font-weight: 800; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.tag { background: #e8edf9; color: var(--navy); border-radius: 99px; padding: 3px 10px; font-size: 13px; font-weight: 800; }
.tag.vr { background: #ffe0f1; color: #a0306c; }
.tag.new { background: #dff7ea; color: #1d7a4c; }
.lessons { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.lessons li { background: #fff; border-radius: 12px; padding: 9px 12px; font-weight: 700; display: flex; gap: 10px; align-items: center; }
.lessons li span { background: var(--navy); color: #fff; border-radius: 8px; padding: 0 8px; font-size: 13px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.two-col { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 680px) { .two-col { grid-template-columns: 1fr; } .modal-card { padding: 16px; } .modal h2 { font-size: 25px; } }

.quiz-q { font-family: var(--font-title); font-size: 24px; color: var(--navy); line-height: 1.2; margin: 6px 0 14px; }
.quiz-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .quiz-opts { grid-template-columns: 1fr; } }
.quiz-opts button { border: 0; border-radius: 14px; padding: 14px; font-weight: 800; font-size: 17px; background: #fff; color: var(--ink); box-shadow: 0 4px 0 rgba(29, 58, 122, .18); text-align: left; }
.quiz-opts button.ok { background: #c9f2da; }
.quiz-opts button.bad { background: #ffd2d2; }
.timer-bar { height: 10px; background: #e3e8f6; border-radius: 99px; overflow: hidden; }
.timer-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--gold)); width: 100%; }
.big-score { font-family: var(--font-title); font-size: 64px; color: var(--navy); text-align: center; line-height: 1; margin: 10px 0; }

/* minigame feedback: medals, record badge, trivia stamp, floating points, counter bump */
.medal { position: relative; width: 84px; height: 104px; margin: 0 auto; animation: medal .7s cubic-bezier(.2, 1.5, .45, 1) both; }
.medal::before, .medal::after { content: ""; position: absolute; top: 0; width: 24px; height: 44px; background: var(--navy-2); border-radius: 2px; }
.medal::before { left: 19px; transform: skewX(16deg); }
.medal::after { right: 19px; transform: skewX(-16deg); background: var(--pink); }
.medal span { position: absolute; left: 6px; bottom: 0; z-index: 1; width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; font: 800 36px/1 var(--font-title); color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .25); background: radial-gradient(circle at 34% 28%, var(--m1), var(--m2) 58%, var(--m3)); box-shadow: inset 0 0 0 5px rgba(255, 255, 255, .45), 0 6px 14px rgba(20, 30, 80, .3); }
.medal.gold { --m1: #fff4b8; --m2: #f5c542; --m3: #c98a12; }
.medal.silver { --m1: #ffffff; --m2: #c9d3e3; --m3: #8592a8; }
.medal.bronze { --m1: #ffdcbc; --m2: #d98c4f; --m3: #9a5426; }
@keyframes medal { from { transform: translateY(-40px) scale(.3) rotate(-25deg); opacity: 0; } to { transform: none; opacity: 1; } }
.modal .medal-name { text-align: center; margin: 2px 0 0; font-weight: 800; color: var(--muted); font-size: 14px; }
.record-badge { width: fit-content; margin: 2px auto 8px; padding: 4px 14px; border-radius: 99px; background: linear-gradient(180deg, #ff9fd0, #ff6fb1); color: #fff; font: 800 17px/1.4 var(--font-title); box-shadow: 0 4px 0 #d94f93; animation: glow 1.4s ease-in-out infinite; }
@keyframes glow { 50% { transform: scale(1.06); } }
.modal .next-goal { text-align: center; color: var(--navy-2); font-weight: 800; }
.stamp { position: absolute; right: 62px; top: 16px; z-index: 3; padding: 4px 14px; border: 4px solid currentColor; border-radius: 12px; font: 800 24px/1.2 var(--font-title); text-transform: uppercase; letter-spacing: .5px; transform: rotate(-9deg); background: rgba(255, 255, 255, .85); animation: stamp .32s cubic-bezier(.3, 1.6, .5, 1) both; pointer-events: none; }
.stamp.ok { color: #1f9a5c; }
.stamp.bad { color: #d4463c; }
@keyframes stamp { from { transform: rotate(-9deg) scale(2.4); opacity: 0; } to { transform: rotate(-9deg) scale(1); opacity: 1; } }
.fly-up { position: absolute; z-index: 35; transform: translate(-50%, -50%); font: 800 28px/1 var(--font-title); color: #fff; white-space: nowrap; text-shadow: 0 2px 0 var(--navy), 0 6px 14px rgba(0, 0, 0, .3); pointer-events: none; animation: flyup .95s ease-out forwards; }
.fly-up.gold { color: #ffd56b; }
.fly-up.good { color: #2bb673; text-shadow: 0 2px 0 #0f5e3a, 0 6px 14px rgba(0, 0, 0, .25); }
@keyframes flyup { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -260%) scale(1); } }
.bump { animation: bump .35s ease-out; }
@keyframes bump { 40% { transform: scale(1.35); color: #f0a92e; } }
.help-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 16px; }
.help-grid div { background: #fff; border-radius: 12px; padding: 8px 12px; font-weight: 700; }
.help-grid kbd { background: var(--navy); color: #fff; border-radius: 6px; padding: 1px 7px; margin-right: 4px; }

.tour-layer { position: absolute; inset: 0; z-index: 25; }
/* shown while the tour loads; left side, clear of the tour's title card */
.tour-exit { position: absolute; z-index: 26; left: max(12px, env(safe-area-inset-left)); top: calc(88px + env(safe-area-inset-top)); border: 0; border-radius: 999px; padding: 9px 16px; background: rgba(20, 30, 70, .82); color: #fff; font: 800 15px/1.1 var(--font); box-shadow: 0 6px 18px rgba(0, 0, 0, .3); backdrop-filter: blur(6px); cursor: pointer; }
.tour-exit:hover { background: rgba(29, 58, 122, .95); }
.tour-exit:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
@media (max-width: 640px) { .tour-exit { top: calc(62px + env(safe-area-inset-top)); font-size: 13px; padding: 8px 12px; } }
.travel { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-top: 12px; }
.travel-btn { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; text-align: left; border: 0; border-radius: 18px; padding: 14px 16px; background: #fff; color: var(--navy); box-shadow: 0 4px 0 rgba(29, 58, 122, .18), 0 8px 18px rgba(29, 58, 122, .12); cursor: pointer; transition: transform .08s; }
.travel-btn:hover { transform: translateY(-2px); }
.travel-btn:active { transform: translateY(2px); }
.travel-btn:focus-visible { outline: 3px solid var(--navy-2); outline-offset: 2px; }
.travel-btn .ico { grid-row: span 2; font-size: 30px; }
.travel-btn b { font-family: var(--font-title); font-size: 19px; line-height: 1.1; }
.travel-btn small { font-weight: 700; color: #5a6b8f; }
.fade { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .45s; z-index: 40; }
.fade.on { opacity: 1; }

@media (max-width: 640px) {
  .zone-title { top: 26%; font-size: 26px; }
  #minimap { width: 104px; height: 104px; }
  .hud-buttons { max-width: 140px; }
  .icon-btn { width: 36px; height: 36px; font-size: 16px; }
  .player-card { padding: 6px 10px; font-size: 14px; }
  /* during a minigame the banner sits under the player card (clear of the minimap) and the quests step aside */
  .game-banner { left: max(12px, env(safe-area-inset-left)); transform: none; top: calc(max(12px, env(safe-area-inset-top)) + 46px); max-width: calc(100vw - 136px); flex-wrap: wrap; gap: 4px 8px; padding: 6px 10px; font-size: 15px; }
  .game-banner .big { font-size: 22px; }
  .game-banner .btn { padding: 6px 12px; font-size: 14px; }
  body.in-game :is(.quests, .online) { display: none; }
  #toasts { top: 214px; }
}

/* landscape phones: a smaller minimap, one row of buttons, a shorter chat and the prompt low between the thumbs */
@media (max-height: 500px) {
  #minimap { width: 96px; height: 96px; }
  .hud-buttons { max-width: none; flex-wrap: nowrap; }
  .icon-btn { width: 34px; height: 34px; font-size: 15px; }
  .zone-title { top: 12%; font-size: 24px; }
  .chat-log { max-height: 92px; }
  body.is-touch .chat { bottom: 158px; }
  body.is-touch .prompt { bottom: max(22px, env(safe-area-inset-bottom)); }
  .game-banner { padding: 6px 14px; font-size: 15px; }
  .game-banner .big { font-size: 22px; }
  #toasts { top: 64px; }
}

/* ---------- menus without a mouse ---------- */
/* keyboard focus: a chunky gold ring that is easy to follow (body.kbd-nav: the last input was a key) */
body.kbd-nav :is(.modal, #title, #hud) :is(button, input):focus,
:is(.modal, #title, #hud) :is(button, input):focus-visible { outline: 4px solid var(--gold); outline-offset: 3px; }
body.kbd-nav .modal :is(.course-card, .travel-btn, .quiz-opts button, .btn):focus { transform: translateY(-2px); }
.keyhint { display: none; justify-content: center; flex-wrap: wrap; gap: 4px 6px; align-items: center; margin: 14px 0 0; font-size: 13px; font-weight: 800; color: var(--muted); }
body.kbd-nav:not(.is-touch) .keyhint { display: flex; }
.keyhint kbd, .game-banner kbd, .quiz-opts kbd { background: var(--navy); color: #fff; border-radius: 6px; padding: 0 6px; font-size: 13px; line-height: 1.5; box-shadow: 0 2px 0 #0f234f; }
.quiz-opts kbd { margin-right: 10px; vertical-align: 1px; }
body.is-touch :is(.game-banner, .quiz-opts) kbd { display: none; }
@media (pointer: coarse) { .title-wrap .hint { display: none; } }

/* Tablas relámpago (src/games/tablas.js): entrada con opciones, ronda de 60 s y práctica de una tabla */
.tb-head { display: flex; gap: 16px; align-items: center; }
.tb-logo { flex: none; width: 112px; height: 112px; border-radius: 22px; background: var(--navy); color: #fff; display: grid; place-items: center; align-content: center; gap: 2px; font: 800 18px/1.1 var(--font-title); box-shadow: 0 6px 0 #0f234f; }
.tb-logo b { color: var(--gold); font-size: 30px; line-height: 1; }
.tb-logo span:last-child { color: #ff9fcf; }
.tb-lobby h3 { margin-top: 12px; }
.tb-group { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.tb-choice { border: 3px solid transparent; border-radius: 14px; padding: 10px 12px; background: #fff; color: var(--ink); text-align: left; box-shadow: 0 4px 0 rgba(29, 58, 122, .18); font-size: 16px; }
.tb-choice b { display: block; font-weight: 800; }
.tb-choice small { display: block; color: var(--muted); font-weight: 700; font-size: 13px; }
.tb-choice[aria-pressed="true"] { border-color: var(--navy); background: #e9f0ff; }
.tb-tablas { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.tb-tablas .tb-choice { text-align: center; font: 800 22px/1 var(--font-title); padding: 12px 0; }
.tb-tablas .tb-choice.dura { box-shadow: 0 4px 0 #e0937b; }
.tb-best { color: var(--navy) !important; }
.tb-rules { font-size: 14px; color: var(--muted) !important; }
.tb-play { position: relative; display: flex; flex-direction: column; gap: 12px; }
.tb-play [hidden] { display: none !important; }
.tb-hud { display: flex; align-items: center; gap: 12px; margin-right: 44px; font-weight: 800; color: var(--navy); }
.tb-hud .timer-bar { flex: 1; }
.tb-time { font: 800 30px/1 var(--font-title); min-width: 42px; text-align: center; }
.tb-time.urge { color: #d4463c; }
.tb-pts b { font: 800 26px/1 var(--font-title); }
.tb-racha { padding: 3px 10px; border-radius: 99px; background: #e8edf9; white-space: nowrap; }
.tb-racha.on { background: #ffe1a3; color: #8a4b00; }
.tb-tag { white-space: nowrap; }
.tb-stage { text-align: center; background: var(--navy); color: #fff; border-radius: 20px; padding: 14px 12px 12px; box-shadow: 0 6px 0 #0f234f; transition: background .2s; }
.tb-stage.oculto { visibility: hidden; }
.tb-stage.bien { background: #1f7a50; }
.tb-stage.mal { background: #8a2f2a; }
.tb-label { color: var(--gold) !important; margin: 0 !important; letter-spacing: .12em; text-transform: uppercase; font-size: 13px; }
.tb-eq { font: 800 clamp(48px, 12vw, 84px)/1 var(--font-title); }
.tb-eq span { color: var(--gold); margin: 0 .12em; }
.tb-ans { font: 800 40px/1.1 var(--font-title); min-height: 44px; }
.tb-ans.bien { color: #bff5d6; }
.tb-ans.mal { color: #ffd2cf; }
.tb-cap { color: #e9eefc !important; min-height: 1.5em; margin: 4px 0 0 !important; }
.tb-opts button { text-align: center; font-size: 26px; font-family: var(--font-title); padding: 12px; }
.tb-pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tb-key { display: grid; place-items: center; min-height: 52px; border-radius: 14px; background: #fff; color: var(--ink); font: 800 26px/1 var(--font-title); box-shadow: 0 4px 0 rgba(29, 58, 122, .18); cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.tb-key:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(29, 58, 122, .18); }
.tb-key.del { background: #e8edf9; }
.tb-send { font-size: 26px; min-height: 52px; }
.tb-next { justify-content: center; }
.tb-count { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; background: rgba(255, 248, 236, .92); border-radius: 18px; color: var(--navy); font-family: var(--font-title); z-index: 2; }
.tb-count b { font-size: 96px; line-height: 1; }
.tb-count small { font-size: 18px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.tb-hint { font-size: 13px; color: var(--muted) !important; text-align: center; }
.tb-hint kbd { background: var(--navy); color: #fff; border-radius: 6px; padding: 0 6px; font-size: 12px; }
body.is-touch .tb-hint { display: none; }
.tb-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin: 10px 0; }
.tb-facts span { border-radius: 10px; padding: 6px 10px; font-weight: 800; background: #c9f2da; color: #145a37; }
.tb-facts span.bad { background: #ffd2d2; color: #8a2f2a; }
@media (max-width: 560px) {
  .tb-logo { width: 84px; height: 84px; font-size: 14px; }
  .tb-logo b { font-size: 22px; }
  .tb-tablas { grid-template-columns: repeat(4, 1fr); }
  .tb-hud { gap: 8px; }
  .tb-time { font-size: 24px; min-width: 32px; }
  .tb-opts { grid-template-columns: 1fr 1fr !important; }
}
