/**
 * Garden Bot mobile usability pass — TEST PAGE ONLY.
 *
 * The existing Garden Bot transaction logic is untouched. This file is loaded
 * only at /battle/garden-bot-preview; the normal /battle entry omits it.
 *
 * Priorities: remove redundant step jumps when choices are already present,
 * preserve readable last-action feedback, make reroll compact, and keep
 * result/share controls accessible in the Slush phone browser.
 */
@media screen and (max-width: 640px) {
  /* The Step 2 cards are already visible on the compact play surface.
     Never hide the jump while choices have not actually loaded. */
  .gb-battle-options:has(> .gb-move-card-grid > .gb-battle-move-card)
    .gb-bonus-step-help button[data-testid="button-bonus-next-step"] {
    display: none !important;
  }

  /* Once the five playable cards are actually rendered, the Step 2 title
     supplies sufficient guidance. Remove the now-redundant explanatory block
     to keep the fifth card visible even at 320×568. Step 1 remains intact. */
  .gb-battle-options:has(> .gb-move-card-grid > .gb-battle-move-card)
    .gb-bonus-step-help {
    display: none !important;
  }

  /* Step 1 already labels the choice, so avoid two large duplicate headings.
     Keep the short explanation and the bonus cards themselves visible. */
  .gb-battle-page-active .gb-battle-options > .gb-fifth-picker .gb-fifth-picker-title {
    display: none;
  }
  .gb-battle-page-active .gb-battle-options > .gb-fifth-picker > p {
    margin: 0 0 6px;
    font-family: system-ui, sans-serif;
    font-size: 11px;
    line-height: 1.3;
  }

  /* Preserve the jump on very short phones. Taller phones already display
     the fifth-card picker immediately below Step 1. */
  @media (min-height: 740px) {
    .gb-battle-options:has(> .gb-fifth-picker)
      .gb-bonus-step-help button[data-testid="button-bonus-next-step"] {
      display: none !important;
    }
  }

  /* Make the previous Garden Bot move understandable, not just a card name.
     The detailed description remains in the full battle history. */
  .gb-battle-page-active .gb-battle-options > .gb-last-opponent-move {
    max-height: 64px !important;
    min-height: 46px !important;
  }
  .gb-battle-page-active .gb-last-opponent-move-copy > span {
    display: block !important;
    font-size: 9px !important;
    color: #ffe6cd !important;
    line-height: 1.18;
    overflow: hidden;
    white-space: normal;
    display: -webkit-box !important;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  /* Reroll is optional: keep the real on-chain reroll action and its disabled
     state, but stop spending a large vertical block on repeated instructions. */
  .gb-battle-page-active .gb-battle-options > .gb-free-bot-reroll {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(118px, 45%);
    gap: 7px;
    align-items: center !important;
    padding: 8px !important;
    margin: 4px 0 !important;
    min-height: 55px;
  }
  .gb-battle-page-active .gb-free-bot-reroll > span {
    display: grid;
    gap: 1px;
    min-width: 0;
  }
  .gb-battle-page-active .gb-free-bot-reroll > span strong {
    font-size: clamp(9px, 2.6vw, 11px);
    line-height: 1.2;
  }
  .gb-battle-page-active .gb-free-bot-reroll > span small {
    font-size: 9px;
    line-height: 1.25;
    max-height: 2.5em;
    overflow: hidden;
  }
  .gb-battle-page-active .gb-free-bot-reroll > button {
    margin: 0 !important;
    width: 100% !important;
    min-width: 0;
    min-height: 44px !important;
    font-size: 9px !important;
    line-height: 1.25;
    padding: 6px !important;
    overflow-wrap: anywhere;
  }

  /* Keep forfeit/paid reroll/history reachable in the existing inner
     scrolling control pane, never as an overlay on the five main cards. */
  .gb-battle-page-active .gb-battle-options > .gb-battle-secondary-controls {
    margin-top: 8px !important;
    gap: 7px !important;
  }
  .gb-battle-page-active .gb-battle-options > .gb-battle-secondary-controls button {
    min-height: 44px !important;
  }

  /* Finish screen: compress excess spacing so the result, selected art and
     native share action can be found quickly without awkward full-page jumps.
     Unique NFT-backed artwork generation belongs to follow-on issue #14. */
  .gb-result-modal-backdrop {
    align-items: center !important;
    padding: max(8px, env(safe-area-inset-top, 0px)) 8px
      max(8px, env(safe-area-inset-bottom, 0px)) !important;
  }
  .gb-result-modal {
    box-sizing: border-box;
    display: flex !important;
    flex-direction: column;
    gap: 9px !important;
    width: 100% !important;
    max-width: min(460px, calc(100vw - 16px)) !important;
    max-height: min(92dvh, 800px) !important;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px !important;
    padding: 12px !important;
    text-align: left;
  }
  .gb-result-modal-close {
    z-index: 3;
    min-width: 36px;
    min-height: 36px;
    top: 9px;
    right: 9px;
  }
  .gb-result-modal-visual {
    display: grid !important;
    grid-template-columns: 92px minmax(0, 1fr);
    align-items: center;
    justify-items: stretch;
    gap: 9px !important;
    max-width: none !important;
    width: 100%;
  }
  .gb-result-modal-image-wrap {
    box-sizing: border-box;
    max-width: 92px !important;
    width: 92px !important;
    height: 92px;
  }
  .gb-result-modal-score-card {
    min-width: 0;
    font-size: 11px !important;
    line-height: 1.4;
    margin: 0 !important;
    padding: 8px !important;
  }
  .gb-result-modal-copy {
    min-width: 0;
    text-align: left !important;
    padding-right: 0 !important;
  }
  .gb-result-modal-kicker { font-size: 9px !important; margin-bottom: 4px !important; }
  .gb-result-modal h2 {
    font-size: clamp(20px, 6vw, 28px) !important;
    margin: 0 34px 6px 0 !important;
    line-height: 1.12;
  }
  .gb-result-modal-summary {
    font-size: 11px !important;
    line-height: 1.35 !important;
    margin: 0 0 8px !important;
  }
  .gb-result-share-picker { padding: 8px !important; margin-bottom: 8px !important; }
  .gb-result-share-heading { margin-bottom: 7px !important; gap: 7px; }
  .gb-result-share-heading h3 { font-size: 12px !important; }
  .gb-result-share-options { gap: 6px !important; }
  .gb-result-share-options button { min-height: 44px !important; padding: 6px 4px !important; }
  .gb-result-share-options strong { font-size: 9px !important; }
  .gb-result-modal-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px !important;
  }
  .gb-result-modal-actions button,
  .gb-result-modal-actions a {
    min-width: 0;
    width: 100% !important;
    min-height: 44px !important;
    font-size: 10px !important;
    padding: 8px !important;
    overflow-wrap: anywhere;
  }
  .gb-result-modal-actions .gb-result-share-primary { grid-column: 1 / -1; }
}

@media screen and (max-width: 360px) {
  .gb-result-modal-visual { grid-template-columns: 76px minmax(0, 1fr); }
  .gb-result-modal-image-wrap { max-width: 76px !important; width: 76px !important; height: 76px; }
  .gb-battle-page-active .gb-battle-options > .gb-free-bot-reroll {
    grid-template-columns: minmax(0, 1fr) minmax(102px, 44%);
  }
}

/* 320×568 has less room for contextual detail. Preserve five complete
   move buttons and the bot action name; full action details remain in history. */
@media screen and (max-width: 360px) and (max-height: 650px) {
  .gb-battle-page-active .gb-battle-options > .gb-last-opponent-move {
    min-height: 30px !important;
    max-height: 30px !important;
    height: 30px !important;
    padding: 2px 5px !important;
  }
  .gb-battle-page-active .gb-last-opponent-move-copy > span {
    display: none !important;
  }
  .gb-battle-page-active .gb-last-opponent-move > img {
    width: 22px !important;
    height: 22px !important;
  }
}

/* Never override accessible reduced-motion preferences. */
@media (prefers-reduced-motion: reduce) {
  .gb-result-modal *,
  .gb-battle-page-active .gb-battle-options * {
    scroll-behavior: auto;
  }
}

/* Phase-one onboarding closeout: one clear instruction, no repeated text. */
@media screen and (max-width: 640px) {
  .gb-battle-page-active .gb-battle-options > .gb-fifth-picker > p {
    display: none !important;
  }

  /* Bonus cards remain full-width tap targets. Tapping opens an inspect-first
     dialog showing the complete effect, then the player chooses explicitly. */
  .gb-battle-page-active .gb-fifth-picker-card {
    min-height: 60px !important;
    touch-action: manipulation;
  }

  /* Dangerous action lives in a quiet disclosure instead of a giant red CTA. */
  .gb-battle-page-active .gb-battle-secondary-controls .gb-match-options-disclosure {
    flex: 0 1 auto;
    width: min(240px, 100%);
    margin: 0 auto;
    padding: 0;
    border: 1px solid rgba(156, 181, 173, .38);
    border-radius: 9px;
    background: rgba(5, 28, 25, .8);
    color: #d7f7ee;
    font-family: Orbitron, sans-serif;
  }
  .gb-match-options-disclosure > summary {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 9px 13px;
    font-weight: 800;
    font-size: 11px;
    list-style: none;
  }
  .gb-match-options-disclosure > summary::-webkit-details-marker { display: none; }
  .gb-match-options-disclosure > summary::after {
    content: " ▾";
    margin-left: 8px;
    color: #b5d5c9;
  }
  .gb-match-options-disclosure[open] > summary { border-bottom: 1px solid #56736b55; }
  .gb-battle-page-active .gb-match-options-disclosure .gb-battle-forfeit-button {
    display: block;
    width: calc(100% - 16px);
    min-height: 44px;
    margin: 8px;
    padding: 8px 10px;
    border: 1px solid rgba(248, 113, 113, .7) !important;
    background: rgba(87, 24, 24, .65) !important;
    color: #ffe5e5 !important;
    font-size: 10px !important;
    box-shadow: none !important;
    font-weight: 800;
    cursor: pointer;
  }
}

/* Card-effect and forfeit confirmations are available on all preview widths,
   including desktop if the user opens the same test route. */
.gb-bonus-detail-backdrop,
.gb-forfeit-confirm-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top, 0px)) 12px
    max(12px, env(safe-area-inset-bottom, 0px));
  background: rgba(0, 7, 9, .9);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  z-index: 550;
  box-sizing: border-box;
}
.gb-bonus-detail-dialog,
.gb-forfeit-confirm-dialog {
  box-sizing: border-box;
  width: min(430px, 100%);
  max-height: min(88dvh, 740px);
  padding: 17px;
  border-radius: 14px;
  background: linear-gradient(150deg, #142c2a, #190d24);
  color: #f3fff9;
  border: 2px solid #b56cff;
  box-shadow: 0 0 30px #a878ff66;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  position: relative;
  text-align: left;
  font-family: Orbitron, sans-serif;
}
.gb-forfeit-confirm-dialog {
  border-color: #f87171;
  box-shadow: 0 0 30px #f8717155;
}
.gb-bonus-detail-close {
  position: absolute;
  right: 9px;
  top: 8px;
  min-height: 44px;
  min-width: 44px;
  border: 1px solid #f6edff88;
  background: #271636;
  color: white;
  border-radius: 9px;
  cursor: pointer;
  font-size: 24px;
}
.gb-bonus-detail-kicker {
  display: block;
  color: #d9b6ff;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  margin: 6px 45px 10px 0;
}
.gb-bonus-detail-dialog h2,
.gb-forfeit-confirm-dialog h2 {
  font-size: clamp(17px, 5vw, 23px);
  margin: 0 40px 13px 0;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.gb-bonus-detail-art {
  display: block;
  max-height: min(150px, 23dvh);
  max-width: 100%;
  margin: 0 auto 14px;
  object-fit: contain;
}
.gb-bonus-detail-effect {
  font: 600 15px/1.5 system-ui, sans-serif;
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
  margin: 0 0 10px;
}
.gb-bonus-detail-help,
.gb-forfeit-confirm-dialog p {
  color: #d3e4e0;
  font: 400 12px/1.5 system-ui, sans-serif;
  margin: 0 0 15px;
}
.gb-bonus-detail-actions,
.gb-forfeit-confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.gb-bonus-detail-actions button,
.gb-forfeit-confirm-actions button {
  min-height: 48px;
  border-radius: 9px;
  padding: 8px 10px;
  font: 800 11px/1.3 Orbitron, sans-serif;
  color: #ecfff6;
  border: 1px solid #b2cebf88;
  background: #122a29;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.gb-bonus-detail-actions .gb-bonus-detail-select {
  border-color: #d8c7ff;
  color: #170925;
  background: linear-gradient(135deg, #caa4ff, #f2d175);
}
.gb-forfeit-confirm-actions .gb-forfeit-confirm-danger {
  border-color: #fbb;
  color: #fff;
  background: #a52b31;
}
.gb-forfeit-confirm-actions .gb-forfeit-confirm-danger:disabled { opacity: .5; }
.gb-bonus-detail-actions button:focus-visible,
.gb-bonus-detail-close:focus-visible,
.gb-forfeit-confirm-actions button:focus-visible,
.gb-match-options-disclosure summary:focus-visible {
  outline: 3px solid #f4edff;
  outline-offset: 3px;
}

@media (max-width: 360px) {
  .gb-bonus-detail-dialog, .gb-forfeit-confirm-dialog { padding: 12px; }
  .gb-bonus-detail-actions,
  .gb-forfeit-confirm-actions { gap: 6px; }
  .gb-bonus-detail-actions button,
  .gb-forfeit-confirm-actions button { font-size: 10px; padding: 6px; }
}

/* Garden Bot landing screen: readable mobile rank summaries.
   This stylesheet is loaded only by the same-origin TEST path, not /battle. */
@media screen and (max-width: 700px) {
  .gb-player-status-strip .gb-mobile-profile-heading {
    gap: 8px;
    margin-bottom: 9px;
  }
  .gb-player-status-strip .gb-mobile-profile-heading > span {
    font-size: 11px !important;
    line-height: 1.3;
  }
  .gb-player-status-strip .gb-mobile-profile-heading a,
  .gb-player-status-strip .gb-mobile-profile-heading button {
    min-height: 40px !important;
    font-size: 9px !important;
    padding: 7px 9px !important;
  }

  /* The underlying two-column mobile grid is too narrow for a live
     balance/rank plus three large numbers. Give each rank full width. */
  .gb-player-status-strip .gb-player-profile-content {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 8px !important;
  }
  .gb-player-status-strip .gb-rank-showcase { display: contents !important; }
  .gb-player-status-strip .gb-player-profile-content > *,
  .gb-player-status-strip .gb-player-profile-content .gb-rank-showcase > * {
    min-width: 0;
  }
  .gb-player-status-strip .gb-player-record-card.gb-hud-rank-card,
  .gb-player-status-strip .gb-tree-status-card {
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box;
    min-height: 88px !important;
    grid-template-columns: 60px minmax(0, 1fr) !important;
    gap: 11px !important;
    padding: 11px !important;
    align-items: center;
  }
  .gb-player-status-strip .gb-tree-status-card {
    min-height: 135px !important;
  }
  .gb-player-status-strip .gb-hud-rank-crest-shell {
    height: 58px !important;
    width: 58px !important;
  }
  .gb-player-status-strip .gb-hud-rank-card .gb-tree-badge-crest-lg,
  .gb-player-status-strip .gb-player-record-card .gb-hud-rank-crest-shell .gb-tree-badge-crest-lg {
    height: 52px !important;
    width: 52px !important;
  }
  .gb-player-status-strip .gb-hud-rank-content {
    min-width: 0 !important;
    display: flex;
    flex-direction: column;
    gap: 4px !important;
  }
  .gb-player-status-strip .gb-hud-rank-card .gb-holder-rank-kicker,
  .gb-player-status-strip .gb-hud-rank-card .gb-battle-rank-kicker {
    font-size: 10px !important;
    line-height: 1.3 !important;
    letter-spacing: .4px !important;
    overflow-wrap: anywhere;
  }
  .gb-player-status-strip .gb-hud-rank-card .gb-holder-rank-title,
  .gb-player-status-strip .gb-hud-rank-card .gb-battle-rank-title {
    font-size: clamp(16px, 4.6vw, 20px) !important;
    line-height: 1.2 !important;
    letter-spacing: .1px !important;
    overflow-wrap: anywhere;
  }
  .gb-player-status-strip .gb-hud-rank-card .gb-holder-rank-balance {
    font-size: 12px !important;
    line-height: 1.35 !important;
    letter-spacing: 0 !important;
    font-family: system-ui, sans-serif;
    font-weight: 700 !important;
    color: #ebfff4;
    padding-top: 5px !important;
    overflow-wrap: anywhere;
  }
  .gb-player-status-strip .gb-tree-status-qualifying {
    font: 700 12px/1.4 system-ui, sans-serif !important;
    color: #aaffc8;
    overflow-wrap: anywhere;
  }
  .gb-player-status-strip .gb-tree-status-next-tier {
    font: 600 11px/1.35 system-ui, sans-serif !important;
    color: #ffdfa0;
    overflow-wrap: anywhere;
  }

  /* Stats already expands the profile in the React app. Initially show the
     tier and holdings; reveal full LP/staked source data on request. */
  .gb-player-status-strip:not([data-expanded="true"]) .gb-tree-status-sources {
    display: none !important;
  }
  .gb-player-status-strip[data-expanded="true"] .gb-player-profile-content {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .gb-player-status-strip[data-expanded="true"] .gb-tree-status-sources {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 6px !important;
    margin-top: 6px;
    width: 100%;
  }
  .gb-player-status-strip[data-expanded="true"] .gb-tree-status-sources > span {
    box-sizing: border-box;
    display: grid !important;
    grid-template-columns: minmax(74px, 100px) minmax(0, 1fr) !important;
    align-items: center;
    gap: 8px;
    padding: 8px 10px !important;
    min-width: 0;
    min-height: 40px;
    text-align: left !important;
  }
  .gb-player-status-strip[data-expanded="true"] .gb-tree-status-sources > span > strong {
    color: #c5ffe0;
    font-size: 10px !important;
    line-height: 1.25;
    letter-spacing: .2px;
  }
  .gb-player-status-strip[data-expanded="true"] .gb-tree-status-sources > span > span {
    color: #effff4;
    font: 700 12px/1.35 system-ui, sans-serif !important;
    text-align: right;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  /* Keep the game entry directly below the profile, rather than expanding
     the rank cards into an oversized pre-game dashboard. */
  .gb-player-status-strip .gb-rank-showcase-copy { display: none !important; }
}
