/* ============ MOBILE STAGE ============ */
.mob-stage {
  grid-column: 2 / 4;
  background: transparent;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 0;
  position: relative;
  overflow-y: auto;
}

.mob-stage-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 24px 40px 16px;
  gap: 24px;
  z-index: 2;
}

.mob-stage-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px 40px;
  min-height: 0;
}

.mob-context {
  max-width: 460px;
  min-width: 0;
}
.mob-context-label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--fg-muted);
  margin-bottom: 6px;
}
.mob-context-help {
  font-size: 13px;
  color: var(--fg-dim);
  line-height: 1.5;
  text-wrap: pretty;
}

.mob-sun-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--fg-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: all 0.15s;
}
.mob-sun-toggle:hover { color: var(--fg); border-color: var(--fg-muted); }
.mob-stage.sunlight .mob-sun-toggle { background: var(--amarillo); color: #2b1e0e; border-color: var(--amarillo); }

/* ============ APP INSIDE PHONE ============ */
.mob-app {
  height: 100%;
  padding: 60px 0 34px; /* respeta dynamic island + home indicator */
  color: #fff;
  font-family: -apple-system, "SF Pro Text", system-ui, sans-serif;
  background: #0a0a0c;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Sunlight mode — contraste extremo */
.mob-stage.sunlight .mob-app {
  background: #000;
}
.mob-stage.sunlight .mob-app * {
  --accent-mobile: #fff !important;
}

/* Design tokens específicos para el modo móvil */
.mob-app {
  --mob-accent: #d4ff3f;
  --mob-warn: #ff9a3c;
  --mob-danger: #ff4d5f;
  --mob-ok: #4ade80;
  --mob-dim: rgba(255,255,255,0.55);
  --mob-mute: rgba(255,255,255,0.35);
  --mob-line: rgba(255,255,255,0.1);
  --mob-surface: rgba(255,255,255,0.06);
  --mob-surface-2: rgba(255,255,255,0.1);
}

/* Sunlight overrides — maximum contrast */
.mob-stage.sunlight .mob-app {
  --mob-accent: #ffffff;
  --mob-dim: rgba(255,255,255,0.85);
  --mob-mute: rgba(255,255,255,0.6);
  --mob-line: rgba(255,255,255,0.25);
  --mob-surface: rgba(255,255,255,0.12);
  --mob-surface-2: rgba(255,255,255,0.2);
}

/* ============ LOBBY SCREEN ============ */
.mob-lobby {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100%;
}
.mob-lobby-eyebrow {
  font-size: 13px;
  color: var(--mob-mute);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  padding-top: 4px;
}
.mob-lobby-group { }
.mob-lobby-group-name {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 6px;
}
.mob-lobby-group-meta {
  font-size: 15px;
  color: var(--mob-dim);
  font-weight: 500;
}

.mob-lobby-card {
  background: var(--mob-surface);
  border: 1px solid var(--mob-line);
  border-radius: 22px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.mob-lobby-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-wrap: balance;
}
.mob-lobby-stats {
  display: flex;
  gap: 24px;
}
.mob-lobby-stat { }
.mob-lobby-stat-num {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--mob-accent);
}
.mob-lobby-stat-unit {
  font-size: 12px;
  color: var(--mob-mute);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
  font-weight: 600;
}

.mob-lobby-blocks {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--mob-line);
}
.mob-lobby-block {
  display: grid;
  grid-template-columns: 4px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
}
.mob-lobby-block-stripe {
  width: 4px;
  height: 28px;
  border-radius: 2px;
}
.mob-lobby-block-name {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}
.mob-lobby-block-time {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--mob-dim);
}

/* Big buttons */
.mob-big-btn {
  padding: 20px 24px;
  border-radius: 22px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: transform 0.1s, opacity 0.1s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 68px;
  white-space: nowrap;
  width: 100%;
}
.mob-big-btn > span { white-space: nowrap; }
.mob-big-btn.primary {
  background: var(--mob-accent);
  color: #0a0a0c;
  box-shadow: 0 6px 24px rgba(212, 255, 63, 0.3);
}
.mob-big-btn.primary:active { transform: scale(0.98); }
.mob-big-btn.secondary {
  background: var(--mob-surface);
  color: #fff;
  border: 1px solid var(--mob-line);
}
.mob-stage.sunlight .mob-big-btn.primary { box-shadow: 0 6px 24px rgba(255,255,255,0.15); }
.mob-stage.sunlight .mob-big-btn.secondary { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.3); }

/* ============ RUNNING SCREEN ============ */
.mob-run {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 12px 0 0;
}

/* TOP */
.mob-run-top {
  padding: 8px 22px 12px;
}
.mob-segs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}
.mob-seg {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--mob-line);
  overflow: hidden;
}
.mob-seg.done { background: var(--mob-accent); }
.mob-seg-fill {
  height: 100%;
  background: var(--mob-accent);
  transition: width 1s linear;
}
.mob-run-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.mob-run-phase {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--mob-dim);
  letter-spacing: -0.005em;
}
.mob-run-phase-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
}
.mob-run-phase-dot.color-coral { background: #ff6b4a; }
.mob-run-phase-dot.color-azul { background: #6bb6ff; }
.mob-run-phase-dot.color-verde { background: #4ade80; }
.mob-run-phase-dot.color-amarillo { background: #fbbf24; }
.mob-run-total {
  font-family: -apple-system, "SF Mono", monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--mob-accent);
  font-variant-numeric: tabular-nums;
}

/* HERO */
.mob-run-hero {
  flex: 1;
  padding: 20px 22px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  min-height: 0;
}
.mob-run-material {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.mob-run-material-chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--mob-surface);
  border: 1px solid var(--mob-line);
  color: var(--mob-dim);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.mob-run-material-chip.empty { opacity: 0.7; font-style: italic; }

.mob-run-title {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1;
  text-wrap: balance;
  color: #fff;
}
.mob-stage.sunlight .mob-run-title { font-weight: 900; }

.mob-run-timer-wrap {
  padding: 20px 0 4px;
  text-align: left;
}
.mob-run-timer {
  font-family: -apple-system, "SF Pro Display", system-ui;
  font-size: 96px;
  font-weight: 200;
  letter-spacing: -0.05em;
  line-height: 1;
  color: #fff;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: color 0.2s;
}
.mob-run.paused .mob-run-timer { color: var(--mob-mute); }
.mob-run.near-end .mob-run-timer { color: var(--mob-warn); }
.mob-run.time-up .mob-run-timer { color: var(--mob-danger); animation: mobBlink 1s ease-in-out infinite; }
@keyframes mobBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.mob-run-timer-label {
  font-size: 12px;
  color: var(--mob-mute);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  margin-top: 4px;
}
.mob-run.time-up .mob-run-timer-label { color: var(--mob-danger); }

.mob-detail-link {
  align-self: flex-start;
  color: var(--mob-dim);
  font-size: 14px;
  font-weight: 600;
  padding: 4px 0;
  border-bottom: 1px solid var(--mob-line);
}
.mob-detail-link:active { color: var(--mob-accent); }

/* BOTTOM */
.mob-run-bottom {
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mob-next {
  background: var(--mob-surface);
  border: 1px solid var(--mob-line);
  border-radius: 16px;
  padding: 12px 14px;
}
.mob-next.final {
  padding: 16px 14px;
  text-align: center;
  color: var(--mob-dim);
  font-size: 14px;
  font-style: italic;
}
.mob-next-label {
  font-size: 11px;
  color: var(--mob-mute);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  margin-bottom: 6px;
}
.mob-next-body {
  display: grid;
  grid-template-columns: 4px 1fr auto;
  gap: 10px;
  align-items: center;
}
.mob-next-stripe {
  width: 4px;
  height: 22px;
  border-radius: 2px;
}
.mob-next-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}
.mob-next-time {
  font-size: 13px;
  font-weight: 700;
  color: var(--mob-dim);
  font-variant-numeric: tabular-nums;
}

.mob-run-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
}
.mob-action-btn {
  padding: 18px 12px;
  border-radius: 18px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 64px;
  transition: transform 0.1s;
}
.mob-action-btn:active { transform: scale(0.97); }
.mob-action-btn.secondary {
  background: var(--mob-surface);
  color: #fff;
  border: 1px solid var(--mob-line);
}
.mob-action-btn.primary {
  background: var(--mob-accent);
  color: #0a0a0c;
  box-shadow: 0 4px 16px rgba(212, 255, 63, 0.35);
}
.mob-stage.sunlight .mob-action-btn.primary { box-shadow: 0 4px 16px rgba(255,255,255,0.2); }

/* Color helpers para stripes (reutilizadas del design system) */
.mob-lobby-block-stripe.color-coral, .mob-next-stripe.color-coral, .mob-finish-stripe.color-coral { background: #ff6b4a; }
.mob-lobby-block-stripe.color-azul, .mob-next-stripe.color-azul, .mob-finish-stripe.color-azul { background: #6bb6ff; }
.mob-lobby-block-stripe.color-verde, .mob-next-stripe.color-verde, .mob-finish-stripe.color-verde { background: #4ade80; }
.mob-lobby-block-stripe.color-amarillo, .mob-next-stripe.color-amarillo, .mob-finish-stripe.color-amarillo { background: #fbbf24; }

/* ============ FINISHED ============ */
.mob-finish {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
}
.mob-finish-check {
  color: var(--mob-accent);
  margin: 12px 0 4px;
}
.mob-finish-title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.mob-finish-sub {
  font-size: 15px;
  color: var(--mob-dim);
  margin-bottom: 8px;
}
.mob-finish-summary {
  background: var(--mob-surface);
  border: 1px solid var(--mob-line);
  border-radius: 18px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mob-finish-row {
  display: grid;
  grid-template-columns: 4px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--mob-line);
}
.mob-finish-row:last-child { border-bottom: none; }
.mob-finish-stripe { width: 4px; height: 24px; border-radius: 2px; }
.mob-finish-name { font-size: 14px; font-weight: 600; }
.mob-finish-time { font-size: 13px; font-weight: 700; color: var(--mob-dim); font-variant-numeric: tabular-nums; }

/* ============ BOTTOM SHEET (detail) ============ */
.mob-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 30;
  animation: mobFade 0.15s ease-out;
}
@keyframes mobFade { from { opacity: 0; } to { opacity: 1; } }

.mob-sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: #1a1a1e;
  border-radius: 22px 22px 0 0;
  max-height: 82%;
  display: flex;
  flex-direction: column;
  animation: mobSheetIn 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes mobSheetIn {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.mob-sheet-handle {
  width: 40px; height: 5px;
  border-radius: 3px;
  background: rgba(255,255,255,0.3);
  margin: 10px auto 4px;
}
.mob-sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px 8px;
}
.mob-sheet-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  padding-right: 16px;
}
.mob-sheet-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 16px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.mob-sheet-scroll {
  padding: 8px 20px 40px;
  overflow-y: auto;
  color: #fff;
}
.mob-sheet-lede {
  font-size: 14px;
  color: rgba(255,255,255,0.75);
  line-height: 1.5;
  margin-bottom: 20px;
  text-wrap: pretty;
}
.mob-sheet-sec { margin-bottom: 22px; }
.mob-sheet-sec h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.5);
  margin-bottom: 10px;
  font-weight: 700;
}
.mob-sheet-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mob-sheet-steps li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  font-size: 14px;
  line-height: 1.5;
  color: rgba(255,255,255,0.9);
  align-items: start;
  text-wrap: pretty;
}
.mob-sheet-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--mob-accent);
  color: #0a0a0c;
  display: grid; place-items: center;
  font-size: 12px;
  font-weight: 700;
}
.mob-sheet-rules {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mob-sheet-rules li {
  padding: 10px 12px;
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  color: rgba(255,255,255,0.85);
  text-wrap: pretty;
}
.mob-sheet-adapt {
  padding: 12px;
  background: rgba(107, 182, 255, 0.12);
  border: 1px solid rgba(107, 182, 255, 0.25);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  color: #fff;
  margin-bottom: 6px;
  text-wrap: pretty;
}
.mob-sheet-empty {
  padding: 40px 20px;
  text-align: center;
  color: rgba(255,255,255,0.4);
  font-size: 14px;
  font-style: italic;
}

/* ============ LOBBY DETAIL SHEET ============ */
.mob-lobby-sheet-eyebrow {
  font-family: -apple-system, "SF Mono", monospace;
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  margin-bottom: 4px;
}
.mob-lobby-sheet-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px;
  background: rgba(255,255,255,0.06);
  border-radius: 14px;
  margin-bottom: 24px;
}
.mob-lobby-sheet-stat {
  text-align: center;
  padding: 4px 0;
}
.mob-lobby-sheet-stat-num {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #d4ff3f;
  line-height: 1;
}
.mob-lobby-sheet-stat-label {
  font-family: -apple-system, "SF Mono", monospace;
  font-size: 10px;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  margin-top: 4px;
}

.mob-lobby-sheet-phasetime {
  float: right;
  color: rgba(255,255,255,0.65);
  font-family: -apple-system, "SF Mono", monospace;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0;
}

.mob-lobby-sheet-blocks {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mob-lobby-sheet-block {
  display: grid;
  grid-template-columns: 4px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.mob-lobby-sheet-block:last-child { border-bottom: none; }
.mob-lobby-sheet-stripe {
  width: 4px;
  height: 28px;
  border-radius: 2px;
}
.mob-lobby-sheet-stripe.color-coral { background: #ff6b4a; }
.mob-lobby-sheet-stripe.color-azul { background: #6bb6ff; }
.mob-lobby-sheet-stripe.color-verde { background: #4ade80; }
.mob-lobby-sheet-stripe.color-amarillo { background: #fbbf24; }
.mob-lobby-sheet-block-body { min-width: 0; }
.mob-lobby-sheet-block-name {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}
.mob-lobby-sheet-block-meta {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mob-lobby-sheet-block-time {
  font-family: -apple-system, "SF Mono", monospace;
  font-size: 14px;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  font-variant-numeric: tabular-nums;
}

.mob-lobby-sheet-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.mob-lobby-sheet-chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.85);
  font-size: 12px;
  font-weight: 600;
}
.mob-lobby-sheet-chip.alt {
  background: rgba(212, 255, 63, 0.12);
  border-color: rgba(212, 255, 63, 0.3);
  color: #d4ff3f;
}

/* ============================================================ */
/* ============ RESPONSIVE — TABLET (768px – 1279px) ========== */
/* ============================================================ */
@media (max-width: 1279px) {
  /* .app pasa a 2 columnas (76px 1fr) — .mob-stage ya no debe intentar
     ocupar un 3er tramo que no existe */
  .mob-stage { grid-column: 2; }
}

/* ============================================================ */
/* ============ RESPONSIVE — MOBILE (< 768px) ================= */
/* ============================================================ */
/* Spec: en móvil real solo tiene sentido la vista "En clase". App.tsx
   fuerza view='mobile' por debajo de 768px vía JS. El mockup de iPhone
   deja de ser un "bisel" decorativo (pensado para verse en escritorio)
   y pasa a ocupar la pantalla real, sin notch ni barra de estado falsa. */
@media (max-width: 767px) {
  .mob-stage {
    grid-column: auto;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .mob-stage-header { display: none; }

  .mob-stage-frame {
    padding: 0;
    flex: 1;
    min-height: 0;
    align-items: stretch;
  }
  .ios-device {
    width: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }
  .ios-notch,
  .ios-statusbar-wrap,
  .ios-home-wrap {
    display: none;
  }
  .ios-content {
    height: 100%;
  }
  .mob-app { padding-top: 16px; }
}
