/* PixelLoop · pantalla de juego */

.page-game { overflow: hidden; }
.app {
  position: relative; height: 100dvh; display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 1fr 340px;
  grid-template-areas: "top top" "stage side" "dock side";
}

.topbar {
  grid-area: top; display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); background: var(--panel); min-width: 0;
}
.war-bar { display: flex; align-items: center; gap: 18px; flex: 1; min-width: 0; }
.war { display: flex; align-items: center; gap: 10px; min-width: 0; }
.war__title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.war__clock { font-size: 17px; font-weight: 700; }
.budget { display: flex; align-items: center; gap: 8px; margin-left: auto; padding: 4px 12px 4px 8px; background: var(--panel-2); border-radius: 999px; }
.budget__icon { width: 14px; height: 14px; background: var(--accent); box-shadow: 4px 4px 0 #ff5f6a; margin-right: 4px; }
.budget__count { font-weight: 800; }
.budget__meter { width: 70px; height: 6px; background: var(--panel-3); border-radius: 3px; overflow: hidden; }
.budget__fill { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.budget__next { font-size: 12px; color: var(--muted); min-width: 76px; }
.war-bar.is-empty .budget__count { color: var(--warn); }
.account { display: flex; align-items: center; gap: 8px; }
.account__name { font-weight: 600; color: var(--muted); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stage { grid-area: stage; position: relative; min-height: 0; overflow: hidden; }
.stage__canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; display: block; }
body[data-mode="view"] .stage__canvas { cursor: grab; }
.stage__coach { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); pointer-events: none; width: max-content; max-width: calc(100% - 24px); }
.stage__status { position: absolute; left: 12px; top: 12px; }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: rgba(14, 13, 19, .8); }
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(79, 209, 139, .25); }
.conn[data-state="offline"]::before { background: var(--danger); box-shadow: 0 0 0 3px rgba(255, 95, 106, .25); }
.conn[data-state="resyncing"]::before { background: var(--warn); }
.stage__zoom { position: absolute; right: 12px; bottom: 12px; display: grid; gap: 6px; }
.stage__zoom .btn { background: rgba(32, 29, 43, .92); }

.coach { display: flex; gap: 6px; margin: 0; padding: 6px; list-style: none; background: rgba(23, 21, 31, .94); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); transition: opacity .4s; }
.coach__step { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; color: var(--faint); font-weight: 600; font-size: 14px; white-space: nowrap; }
.coach__num { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--panel-3); font-size: 13px; }
.coach__step.is-current { background: var(--accent); color: var(--accent-ink); }
.coach__step.is-current .coach__num { background: rgba(0, 0, 0, .15); }
.coach__step.is-done { color: var(--ok); }
.coach__step.is-done .coach__num { background: rgba(79, 209, 139, .2); }
.coach.is-finished { opacity: 0; }
body[data-coach-step="color"] .palette { animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 50% { box-shadow: 0 0 0 3px var(--accent); } }

.confirm-bar {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 6px 6px 12px; box-shadow: var(--shadow);
}
.confirm-bar__swatch { width: 22px; height: 22px; border-radius: 5px; border: 2px solid #fff; }
.confirm-bar__text { font-size: 13px; color: var(--muted); white-space: nowrap; }
.closed-banner { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--info); padding: 10px 16px; border-radius: 999px; font-weight: 600; }

.side { grid-area: side; display: flex; flex-direction: column; gap: 14px; padding: 14px; border-left: 1px solid var(--line); background: var(--panel); overflow-y: auto; min-height: 0; }
.player-card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.player-card__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.player-card__canvas { display: block; width: 100%; aspect-ratio: var(--canvas-aspect, 16 / 9); image-rendering: pixelated; background: #000; border-radius: 6px; }
.player-card__pitch { margin: 10px 0 8px; font-size: 14px; color: var(--muted); }
.player-card__pitch strong { color: var(--ink); }
.fps { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.fps input { flex: 1; accent-color: var(--accent); }

.frame-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.frame-tab { position: relative; padding: 4px; border-radius: var(--radius-sm); border: 2px solid var(--line); background: var(--bg); cursor: pointer; }
.frame-tab__thumb { display: block; width: 100%; aspect-ratio: var(--canvas-aspect, 16 / 9); image-rendering: pixelated; border-radius: 3px; }
.frame-tab__label { position: absolute; left: 7px; top: 6px; font-size: 11px; font-weight: 800; background: rgba(14, 13, 19, .8); padding: 0 5px; border-radius: 4px; }
.frame-tab.is-active { border-color: var(--accent); }
.frame-tab.is-playing::after { content: ""; position: absolute; right: 7px; top: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }

.tools { display: grid; gap: 12px; }
.tools__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.tools__label { font-weight: 600; font-size: 14px; }
.onion-legend { display: flex; gap: 10px; font-size: 12px; color: var(--muted); }
.onion-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.onion-legend .prev::before { background: rgb(255, 64, 96); }
.onion-legend .next::before { background: rgb(48, 170, 255); }
.side__links { margin-top: auto; display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.side__links a { color: var(--muted); }

.dock { grid-area: dock; min-width: 0; border-top: 1px solid var(--line); background: var(--panel); padding: 10px 16px; }
.palette { display: grid; grid-template-columns: repeat(16, 1fr); gap: 5px; max-width: 760px; margin: 0 auto; border-radius: var(--radius-sm); }
.swatch { aspect-ratio: 1; min-width: 0; border-radius: 6px; border: 2px solid rgba(255, 255, 255, .08); background: var(--swatch); cursor: pointer; padding: 0; transition: transform .1s; }
.swatch:hover { transform: scale(1.12); }
.swatch.is-selected { border-color: #fff; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); transform: scale(1.08); }

@media (max-width: 900px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr auto auto;
    grid-template-areas: "top" "stage" "side" "dock";
  }
  .topbar { gap: 10px; padding: 8px 12px; }
  .topbar .brand span:last-child { display: none; }
  .war-bar { gap: 8px; }
  .war .badge, .budget__meter, .budget__next { display: none; }
  .war__clock { font-size: 14px; }
  .sim { bottom: auto; top: 96px; left: 8px; }
  .side { border-left: 0; border-top: 1px solid var(--line); flex-direction: row; overflow-x: auto; padding: 10px 12px; gap: 12px; }
  .player-card { position: absolute; right: 10px; top: 58px; width: 150px; padding: 6px; z-index: 5; }
  .player-card__head, .player-card__pitch, .fps { display: none; }
  .player-card.is-intro { width: min(260px, 60vw); }
  .player-card.is-intro .player-card__pitch { display: block; font-size: 12px; margin: 6px 2px 2px; }
  .frame-strip { min-width: 250px; }
  .tools { grid-auto-flow: column; align-items: center; }
  .side__links { display: none; }
  .stage__coach { top: auto; bottom: 70px; }
  .coach__step:not(.is-current) { display: none; }
  .palette { grid-template-columns: none; grid-template-rows: repeat(2, 36px); grid-auto-flow: column; grid-auto-columns: 36px; gap: 6px; overflow-x: auto; padding: 4px; scrollbar-width: thin; }
  .dock { padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
}

@media (max-width: 420px) {
  .war__title { display: none; }
}

/* ---- Portada sin guerra en marcha ---- */
.page-landing .app { display: block; overflow-y: auto; }
.landing {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 20px 64px;
  display: grid;
  gap: 30px;
}
.landing__top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.landing__account { display: flex; align-items: center; gap: 10px; }
.landing__user { color: var(--muted); font-size: 14px; }
.landing__hero { display: grid; gap: 16px; }
.landing__title { font-size: clamp(28px, 5vw, 42px); letter-spacing: -0.01em; text-wrap: balance; }
.landing__pitch { margin: 0; color: var(--muted); font-size: 17px; max-width: 58ch; }
.landing__next {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: grid;
  gap: 6px;
  justify-items: start;
}
.landing__next .eyebrow { color: var(--accent); }
.landing__count { font-size: clamp(26px, 6vw, 38px); line-height: 1.1; }
.landing__next--empty .landing__count { color: var(--muted); font-size: 22px; }
.landing__when { color: var(--muted); font-size: 14px; }
.landing__actions { display: flex; gap: 10px; flex-wrap: wrap; }
.landing__example { margin: 0; display: grid; gap: 10px; }
.landing__example img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  display: block;
}
.landing__example figcaption { color: var(--muted); font-size: 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.landing__example figcaption strong { color: var(--ink); }
.landing__example figcaption a { margin-left: auto; }
.landing__how { display: grid; gap: 12px; }
.landing__how h2 { font-size: 18px; }
.landing__steps { margin: 0; padding-left: 1.2em; display: grid; gap: 8px; color: var(--muted); max-width: 64ch; }
.landing__steps strong { color: var(--ink); }
.landing__foot { display: flex; gap: 18px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 14px; }

@media (max-width: 600px) {
  .landing { gap: 22px; padding: 18px 16px 48px; }
  .landing__example figcaption a { margin-left: 0; width: 100%; }
}
