/* Mi Terapia Virtual v39 — Gemas de colores (gemas.html) */
body.portada.gm-body { background: linear-gradient(180deg, #FFF6EA, #FBE9D6); min-height: 100%; color: #3d3360; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; overscroll-behavior: none; }
.gm-view { box-sizing: border-box; }
.gm-view[hidden] { display: none !important; }
.gm-menu, .gm-gal { padding: calc(0.9rem + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right)) calc(1.5rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left)); max-width: 1180px; margin: 0 auto; }
.gm-head { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.gm-back { margin: 0; font-size: 1.15rem; padding: 0.55rem 1.1rem; cursor: pointer; font-family: inherit; }
.gm-title { flex: 1 1 320px; min-width: 0; }
.gm-title h1 { margin: 0; font-size: 2.1rem; line-height: 1.1; color: #3d3360; }
.gm-sub { margin: 0.2rem 0 0; font-size: 1.05rem; color: #6b5d7a; }
.gm-hbtns { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.gm-b { font: inherit; font-weight: 800; font-size: 1.1rem; min-height: 54px; min-width: 54px; padding: 0 16px; border-radius: 16px; border: 3px solid #E8D5C0; background: #fff; color: #3d3360; cursor: pointer; touch-action: manipulation; box-shadow: 0 3px 8px rgba(120,80,40,.1); }
.gm-b:active { transform: scale(.97); }
.gm-snd.off { opacity: .6; }
.gm-big { display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0.4rem auto 1.1rem; width: min(520px, 100%); min-height: 96px; border: 4px solid #fff; border-radius: 30px; background: linear-gradient(160deg, #FFB86B, #FF8FA3); color: #fff; font: inherit; cursor: pointer; box-shadow: 0 8px 22px rgba(220,110,90,.3); touch-action: manipulation; }
.gm-big-n { font-size: 2.2rem; font-weight: 900; line-height: 1.1; text-shadow: 0 2px 0 rgba(0,0,0,.12); }
.gm-big-d { font-size: 1.2rem; font-weight: 800; background: rgba(255,255,255,.3); border-radius: 99px; padding: 0.1rem 0.9rem; margin-top: 0.2rem; }
.gm-chaps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.gm-chap { background: rgba(255,255,255,.75); border: 3px solid #fff; border-radius: 24px; padding: 0.8rem; box-shadow: 0 5px 16px rgba(120,80,40,.1); }
.gm-chap h2 { margin: 0 0 0.6rem; font-size: 1.3rem; color: #5E4E92; }
.gm-chap h2 small { font-size: 0.95rem; color: #8a7a99; font-weight: 700; }
.gm-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.55rem; }
.gm-tile { aspect-ratio: 1; border-radius: 18px; border: 3px solid #EADCF7; background: #F7F2FF; display: flex; align-items: center; justify-content: center; font: inherit; font-size: 1.8rem; font-weight: 900; color: #8a7a99; cursor: pointer; padding: 4px; position: relative; touch-action: manipulation; min-height: 64px; }
.gm-tile canvas { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.gm-tile.done { background: #fff; border-color: #9ED9C3; }
.gm-tile.next { background: linear-gradient(160deg, #FFE9A8, #FFD27A); border-color: #fff; color: #7a4a10; box-shadow: 0 0 0 3px #FFB86B; animation: gmPulse 1.8s ease-in-out infinite; }
.gm-tile.prog::after { content: '⏸'; position: absolute; right: 4px; bottom: 2px; font-size: 1rem; }
.gm-tile.locked { opacity: .55; }
.gm-tile.locked::after { content: '🔒'; position: absolute; right: 4px; bottom: 2px; font-size: 0.9rem; }
@keyframes gmPulse { 50% { transform: scale(1.05); } }
@media (max-width: 900px) and (orientation: portrait) { .gm-chaps { grid-template-columns: 1fr; } .gm-tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

/* ---------- juego ---------- */
.gm-play { position: fixed; inset: 0; display: flex; flex-direction: column; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.gm-hud { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.7rem; background: rgba(255,255,255,.7); border-bottom: 2px solid #F3E2CF; }
.gm-hname { font-weight: 900; font-size: 1.3rem; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-prog { font-weight: 800; font-size: 1.15rem; background: #fff; border-radius: 99px; padding: 0.3rem 0.9rem; border: 2px solid #E8D5C0; white-space: nowrap; }
.gm-main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 0.5rem; padding: 0.5rem; }
.gm-boardwrap { flex: 1 1 auto; min-height: 0; position: relative; }
.gm-vp { position: absolute; inset: 0; overflow: hidden; touch-action: none; border-radius: 22px; background: rgba(255,255,255,.55); border: 3px solid #fff; }
.gm-zoom { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.gm-zoom canvas { display: block; }
.gm-zbtns { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 6px; }
.gm-z { min-width: 54px; padding: 0; font-size: 1.5rem; opacity: .92; }
.gm-side { flex: 0 0 auto; display: flex; flex-direction: column; gap: 0.5rem; box-sizing: border-box; min-width: 0; }
.gm-traybox { flex: 0 0 auto; background: rgba(255,255,255,.85); border: 3px solid #fff; border-radius: 20px; padding: 0.35rem 0.5rem 0.5rem; box-shadow: 0 4px 12px rgba(120,80,40,.1); }
.gm-traylab { display: flex; justify-content: space-between; font-weight: 800; color: #6b5d7a; font-size: 1rem; margin: 0 0.2rem 0.25rem; }
.gm-tray { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; max-width: 760px; margin: 0 auto; touch-action: manipulation; }
.gm-slot { aspect-ratio: 1; border-radius: 10px; background: #F4ECE2; border: 2px dashed #E3D2C0; display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; min-width: 0; }
.gm-slot .gm-gem { width: 90%; height: 90%; pointer-events: none; }
.gm-slot.sel { background: #FFE9A8; border: 2px solid #FFB86B; }
.gm-tray.shake { animation: gmShake .45s; }
.gm-traybox.warn { box-shadow: 0 0 0 4px #FFB4A2; }
@keyframes gmShake { 20% { transform: translateX(-9px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }
.gm-acts { display: flex; gap: 0.5rem; }
.gm-act { flex: 1 1 0; font: inherit; font-weight: 900; font-size: 1.15rem; min-height: 60px; border-radius: 18px; border: 3px solid #fff; background: linear-gradient(160deg, #F0E8FC, #E2D5F7); color: #3d3360; cursor: pointer; touch-action: manipulation; box-shadow: 0 3px 10px rgba(80,60,120,.12); }
.gm-act:nth-child(2) { background: linear-gradient(160deg, #FFF1C9, #FCE3A6); }
.gm-act:nth-child(3) { background: linear-gradient(160deg, #E4F8EF, #C8EEDC); }
.gm-act:disabled { opacity: .45; }
.gm-act.pulse { animation: gmPulse 1s ease-in-out 3; box-shadow: 0 0 0 4px #FFB86B; }
@media (orientation: landscape) {
  .gm-main { display: grid; grid-template-columns: minmax(0, 1fr) 190px; grid-template-rows: minmax(0, 1fr) auto; }
  .gm-boardwrap { grid-column: 1; grid-row: 1; }
  .gm-traybox { grid-column: 1; grid-row: 2; }
  .gm-side { grid-column: 2; grid-row: 1 / 3; justify-content: center; }
  .gm-acts { flex-direction: column; }
  .gm-tray { max-width: 640px; }
}
.gm-gem { display: block; background-size: 100% 100%; background-repeat: no-repeat; }
.gm-fly { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
.gm-fly .gm-gem { position: absolute; left: 0; top: 0; }
.gm-glow { position: absolute; border-radius: 30%; pointer-events: none; box-shadow: 0 0 0 3px rgba(255,255,255,.95), 0 0 16px 6px rgba(255,235,150,.9); animation: gmGlow .45s ease-out forwards; }
@keyframes gmGlow { from { transform: scale(.6); opacity: 1; } to { transform: scale(1.5); opacity: 0; } }
/* ajustes de música */
.gm-mlist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; margin: 0.6rem 0; }
.gm-mopt { font: inherit; font-weight: 800; font-size: 1.15rem; min-height: 60px; border-radius: 16px; border: 3px solid #E8D5C0; background: #fff; color: #3d3360; cursor: pointer; text-align: left; padding: 0 14px; }
.gm-mopt.on { background: #FFE9A8; border-color: #3d3360; }
.gm-vol { display: flex; align-items: center; gap: 0.6rem; font-weight: 800; font-size: 1.15rem; margin: 0.6rem 0; justify-content: center; }
.gm-vol input { width: 60%; height: 44px; accent-color: #FF8FA3; }

/* ---------- modal (fin, galería, aviso) ---------- */
.gm-modal { position: fixed; inset: 0; background: rgba(45,38,64,.45); display: none; z-index: 50; align-items: center; justify-content: center; padding: 14px; }
.gm-modal.on { display: flex; }
.gm-card { background: #FFFDF8; border-radius: 28px; padding: 1.2rem 1.4rem; max-width: 640px; width: 100%; max-height: 100%; overflow: auto; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.gm-card h2 { margin: 0.2rem 0 0.4rem; font-size: 2rem; color: #3d3360; }
.gm-card p { font-size: 1.3rem; line-height: 1.4; margin: 0.4rem 0 0.8rem; color: #4d4060; }
.gm-card canvas { max-width: 100%; max-height: 52vh; image-rendering: pixelated; }

.gm-card h3 { margin: 0.8rem 0 0.2rem; color: #5E4E92; font-size: 1.25rem; }
.gm-card .gm-btns { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; margin-top: 0.6rem; }
.gm-card .gm-b { min-height: 62px; font-size: 1.25rem; }
.gm-card .gm-b.go { background: linear-gradient(160deg, #DFF5E8, #BFEBD5); border-color: #9ED9C3; }
.gm-fin canvas { animation: gmShine 1.6s ease-in-out infinite alternate; border-radius: 12px; }
@keyframes gmShine { from { filter: brightness(1) drop-shadow(0 0 0 #fff6); } to { filter: brightness(1.12) drop-shadow(0 0 14px #FFE38A); } }
.gm-confetti { position: fixed; top: -30px; width: 22px; height: 22px; z-index: 55; pointer-events: none; animation: gmFall linear forwards; }
@keyframes gmFall { to { transform: translateY(110vh) rotate(540deg); } }
.gm-galgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.9rem; }
.gm-galitem { background: #fff; border: 3px solid #fff; border-radius: 22px; padding: 0.7rem; display: flex; flex-direction: column; align-items: center; gap: 0.4rem; font: inherit; font-weight: 800; font-size: 1.1rem; color: #3d3360; cursor: pointer; box-shadow: 0 5px 14px rgba(120,80,40,.12); }
.gm-galitem canvas { width: 100%; height: 150px; object-fit: contain; image-rendering: pixelated; }
.gm-galitem.empty { opacity: .45; cursor: default; }
.gm-galitem.empty span.q { height: 150px; display: flex; align-items: center; font-size: 3rem; }
.gm-vp.shake, #p-vp.shake { animation: gmShake .45s; }
.gm-slot.pick { background: #CFE2FF; border: 3px solid #2878FF; }
.gm-slot.pick .gm-gem { transform: translateY(-3px) scale(1.06); }
.gm-traybox.hintd { box-shadow: 0 0 0 5px #3CC07A; }
/* avisos arriba, sin tapar el centro del dibujo */
.gm-body .flash { top: 66px; transform: translate(-50%, 0); max-width: 88vw; font-size: 1.1rem; padding: 0.55rem 1.1rem; background: rgba(61,51,96,.9); text-align: center; }
