/* Phones.
   Files in css/ load in name order (index.html); later files win on equal selectors. */
/* ---------- Phones ---------- */
/* Filter chips sit inline with the search on desktop and get their own swipeable row on phones. */
.toolbar-chips { display: contents; }
/* No 300 ms double-tap zoom delay on anything you tap quickly (+1, cards, chips). */
button, a, label, .pcard, .region { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

@media (max-width: 900px) {
  .topbar {
    padding: calc(8px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 8px calc(12px + env(safe-area-inset-left));
    background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  }
  .sidebar { padding-top: calc(26px + env(safe-area-inset-top)); padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .toolbar { top: calc(57px + env(safe-area-inset-top)); }
  .main { padding-left: calc(16px + env(safe-area-inset-left)); padding-right: calc(16px + env(safe-area-inset-right)); padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(20px + env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); }
}

@media (max-width: 560px) {
  /* iOS zooms into inputs under 16px. */
  input, select, textarea, .search input { font-size: 16px; }
  .icon-btn { width: 40px; height: 40px; }

  /* Hero: title, three stats in a row, then the ring next to the recommendations. */
  .hero, .banner { padding: 20px 18px; border-radius: 22px; gap: 18px; }
  .hero h1, .banner h1 { font-size: 34px; }
  .hero-sub { margin-top: 10px; font-size: 14px; }
  .eyebrow { margin-bottom: 10px; font-size: 10px; }
  .stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
  #huntsStats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { min-width: 0; padding: 10px 12px; border-radius: 14px; }
  .stat b { font-size: 20px; }
  .stat span { font-size: 9px; letter-spacing: .06em; display: block; line-height: 1.3; }
  .hero-side { flex-wrap: nowrap; align-items: center; gap: 14px; }
  .ring.big { width: 104px; height: 104px; }
  .ring.big .ring-label b { font-size: 24px; }
  .ring-label span { font-size: 8.5px; }
  .up-next { flex: 1; min-width: 0; width: auto; }
  .up-next-row { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .up-next .mini-label { margin-bottom: 6px; }

  /* Game banner: logo and ring on top, text below. */
  .banner-content { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px 12px; }
  .banner-logo { width: 100%; max-width: 180px; height: 80px; justify-self: start; }
  .banner-logo img { object-position: left center; }
  .banner-text { grid-column: 1 / -1; grid-row: 2; }
  .banner .ring { width: 92px; height: 92px; grid-column: 2; grid-row: 1; }
  .banner .ring-label b { font-size: 21px; }
  .wordmark { font-size: 22px; text-align: left; }

  /* Region strip and dex tabs */
  .regions { gap: 6px; padding-top: 14px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scroll-padding-inline: 16px; }
  .region { min-width: 96px; padding: 10px 12px 12px; border-radius: 14px; }
  .region .r-name { font-size: 14px; }
  .segmented { display: flex; margin-top: 14px; }
  .seg { padding: 9px 12px; font-size: 13px; gap: 7px; }

  /* Toolbar: full-width search, chips in one swipeable row. */
  .toolbar { gap: 8px; margin: 8px -16px 14px; padding: 10px 16px; box-shadow: 0 10px 16px -14px rgba(0, 0, 0, .5); }
  .search { flex: 1 1 100%; height: 42px; }
  .search kbd { display: none; }
  .toolbar-chips {
    display: flex; gap: 6px; width: calc(100% + 32px); margin: 0 -16px; padding: 0 16px; overflow-x: auto; scrollbar-width: none;
  }
  .toolbar-chips::-webkit-scrollbar { display: none; }
  .toolbar-chips > * { flex: none; }
  .chip-toggle, .random-btn { flex: none; height: 36px; padding: 0 13px; border-radius: 11px; font-size: 12.5px; white-space: nowrap; }
  .chip-toggle::before { margin-right: 6px; width: 7px; height: 7px; }
  .random-btn svg { width: 15px; height: 15px; }

  /* Sections */
  .dex-section + .dex-section { margin-top: 30px; }
  .section-head { gap: 10px; margin-bottom: 12px; align-items: center; }
  .section-num { font-size: 26px; }
  .section-title { font-size: 18px; }

  /* Cards: three compact cards per row. */
  .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .pcard { padding: 8px 6px 9px; border-radius: 14px; contain-intrinsic-size: auto 168px; }
  .card-top { min-height: 16px; gap: 3px; overflow: hidden; }
  .no { font-size: 9px; }
  .seal { width: 15px; height: 15px; }
  .sprite { width: min(76px, 100%); height: auto; aspect-ratio: 1; margin: 6px 0 6px; }
  .pname { font-size: 12.5px; }
  .form-tag { font-size: 7.5px; padding: 3px 4px; margin-top: 4px; }
  .types { gap: 2px; margin: 6px 0 0; min-height: 12px; }
  .types img { height: 11px; border-radius: 2px; }
  .shiny-count, .via-chip { font-size: 8.5px; padding: 2px 4px; }
  .status-chip { transform: scale(.85); }
  /* Hunt strip stacks count over time so it fits a narrow card. */
  .hunt-strip { flex-direction: column; align-items: center; gap: 4px; margin-top: 6px; padding: 5px 4px; border-radius: 8px; font-size: 9.5px; }
  .types { flex-wrap: wrap; width: 100%; }
  .types img { height: auto; max-height: 11px; max-width: calc(50% - 1px); object-fit: contain; }
  .toolbar-chips .random-btn { order: -1; }
  #huntCards .section-head { flex-wrap: wrap; row-gap: 4px; }
  #huntCards .section-meta { margin-left: 0; width: 100%; }
  .empty-state { padding: 50px 16px; font-size: 14px; border-radius: 20px; }

  /* Opaque sticky toolbar, so card text doesn't show through. */
  .toolbar { background: var(--bg); }
  /* Swipeable rows fade out at the edge to hint there's more. */
  .toolbar-chips, .regions {
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
  }
  /* Cards: no reserved space for a missing form label; types sit at the bottom. */
  .pcard .form-tag.blank { display: none; }
  .pcard .types { margin-top: auto; padding-top: 6px; }
  .pname { margin-top: 2px; }

  /* Adjust hunt: step + encounters on one row, hours/min/sec on the next. */
  .dr-fields { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .dr-fields label { grid-column: span 2; }
  .dr-fields label:nth-child(2) { grid-column: span 4; }
  .dr-fields input { font-size: 16px; padding: 10px 6px; }

  /* Recommended: columns may shrink below the sprite's natural width. */
  .up-next-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .up-next-row button { min-width: 0; }

  /* Date/time pickers (Caught on): iOS gives them a fixed intrinsic width; let them fit the form. */
  .en-add-form label, .en-edit label { min-width: 0; }
  input[type="datetime-local"] {
    display: block; width: 100%; min-width: 0; max-width: 100%; min-height: 42px; -webkit-appearance: none; appearance: none;
  }
  input[type="datetime-local"]::-webkit-date-and-time-value { text-align: center; }

  /* Bigger tap targets for close / delete (✕) buttons. */
  .dr-head .dr-icon, .rl-close { width: 42px; height: 42px; border-radius: 13px; font-size: 19px; }
  .log-del, .log-share { min-width: 38px; height: 38px; padding: 0 10px; border-radius: 11px; font-size: 15px; }
  .share-ico { width: 17px; height: 17px; }
  .share-dlg.roulette { padding: 12px; }
  .st-hero-side { width: 100%; align-items: stretch; }
  .st-years { align-self: flex-start; }
  #stStats .stat { padding: 12px; }
  #stStats .stat b { font-size: 20px; }
  .st-share { justify-content: center; height: 48px; }
  .st-highlights { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .st-hl { padding: 12px 12px 14px; border-radius: 18px; }
  .st-hl-img { width: 76px; height: 76px; }
  .st-hl-value { font-size: 18px; }
  .st-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .st-card { padding: 16px 14px 14px; border-radius: 18px; }
  .st-cols { gap: 3px; height: 150px; }
  .st-row { grid-template-columns: minmax(0, 46%) minmax(0, 1fr) auto; gap: 8px; padding: 0 2px; }
  .st-col-label { font-size: 9px; }
  .share-dlg .rl-card { padding: 20px 18px 16px; }

  /* Add / edit a shiny: encounters gets its own row, then hours · min · sec. */
  .en-add-form, .en-edit { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .en-add-form input, .en-edit input { font-size: 16px; padding: 10px 8px; }

}

@media (max-width: 360px) {
  .hero h1, .banner h1 { font-size: 30px; }
  .card-grid { gap: 6px; }
  .pname { font-size: 11.5px; }
  .ring.big { width: 92px; height: 92px; }
}

/* Login on phones: the card fills the screen width, the Google button fits inside it. */
@media (max-width: 560px) {
  .gate-card { padding: 26px 20px 22px; border-radius: 24px; }
  .gate-logo { margin-bottom: 18px; }
  .gate-card h2 { font-size: 26px; }
  .gate-sub { margin: 8px 0 18px; font-size: 13.5px; }
  .gate-or { margin: 14px 0; }
  #gateForm { gap: 10px; }
  #gateForm input { font-size: 16px; }
  .gate-switch { line-height: 1.9; }
}
