:root {
  --ink: #14122b;
  --panel: #1e1a3d;
  --panel-2: #272250;
  --line: #3a3470;
  --text: #ece9ff;
  --muted: #a8a4d0;
  --coin: #ffc53d;
  --teal: #3de0c6;
  --pink: #ff5c7a;
  --nav-h: 56px;
  --bs-body-bg: var(--ink);
  --bs-body-color: var(--text);
  --bs-border-color: var(--line);
  --bs-link-color: var(--teal);
  --bs-link-hover-color: #8af2e1;
}
body { background: var(--ink); color: var(--text); font-family: 'Nunito Sans', system-ui, sans-serif; font-size: 1rem; line-height: 1.55; }
h1, h2, h3, h4, h5, h6, .gm-brand, .gm-title { font-family: 'Chakra Petch', system-ui, sans-serif; font-weight: 600; letter-spacing: .01em; }
.text-muted { color: var(--muted) !important; }
:focus-visible { outline: 3px solid var(--coin); outline-offset: 2px; }

/* Navegación */
.gm-nav { background: var(--panel); border-bottom: 2px solid var(--line); min-height: var(--nav-h); }
.gm-brand { display: flex; align-items: center; gap: .6rem; color: var(--text) !important; font-size: 1.25rem; }
.gm-logo { display: grid; grid-template-columns: 9px 9px; gap: 2px; }
.gm-logo i { display: block; width: 9px; height: 9px; background: var(--teal); }
.gm-logo i:nth-child(2) { background: var(--coin); }
.gm-logo i:nth-child(3) { background: var(--pink); }
.gm-logo i:nth-child(4) { background: var(--line); }
.gm-nav .nav-link { color: var(--muted); }
.gm-nav .nav-link:hover { color: var(--text); }
.gm-user { color: var(--muted); font-size: .95rem; }

/* Botones y paneles */
.gm-btn-primary { background: var(--coin); border: 0; color: #2a2100; font-weight: 700; box-shadow: 0 3px 0 #b8861a; }
.gm-btn-primary:hover, .gm-btn-primary:focus { background: #ffd366; color: #2a2100; }
.gm-btn-primary:active { transform: translateY(2px); box-shadow: 0 1px 0 #b8861a; }
.gm-btn-primary:disabled { background: #6b5a2a; color: #b9ab80; box-shadow: none; }
.gm-panel { background: var(--panel); border: 2px solid var(--line); border-radius: 6px; padding: 1.5rem; }
.gm-game { display: flex; flex-direction: column; }
.gm-empty { color: var(--muted); padding: 1rem 0; margin: 0; }
.gm-list li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 0; border-top: 1px solid var(--line); }
.gm-list li:first-child { border-top: 0; padding-top: 0; }
.gm-list code, .gm-code { color: var(--teal); }
.gm-auth { max-width: 440px; padding: 3rem 1rem; }
.form-control, .form-select { background-color: var(--ink); border-color: var(--line); }
.form-control:focus, .form-select:focus { border-color: var(--teal); box-shadow: 0 0 0 .2rem rgba(61,224,198,.2); background-color: var(--ink); }

/* Portada */
.gm-home { padding-top: 4rem; padding-bottom: 4rem; }
.gm-title { font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.08; }
.gm-lead { color: var(--muted); max-width: 34rem; }
.gm-features p { color: var(--muted); }
.gm-stage { background: var(--panel); border: 2px solid var(--line); border-radius: 6px; padding: 14px; }
.gm-stage-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.gm-face { aspect-ratio: 4/3; background: var(--panel-2); border-radius: 4px; position: relative; }
.gm-face::after { content: ''; position: absolute; left: 50%; top: 34%; width: 34%; aspect-ratio: 1; transform: translateX(-50%); border-radius: 50%; background: var(--line); }
.gm-face.f1::after { background: var(--teal); } .gm-face.f2::after { background: var(--pink); } .gm-face.f3::after { background: var(--coin); }
.gm-stage-game { position: relative; height: 210px; background: #1d1a3a; border-radius: 4px; overflow: hidden; }
.gm-stage-game .floor { position: absolute; left: 0; right: 0; bottom: 0; height: 34px; background: #3a3470; border-top: 7px solid var(--teal); }
.gm-stage-game .plat { position: absolute; height: 18px; background: #3a3470; border-top: 6px solid var(--teal); }
.gm-stage-game .p1 { left: 18%; width: 90px; bottom: 80px; } .gm-stage-game .p2 { left: 58%; width: 110px; bottom: 112px; }
.gm-stage-game .coin { position: absolute; width: 16px; height: 16px; border-radius: 50%; background: var(--coin); box-shadow: inset -3px -3px 0 #e09b00; }
.gm-stage-game .c1 { left: 26%; bottom: 112px; } .gm-stage-game .c2 { left: 66%; bottom: 144px; } .gm-stage-game .c3 { left: 74%; bottom: 144px; }
.gm-stage-game .hero { position: absolute; left: 9%; bottom: 41px; width: 22px; height: 28px; border-radius: 6px; background: var(--teal); animation: hop 1.8s ease-in-out infinite; }
@keyframes hop { 0%, 55%, 100% { transform: translateY(0); } 25% { transform: translateY(-46px); } }

/* Canvas de Phaser */
.gm-canvas { width: 100%; aspect-ratio: 2 / 1; background: #1d1a3a; border: 2px solid var(--line); border-radius: 6px; overflow: hidden; }
.gm-canvas canvas { display: block; }

/* Editor */
.gm-editor { display: grid; grid-template-columns: 190px 1fr; gap: 1rem; align-items: start; }
.gm-tools { background: var(--panel); border: 2px solid var(--line); border-radius: 6px; padding: .75rem; display: grid; gap: .4rem; }
.gm-tool { display: flex; align-items: center; gap: .6rem; background: transparent; border: 2px solid transparent; color: var(--text); border-radius: 4px; padding: .45rem .55rem; text-align: left; }
.gm-tool:hover { background: var(--panel-2); }
.gm-tool.active { border-color: var(--coin); background: var(--panel-2); }
.sw { width: 20px; height: 20px; border-radius: 3px; flex: none; }
.sw-ground { background: linear-gradient(var(--teal) 0 35%, #3a3470 35%); }
.sw-coin { background: var(--coin); border-radius: 50%; }
.sw-enemy { background: var(--pink); border-radius: 6px; }
.sw-spike { background: linear-gradient(135deg, transparent 50%, #d7d4ff 50%); clip-path: polygon(0 100%, 50% 15%, 100% 100%); background: #d7d4ff; }
.sw-start { background: var(--teal); border-radius: 5px; width: 14px; margin: 0 3px; }
.sw-goal { background: linear-gradient(90deg, #d7d4ff 0 15%, transparent 15%), linear-gradient(135deg, var(--coin) 50%, transparent 50%); }
.sw-erase { background: transparent; border: 2px dashed var(--muted); }
.gm-modal { background: var(--panel); border: 2px solid var(--line); }

/* Sala */
.page-room { overflow: hidden; }
.gm-room { display: grid; grid-template-columns: minmax(0, 1fr) 340px; height: calc(100vh - var(--nav-h)); height: calc(100dvh - var(--nav-h)); }
.gm-main { display: flex; flex-direction: column; min-height: 0; padding: .75rem; gap: .75rem; }
.gm-roombar { display: flex; align-items: center; }
.min-w-0 { min-width: 0; }
.gm-code { background: none; border: 0; padding: 0; font-family: 'Chakra Petch', monospace; font-size: .9rem; cursor: pointer; }
.gm-code::after { content: ' · copiar'; color: var(--muted); font-size: .8rem; }
.gm-code[data-copied]::after { content: ' · copiado'; color: var(--coin); }
.gm-tiles { flex: 1; min-height: 0; display: grid; gap: .6rem; grid-template-columns: 1fr; grid-auto-rows: 1fr; }
.gm-tiles[data-count="2"], .gm-tiles[data-count="3"], .gm-tiles[data-count="4"] { grid-template-columns: repeat(2, 1fr); }
.gm-tiles[data-count="5"], .gm-tiles[data-count="6"], .gm-tiles[data-count="7"], .gm-tiles[data-count="8"], .gm-tiles[data-count="9"] { grid-template-columns: repeat(3, 1fr); }
.gm-tile { position: relative; background: var(--panel-2); border: 2px solid var(--line); border-radius: 6px; overflow: hidden; min-height: 0; display: flex; align-items: center; justify-content: center; }
.gm-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; }
.gm-tile.has-video video { opacity: 1; }
.gm-tile video.mirror { transform: scaleX(-1); }
.gm-avatar { width: 64px; height: 64px; border-radius: 12px; background: var(--teal); color: #08352d; display: grid; place-items: center; font: 700 1.8rem 'Chakra Petch', sans-serif; }
.gm-tilename { position: absolute; left: 8px; bottom: 8px; background: rgba(20,18,43,.8); padding: 2px 8px; border-radius: 3px; font-size: .85rem; }
.gm-controls { display: flex; justify-content: center; flex-wrap: wrap; gap: .5rem; }
.gm-ctl { background: var(--panel-2); color: var(--text); border: 2px solid var(--line); border-radius: 4px; padding: .5rem 1rem; text-decoration: none; font-weight: 600; }
.gm-ctl:hover:not(:disabled) { border-color: var(--teal); color: var(--text); }
.gm-ctl.off { background: #4a2233; border-color: var(--pink); }
.gm-ctl:disabled { opacity: .5; }
.gm-ctl-leave { background: var(--pink); border-color: var(--pink); color: #2a0510; }
.gm-ctl-leave:hover { background: #ff829a; color: #2a0510 !important; }

.gm-gamestage { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: .5rem; }
.gm-gamebar { display: flex; justify-content: space-between; align-items: center; }
.gm-gamestage .gm-canvas { flex: 1; min-height: 0; aspect-ratio: auto; }
.game-open .gm-tiles { flex: none; height: 96px; display: flex; overflow-x: auto; }
.game-open .gm-tile { flex: 0 0 140px; }
.game-open .gm-avatar { width: 40px; height: 40px; font-size: 1.2rem; }

.gm-side { background: var(--panel); border-left: 2px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.gm-tabs { padding: .6rem; gap: .4rem; }
.gm-tabs .nav-link { color: var(--muted); border-radius: 4px; }
.gm-tabs .nav-link.active { background: var(--coin); color: #2a2100; font-weight: 700; }
.gm-tabcontent { flex: 1; min-height: 0; display: flex; }
.gm-tabcontent .tab-pane { flex: 1; min-height: 0; overflow-y: auto; }
.gm-tabcontent .tab-pane.active { display: flex; flex-direction: column; }
#tabGame.active { display: block; }
.gm-chatlog { flex: 1; overflow-y: auto; padding: .75rem; display: flex; flex-direction: column; gap: .5rem; }
.gm-msg { display: flex; flex-direction: column; max-width: 90%; background: var(--panel-2); border-radius: 6px; padding: .4rem .6rem; align-self: flex-start; overflow-wrap: anywhere; }
.gm-msg .who { font-size: .75rem; color: var(--teal); }
.gm-msg.mine { align-self: flex-end; background: #3a3470; }
.gm-msg.mine .who { color: var(--coin); }
.gm-chatform { display: flex; gap: .5rem; padding: .6rem; border-top: 2px solid var(--line); }
.gm-board { padding-left: 1.2rem; margin-bottom: 1rem; }

@media (max-width: 900px) {
  .page-room { overflow: auto; }
  .gm-room { grid-template-columns: 1fr; height: auto; }
  .gm-main { height: 70vh; }
  .gm-side { border-left: 0; border-top: 2px solid var(--line); height: 60vh; }
  .gm-editor { grid-template-columns: 1fr; }
  .gm-tools { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .gm-tools p { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { .gm-stage-game .hero { animation: none; } * { scroll-behavior: auto !important; transition: none !important; } }
.gm-board li.text-muted { list-style: none; margin-left: -1.2rem; }
