/* Trail Radio: compact, persistent music controls without another modal. */
.topbar {
  z-index: 30;
  overflow: visible;
}

.audio-control {
  position: relative;
  z-index: 50;
  flex: 0 0 auto;
}

.sound-button {
  display: inline-flex;
  min-width: 88px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-color: rgba(129, 205, 235, .62);
  background: linear-gradient(180deg, #31536a, #172b3b);
  box-shadow: inset 0 1px 0 rgba(218, 248, 255, .18), 0 3px 0 #0d1d29, 0 0 12px rgba(96, 202, 236, .13);
  color: #d9f7ff;
}

.sound-button:hover,
.sound-button[aria-expanded="true"] {
  border-color: #b8f3ff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28), 0 3px 0 #0d1d29, 0 0 18px rgba(100, 220, 255, .32);
}

.sound-button[data-muted="true"] {
  border-color: rgba(180, 166, 190, .56);
  background: linear-gradient(180deg, #514354, #29202f);
  box-shadow: inset 0 1px 0 rgba(255, 239, 255, .1), 0 3px 0 #171018;
  color: #e0d4e2;
}

.sound-icon {
  display: inline-grid;
  width: 17px;
  height: 17px;
  place-items: center;
  color: #aef3ff;
  font-size: 16px;
  line-height: 1;
  text-shadow: 0 0 8px rgba(119, 233, 255, .72);
}

.sound-button[data-muted="true"] .sound-icon {
  color: #d6c9d7;
  text-shadow: none;
}

.audio-panel {
  position: absolute;
  z-index: 100;
  top: calc(100% + 10px);
  right: 0;
  width: 246px;
  padding: 11px;
  border: 1px solid rgba(231, 192, 117, .63);
  border-radius: 12px;
  background:
    linear-gradient(145deg, rgba(87, 58, 46, .98), rgba(24, 18, 27, .98) 72%),
    repeating-linear-gradient(0deg, rgba(255, 222, 166, .04) 0 1px, transparent 1px 7px);
  box-shadow: inset 0 1px 0 rgba(255, 235, 191, .16), 0 8px 0 rgba(10, 6, 11, .8), 0 18px 32px rgba(0, 0, 0, .52);
  color: #ffe9be;
}

.audio-panel.hidden { display: none; }

.audio-panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.audio-panel-heading > span {
  color: #ffe0a0;
  font-family: "Cinzel", Georgia, serif;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
}

.audio-panel-heading small {
  max-width: 132px;
  color: #aad7df;
  font-size: 7px;
  font-weight: 800;
  line-height: 1.15;
  text-align: right;
}

.music-volume-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #dac3a2;
  font-size: 9px;
  font-weight: 900;
}

.music-volume-label output {
  min-width: 33px;
  color: #aef3ff;
  text-align: right;
}

.music-volume {
  width: 100%;
  height: 17px;
  margin: 3px 0 8px;
  accent-color: #87e0ee;
  cursor: pointer;
}

.music-volume:focus-visible {
  outline: 2px solid #d7faff;
  outline-offset: 2px;
}

.audio-mute-button {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid rgba(181, 225, 239, .52);
  border-radius: 8px;
  background: linear-gradient(#386278, #1b3345);
  box-shadow: inset 0 1px 0 rgba(238, 255, 255, .16), 0 2px 0 #0b1822;
  color: #e0fbff;
  font-size: 9px;
  font-weight: 1000;
}

.audio-mute-button:hover { filter: brightness(1.13); transform: translateY(-1px); }
.audio-mute-button[aria-pressed="true"] { border-color: rgba(221, 188, 227, .62); background: linear-gradient(#684b68, #34263b); color: #ffe3f7; }

@media (max-width: 1130px) {
  .sound-button { min-width: 38px; padding-right: 9px; padding-left: 9px; }
  .sound-label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .audio-mute-button:hover,
  .sound-button:hover { transform: none; }
}

/* Phone battlefield: reflow the game for touch screens instead of shrinking the desktop table. */
@media (max-width: 760px) {
  html,
  body {
    min-width: 0 !important;
    max-width: 100%;
    overflow-x: clip;
  }

  body {
    background-size: auto, auto, 96px 96px, auto;
  }

  .game-shell {
    width: 100%;
    min-width: 0;
    max-width: none;
    padding: 8px 8px calc(30px + env(safe-area-inset-bottom));
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 58px auto;
    min-height: 52px;
    height: auto;
    gap: 4px;
    padding: 6px 7px;
    border-radius: 13px 13px 8px 8px;
  }

  .logo { min-width: 0; gap: 4px; }
  .logo-crown { font-size: 23px; }
  .logo b { font-size: 12px; letter-spacing: 1.15px; }
  .logo small { font-size: 6px; letter-spacing: 3.6px; }
  .round-readout { min-width: 0; text-align: center; }
  .round-readout span { display: none; }
  .round-readout strong { display: block; font-size: 10px; line-height: 1.05; letter-spacing: .2px; }

  .topbar-actions { gap: 4px; }
  .topbar-actions .settings-button {
    display: grid;
    width: 35px;
    min-width: 35px;
    height: 34px;
    place-items: center;
    padding: 5px;
    border-radius: 9px;
  }
  .locker-button span,
  #resetButton span { display: none; }
  .sound-button { min-width: 35px; }
  .sound-icon { font-size: 15px; }
  .audio-panel { right: -4px; top: calc(100% + 7px); width: min(246px, calc(100vw - 20px)); }

  .adventure-bar {
    min-height: 0;
    margin: 9px 0 0;
    grid-template-columns: minmax(0, 1fr) 30px minmax(0, 1fr);
    gap: 3px;
  }

  .hero-card {
    min-width: 0;
    height: 70px;
    border-width: 2px;
    border-radius: 13px;
  }

  .portrait {
    width: 45px;
    height: 66px;
    flex-basis: 45px;
  }
  .portrait span { font-size: 31px; }
  .hero-details { min-width: 0; padding: 4px 3px; }
  .hero-details .eyebrow { font-size: 6px; letter-spacing: .3px; }
  .hero-details strong,
  #playerHero .hero-details strong { overflow: hidden; font-size: 10px; line-height: 1.05; text-overflow: ellipsis; }
  .hero-details small { margin-top: 2px; font-size: 7px; line-height: 1.08; }
  .rival-power,
  .npc-readout {
    max-width: 100%;
    margin: 2px 0 0;
    padding: 1px 3px;
    overflow: hidden;
    font-size: 6px;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #playerHero .player-details { padding: 3px 2px; }
  #statusText,
  .player-sticker-bar { display: none; }
  .player-title-ribbon { max-width: 100%; padding: 1px 3px; font-size: 5px !important; }
  .health-orb {
    width: 31px;
    height: 31px;
    flex: 0 0 31px;
    margin: 0 2px;
    border-width: 2px;
  }
  .health-orb b { font-size: 13px; }
  .health-orb small { font-size: 5px; }
  .versus span { display: none; }
  .versus b { width: 29px; height: 29px; font-size: 9px; }

  .arena-wrap:not(.boss-encounter) {
    height: 490px;
    margin-top: 10px;
    border-width: 2px;
    border-radius: 19px;
  }

  .arena-wrap:not(.boss-encounter) .arena {
    padding: 47px 8px 31px;
    grid-template-rows: minmax(168px, 1fr) 29px minmax(168px, 1fr);
  }

  .rival-rail { display: none; }
  .battle-banner {
    top: 9px;
    max-width: calc(100% - 26px);
    padding: 4px 10px 3px;
    overflow: hidden;
    font-size: 7px;
    letter-spacing: .45px;
    text-overflow: ellipsis;
  }
  .battle-banner span { margin: 0 2px; }
  .side-label {
    padding: 2px 5px;
    border-radius: 5px;
    font-size: 6px;
    letter-spacing: .45px;
  }
  .side-label i { display: none; }
  .arena-wrap:not(.boss-encounter) .enemy-side-label { top: 3.5%; left: 9px; }
  .arena-wrap:not(.boss-encounter) .player-side-label { right: 9px; bottom: 2.4%; }

  .arena-wrap:not(.boss-encounter) .enemy-board,
  .arena-wrap:not(.boss-encounter) .player-board {
    align-self: stretch;
    min-height: 168px;
    height: 100%;
    padding: 6px;
    border-radius: 16px;
  }
  .arena-wrap:not(.boss-encounter) .enemy-board { grid-row: 1; }
  .arena-wrap:not(.boss-encounter) .duel-ribbon { display: block; grid-row: 2; }
  .arena-wrap:not(.boss-encounter) .player-board { grid-row: 3; }
  .arena-wrap:not(.boss-encounter) .board {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(2, 76px);
    gap: 8px 5px;
    align-content: center;
  }
  .arena-wrap:not(.boss-encounter) .board-slot { height: 76px; min-width: 0; border-radius: 12px; }
  .arena-wrap:not(.boss-encounter) .board .critter-card {
    width: 100%;
    max-width: 78px;
    height: 76px;
    border-width: 2px;
    border-radius: 35% 35% 18% 18%;
  }
  .arena-wrap:not(.boss-encounter) .board .critter-card::before { inset: 3px; border-radius: 33% 33% 15% 15%; }
  .arena-wrap:not(.boss-encounter) .board .critter-card::after { top: 4px; right: 4px; left: 4px; height: 48px; }
  .arena-wrap:not(.boss-encounter) .board .critter-portrait { top: 12px; font-size: 40px; }
  .arena-wrap:not(.boss-encounter) .board .critter-portrait::after { width: 49px; left: 0; bottom: -4px; }
  .arena-wrap:not(.boss-encounter) .board .ability-gem { top: 2px; left: 14px; min-width: 17px; width: 17px; height: 17px; }
  .arena-wrap:not(.boss-encounter) .board .trait-dot { top: 3px; right: 3px; width: 17px; height: 17px; border-width: 1px; font-size: 8px; }
  .arena-wrap:not(.boss-encounter) .board .card-level { top: -7px; left: -3px; width: 19px; height: 19px; border-width: 1px; font-size: 7px; }
  .arena-wrap:not(.boss-encounter) .board .stat { bottom: -8px; min-width: 24px; height: 24px; border-width: 1px; font-size: 13px; }
  .arena-wrap:not(.boss-encounter) .board .attack { left: -4px; }
  .arena-wrap:not(.boss-encounter) .board .heart { right: -4px; }
  .arena-wrap:not(.boss-encounter) .board .activate-ability { right: 2px; bottom: 3px; min-width: 20px; height: 17px; padding: 0 3px; }
  .arena-wrap:not(.boss-encounter) .board .activate-ability b { font-size: 6px; }
  .arena-wrap:not(.boss-encounter) .player-board .board-slot.empty span { width: 25px; height: 25px; font-size: 15px; }
  .duel-ribbon span { padding: 3px 8px; font-size: 6px; letter-spacing: .6px; }
  .arena-wrap:not(.boss-encounter) .combat-feed {
    width: min(76%, 260px);
    min-width: 0;
    padding: 3px 7px;
    border-radius: 7px;
  }
  .combat-feed b { font-size: 6px; }
  .combat-feed small { display: block; font-size: 6px; line-height: 1.1; }

  .arena-wrap.boss-encounter {
    height: 540px !important;
    margin-top: 10px;
    border-radius: 19px;
  }
  .arena-wrap.boss-encounter .arena { padding: 50px 10px 30px; grid-template-rows: 285px 26px minmax(134px, 1fr); }
  .arena-wrap.boss-encounter .enemy-board {
    grid-row: 1;
    align-self: stretch;
    min-height: 285px;
    height: 100%;
    grid-template-columns: 1fr;
    grid-template-rows: 285px;
    padding: 0 12px;
  }
  .arena-wrap.boss-encounter .enemy-board .boss-field { height: 278px; }
  .arena-wrap.boss-encounter .enemy-board .board-slot:has(.boss-card) { height: 285px; grid-column: 1 / -1; }
  .arena-wrap.boss-encounter .enemy-board .boss-card {
    width: min(300px, 100%) !important;
    min-width: 0;
    height: 278px !important;
    transform: none;
    border-radius: 20px;
  }
  .arena-wrap.boss-encounter .battle-banner,
  .arena-wrap.boss-encounter .enemy-side-label { display: none; }
  .arena-wrap.boss-encounter .duel-ribbon { display: block; grid-row: 2; }
  .arena-wrap.boss-encounter .combat-feed {
    top: 65%;
    right: auto;
    bottom: auto;
    left: 50%;
    width: min(76%, 260px);
    min-width: 0;
    transform: translate(-50%, -50%);
  }
  .arena-wrap.boss-encounter .player-board {
    grid-row: 3;
    align-self: stretch;
    min-height: 134px;
    height: 100%;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(2, 58px);
    gap: 6px 5px;
    padding: 5px;
  }
  .arena-wrap.boss-encounter .player-board .board-slot { height: 58px; min-width: 0; }
  .arena-wrap.boss-encounter .player-board .critter-card { width: 100%; max-width: 66px; height: 58px; }
  .arena-wrap.boss-encounter .player-board .critter-portrait { top: 8px; font-size: 33px; }
  .arena-wrap.boss-encounter .player-board .critter-portrait::after { width: 42px; left: 0; }
  .arena-wrap.boss-encounter .player-board .stat { bottom: -7px; min-width: 21px; height: 21px; font-size: 11px; }

  .controls-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 7px;
    margin: 12px 0 11px;
    padding: 7px;
    border-radius: 16px;
  }
  .controls-row > * { min-width: 0; min-height: 57px; }
  .camp-card,
  .hero-power-card { grid-column: 1 / -1; min-height: 60px; border-radius: 12px; }
  .camp-card { gap: 6px; padding: 6px 7px; }
  .camp-icon { width: 37px; height: 37px; font-size: 22px; }
  .camp-card strong { font-size: 11px; }
  .camp-card .eyebrow { font-size: 7px; }
  .upgrade-button { flex: 0 0 auto; padding: 7px; font-size: 8px; }
  .hero-power-card { padding: 6px 7px; }
  .power-orb { width: 36px; height: 36px; flex: 0 0 36px; font-size: 18px; }
  .power-copy { min-width: 0; }
  .power-copy .eyebrow { font-size: 7px; }
  .power-copy strong { display: block; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
  .power-copy small { display: block; overflow: hidden; font-size: 7px; text-overflow: ellipsis; white-space: nowrap; }
  .power-cost { flex: 0 0 42px; min-width: 42px; }
  .power-cost small { font-size: 5px; }
  .power-cost b { font-size: 16px; }
  .gold-bank { min-height: 57px; border-radius: 12px; }
  .gold-bank .coin { font-size: 22px; }
  .gold-bank b { font-size: 23px; }
  .gold-bank small { margin-bottom: 5px; font-size: 7px; }
  .battle-button { min-height: 57px; height: auto; border-radius: 12px; }
  .battle-button b { font-size: 12px; }
  .battle-button small { font-size: 7px; }
  .button-spark { top: 9px; left: 9px; font-size: 12px; }

  .progress-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin: 0 0 12px;
    padding: 7px;
    border-radius: 12px;
  }
  .progress-row > * { min-width: 0; min-height: 39px; }
  .difficulty-chip { grid-column: 1 / -1; justify-content: center; }
  .difficulty-chip span { font-size: 7px; }
  .difficulty-chip b { overflow: hidden; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
  .adventure-wins-chip,
  .boss-progress-chip { order: initial; margin: 0; border-radius: 8px; }
  .adventure-wins-chip small,
  .boss-progress-chip small { font-size: 6px; }
  .adventure-wins-chip strong,
  .boss-progress-chip strong { font-size: 9px; }
  .paragon-chip,
  .garden-chip { padding: 5px 7px; }
  .paragon-chip small,
  .garden-chip small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .save-status { grid-column: 1 / -1; text-align: center; }
  .boss-notice { width: calc(100% - 4px); margin: -1px auto 12px; padding: 8px; }
  .boss-notice b { font-size: 10px; }
  .boss-notice small { font-size: 7px; }

  .market-section { padding: 12px 10px 13px; border-radius: 16px; }
  .market-heading { gap: 7px; margin: 0; padding-bottom: 7px; }
  .market-heading h1 { font-size: 15px; }
  .market-heading .eyebrow { font-size: 7px; }
  .reroll-button { flex: 0 0 auto; padding: 6px 7px; font-size: 8px; }
  .reroll-button > span { font-size: 13px; }
  .reroll-button b { width: 15px; height: 15px; font-size: 8px; }
  .market-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 10px;
    padding: 5px 4px 16px;
  }
  .market-grid .shop-critter { min-width: 0; height: 177px; }
  .market-grid .shop-critter:last-child { grid-column: 1 / -1; width: calc((100% - 10px) / 2); justify-self: center; }
  .market-grid .shop-critter:hover { transform: none !important; }
  .hint { margin-top: 10px; font-size: 8px; line-height: 1.3; }

  .bench-section { margin: 14px 0 0; }
  .bench-heading { margin: 0 4px 7px; }
  .bench-heading strong { font-size: 9px; }
  .pack-row { grid-template-columns: 1fr; gap: 9px; }
  .bench {
    min-height: 171px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: 75px;
    gap: 10px 7px;
    padding: 8px;
    border-radius: 15px;
  }
  .bench .board-slot { height: 75px; min-width: 0; }
  .bench .critter-card { width: 100%; max-width: 72px; height: 75px; }
  .bench .critter-portrait { top: 8px; font-size: 36px; }
  .bench .critter-portrait::after { width: 46px; left: 0; }
  .bench .critter-name { font-size: 7px; }
  .sell-zone { min-height: 58px; padding: 6px 12px; border-radius: 14px; }
  .sell-zone span { font-size: 23px; }
  .sell-zone b { font-size: 10px; }
  .sell-zone small { font-size: 7px; }
  .sell-zone em { font-size: 10px; }
  .bench .critter-card:hover .critter-name { right: 2px; bottom: 3px; left: 2px; font-size: 7px; }

  .boss-inventory,
  .boss-inventory:has(.boss-inventory-empty) { width: 100%; margin-top: 12px; padding: 9px; }
  .boss-inventory-heading strong { font-size: 12px; }
  .boss-inventory-heading small { display: none; }
  .boss-inventory-items { gap: 7px; }

  .modal-backdrop { padding: 10px; }
  .modal {
    width: 100%;
    max-width: 520px;
    max-height: calc(100dvh - 20px);
    padding: 19px 15px 18px;
    border-radius: 20px;
  }
  .modal h2 { font-size: 22px; }
  .modal p { font-size: 11px; }
  .modal-icon { font-size: 42px; }
  .battle-log { max-height: 132px; font-size: 9px; }
  .setup-modal { width: 100%; max-height: calc(100dvh - 20px); padding: 16px 12px 14px; }
  .setup-label { margin: 10px 0 5px; }
  .hero-draft,
  .difficulty-draft { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .hero-draft .draft-choice:last-child { grid-column: 1 / -1; width: calc(50% - 3px); justify-self: center; }
  .draft-choice { min-height: 73px; padding: 6px; }
  .hero-choice > span { margin-bottom: 1px; font-size: 20px; }
  .draft-choice b { font-size: 9px; }
  .draft-choice small { font-size: 7px; }
  .difficulty-choice { min-height: 57px; }
  .setup-modal .modal-action,
  .boss-now-button { margin-top: 10px; }
  .trait-grid,
  .garden-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trait-button { min-height: 60px; padding: 6px 27px 6px 25px; }
  .seed-card { min-height: 108px; }
  .garden-sprite { height: 51px; }

  .locker-modal { width: 100%; height: calc(100dvh - 20px); max-height: calc(100dvh - 20px); padding: 14px 12px 11px; }
  .locker-heading { padding: 0 31px 8px 1px; }
  .locker-heading-icon { width: 30px; height: 30px; font-size: 17px; }
  .locker-heading h2 { font-size: 17px; }
  .locker-heading > small { display: none; }
  .locker-layout { grid-template-columns: 1fr; gap: 9px; padding-top: 9px; overflow: auto; }
  .locker-preview { padding: 8px; overflow: visible; }
  .locker-controls { min-height: 340px; }
  .locker-tabs { overflow-x: auto; padding-bottom: 3px; }
  .locker-tab { flex: 0 0 auto; }
  .locker-footer { gap: 8px; padding-top: 8px; }
  .locker-footer small { display: none; }
  .locker-done { width: 100%; }
}

@media (max-width: 360px) {
  .topbar { grid-template-columns: minmax(0, 1fr) 46px auto; }
  .round-readout strong { font-size: 8px; }
  .arena-wrap:not(.boss-encounter) { height: 476px; }
  .arena-wrap:not(.boss-encounter) .arena { grid-template-rows: minmax(160px, 1fr) 27px minmax(160px, 1fr); }
  .arena-wrap:not(.boss-encounter) .board { grid-template-rows: repeat(2, 72px); gap: 7px 4px; }
  .arena-wrap:not(.boss-encounter) .board-slot,
  .arena-wrap:not(.boss-encounter) .board .critter-card { height: 72px; }
  .market-grid { gap: 10px 8px; }
  .market-grid .shop-critter:last-child { width: calc((100% - 8px) / 2); }
}

@media (hover: none) {
  .critter-card:hover:not(.enemy-card),
  .board .critter-card:hover:not(.enemy-card),
  .market-grid .shop-critter:hover,
  .bench .critter-card:hover { transform: none !important; }
}
