/* Mobile guide layouts (max-width: 1024px) */

@media (max-width: 1024px) {
  .how-to-play-shell {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
  }

  .how-to-play__chapter-picker {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
    padding: 10px 12px;
    border-bottom: 1px solid var(--glass-line);
    background: oklch(18% 0.02 260 / 92%);
  }

  .how-to-play__chapter-picker-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .how-to-play__chapter-select {
    width: 100%;
    min-height: 44px;
    margin: 0;
    font-size: 15px;
    touch-action: manipulation;
  }

  .how-to-play__nav {
    display: none !important;
  }

  .how-to-play-layout {
    flex: 1;
    min-height: 0;
  }

  .how-to-play-footer {
    flex-shrink: 0;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--glass-line);
    text-align: center;
    background: oklch(18% 0.02 260 / 88%);
  }

  .how-to-play-footer__link {
    font-size: 14px;
    font-weight: 500;
    color: var(--tile-hover);
    text-decoration: none;
  }

  .how-to-play-footer__link:hover {
    text-decoration: underline;
  }

  .how-to-play__chapter {
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  }

  .how-to-play__copy::before,
  .how-to-play__demo-panel::before {
    display: none;
  }

  .how-to-play__copy > .how-to-play__heading {
    display: none;
  }

  /* Overview: centered hero + lead copy */
  .how-to-play__chapter[data-chapter="overview"] {
    grid-template-rows: minmax(0, 1fr);
  }

  .how-to-play__chapter[data-chapter="overview"] .how-to-play__demo-panel {
    justify-content: center;
    padding: 16px;
  }

  .how-to-play__chapter[data-chapter="overview"] .how-to-play__hero-lead {
    font-size: 15px;
  }

  /* Setup: demo top, copy below centered */
  .how-to-play__chapter[data-chapter="setup"] {
    grid-template-rows: minmax(0, 3fr) minmax(0, 1fr);
  }

  .how-to-play__chapter[data-chapter="setup"] .how-to-play__demo-panel {
    grid-row: 1;
  }

  .how-to-play__chapter[data-chapter="setup"] .how-to-play__copy {
    grid-row: 2;
    text-align: center;
  }

  /* Board: board top, fixed zone detail dock */
  .how-to-play__chapter[data-chapter="zones"] {
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .how-to-play__chapter[data-chapter="zones"] .how-to-play__copy {
    display: none;
  }

  .how-to-play__chapter[data-chapter="zones"] .how-to-play__demo-panel {
    grid-row: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 8px 10px 0;
  }

  .how-to-play__chapter[data-chapter="zones"] .how-to-play__zones-stage {
    flex: 1;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
    grid-template-columns: 1fr;
  }

  .how-to-play__chapter[data-chapter="zones"] .how-to-play__demo-mount {
    min-height: 140px;
  }

  .how-to-play__chapter[data-chapter="zones"] .how-to-play__zone-detail {
    flex: 0 0 auto;
    max-height: 150px;
    min-height: 120px;
    margin-top: 8px;
    text-align: center;
  }

  .how-to-play__chapter[data-chapter="zones"] .how-to-play__zone-detail-text,
  .how-to-play__chapter[data-chapter="zones"] .how-to-play__zone-detail-placeholder {
    text-align: center;
  }

  /* Ways to Win: hide copy, full demo stack */
  .how-to-play__chapter[data-chapter="wins"] .how-to-play__copy {
    display: none;
  }

  .how-to-play__chapter[data-chapter="wins"] {
    grid-template-rows: minmax(0, 1fr);
  }

  .how-to-play__chapter[data-chapter="wins"] .how-to-play__demo-panel {
    grid-row: 1;
  }

  .how-to-play__wins-mobile {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
    min-height: 0;
  }

  .how-to-play__virtue-rail {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
  }

  .how-to-play__virtue-rail-btn {
    flex: 1 1 calc(33% - 8px);
    min-width: 88px;
    min-height: 44px;
    margin: 0;
    padding: 8px 10px;
    border-radius: 10px;
    border: 2px solid oklch(100% 0 0 / 14%);
    background: oklch(100% 0 0 / 5%);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    transition:
      border-color 0.15s ease,
      background 0.15s ease,
      color 0.15s ease,
      box-shadow 0.15s ease;
  }

  .how-to-play__virtue-rail-btn[class*="how-to-play__virtue-rail-btn--"] {
    background: color-mix(in oklch, var(--virtue-tone) 14%, oklch(22% 0.02 260));
    border-color: color-mix(in oklch, var(--virtue-tone) 52%, oklch(100% 0 0 / 10%));
    color: var(--virtue-ink);
  }

  .how-to-play__virtue-rail-btn[class*="how-to-play__virtue-rail-btn--"].is-selected {
    background: color-mix(in oklch, var(--virtue-tone) 28%, oklch(22% 0.02 260));
    border-color: var(--virtue-tone);
    box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--virtue-tone) 35%, transparent);
    color: var(--virtue-ink);
  }

  .how-to-play__wins-mobile-detail {
    text-align: center;
    font-size: 14px;
    line-height: 1.55;
  }

  .how-to-play__wins-mobile-points {
    margin: 6px 0 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
  }

  .how-to-play__chapter[data-chapter="wins"] .how-to-play__win-anim-mount {
    flex: 1;
    min-height: 160px;
    display: flex;
    align-items: stretch;
    justify-content: center;
  }

  .how-to-play__chapter[data-chapter="wins"] .how-to-play__win-anim-mount:has(.win-demo__vigor) {
    min-height: 220px;
  }

  .how-to-play__chapter[data-chapter="wins"] .win-demo__svg--vigor {
    min-height: 180px;
    max-height: min(320px, 42vh);
  }

  /* Each Turn: flowchart top, detail bottom */
  .how-to-play__chapter[data-chapter="turns"] .how-to-play__copy {
    display: none;
  }

  .how-to-play__chapter[data-chapter="turns"] {
    grid-template-rows: minmax(0, 1fr);
  }

  .how-to-play__chapter[data-chapter="turns"] .how-to-play__demo-panel {
    grid-row: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    overflow: hidden;
  }

  .how-to-play__chapter[data-chapter="turns"] .how-to-play__demo-mount {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .how-to-play__chapter[data-chapter="turns"] .how-to-play__demo-hint {
    display: none;
  }

  .how-to-play__turns-mobile {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 12px 14px 0;
  }

  .how-to-play__turn-flow {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    overflow-y: auto;
  }

  .how-to-play__turn-flow-node {
    flex: 0 0 auto;
    min-height: 36px;
    margin: 0;
    padding: 5px 10px;
    font-size: 12px;
    line-height: 1.2;
    white-space: normal;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
  }

  .how-to-play__turn-flow-node.is-active {
    border-color: var(--tile-hover);
    color: var(--tile-hover);
  }

  .how-to-play__turn-flow-arrow {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1px 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1;
  }

  .how-to-play__mobile-phase-detail {
    flex: 0 0 auto;
    max-height: 38%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--glass-line);
    background: oklch(22% 0.02 260 / 88%);
    text-align: center;
    font-size: 14px;
    line-height: 1.55;
  }

  .how-to-play__turn-flow-title {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 600;
  }

  /* Movement: demo only */
  .how-to-play__chapter[data-chapter="movement"] .how-to-play__copy {
    display: none;
  }

  .how-to-play__chapter[data-chapter="movement"] {
    grid-template-rows: minmax(0, 1fr);
  }

  .how-to-play__movement-table {
    display: none;
  }

  .how-to-play__koi-detail {
    margin: 0;
    padding: 10px 12px;
    text-align: center;
    font-size: 14px;
    line-height: 1.5;
    color: var(--muted);
    border-top: 1px solid oklch(100% 0 0 / 8%);
  }

  .how-to-play__chapter[data-chapter="movement"] .how-to-play__demo-board-row {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .how-to-play__chapter[data-chapter="movement"] .how-to-play__demo-mount {
    flex: 1;
    min-height: 160px;
  }

  /* Capturing, Lilies: demo majority, centered copy below */
  .how-to-play__chapter[data-chapter="capturing"],
  .how-to-play__chapter[data-chapter="lilies"] {
    grid-template-rows: minmax(0, 7fr) minmax(0, 3fr);
  }

  .how-to-play__chapter[data-chapter="capturing"] .how-to-play__copy,
  .how-to-play__chapter[data-chapter="lilies"] .how-to-play__copy {
    text-align: center;
  }

  .how-to-play__chapter[data-chapter="capturing"] .how-to-play__demo-panel,
  .how-to-play__chapter[data-chapter="lilies"] .how-to-play__demo-panel {
    grid-row: 1;
  }

  .how-to-play__chapter[data-chapter="capturing"] .how-to-play__copy,
  .how-to-play__chapter[data-chapter="lilies"] .how-to-play__copy {
    grid-row: 2;
  }

  /* Revival: board top, tap-friendly bank dock below */
  .how-to-play__chapter[data-chapter="revival"] {
    grid-template-rows: minmax(0, 7fr) minmax(0, 3fr);
  }

  .how-to-play__chapter[data-chapter="revival"] .how-to-play__copy {
    grid-row: 2;
    text-align: center;
  }

  .how-to-play__chapter[data-chapter="revival"] .how-to-play__demo-panel {
    grid-row: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    overflow: hidden;
    min-height: 0;
  }

  .how-to-play__chapter[data-chapter="revival"] .how-to-play__demo-hint,
  .how-to-play__chapter[data-chapter="revival"] .how-to-play__demo-toast {
    flex-shrink: 0;
    margin: 0;
    padding: 8px 12px;
  }

  .how-to-play__chapter[data-chapter="revival"] .how-to-play__revival-stage {
    flex: 1;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-columns: 1fr;
  }

  .how-to-play__chapter[data-chapter="revival"] .how-to-play__demo-mount {
    grid-row: 1;
    min-height: 0;
  }

  .how-to-play__chapter[data-chapter="revival"] .how-to-play__revival-bank {
    grid-row: 2;
    flex-direction: row;
    align-items: stretch;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--glass-line);
    background: oklch(22% 0.02 260 / 88%);
  }

  .how-to-play__chapter[data-chapter="revival"] .how-to-play__revival-bank.is-active {
    background: oklch(76% 0.13 82 / 10%);
  }

  .how-to-play__chapter[data-chapter="revival"] .how-to-play__revival-bank-label {
    display: none;
  }

  .how-to-play__chapter[data-chapter="revival"] .how-to-play__revival-bank-rack {
    flex-direction: row;
    flex: 1;
    gap: 8px;
  }

  .how-to-play__chapter[data-chapter="revival"] .how-to-play__revival-bank-slot {
    flex: 1;
    flex-direction: row;
    justify-content: center;
    padding: 8px;
    min-height: 52px;
    touch-action: manipulation;
  }

  .how-to-play__chapter[data-chapter="revival"] .how-to-play__revival-bank-slot.is-pickable {
    touch-action: manipulation;
    cursor: pointer;
  }

  .how-to-play__chapter[data-chapter="revival"] .how-to-play__revival-bank-slot.is-pickable .how-to-play__revival-bank-svg {
    touch-action: manipulation;
    pointer-events: none;
  }

  .how-to-play__chapter[data-chapter="revival"] .how-to-play__revival-slot-label {
    font-size: 12px;
  }

  /* Scoring: demo only */
  .how-to-play__chapter[data-chapter="scoring"] .how-to-play__copy {
    display: none;
  }

  .how-to-play__chapter[data-chapter="scoring"] {
    grid-template-rows: minmax(0, 1fr);
  }

  .how-to-play__score-footnote {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid oklch(100% 0 0 / 10%);
    font-size: 13px;
    color: var(--muted);
    text-align: center;
  }

  /* Glossary: full height */
  .how-to-play__chapter--glossary {
    grid-template-rows: minmax(0, 1fr);
  }

  .how-to-play__chapter--glossary .how-to-play__copy {
    grid-row: 1;
  }

  .how-to-play-demo .demo-board {
    max-height: min(100%, 320px);
  }

  .how-to-play__phase-btn,
  .how-to-play__lily-tab,
  .how-to-play__piece-chip {
    min-height: 44px;
    touch-action: manipulation;
  }
}

@media (min-width: 1025px) {
  .how-to-play__chapter-picker,
  .how-to-play-footer {
    display: none;
  }
}
