:root {
  --bg1: #140b2e;
  --bg2: #3b1f6b;
  --card: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.14);
  --text: #fff8ec;
  --muted: #c9bde6;
  --gold: #ffd166;
  --jere: #ff8a3d;
  --jere-dark: #c45a17;
  --jose: #4fc3ff;
  --jose-dark: #1b82b8;
  --good: #3ddc84;
  --bad: #ff5d6c;
  --primary: #ffcf4a;
  --primary-dark: #c9921a;
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100dvh;
}

body {
  background:
    radial-gradient(2px 2px at 20% 15%, #fff8 50%, transparent 51%),
    radial-gradient(2px 2px at 75% 8%, #fff6 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 60% 30%, #fff7 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 10% 45%, #fff5 50%, transparent 51%),
    radial-gradient(2px 2px at 88% 40%, #fff6 50%, transparent 51%),
    radial-gradient(ellipse at 50% 120%, #6b2f8f 0%, transparent 60%),
    linear-gradient(180deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Baloo 2', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

.jere { color: var(--jere); }
.jose { color: var(--jose); }
b.jere, b.jose { font-weight: 800; }

#screen {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

h1, h2 {
  margin: 0.2em 0;
  line-height: 1.1;
  text-align: center;
}

h2 {
  font-size: 1.6rem;
  color: var(--gold);
}

.muted { color: var(--muted); margin: 0; }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.error { color: var(--bad); min-height: 1.4em; font-weight: 700; text-align: center; }
.loading { text-align: center; margin-top: 40vh; color: var(--muted); }

/* ---------- barra superior ---------- */
#topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: rgba(20, 11, 46, 0.85);
  backdrop-filter: blur(6px);
  font-size: 0.9rem;
}
#topbar .room b { color: var(--gold); letter-spacing: 2px; }
#topbar .status { flex: 1; text-align: center; }
#topbar .status::before { content: '●'; margin-right: 5px; }
#topbar .status.on::before { color: var(--good); }
#topbar .status.off::before { color: var(--bad); }
#topbar .exit {
  background: none;
  border: 1px solid var(--card-border);
  color: var(--muted);
  border-radius: 999px;
  padding: 2px 12px;
  font: inherit;
}

#offline {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: var(--bad);
  color: #fff;
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 700;
}

/* ---------- botones ---------- */
.btn {
  font: inherit;
  font-weight: 800;
  font-size: 1.15rem;
  color: #2a1740;
  background: #fff;
  border: none;
  border-radius: 18px;
  padding: 12px 20px;
  box-shadow: 0 5px 0 #b9a8d6;
  cursor: pointer;
  transition: transform 0.06s;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 #b9a8d6; }
.btn.big { width: 100%; font-size: 1.35rem; padding: 16px; }
.btn.primary { background: var(--primary); box-shadow: 0 5px 0 var(--primary-dark); }
.btn.primary:active:not(:disabled) { box-shadow: 0 1px 0 var(--primary-dark); }
.btn:disabled { opacity: 0.6; box-shadow: none; transform: translateY(4px); }

/* ---------- inicio ---------- */
.home { text-align: center; padding-top: 6vh; }
.home h1 { font-size: 2.6rem; }
.home h1 small { display: block; font-size: 1.3rem; color: var(--gold); margin-top: 4px; }
.lead { color: var(--muted); margin: 12px 0 28px; }
.or { color: var(--muted); margin: 22px 0 10px; font-size: 0.95rem; }
.join { display: flex; gap: 10px; }
.join input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 6px;
  text-align: center;
  text-transform: uppercase;
  border-radius: 18px;
  border: 2px solid var(--card-border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  padding: 8px;
  user-select: text;
  -webkit-user-select: text;
}

/* ---------- tarjetas ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 20px;
}

.room-info { margin: 8px 0 16px; }
.code {
  font-size: 3.2rem;
  font-weight: 800;
  letter-spacing: 10px;
  color: var(--gold);
  line-height: 1;
  margin: 4px 0 8px;
}
.link { color: var(--text); word-break: break-all; user-select: text; -webkit-user-select: text; }

.chars { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.char {
  font: inherit;
  color: var(--text);
  border-radius: 20px;
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  border: 3px solid transparent;
}
.char.jere { background: linear-gradient(160deg, #ff8a3d55, #ff8a3d22); border-color: var(--jere); }
.char.jose { background: linear-gradient(160deg, #4fc3ff55, #4fc3ff22); border-color: var(--jose); }
.char .avatar { font-size: 3rem; }
.char b { font-size: 1.5rem; }
.char small { color: var(--muted); font-size: 0.85rem; }
.char em { font-style: normal; font-weight: 800; margin-top: 6px; background: #fff2; padding: 2px 12px; border-radius: 999px; }
.char:disabled { opacity: 0.4; }
.char:active:not(:disabled) { transform: scale(0.96); }

.me { font-size: 2rem; font-weight: 800; }
.me .avatar { font-size: 2.4rem; }
.waiting { font-size: 1.2rem; margin: 10px 0 0; }
.dots i { font-style: normal; animation: blink 1.4s infinite; }
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }

.chip {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 700;
  background: #0003;
  border: 2px solid currentColor;
}

/* ---------- elegir nivel ---------- */
.worlds { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 4px 0 10px; }
.world {
  font: inherit;
  color: var(--text);
  background: #0003;
  border: 3px solid var(--card-border);
  border-radius: 14px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  text-align: left;
}
.world img { width: 100%; image-rendering: pixelated; border-radius: 8px; }
.world span { font-size: 0.8rem; color: var(--muted); line-height: 1.1; }
.world b { display: block; color: var(--text); font-size: 0.95rem; }
.world.on { border-color: var(--gold); background: #ffd16622; box-shadow: 0 0 0 2px #ffd16655; }
.btn.small { font-size: 0.9rem; padding: 6px 12px; box-shadow: 0 3px 0 #b9a8d6; }

/* ---------- mi personaje ---------- */
.look { display: flex; gap: 14px; align-items: center; }
.look .pixel-avatar { width: 96px; height: 96px; background: #e8f1fb; border-radius: 12px; }
.look-fields { flex: 1; }
.look-fields input {
  font: inherit;
  font-weight: 800;
  width: 100%;
  border: 2px solid #8b5a2b;
  border-radius: 10px;
  padding: 4px 8px;
  user-select: text;
  -webkit-user-select: text;
}
.look-label { margin: 6px 0 2px !important; font-weight: 700; font-size: 0.9rem; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px #0005; cursor: pointer; }
.swatch.on { border-color: #1a1c2c; transform: scale(1.12); }
.genders { display: flex; gap: 8px; }
.gender-btn { flex: 1; font: inherit; font-weight: 800; padding: 6px 10px; border-radius: 12px; border: 3px solid #fff4; background: #fff1; color: inherit; cursor: pointer; }
.gender-btn.on { border-color: var(--gold); background: #ffd16633; }
.setup .look { text-align: left; margin: 10px 0 14px; }

/* ---------- escenas en pixel art ---------- */
.scene {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  image-rendering: pixelated;
  border-radius: 14px;
  border: 3px solid #1a1c2c;
  box-shadow: 0 6px 0 #0006;
  margin-bottom: 10px;
}
.scene.hero { max-width: 420px; margin: 0 auto 8px; }
.home h1, .story h2, .card h2 { font-family: 'Pixelify Sans', 'Baloo 2', sans-serif; letter-spacing: 1px; }

/* ---------- historia ---------- */
.story { text-align: center; }
.story p { margin: 0.6em 0; }
.story.intro { filter: saturate(0.6); }
.ready-row { display: flex; justify-content: center; gap: 10px; margin: 18px 0 14px; }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  top: 30%;
  left: 50%;
  z-index: 30;
  transform: translate(-50%, -50%);
  min-width: 70vw;
  max-width: 420px;
  padding: 18px 22px;
  border-radius: 24px;
  text-align: center;
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.15;
  color: #fff;
  pointer-events: none;
  animation: toast 0.35s cubic-bezier(0.3, 1.6, 0.6, 1);
  box-shadow: 0 10px 40px #0008;
}
#toast small { font-size: 1rem; font-weight: 700; opacity: 0.9; }
#toast.good { background: linear-gradient(160deg, #3ddc84, #1d9c55); }
#toast.bad { background: linear-gradient(160deg, #ff7a6c, #d23c4f); }
#toast.info { background: rgba(42, 23, 64, 0.95); font-size: 1.2rem; top: 18%; }

/* ---------- mundo ---------- */
#world {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  touch-action: none;
  display: block;
  background: #16301f;
}
body.playing { overflow: hidden; }
body.playing #topbar {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  background: rgba(20, 11, 46, 0.55);
}
.top-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  color: var(--text);
  border-radius: 999px;
  padding: 2px 12px;
  font: inherit;
  font-weight: 700;
}
#topbar .top-btn.exit { color: var(--muted); }

#ring { position: fixed; inset: 0; z-index: 15; }
.ring-btn {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: rgba(42, 23, 64, 0.92);
  color: #fff;
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 4px 14px #0008;
  animation: pop 0.2s;
  touch-action: none;
}
.ring-btn span { font-size: 1.5rem; }
.ring-btn small { font-size: 0.7rem; font-weight: 800; margin-top: 2px; }
.ring-btn.note.red { background: radial-gradient(circle at 35% 30%, #ff9aa6, #e04358 60%, #9e2835); }
.ring-btn.note.blue { background: radial-gradient(circle at 35% 30%, #a8e4ff, #41a6f6 60%, #1f5fa8); }
.ring-btn:active { transform: translate(-50%, -50%) scale(0.9); }

#banner {
  position: fixed;
  top: 54px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  padding: 6px 20px;
  border-radius: 999px;
  background: rgba(20, 11, 46, 0.8);
  color: var(--gold);
  font-weight: 800;
  font-size: 1.2rem;
  white-space: nowrap;
  pointer-events: none;
  animation: banner 2.6s ease-in-out forwards;
}

#panel {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(460px, calc(100vw - 32px));
  z-index: 25;
  background: #fbf1d8;
  color: #3a2614;
  border: 4px solid #8b5a2b;
  border-radius: 18px;
  padding: 14px 18px;
  box-shadow: 0 10px 30px #000a;
  animation: toast 0.3s cubic-bezier(0.3, 1.4, 0.6, 1);
}
#panel h3 { margin: 0 0 6px; }
#panel p { margin: 6px 0; }
.sign-text { font-size: 1.1rem; font-weight: 700; }
.panel-hint { text-align: right; font-size: 0.8rem; opacity: 0.6; margin: 4px 0 0 !important; }
.panel-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 10px; }

.pixel-avatar { width: 64px; height: 64px; image-rendering: pixelated; }
.me .pixel-avatar { width: 56px; height: 56px; vertical-align: middle; }

/* ---------- horizontal ---------- */
#rotate { display: none; }
@media (orientation: portrait) {
  body.playing:not(.portrait-ok) #rotate {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(20, 11, 46, 0.96);
    text-align: center;
    font-size: 1.4rem;
    font-weight: 800;
  }
}
.rotate-icon { font-size: 5rem; animation: rotate-hint 2s ease-in-out infinite; }
#rotate .btn { font-size: 1rem; opacity: 0.8; }
@keyframes rotate-hint { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
/* ---------- Puerta Parlante ---------- */
#talk {
  position: fixed;
  inset: 0;
  z-index: 22;
  display: grid;
  place-items: center;
  padding: 56px 16px 16px;
  background: rgba(10, 6, 24, 0.72);
  overflow-y: auto;
}
.talk-card {
  width: min(460px, 100%);
  background: linear-gradient(#e9e4d8, #cfc6b3);
  color: #2a2233;
  border: 5px solid #5f6a80;
  border-radius: 22px;
  padding: 14px 16px 12px;
  text-align: center;
  box-shadow: 0 12px 40px #000c;
  animation: toast 0.3s cubic-bezier(0.3, 1.4, 0.6, 1);
}
.talk-card header { display: flex; justify-content: space-between; font-weight: 800; font-size: 1.1rem; }
.talk-card .stars { font-size: 1.3rem; letter-spacing: 2px; }
.talk-card .stars i { font-style: normal; opacity: 0.4; }
.talk-role { margin: 10px 0 6px; font-size: 1.1rem; }
.talk-card b.jere { color: #c4561a; }
.talk-card b.jose { color: #1f7fb8; }
.secret {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  border-radius: 18px;
  padding: 8px;
  border: 3px dashed #8a95a8;
}
.secret span { font-size: 3.4rem; line-height: 1.1; }
.secret b { font-size: 2.2rem; line-height: 1.1; }
.banned-title { margin: 12px 0 6px; font-weight: 800; color: #b13e53; }
.banned { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.banned span {
  background: #ffe1e5;
  color: #9e2835;
  border: 2px solid #e04358;
  border-radius: 999px;
  padding: 2px 12px;
  font-weight: 800;
  text-decoration: line-through;
}
.talk-tip { font-size: 0.9rem; opacity: 0.75; margin: 10px 0; }
.options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0 14px; }
.option {
  font: inherit;
  font-weight: 800;
  font-size: 1rem;
  background: #fff;
  color: #2a2233;
  border: 3px solid #8a95a8;
  border-radius: 16px;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 4px 0 #8a95a8;
}
.option span { font-size: 2.2rem; line-height: 1.2; }
.option:active { transform: translateY(3px); box-shadow: 0 1px 0 #8a95a8; }
.btn.foul { background: #e04358; color: #fff; box-shadow: 0 5px 0 #9e2835; width: 100%; }
.talk-quit { margin-top: 10px; background: none; border: none; color: #566c86; font: inherit; text-decoration: underline; }

/* ---------- Canción del Despertar ---------- */
.talk-card.song { background: linear-gradient(#2a1f4f, #1b1036); color: var(--text); border-color: #ffd166; }
.song-canvas { display: block; width: 100%; height: 46vh; border-radius: 14px; background: #0e0a1c; touch-action: none; margin: 6px 0; }
.song-tap {
  width: 100%;
  font: inherit;
  font-weight: 800;
  font-size: 1.6rem;
  padding: 14px;
  border: none;
  border-radius: 18px;
  background: #ffd166;
  color: #2a1740;
  box-shadow: 0 6px 0 #c9921a;
  touch-action: none;
}
.song-tap:active { transform: translateY(5px); box-shadow: 0 1px 0 #c9921a; }
.song-help { font-size: 0.85rem; margin: 6px 0 0; color: var(--muted); }

/* ---------- Espejo Ardiente ---------- */
.mirror { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: min(300px, 100%); margin: 8px auto 4px; }
.mcell {
  position: relative;
  aspect-ratio: 1;
  font: inherit;
  font-size: 1.7rem;
  background: #2a1f4f;
  border: 3px solid #5d2e9b;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  padding: 0;
}
.mcell.fire { background: #5c2a1a; border-color: #ff8a3d; }
.mcell.tap:active { transform: scale(0.94); }
.mcell i { position: absolute; right: 3px; bottom: 0; font-style: normal; font-size: 0.9rem; font-weight: 800; }
.mcell i.ok { color: #3ddc84; }
.mcell i.bad { color: #ff5d6c; }

/* ---------- Runas y Pintor ---------- */
.rune-slots { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 10px 0 6px; }
.rune-slot {
  background: #fff;
  border: 3px solid #8a95a8;
  border-radius: 12px;
  padding: 4px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.rune-slot span { font-size: 1.8rem; line-height: 1.2; }
.rune-slot small { font-size: 0.62rem; font-weight: 700; opacity: 0.75; line-height: 1.1; text-align: center; }
.rune-slot.mine { background: #fff7d6; }
.rune-slot.current { border-color: #9b5de5; box-shadow: 0 0 0 3px #9b5de566; }
.rune-slot.done { opacity: 0.55; }
.rune-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rune-key {
  font: inherit;
  font-weight: 800;
  font-size: 0.8rem;
  background: #fff;
  color: #2a2233;
  border: 3px solid #9b5de5;
  border-radius: 14px;
  padding: 4px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 4px 0 #5d2e9b;
}
.rune-key span { font-size: 1.7rem; line-height: 1.2; }
.rune-key:disabled { opacity: 0.35; box-shadow: none; }
.rune-key:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #5d2e9b; }
canvas.paint {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #fff;
  border: 3px solid #8b5a2b;
  border-radius: 12px;
  touch-action: none;
  margin: 6px 0 8px;
}
canvas.paint.watch { border-style: dashed; }
.paint-tools { display: flex; gap: 8px; justify-content: center; }
.paint-hint { font-weight: 800; letter-spacing: 2px; color: #9b5de5; white-space: nowrap; }
.paint-guess { display: flex; gap: 8px; }
.paint-msg { min-height: 1.3em; margin: 6px 0 0; font-weight: 700; color: #9e2835; }
.paint-guess input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-weight: 800;
  font-size: 1.1rem;
  border: 3px solid #8b5a2b;
  border-radius: 12px;
  padding: 6px 10px;
  user-select: text;
  -webkit-user-select: text;
}
.paint-word { font-size: 1.2rem; color: #9b5de5; }

/* ---------- animaciones ---------- */
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -10px); } 12%, 80% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
@keyframes float { 50% { transform: translateY(-10px); } }
@keyframes blink { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }
@keyframes pop { 0% { transform: scale(0.4); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
@keyframes pulse { 50% { box-shadow: 0 0 35px var(--gold); filter: brightness(1.2); } }
@keyframes glow { 50% { box-shadow: 0 0 60px #b48cffcc, inset 0 0 30px #fff5; } }
@keyframes keeper { 0%, 100% { transform: translateX(-90%); } 50% { transform: translateX(-10%); } }
@keyframes zzz { 50% { transform: translate(6px, -10px); } }
@keyframes toast { from { transform: translate(-50%, -50%) scale(0.5); opacity: 0; } }

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

/* Celular acostado (va al final para ganarle a los estilos base) */
@media (orientation: landscape) and (max-height: 500px) {
  body.playing #topbar { padding: 4px 12px; font-size: 0.8rem; gap: 8px; }
  #banner { top: 40px; font-size: 1rem; }
  #talk { padding: 36px 12px 8px; align-items: start; }
  .talk-card { width: min(760px, 100%); padding: 8px 14px; border-width: 4px; }
  .talk-role { margin: 4px 0; font-size: 1rem; }
  .secret { flex-direction: row; justify-content: center; gap: 14px; padding: 4px; }
  .secret span { font-size: 2.4rem; }
  .secret b { font-size: 1.8rem; }
  .banned-title { margin: 6px 0 4px; }
  .talk-tip { margin: 4px 0 6px; font-size: 0.8rem; }
  .options { grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 6px 0 8px; }
  .option { font-size: 0.85rem; padding: 4px 2px; }
  .option span { font-size: 1.8rem; }
  .btn.foul, #passBtn { padding: 8px 16px; font-size: 1rem; }
  .talk-quit { margin-top: 4px; }
}

/* Historia e inicio con el celu acostado: escena a la izquierda, texto a la derecha */
@media (orientation: landscape) and (max-height: 500px) {
  #screen { max-width: 900px; padding-top: 8px; }
  .story {
    display: grid;
    grid-template-columns: minmax(0, 40%) minmax(0, 1fr);
    grid-template-rows: auto;
    column-gap: 18px;
    align-items: center;
    text-align: left;
    padding: 14px 18px;
  }
  .story .scene { grid-row: 1 / span 20; margin: 0; }
  .story h2 { text-align: left; margin-top: 0; }
  .story p { margin: 0.3em 0; font-size: 0.86rem; line-height: 1.25; }
  .story h2 { font-size: 1.4rem; }
  .story .btn.big { padding: 10px; font-size: 1.15rem; }
  .story .ready-row { justify-content: flex-start; margin: 8px 0; }
  .home {
    display: grid;
    grid-template-columns: minmax(0, 46%) minmax(0, 1fr);
    column-gap: 22px;
    align-items: center;
    padding-top: 2vh;
  }
  .home .scene.hero { grid-row: 1 / span 10; margin: 0; }
  .home h1 { font-size: 2.1rem; }
  .home .lead { margin: 6px 0 12px; }
  .home .or { margin: 12px 0 8px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .story .worlds { margin: 0 0 4px; }
  .world img { display: none; }
  .world { padding: 4px 8px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .game-pintor { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; align-items: start; }
  .game-pintor header, .game-pintor .talk-role { grid-column: 1 / -1; }
  .game-pintor canvas.paint { grid-row: span 3; aspect-ratio: 4 / 3; max-height: 62vh; width: auto; margin: 0 auto; }
  .game-pintor .options { grid-template-columns: repeat(3, 1fr); margin: 0; }
  .rune-slot span { font-size: 1.4rem; }
  .rune-keys { grid-template-columns: repeat(8, 1fr); }
  .rune-key span { font-size: 1.3rem; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .talk-card.song { display: grid; grid-template-columns: 1.4fr 1fr; column-gap: 12px; align-items: center; width: min(820px, 100%); }
  .talk-card.song header { grid-column: 1 / -1; }
  .song-canvas { grid-row: span 2; height: 70vh; margin: 0; }
  .song-tap { height: 42vh; font-size: 2rem; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .game-espejo { display: grid; grid-template-columns: 1fr auto; column-gap: 14px; align-items: center; }
  .game-espejo header { grid-column: 1 / -1; }
  .mirror { width: 60vh; margin: 0; grid-row: span 2; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .talk-card.game-balsa { display: grid; grid-template-columns: 1.4fr 1fr; column-gap: 12px; align-items: center; width: min(820px, 100%); }
  .game-balsa header { grid-column: 1 / -1; }
  .game-balsa .song-canvas { grid-row: span 2; height: 70vh; margin: 0; }
  .game-balsa .song-tap { height: 42vh; font-size: 1.8rem; }
}
.game-balsa .song-help { color: #566c86; }

/* ---------- contador y récords ---------- */
#topbar .clock { font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }
.result { background: #0003; border-radius: 14px; padding: 8px 12px; margin: 8px 0; }
.result p { margin: 2px 0 !important; }
.result-time { font-size: 1.1rem; }
.result-record { color: var(--gold); font-weight: 800; font-size: 1.2rem; animation: pop 0.5s; }
.result-title { font-size: 0.85rem; color: var(--muted); margin-top: 6px !important; }
.records { margin: 2px 0 0; padding-left: 0; list-style: none; font-size: 0.9rem; }
.records li { padding: 1px 0; }
.records li.mine { color: var(--gold); }
.records small { color: var(--muted); }

/* ---------- pistas y candados ---------- */
.clue h3 { margin: 0 0 6px; }
.clue-pic { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; font-size: 2rem; background: #fff; border: 4px solid #8b5a2b; border-radius: 8px; padding: 8px; }
.clue-text { font-size: 1.2rem; font-weight: 700; }
.clue-math { font-size: 2rem; font-weight: 800; text-align: center; }
.clue-candles { display: flex; gap: 14px; justify-content: center; }
.candle { display: flex; flex-direction: column; align-items: center; }
.candle span { width: 22px; height: 44px; border-radius: 6px; border: 3px solid #1a1c2c; box-shadow: 0 -10px 12px #ffcd75; }
.clue-table { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-size: 1.2rem; }
.swatch-sm { display: inline-block; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #1a1c2c; vertical-align: middle; }
.clue-note { font-size: 0.85rem; opacity: 0.8; }
.wheels { display: flex; gap: 12px; justify-content: center; margin: 8px 0; }
.wheel { display: flex; flex-direction: column; align-items: center; background: #fff; border: 3px solid #8b5a2b; border-radius: 12px; padding: 4px 8px; }
.wheel b { font-size: 2.2rem; line-height: 1.1; min-width: 1.2em; text-align: center; }
.wheel button { font: inherit; font-size: 1.2rem; background: none; border: none; color: #8b5a2b; padding: 4px 10px; }
#panel.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(calc(-50% - 10px)); } 40%, 80% { transform: translateX(calc(-50% + 10px)); } }

/* ---------- inventario ---------- */
#topbar .inv { display: flex; gap: 4px; }
.inv-item { font-size: 1.1rem; background: #ffffff22; border: 1px solid var(--card-border); border-radius: 8px; padding: 0 6px; }

/* ---------- mensaje cifrado ---------- */
.cipher-msg { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 8px 0; }
.cipher-msg span { font-size: 2.2rem; background: #2a1f4f; color: #ffd166; border-radius: 10px; min-width: 52px; text-align: center; padding: 4px 6px; }
.cipher-table { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0; font-size: 1.2rem; }
.cipher-table div { background: #fff; border: 2px solid #9b5de5; border-radius: 10px; padding: 2px 6px; text-align: center; }
.cipher-table span { font-size: 1.4rem; color: #5d2e9b; }
