/* Seven Steps — mobile layout overrides (load after other v4 CSS) */

/* Touch targets */
@media (max-width: 900px) {
  .icon-btn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px;
    min-height: 44px;
  }

  :root { --header-h: 64px; }

  .global-header {
    padding: 6px 10px !important;
  }
}

/* ——— Modes: compact stacked cards that fit the viewport ——— */
@media (max-width: 900px) {
  body:has(#modeScreen.active),
  body:has(#eraScreen.active),
  body:has(#modeScreen.active) .app-shell,
  body:has(#eraScreen.active) .app-shell {
    overflow: hidden !important;
    height: 100dvh;
    max-height: 100dvh;
  }

  body:has(#modeScreen.active) .global-header,
  body:has(#eraScreen.active) .global-header {
    height: 64px !important;
  }

  #modeScreen.active,
  #eraScreen.active {
    height: calc(100dvh - 64px) !important;
    min-height: calc(100dvh - 64px) !important;
    max-height: calc(100dvh - 64px) !important;
    padding: 6px 10px 10px !important;
    overflow: hidden !important;
    align-items: flex-start !important;
  }

  #modeScreen .console-panel,
  #eraScreen .console-panel {
    width: 100% !important;
    max-height: 100%;
    padding: 14px 12px 12px !important;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }

  #modeScreen .section-kicker,
  #eraScreen .section-kicker {
    margin-bottom: 4px !important;
    font-size: 10px !important;
  }

  #modeScreen h2,
  #eraScreen h2 {
    margin: 0 0 8px !important;
    font-size: clamp(26px, 8vw, 34px) !important;
  }

  #modeScreen .mode-grid {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    margin-top: 8px !important;
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  #modeScreen .mode-card {
    min-height: 0 !important;
    padding: 12px 12px 12px 14px !important;
    display: grid !important;
    grid-template-columns: 52px minmax(0, 1fr);
    grid-template-areas:
      "icon title"
      "icon copy"
      "icon tag";
    column-gap: 12px;
    row-gap: 2px;
    align-items: center;
    text-align: left !important;
  }

  #modeScreen .mode-icon {
    grid-area: icon;
    width: 52px !important;
    height: 52px !important;
    margin: 0 !important;
    font-size: 22px !important;
    border-radius: 14px !important;
    box-shadow: 0 5px 0 #593302 !important;
  }

  #modeScreen .mode-card h3 {
    grid-area: title;
    margin: 0 !important;
    font-size: 18px !important;
  }

  #modeScreen .mode-card p {
    grid-area: copy;
    margin: 0 !important;
    font-size: 13px !important;
    line-height: 1.3 !important;
  }

  #modeScreen .mode-card > span {
    grid-area: tag;
    position: static !important;
    display: block !important;
    margin: 4px 0 0 !important;
    font-size: 10px !important;
  }

  #modeScreen .panel-actions {
    margin-top: 10px !important;
    flex: 0 0 auto;
  }

  #eraScreen .era-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    overflow: auto;
    min-height: 0;
  }
}

/* ——— Game: trivia fills the phone; climb lives in HUD dots ——— */
@media (max-width: 900px) {
  body:has(#gameScreen.active),
  body:has(#gameScreen.active) .app-shell {
    overflow: hidden !important;
    height: 100dvh;
    max-height: 100dvh;
  }

  body:has(#gameScreen.active) .global-header {
    height: 56px !important;
  }

  #gameScreen.active {
    display: flex !important;
    flex-direction: column;
    align-items: stretch !important;
    justify-content: flex-start !important;
    width: 100%;
    max-width: none;
    height: calc(100dvh - 56px) !important;
    min-height: calc(100dvh - 56px) !important;
    max-height: calc(100dvh - 56px) !important;
    padding: 4px 8px 6px !important;
    overflow: hidden !important;
    box-sizing: border-box;
  }

  #gameScreen .hud-top {
    flex: 0 0 auto;
    gap: 4px !important;
    margin-bottom: 4px !important;
  }

  #gameScreen .hud-profile,
  #gameScreen .hud-mode,
  #gameScreen .hud-stats {
    padding: 5px 8px !important;
    border-radius: 12px !important;
  }

  #gameScreen .hud-profile strong {
    font-size: 13px !important;
  }

  #gameScreen .hud-profile span {
    font-size: 10px !important;
  }

  #gameScreen .mini-avatar {
    width: 36px !important;
    height: 36px !important;
  }

  #gameScreen .hud-stats {
    display: none !important;
  }

  #gameScreen .game-layout {
    flex: 1 1 auto;
    min-height: 0;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    overflow: hidden;
    width: 100%;
  }

  /* Tiny staircase looked odd and stole answer space — progress is in HUD/dots */
  #gameScreen .climb-panel {
    display: none !important;
  }

  #gameScreen .question-stage {
    order: 1 !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    width: 100% !important;
    display: grid !important;
    grid-template-rows: minmax(72px, 18%) minmax(0, 1fr) !important;
    overflow: hidden !important;
  }

  #gameScreen .era-art {
    min-height: 72px !important;
  }

  #gameScreen .question-panel {
    width: 100% !important;
    margin: 0 !important;
    padding: 8px 10px 10px !important;
    overflow: hidden;
    min-height: 0 !important;
    flex: 1 1 auto;
  }

  #gameScreen .question-meta {
    margin-bottom: 4px !important;
  }

  #gameScreen .progress-dots {
    margin: 2px 0 6px !important;
  }

  #gameScreen .question-panel h2 {
    font-size: clamp(16px, 4.4vw, 22px) !important;
    margin: 4px auto 10px !important;
    line-height: 1.25 !important;
  }

  #gameScreen .answers {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    width: 100% !important;
  }

  #gameScreen .answer {
    min-height: 48px !important;
    font-size: 15px !important;
    padding: 10px 12px !important;
  }

  #gameScreen .lifeline-panel {
    order: 2 !important;
    flex: 0 0 auto !important;
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
    padding: 6px 8px !important;
    position: relative !important;
    top: auto !important;
  }

  #gameScreen .lifeline-panel .panel-label {
    display: none !important;
  }

  #gameScreen .pressure-meter {
    display: none !important;
  }

  #gameScreen .lifeline {
    margin: 0 !important;
    padding: 8px 6px !important;
  }

  #gameScreen .lifeline span {
    display: none;
  }
}

@media (max-width: 620px) {
  #gameScreen .question-stage {
    grid-template-rows: minmax(64px, 14%) minmax(0, 1fr) !important;
  }

  #gameScreen .era-art {
    min-height: 64px !important;
  }

  #modeScreen .mode-card {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  #modeScreen .mode-icon {
    width: 48px !important;
    height: 48px !important;
  }
}

/* Short phones (SE / landscape-ish heights) */
@media (max-height: 700px) and (max-width: 900px) {
  #gameScreen .question-stage {
    grid-template-rows: minmax(48px, 10%) minmax(0, 1fr) !important;
  }

  #gameScreen .era-art {
    min-height: 48px !important;
  }

  #gameScreen .answer {
    min-height: 44px !important;
    padding: 8px 10px !important;
  }

  #modeScreen .mode-card p {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #modeScreen .mode-card,
  #gameScreen .answer {
    transition: none !important;
  }
}
