/* Loaded last on every page: less motion when the system asks for it, and layouts for smaller screens. */

@media (prefers-reduced-motion: reduce) {
  .slot-mystery .showcase-face::before,
  .forge-anvil.is-idle .anvil-light,
  .forge-anvil.is-idle .anvil-ember,
  .dial-revealed .dial-core,
  .slot-reveal .target-name,
  .slot-reveal .skin-price,
  .slot-reveal .target-image,
  .reveal-rays,
  .dial-won,
  .dial-lost,
  .slot-won .target-image,
  .skin-media,
  .drop-new,
  .toast,
  .page > *,
  .profile-page > *,
  .stake-tile-new,
  .showcase-face,
  .showcase-face-leaving,
  .skin-withdrawing-label::before,
  .age-gate[open],
  .faq-item[open] .faq-answer,
  .target-image,
  .skin-card-selected::after,
  .balance-changed,
  #forge-button:not(:disabled),
  .case-skeleton,
  .case-hero-art,
  .case-hero-art::before,
  .case-hero-art::after,
  .case-hero-art.is-open::after,
  .case-drops.is-entering .case-drop {
    animation: none;
  }

  /* Cases: the hover lift stays, but without the slide between states */
  .case-art-wrap img,
  .case-card::before,
  .case-card::after,
  .case-reel-tile,
  .case-hero-tilt,
  .case-hero-stage,
  .case-hero-art::before,
  .case-hero-art img {
    transition: none;
  }

  .skin-card-selectable:hover,
  .skin-card-selectable:hover .skin-image,
  .drop:hover,
  .chat-badge:hover,
  .wheel-badge:hover {
    transform: none;
  }

  .button-primary::after {
    display: none;
  }

  /* Without its fade the old Mystery skin would sit on top of the new one, so it goes at once */
  .showcase-face-leaving {
    display: none;
  }

  /* Upgrade dial: no camera move and no strike flash; the light and the result word only fade */
  .forge.is-focused .dial {
    scale: none;
  }

  .dial-arm::after {
    display: none;
  }

  .dial-won::before,
  .dial-won .dial-zone {
    animation: none;
  }

  .dial-won .dial-label,
  .dial-lost .dial-label {
    animation: result-fade 0.2s ease-out both;
  }

  .slot-won::after,
  .slot-burned::after {
    animation: slot-flash 0.6s ease-out;
  }
}

@keyframes result-fade {
  from { opacity: 0; }
}

/* Narrower laptop screens: a smaller coin leaves room for the price in five columns */
@media (max-width: 1500px) {
  .skin-grid .skin-price {
    font-size: 0.78rem;
  }

  .skin-card .coin {
    width: 18px;
    height: 18px;
  }
}

@media (max-width: 1360px) {
  .skin-grid .skin-price {
    gap: 3px;
    font-size: 0.72rem;
  }

  .skin-card .coin {
    width: 15px;
    height: 15px;
  }

  .profile-tabs-panel .skin-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

/* Small laptops and tablets: the panels stack, so each one has room for wide cards again */
@media (max-width: 1120px) {
  .panels {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }

  .skin-grid .skin-price {
    gap: 4px;
    font-size: 0.85rem;
  }

  .skin-card .coin {
    width: 20px;
    height: 20px;
  }

  .catalog-scroll {
    max-height: 640px;
  }

  .history-row {
    grid-template-columns: minmax(0, max-content) auto 130px minmax(120px, 1fr);
    gap: 10px;
  }

  .history-target {
    width: 130px;
  }

  #profile-withdrawals-list .history-row {
    grid-template-columns: minmax(0, 1fr) 110px minmax(200px, 300px);
  }
}

/* Tablets: the forge stacks too */
@media (max-width: 900px) {
  .forge {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    max-width: 520px;
  }

  .dial {
    justify-self: center;
  }

  .slot {
    min-height: 150px;
  }

  /* The stake is above the anvil now, so it falls onto it */
  @keyframes stake-feed {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(120px) scale(0.3); opacity: 0; }
  }

  .skin-grid,
  .profile-tabs-panel .skin-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .profile-top {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .profile-card {
    grid-column: 1 / -1;
  }

  .profile-top > .panel {
    min-height: 220px;
  }

  .profile-extras {
    grid-template-columns: minmax(0, 1fr);
  }

  .history-row {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    text-align: center;
  }

  .history-stake {
    justify-content: center;
  }

  .history-arrow {
    transform: rotate(90deg);
  }

  .history-result {
    align-items: center;
    text-align: center;
  }

  /* Withdrawals stack too: name, price, status under each other */
  #profile-withdrawals-list .history-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  #profile-withdrawals-list .skin-price {
    justify-self: center;
  }

  .withdrawal-reason {
    max-width: none;
    text-align: center;
  }
}

/* Phones */
@media (max-width: 640px) {
  /* Two rows would take too much of a small screen if they stayed pinned to the top */
  .header {
    position: static;
    flex-wrap: wrap;
    gap: 8px 10px;
    /* Two rows: the logo and the account, then the menu. A fixed height let the second row fall on the drops strip */
    height: auto;
    padding: 8px 12px 0;
  }

  .account {
    order: 2;
  }

  /* The menu gets its own row and scrolls sideways when the words are long (other languages) */
  .site-nav {
    order: 3;
    flex-basis: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: 40px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  /* The footer: the brand on its own row, the link lists two by two, long words wrap (other languages) */
  .footer-top {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px 16px;
  }

  .footer-brand {
    grid-column: 1 / -1;
  }

  .footer-links a {
    overflow-wrap: anywhere;
  }

  /* The wheel's hammer picture is wider than a phone: its empty edge must not make the page scroll sideways */
  .wheel-machine {
    overflow-x: hidden; /* fallback for Safari before 16 */
    overflow-x: clip;
  }

  /* The round wheel and chat buttons are smaller, so they cover less of the page */
  .wheel-badge,
  .chat-badge {
    --round-button-size: 44px;
    --round-button-bottom: 12px;
  }

  .wheel-badge .icon,
  .chat-badge .icon {
    width: 22px;
    height: 22px;
  }

  .logo {
    font-size: 1.15rem;
  }

  .logo-icon {
    width: 34px;
  }

  .account {
    flex: 1;
    justify-content: flex-end;
    gap: 8px;
  }

  .account-name {
    display: none;
  }

  .avatar {
    width: 34px;
    height: 34px;
  }

  .balance {
    padding: 4px 10px 4px 5px;
    font-size: 0.9rem;
  }

  .account .button {
    padding: 8px 10px;
    font-size: 0.85rem;
  }

  /* The bottom leaves room for the round wheel and chat buttons, so they never sit on the page's last controls */
  .page {
    padding: 16px 12px 72px;
  }

  .drops {
    padding: 6px 12px;
  }

  .inventory-tools {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .inventory-tools .field-search {
    grid-column: 1 / -1;
  }

  .mode-switch {
    width: 100%;
  }

  .mode-switch .tab {
    flex: 1;
    min-width: 0;
  }

  .dial {
    width: 280px;
    height: 280px;
  }

  .dial-knife {
    height: 60px;
  }

  .button-primary {
    width: 100%;
  }

  .panel {
    padding: 12px;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
    justify-content: center;
    padding: 10px 8px;
    font-size: 0.82rem;
  }

  /* The profile's tab names are long, so they drop the icons to fit side by side */
  .profile-tabs-panel .tab {
    gap: 5px;
    padding: 10px 4px;
    font-size: 0.74rem;
    letter-spacing: 0.02em;
  }

  .profile-tabs-panel .tab .icon {
    display: none;
  }

  .profile-top {
    grid-template-columns: minmax(0, 1fr);
  }

  .skin-grid,
  .profile-tabs-panel .skin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .catalog-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .catalog-filters .field-search {
    grid-column: 1 / -1;
  }

  .catalog-sort {
    grid-column: 1 / -1;
  }

  .mystery-mode .catalog-filters {
    grid-template-columns: minmax(0, 1fr);
  }

  .catalog-scroll {
    max-height: 560px;
  }

  .multiplier-form {
    width: 100%;
  }

  .multiplier-input {
    flex: 1;
  }

  .shop-buy {
    min-width: 0;
    width: auto;
    padding: 10px 20px;
  }

  .profile-head {
    flex-wrap: wrap;
    padding: 18px 16px;
  }

  .profile-avatar {
    width: 76px;
    height: 76px;
  }

  .profile-identity {
    flex: 1;
  }

  .profile-name {
    font-size: 1.3rem;
  }

  /* Narrow: the chips keep their icons; the words stay for screen readers only */
  .profile-chips dt span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .profile-extras {
    gap: 8px;
  }

  .history-skin {
    width: calc(50% - 4px);
  }

  .history-target {
    width: 170px;
  }
}
