/* Desktop and tablet duel setup share one layout; phone setup remains separate. */
@media (min-width: 1101px), (min-width: 700px) and (min-height: 600px) {
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen {
    --lobby-duel-die: 68px;
    --lobby-duel-card: 112px;
    --lobby-duel-instruction: 36px;
    --lobby-duel-instruction-gap: 8px;
    --lobby-duel-roll-gap: 8px;
    --lobby-duel-result: 24px;
    --lobby-duel-height: 296px;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .setup-panels-wrapper {
    height: auto !important;
    min-height: var(--lobby-duel-height) !important;
    max-height: none !important;
    flex: 0 0 auto;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .lobby-duel-panel {
    height: auto !important;
    min-height: var(--lobby-duel-height);
    justify-content: flex-start !important;
    gap: 0 !important;
    flex: 0 0 auto;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .lobby-duel-panel > .setup-body {
    width: 100%;
    height: var(--lobby-duel-instruction);
    min-height: var(--lobby-duel-instruction);
    flex: 0 0 var(--lobby-duel-instruction);
    margin: 0 0 var(--lobby-duel-instruction-gap) !important;
    font: 500 13px/18px Inter, sans-serif !important;
    text-align: center;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .lobby-duel-panel > .rolloff-wrap {
    flex: 0 0 auto;
    width: 100%;
    max-width: 350px;
    min-height: 0 !important;
    height: auto;
    margin: 0 auto !important;
    gap: var(--lobby-duel-roll-gap);
    justify-content: flex-start;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .lobby-duel-panel .rolloff-wrap > .btn {
    width: 100%;
    height: 44px;
    min-height: 44px;
    padding: 8px 24px !important;
    font: 800 12px/18px Inter, sans-serif !important;
    letter-spacing: 2px !important;
    justify-content: center;
    flex: 0 0 44px;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .lobby-faction-grid {
    display: grid !important;
    grid-template-columns: 104px 30px 104px;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: var(--lobby-duel-card);
    margin: 0 !important;
    gap: 20px !important;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .lobby-faction-card {
    display: grid !important;
    grid-template-rows: 14px var(--lobby-duel-die) 12px;
    justify-items: center;
    align-items: center;
    gap: 4px !important;
    box-sizing: border-box;
    width: 104px;
    height: var(--lobby-duel-card);
    padding: 4px 8px !important;
    border: 1px solid color-mix(in srgb, var(--lobby-faction-color) 35%, transparent) !important;
    border-radius: 12px;
    background: color-mix(in srgb, var(--lobby-faction-color) 6%, transparent) !important;
    user-select: none;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .lobby-faction-p1 { --lobby-faction-color: var(--p1-color); }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .lobby-faction-p2 { --lobby-faction-color: var(--p2-color); }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .lobby-faction-card.selected-human {
    border-color: var(--lobby-faction-color) !important;
    background: color-mix(in srgb, var(--lobby-faction-color) 12%, transparent) !important;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .lobby-faction-card > .ai-role-tag {
    box-sizing: border-box;
    min-height: 14px;
    height: 14px;
    margin: 0;
    padding: 2px 7px;
    font: 900 8px/10px Orbitron, sans-serif;
    letter-spacing: 1px;
    white-space: nowrap;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .lobby-role-spacer { visibility: hidden; }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .lobby-faction-card > .ro-val {
    width: var(--lobby-duel-die) !important;
    height: var(--lobby-duel-die) !important;
    margin: 0;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .lobby-faction-card .ro-num {
    font: 900 28px/1 Orbitron, sans-serif !important;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .lobby-faction-card > .ai-faction-name {
    font: 800 10px/12px Orbitron, sans-serif !important;
    color: var(--lobby-faction-color) !important;
    letter-spacing: 1.5px;
    white-space: nowrap;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .lobby-faction-grid > .ro-vs {
    margin: 0 !important;
    font: 900 14px/1.2 Inter, sans-serif !important;
    letter-spacing: 2px;
    align-self: center;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .lobby-duel-panel :is(#ro-result, #ai-ro-result) {
    display: grid;
    place-items: center;
    width: 100%;
    height: var(--lobby-duel-result);
    min-height: var(--lobby-duel-result) !important;
    margin: 0 !important;
    flex: 0 0 var(--lobby-duel-result);
    font: 700 12px/18px Inter, sans-serif !important;
    color: var(--text-mid) !important;
    text-align: center;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .lobby-duel-panel > .setup-rules {
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 350px;
    padding: 12px 0 0 !important;
    margin: 0 auto !important;
    border: 0;
    background: transparent !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .lobby-duel-panel > .setup-rules > .btn {
    width: 100%;
    min-height: 44px;
    height: 44px;
    padding: 8px 24px !important;
    margin: 0;
    font: 800 12px/18px Inter, sans-serif !important;
    letter-spacing: 2px !important;
    justify-content: center;
  }
}

/* Retain the shared layout on shorter laptops without crowding the final action. */
@media (min-width: 700px) and (min-height: 600px) and (max-height: 800px), (min-width: 1101px) and (max-height: 800px) {
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen {
    --lobby-duel-die: 56px;
    --lobby-duel-card: 100px;
    --lobby-duel-instruction: 34px;
    --lobby-duel-instruction-gap: 6px;
    --lobby-duel-roll-gap: 6px;
    --lobby-duel-result: 20px;
    --lobby-duel-height: 272px;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .lobby-duel-panel > .setup-body { line-height: 17px !important; }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .subscribe-mega-card { padding-block: 14px !important; }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .subscribe-content > div:first-child { margin-bottom: 10px !important; }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .subscribe-content > div:has(#btn-start-tutorial) { margin-block: 8px 10px !important; }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .mode-card { height: 94px; }
}

/* Short landscape tablets use opposing columns while retaining the original cards. */
@media (min-width: 700px) and (min-height: 600px) and (max-height: 740px) and (orientation: landscape) {
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .subscribe-mega-card {
    width: min(880px, 100%) !important;
    padding: 16px 24px !important;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .subscribe-content {
    display: grid !important;
    grid-template-columns: minmax(180px, .85fr) minmax(290px, 1.35fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    align-items: stretch !important;
    gap: 8px 24px;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .subscribe-content > div:first-child {
    display: flex !important;
    grid-column: 1;
    grid-row: 1;
    flex-direction: row !important;
    justify-content: flex-start;
    align-items: center;
    align-self: start;
    gap: 10px !important;
    min-height: 40px;
    margin: 0 !important;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .subscribe-content > div:first-child > img {
    width: 36px !important;
    height: 36px;
    object-fit: contain;
    margin: 0 !important;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .setup-title {
    font-size: 18px !important;
    line-height: 1.05 !important;
    letter-spacing: 2px !important;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .mode-cards-container {
    grid-column: 1;
    grid-row: 2;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: repeat(3, 56px);
    align-content: center;
    align-self: stretch;
    max-width: none;
    margin: 0 !important;
    gap: 6px;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .mode-card {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: center;
    align-content: center;
    justify-content: start;
    height: 56px !important;
    min-height: 56px !important;
    padding: 6px 10px;
    gap: 3px 10px;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .mode-card-icon { grid-column: 1; grid-row: 1 / 3; }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen :is(.mode-card-title, .mode-card-sub) { grid-column: 2; text-align: left; }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .mode-card-title { font-size: 13px !important; }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .mode-card-sub { font-size: 10px !important; }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .subscribe-content > div:has(#btn-start-tutorial) {
    grid-column: 1;
    grid-row: 3;
    align-self: stretch;
    margin: 0 !important;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen #btn-start-tutorial {
    width: 100%;
    height: 44px;
    min-height: 44px;
    justify-content: center;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen .setup-panels-wrapper {
    grid-column: 2;
    grid-row: 1 / 4;
    align-self: center;
    width: 100%;
    max-width: none !important;
    padding: 0 !important;
  }
  html:not([data-phone-device='true']) body#top[data-page='play']:not(.phone-match-active) #setup-screen #resume-room-banner {
    grid-column: 1 / -1;
    grid-row: auto;
    max-width: none !important;
    margin: 4px 0 0 !important;
  }
}
