/* ==========================================================================
   Mundo tbō · página del minijuego
   ========================================================================== */
html.world-page { height: 100%; overflow: hidden; overscroll-behavior: none; }
.is-game { overflow: hidden; overscroll-behavior: none; background: var(--w-bg); }
html.world-text, .is-game.is-text { height: auto; overflow: auto; overscroll-behavior: auto; }
/* Materiales del distrito: superficies neutras, aristas finas y acentos de luz. */
.is-game {
  --w-bg: #F4F4F2; --w-panel: #FFFFFF; --w-ink: #17171D; --w-muted: #64646E;
  --w-line: #D8D8DC; --w-soft: #F0EFF3; --w-accent: #6730DB;
  --w-orange: #FF5000; --w-yellow: #FFEA1E; --w-violet: #773FFF;
  --w-shadow: 0 8px 28px -16px rgb(20 20 24 / 0.2);
  --w-backdrop: rgb(244 244 242 / 0.7);
}
html[data-theme='dark'] .is-game {
  --w-bg: #0A0A0D; --w-panel: #141419; --w-ink: #F4F4F2; --w-muted: #ADADB9;
  --w-line: #34343E; --w-soft: #1D1B25; --w-accent: #BEA7FF;
  --w-shadow: 0 8px 28px -16px rgb(0 0 0 / 0.65);
  --w-backdrop: rgb(10 10 13 / 0.72);
}
.w { position: fixed; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; font-family: var(--f-ui, var(--f-body)); }
.w [hidden] { display: none !important; }
.w__canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; image-rendering: auto; outline: none; }
.w button, .w a, .w summary { -webkit-tap-highlight-color: transparent; }
.w button:focus-visible, .w a:focus-visible, .w summary:focus-visible { outline: 3px solid var(--w-orange); outline-offset: 4px; }

/* Una barra de herramientas y dos paneles plegables. */
.w-hud {
  position: absolute; inset: 0 0 auto; z-index: 3;
  display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
  padding: max(0.75rem, env(safe-area-inset-top)) max(0.9rem, env(safe-area-inset-right)) 0 max(0.9rem, env(safe-area-inset-left));
  pointer-events: none;
}
.w-hud > * { pointer-events: auto; }
.w-hud__brand, .w-ideas, .w-btn {
  display: inline-flex; align-items: center; gap: 0.55rem; height: 46px; margin: 0; padding: 0 0.85rem;
  border-radius: 6px; background: var(--w-panel); border: 1px solid var(--w-line);
  box-shadow: var(--w-shadow); color: var(--w-ink); text-decoration: none;
}
.w-hud__brand img { height: 26px; width: auto; }
.w-hud__brand .x-mono { padding-left: 0.6rem; border-left: 1px solid var(--w-line); color: var(--w-muted); }
.w-hud__right { display: flex; align-items: center; gap: 0.45rem; }
.w-btn { padding: 0; width: 46px; justify-content: center; cursor: pointer; font: inherit; flex-shrink: 0; }
.w-btn svg { width: 20px; height: 20px; }
.w-btn--text { width: auto; padding: 0 0.85rem; font-weight: 700; font-size: 0.85rem; }
.w-btn .w-wave { display: none; }
.w-btn[aria-pressed='true'] .w-wave { display: block; }
.w-btn[aria-pressed='true'] .w-mute { display: none; }
#wMap[aria-expanded='true'], #wSound[aria-pressed='true'] { background: var(--w-soft); color: var(--w-accent); border-color: var(--w-violet); box-shadow: inset 0 -2px var(--w-violet); }
.w-hud .theme-toggle { width: 46px; height: 46px; }
.w-ideas { font-weight: 700; font-size: 0.85rem; white-space: nowrap; }
.w-ideas b { color: var(--w-accent); }
.w-ideas__bulbs { display: inline-flex; gap: 6px; padding: 0 2px; }
.w-ideas__bulbs i { width: 6px; height: 6px; border-radius: 0; transform: rotate(45deg); background: var(--w-line); transition: background 200ms, transform 200ms; }
.w-ideas__bulbs i.is-on { background: var(--w-orange); box-shadow: 0 0 6px rgb(255 80 0 / 0.3); transform: rotate(45deg); }

.w-quest, .w-minimap { position: absolute; z-index: 2; border: 1px solid var(--w-line); border-radius: 6px; background: var(--w-panel); color: var(--w-ink); box-shadow: var(--w-shadow); }
.w-quest { left: max(0.9rem, env(safe-area-inset-left)); top: calc(max(0.75rem, env(safe-area-inset-top)) + 58px); width: 250px; overflow: hidden; }
.w-quest summary { min-height: 48px; padding: 10px 12px; display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.8rem; font-weight: 800; list-style: none; }
.w-quest summary::-webkit-details-marker { display: none; }
.w-quest summary::after { content: '+'; font-size: 1.2rem; margin-left: auto; }
.w-quest[open] summary::after { content: '−'; }
.w-quest__count { color: var(--w-accent); white-space: nowrap; }
.w-quest__body { padding: 0 12px 8px; max-height: min(290px, 50dvh); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
.w-quest__intro { font-size: 0.7rem; color: var(--w-muted); margin: 0 0 6px; }
.w-quest__list { display: grid; gap: 1px; list-style: none; margin: 0; padding: 0; }
.w-quest__list li { display: flex; align-items: center; gap: 8px; min-height: 31px; border-bottom: 1px solid var(--w-line); }
.w-quest__mark { display: grid; place-items: center; width: 18px; height: 18px; flex-shrink: 0; border-radius: 5px; background: var(--w-soft); font-size: 13px; }
.w-quest__list li > span:last-child { flex: 1; display: flex; justify-content: space-between; align-items: baseline; gap: 4px; }
.w-quest__list strong { font-size: 0.73rem; font-weight: 700; }
.w-quest__list small { font-size: 0.6rem; color: var(--w-muted); }
.w-quest__list .is-done .w-quest__mark { background: var(--w-yellow); color: #141418; }
.w-quest__list .is-done strong { text-decoration: line-through; text-decoration-color: var(--w-muted); }
.w-quest__next { padding: 9px 12px; margin: 0; border-top: 1px solid var(--w-line); font-size: 0.7rem; font-weight: 600; background: var(--w-soft); }
.w-quest__reset { background: none; color: var(--w-accent); border: 0; font: 600 0.75rem var(--f-ui, sans-serif); padding: 10px 0; min-height: 40px; text-align: left; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.w-quest__reset:disabled { opacity: 0.4; cursor: default; text-decoration: none; }
.w-minimap { top: calc(max(0.75rem, env(safe-area-inset-top)) + 58px); right: max(0.9rem, env(safe-area-inset-right)); width: 216px; padding: 8px; pointer-events: none; }
.w-minimap__heading { display: flex; justify-content: space-between; font-size: 0.68rem; font-weight: 700; margin-bottom: 5px; }
.w-minimap canvas { width: 100%; height: auto; display: block; image-rendering: auto; border-radius: 5px; }
.w-minimap p { display: flex; justify-content: space-between; gap: 4px; font-size: 0.58rem; margin: 7px 0 0; }
.w-minimap p span::before { content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 4px; background: var(--w-orange); border: 1px solid rgb(0 0 0 / 0.25); }
.w-minimap .w-map-player::before { border-radius: 50%; }
.w-minimap .w-map-building::before { background: #773FFF; }
.w-minimap .w-map-idea::before { background: var(--w-yellow); transform: rotate(45deg); }

.w-help { position: absolute; left: 50%; bottom: max(0.9rem, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 2;
  padding: 0.55rem 0.9rem; border-radius: 6px; background: var(--w-panel); color: var(--w-muted); border: 1px solid var(--w-line);
  display: flex; align-items: center; gap: 0.3rem; white-space: nowrap; pointer-events: none; font-size: 0.7rem; }
.w-help kbd { display: inline-grid; place-items: center; min-width: 1.7em; height: 1.7em; padding: 0 0.3em; border-radius: 4px; background: var(--w-soft); font: inherit; }
.w-act { position: absolute; right: max(1rem, env(safe-area-inset-right)); bottom: max(1.25rem, env(safe-area-inset-bottom)); z-index: 3;
  width: 100px; height: 100px; border-radius: 50%; background: var(--w-orange); color: #1C0900;
  border: 1px solid #FF9A6C; font: 800 1rem var(--f-ui, var(--f-body)); cursor: pointer; touch-action: none;
  box-shadow: 0 0 24px -8px rgb(255 80 0 / 0.45); }
.w-act:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .w-act { width: 76px; height: 50px; border-radius: 6px; font-size: 0.8rem; } }
@media (pointer: coarse), (max-width: 700px) { .w-help { display: none; } }
.w-toast { position: absolute; left: 50%; bottom: max(5rem, calc(env(safe-area-inset-bottom) + 4rem)); z-index: 4;
  transform: translate(-50%, 12px); opacity: 0; width: max-content; max-width: calc(100% - 2rem); text-align: center;
  padding: 0.75rem 1rem; border-radius: 6px; background: var(--w-panel); color: var(--w-ink); border: 1px solid var(--w-orange); font-size: 0.85rem; font-weight: 700;
  box-shadow: var(--w-shadow); transition: opacity 200ms, transform 200ms; pointer-events: none; }
.w-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
@media (pointer: coarse) { .w-toast { bottom: max(11rem, calc(env(safe-area-inset-bottom) + 10rem)); } }
@media (max-width: 600px) {
  .w-hud { padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); gap: 5px; }
  .w-hud__right { gap: 4px; }
  .w-hud__brand { width: 49px; padding: 5px; justify-content: center; }
  .w-hud__brand img { width: 37px; height: auto; }
  .w-hud__brand .x-mono, .w-ideas__word, .w-ideas__bulbs { display: none; }
  .w-ideas__txt { display: inline; }
  .w-ideas { padding: 0 7px; font-size: 0.75rem; }
  .w-hud__brand, .w-ideas, .w-btn { height: 44px; border-radius: 6px; }
  .w-btn, .w-hud .theme-toggle { width: 44px; height: 44px; }
  .w-btn--text { padding: 0; font-size: 0.7rem; }
  .w-quest { width: min(190px, calc(100vw - 154px)); left: max(8px, env(safe-area-inset-left)); }
  .w-quest summary { min-height: 51px; padding: 8px; font-size: 0.68rem; gap: 4px; }
  .w-quest__body { padding: 0 8px 5px; }
  .w-quest__list li { min-height: 41px; gap: 5px; }
  .w-quest__list li > span:last-child { display: block; }
  .w-quest__list strong, .w-quest__list small { display: block; }
  .w-quest__next { font-size: 0.63rem; padding: 8px; }
  .w-minimap { width: 136px; padding: 6px; right: max(8px, env(safe-area-inset-right)); }
  .w-minimap p { font-size: 0.45rem; gap: 1px; }
  .w-minimap p span::before { width: 4px; height: 4px; margin-right: 2px; }
}
@media (max-height: 500px) {
  .w-quest { width: 215px; }
  .w-quest__body { max-height: 140px; }
  .w-minimap { width: 150px; }
  .w-help { display: none; }
  .w-act { width: 82px; height: 82px; }
}

/* Pantalla de inicio */
.w-start {
  position: absolute; inset: 0; z-index: 5;
  display: grid; place-items: center;
  padding: 1rem;
  background: var(--w-backdrop);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  transition: opacity 500ms;
}
.w-start.is-out { opacity: 0; pointer-events: none; }
.w-start__card {
  width: min(480px, 100%);
  max-height: calc(100dvh - 2rem); overflow: auto;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  border: 1px solid var(--w-line); border-radius: 12px;
  background: var(--w-panel); color: var(--w-ink);
  box-shadow: var(--w-shadow);
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 0.9rem;
  touch-action: pan-y; overscroll-behavior: contain;
}
.w-start__mascot { width: 68px; height: 68px; display: grid; place-items: center; color: var(--w-orange); }
.w-start__mascot svg { width: 82%; }
.w-start__mascot svg path, .w-start__mascot svg rect { fill: currentColor; }
.w-start__kicker { color: var(--w-accent); }
.w-start__title { font-family: var(--f-x, var(--f-display)); font-weight: 800; font-stretch: 75%; font-size: clamp(3rem, 10vw, 4.5rem); letter-spacing: -0.045em; line-height: 0.85; }
.w-start__title span { color: var(--c-brand); }
.w-start__text { color: var(--c-ink-soft); line-height: 1.55; }
.w-start__keys { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.45rem; font-size: 0.88rem; color: var(--w-muted); }
.w-start__alt { font-size: 0.85rem; color: var(--w-muted); text-decoration: underline; text-underline-offset: 3px; }

/* Ficha */
.w-panel {
  width: min(560px, calc(100vw - 1.5rem));
  max-height: calc(100dvh - 2rem);
  padding: 0; border: 1px solid var(--w-line); border-radius: 12px;
  background: var(--w-panel); color: var(--w-ink);
  box-shadow: var(--w-shadow);
  overflow: auto; touch-action: pan-y; overscroll-behavior: contain; user-select: text; -webkit-user-select: text;
}
.w-panel::backdrop { background: var(--w-backdrop); backdrop-filter: blur(2px); }
.w-panel[open] { animation: wPanel 180ms ease-out; }
@keyframes wPanel { from { transform: translateY(8px); opacity: 0; } }
.w-panel__close { position: absolute; top: 0.75rem; right: 0.75rem; z-index: 1; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--c-ink); color: var(--c-bg); display: grid; place-items: center; cursor: pointer; }
.w-panel__img { margin: 0; aspect-ratio: 16 / 9; overflow: hidden; }
.w-panel__img img { width: 100%; height: 100%; object-fit: cover; }
.w-panel__body { padding: 1.5rem 1.6rem 1.7rem; display: flex; flex-direction: column; gap: 0.8rem; }
.w-panel__kicker { color: var(--w-accent); padding-right: 3rem; }
.w-panel__title { font-family: var(--f-x, var(--f-display)); font-weight: 800; font-stretch: 75%; font-size: clamp(2rem, 6vw, 3rem); letter-spacing: -0.04em; line-height: 0.9; padding-right: 2.5rem; }
.w-panel__text { color: var(--c-ink-soft); line-height: 1.6; }
.w-panel__tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.w-panel__tags:empty { display: none; }
.w-panel__tags span { padding: 0.3rem 0.7rem; border-radius: 4px; background: var(--w-soft); font-size: 0.8rem; font-weight: 600; }
.w-panel__cta { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.4rem; }
.w-panel--win .w-panel__title { color: var(--c-brand); }

/* Versión en texto */
.w-text { touch-action: pan-y pinch-zoom; display: none; padding: 6rem 0 4rem; background: var(--w-bg); }
.is-text .w-text, .w-text:target { display: block; }
.is-text .w { position: relative; height: 0; overflow: hidden; }
.w-text__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2rem; margin-top: 2rem; }
.w-text h3 { font-size: 1.1rem; margin-bottom: 0.75rem; }
.w-text ul { padding-left: 1.1rem; display: grid; gap: 0.5rem; color: var(--c-ink-soft); }
.w-text a { color: var(--w-accent); }
@media (max-width: 860px) { .w-text__grid { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) {
  .w-start__mascot, .w-act { animation: none; }
  .w-panel[open] { animation: none; }
  .w *, .w *::before, .w *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .w-start__card { transform: none; }
}

/* Celular: panel de misión legible (mínimo ~12 px) y sin la leyenda del minimapa, ilegible a ese tamaño */
@media (max-width: 600px) {
  .w-quest summary { font-size: 0.75rem; }
  .w-quest__intro, .w-quest__next, .w-btn--text { font-size: 0.75rem; }
  .w-quest__list strong { font-size: 0.78rem; }
  .w-quest__list small { font-size: 0.75rem; }
  .w-minimap p { display: none; }
  .w-start__alt { display: inline-block; padding-block: 0.75rem; }
}
