/* Four engine-owned dice stay visible; all twelve statuses sit below the carousel. */
body#top[data-page='play'] :is(.phone-reserve-markers, .phone-reserve-details, .phone-reserve-destroyed-cross) { display: none; }

@media (orientation: landscape) and (max-width: 1100px) and (max-height: 599px) {
  body#top[data-page='play'].phone-match-active {
    --phone-reserve-die-size: min(80.5px, calc((var(--phone-reserve-width, 140px) - 12.65px) / 2));
    --phone-reserve-unit-ink: #e8d59a;
    --phone-reserve-unit-lost: #9b8997;
    --phone-reserve-marker-size: 9.2px;
  }
  html[data-theme='light'] body#top[data-page='play'].phone-match-active {
    --phone-reserve-unit-ink: #796028;
    --phone-reserve-unit-lost: #7f6c78;
  }
  body#top[data-page='play'].phone-match-active .phone-group-tabs { display: none !important; }

  body#top[data-page='play'].phone-match-active:not(.combat-active) .side-stash.phone-reserve-carousel {
    display: flex !important;
    box-sizing: border-box;
    flex-direction: column;
    align-items: center;
    position: fixed;
    top: var(--phone-reserve-top, 118px) !important;
    bottom: auto !important;
    width: var(--phone-reserve-width, 140px) !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 5.75px 3.45px 0 !important;
    border-radius: 10px !important;
    overflow: visible !important;
    gap: 3.45px;
    z-index: 54 !important;
    touch-action: pan-y;
    border: 1px solid color-mix(in srgb, var(--phone-reserve-color) 38%, transparent) !important;
    background: linear-gradient(180deg,
      color-mix(in srgb, var(--phone-reserve-color) 25%, var(--phone-field)) 0%,
      color-mix(in srgb, var(--phone-reserve-color) 10%, var(--phone-field)) 62%,
      color-mix(in srgb, var(--phone-reserve-color) 4%, var(--phone-field)) 100%) !important;
    box-shadow: inset 0 0 24px color-mix(in srgb, var(--phone-reserve-color) 8%, transparent), 0 8px 18px #0002 !important;
  }
  body#top[data-page='play'].phone-match-active .phone-reserve-carousel.stash-p1 {
    --phone-reserve-color: var(--p1-color, #0099ff);
    left: var(--phone-board-start);
    right: auto;
  }
  body#top[data-page='play'].phone-match-active .phone-reserve-carousel.stash-p2 {
    --phone-reserve-color: var(--p2-color, #ff2bb1);
    right: var(--phone-controls-end);
    left: auto;
  }
  body#top[data-page='play'].phone-match-active:not(.combat-active) .phone-reserve-carousel .stash-grid-wrapper {
    transform: none !important;
    width: 100%;
    height: auto !important;
    min-height: 0;
    margin: 0;
    padding: 0;
    gap: 0;
    overflow: visible;
  }
  body#top[data-page='play'].phone-match-active:not(.combat-active) .phone-reserve-carousel .stash-group-vert.phone-group-open {
    display: flex;
    gap: 3.45px;
  }
  body#top[data-page='play'].phone-match-active:not(.combat-active) .phone-reserve-carousel .stash-row {
    gap: 3.45px !important;
  }
  body#top[data-page='play'].phone-match-active:not(.combat-active) .phone-reserve-carousel .die-chip {
    width: var(--phone-reserve-die-size) !important;
    height: var(--phone-reserve-die-size) !important;
    box-sizing: border-box;
    min-width: 44px;
    min-height: 44px;
    position: relative;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    gap: 0;
    color: var(--phone-reserve-unit-ink) !important;
    opacity: 1 !important;
    background: color-mix(in srgb, var(--phone-reserve-color) 7%, transparent) !important;
    border: 1px solid color-mix(in srgb, var(--phone-reserve-color) 18%, transparent) !important;
    border-radius: 7px !important;
    box-shadow: none !important;
    transform: none !important;
    transition: background-color .15s, border-color .15s;
    -webkit-tap-highlight-color: transparent;
  }
  body#top[data-page='play'].phone-match-active:not(.combat-active) .phone-reserve-carousel .die-chip .chip-svg {
    display: block !important;
    width: calc(var(--phone-reserve-die-size) - 2.3px) !important;
    height: calc(var(--phone-reserve-die-size) - 2.3px) !important;
    color: inherit !important;
    opacity: 1 !important;
    filter: none !important;
  }
  body#top[data-page='play'].phone-match-active:not(.combat-active) .phone-reserve-carousel .die-chip.tut-die-locked {
    filter: none !important;
  }
  body#top[data-page='play'].phone-match-active:not(.combat-active) .phone-reserve-carousel .phone-die-label {
    position: absolute;
    bottom: 2px;
    right: 3px;
    font: 700 9px/1 Inter, sans-serif;
    color: var(--phone-reserve-unit-ink);
    opacity: .78;
  }
  body#top[data-page='play'].phone-match-active:not(.combat-active) .phone-reserve-carousel .phone-die-state { display: none !important; }
  body#top[data-page='play'].phone-match-active:not(.combat-active) .phone-reserve-carousel .die-chip[data-phone-status='deployed'] {
    color: color-mix(in srgb, var(--phone-reserve-color) 60%, var(--phone-muted)) !important;
    background: color-mix(in srgb, var(--phone-reserve-color) 19%, var(--phone-field)) !important;
    border-color: color-mix(in srgb, var(--phone-reserve-color) 28%, transparent) !important;
    border-style: dashed !important;
  }
  body#top[data-page='play'].phone-match-active:not(.combat-active) .phone-reserve-carousel .die-chip[data-phone-status='deployed'] .chip-svg { opacity: .7 !important; }
  body#top[data-page='play'].phone-match-active:not(.combat-active) .phone-reserve-carousel .die-chip[data-phone-status='destroyed'] {
    color: var(--phone-reserve-unit-lost) !important;
    background: color-mix(in srgb, var(--phone-reserve-unit-lost) 9%, var(--phone-field)) !important;
    border-color: color-mix(in srgb, var(--phone-reserve-unit-lost) 30%, transparent) !important;
  }
  body#top[data-page='play'].phone-match-active:not(.combat-active) .phone-reserve-carousel .die-chip[data-phone-status='destroyed'] .chip-svg { opacity: .34 !important; }
  body#top[data-page='play'].phone-match-active:not(.combat-active) .phone-reserve-carousel .die-chip[data-phone-status='destroyed']::after { content: none !important; }
  body#top[data-page='play'].phone-match-active .phone-reserve-destroyed-cross:not([hidden]) {
    display: block;
    position: absolute;
    inset: 9px;
    pointer-events: none;
    color: var(--phone-reserve-unit-lost);
    opacity: .9;
  }
  body#top[data-page='play'].phone-match-active .phone-reserve-destroyed-cross::before,
  body#top[data-page='play'].phone-match-active .phone-reserve-destroyed-cross::after {
    content: '';
    position: absolute;
    left: 0;
    top: calc(50% - 1.5px);
    width: 100%;
    height: 3px;
    border-radius: 2px;
    background: currentColor;
    transform: rotate(45deg);
  }
  body#top[data-page='play'].phone-match-active .phone-reserve-destroyed-cross::after { transform: rotate(-45deg); }
  body#top[data-page='play'].phone-match-active:not(.combat-active) .phone-reserve-carousel .die-chip.can-roll,
  body#top[data-page='play'].phone-match-active:not(.combat-active) .phone-reserve-carousel .die-chip.tut-beacon-glow {
    border-color: color-mix(in srgb, var(--phone-reserve-color) 65%, white) !important;
    background: color-mix(in srgb, var(--phone-reserve-color) 23%, var(--phone-field)) !important;
    box-shadow: inset 0 0 12px color-mix(in srgb, var(--phone-reserve-color) 15%, transparent) !important;
    outline: 0 !important;
  }
  body#top[data-page='play'].phone-match-active:not(.combat-active) .phone-reserve-carousel .chip-pending {
    border-color: var(--phone-reserve-unit-ink) !important;
    background: color-mix(in srgb, var(--phone-reserve-color) 28%, var(--phone-field)) !important;
  }
  body#top[data-page='play'].phone-match-active .phone-reserve-markers:not([hidden]) {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    gap: 3.45px;
    min-height: 50.6px;
    padding: 0;
  }
  body#top[data-page='play'].phone-match-active .stash-p1 .phone-reserve-markers { align-self: flex-start; }
  body#top[data-page='play'].phone-match-active .stash-p2 .phone-reserve-markers { align-self: flex-end; }
  body#top[data-page='play'].phone-match-active .phone-reserve-marker {
    appearance: none;
    display: grid;
    grid-template-columns: repeat(2, var(--phone-reserve-marker-size));
    grid-template-rows: repeat(2, var(--phone-reserve-marker-size));
    gap: 2.3px;
    align-content: center;
    justify-content: center;
    position: relative;
    min-width: 0;
    min-height: 50.6px;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  body#top[data-page='play'].phone-match-active .phone-reserve-marker::before {
    content: '';
    position: absolute;
    inset: 5.75px 0;
    border: 1px solid color-mix(in srgb, var(--phone-reserve-color) 25%, transparent);
    border-radius: 5px;
    background: color-mix(in srgb, var(--phone-reserve-color) 7%, var(--phone-field));
    pointer-events: none;
  }
  body#top[data-page='play'].phone-match-active .phone-reserve-marker[aria-selected='true']::before {
    border-color: color-mix(in srgb, var(--phone-reserve-color) 65%, transparent);
    background: color-mix(in srgb, var(--phone-reserve-color) 18%, var(--phone-field));
  }
  body#top[data-page='play'].phone-match-active .phone-reserve-marker-unit {
    display: block;
    position: relative;
    width: var(--phone-reserve-marker-size);
    height: var(--phone-reserve-marker-size);
    border: 1px solid color-mix(in srgb, var(--phone-reserve-unit-ink) 60%, transparent);
    background: var(--phone-reserve-unit-ink);
    opacity: .92;
    border-radius: 1px;
  }
  body#top[data-page='play'].phone-match-active .phone-reserve-marker-unit[data-status='deployed'] {
    background: color-mix(in srgb, var(--phone-reserve-color) 24%, var(--phone-field));
    border-color: color-mix(in srgb, var(--phone-reserve-color) 80%, var(--phone-muted));
    opacity: 1;
  }
  body#top[data-page='play'].phone-match-active .phone-reserve-marker-unit[data-status='destroyed'] {
    background: color-mix(in srgb, var(--phone-reserve-unit-lost) 22%, var(--phone-field));
    border-color: var(--phone-reserve-unit-lost);
    opacity: .65;
  }
  body#top[data-page='play'].phone-match-active .phone-reserve-marker-unit[data-status='destroyed']::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(45deg, transparent 43%, var(--phone-reserve-unit-lost) 45%, var(--phone-reserve-unit-lost) 55%, transparent 57%);
  }
  body#top[data-page='play'].phone-match-active .phone-reserve-marker-unit[data-pending='true'] {
    border-color: var(--phone-reserve-unit-ink);
    box-shadow: 0 0 0 1px var(--phone-reserve-unit-ink);
  }
  body#top[data-page='play'].phone-match-active .phone-reserve-details:not([hidden]) {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: absolute;
    top: 0;
    box-sizing: border-box;
    width: 156px;
    padding: 10px;
    color: var(--phone-ink);
    background: linear-gradient(150deg, color-mix(in srgb, var(--phone-reserve-color) 24%, var(--phone-field)), var(--phone-field));
    border: 1px solid color-mix(in srgb, var(--phone-reserve-color) 55%, transparent);
    border-radius: 8px;
    z-index: 3;
    pointer-events: auto;
    box-shadow: 0 6px 20px #0004;
  }
  body#top[data-page='play'].phone-match-active .stash-p1 .phone-reserve-details { left: calc(100% + 6px); }
  body#top[data-page='play'].phone-match-active .stash-p2 .phone-reserve-details { right: calc(100% + 6px); }
  body#top[data-page='play'].phone-match-active .phone-reserve-carousel.phone-side-left .phone-reserve-details { left: calc(100% + 6px); right: auto; }
  body#top[data-page='play'].phone-match-active .phone-reserve-carousel.phone-side-right .phone-reserve-details { right: calc(100% + 6px); left: auto; }
  body#top[data-page='play'].phone-match-active .phone-reserve-description {
    margin: 0;
    font: 700 11px/1.4 Inter, sans-serif;
  }
  body#top[data-page='play'].phone-match-active .phone-reserve-key { display: flex; flex-direction: column; gap: 6px; }
  body#top[data-page='play'].phone-match-active .phone-reserve-key > span {
    display: flex;
    align-items: center;
    gap: 7px;
    font: 500 11px/1.3 Inter, sans-serif;
  }
  body#top[data-page='play'].phone-match-active .phone-reserve-detail-close {
    display: flex;
    align-items: center;
    justify-content: center;
    appearance: none;
    min-height: 44px;
    width: 100%;
    padding: 5px;
    border: 1px solid color-mix(in srgb, var(--phone-reserve-color) 60%, transparent);
    border-radius: 5px;
    background: color-mix(in srgb, var(--phone-reserve-color) 14%, transparent);
    color: var(--phone-ink);
    font: 700 11px/1.3 Orbitron, sans-serif;
    cursor: pointer;
  }
  body#top[data-page='play'].phone-match-active .phone-reserve-carousel :is(.die-chip, .phone-reserve-marker):focus-visible {
    outline: 2px solid var(--phone-reserve-unit-ink);
    outline-offset: -3px;
  }
  body#top[data-page='play'].phone-match-active.combat-active :is(.phone-reserve-markers, .phone-reserve-details) { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  body#top[data-page='play'].phone-match-active .phone-reserve-carousel .die-chip { transition: none; }
}

/* Keep dice details clear of the bottom action row when browser chrome reduces height. */
@media (orientation: landscape) and (max-width: 1100px) and (max-height: 300px) {
  body#top[data-page='play'].phone-match-active .phone-reserve-details:not([hidden]) { padding: 8px; gap: 6px; }
  body#top[data-page='play'].phone-match-active .phone-reserve-key { gap: 4px; }
}
