/**
 * responsive.css - Adaptive Single-Viewport Zero-Scroll Breakpoints
 *
 * Dynamically resizes the board, 3D dice, control actions, and player cards
 * so the entire game fits completely within the visible screen across all devices.
 */

/* Medium Desktops & Laptops (861px - 1100px) */
@media (max-width: 1100px) and (min-width: 861px) {
  .shell {
    padding: clamp(4px, 0.8vh, 8px) clamp(8px, 1.2vw, 14px);
  }
  .layout {
    grid-template-columns: minmax(0, 1.25fr) minmax(250px, 290px);
    gap: 12px;
  }
  .boardwrap {
    height: min(100%, calc(100dvh - 200px));
  }
  .die {
    --die-size: clamp(56px, 7.5vh, 70px);
    --cube-size: clamp(46px, 6.2vh, 58px);
    --cube-depth: clamp(23px, 3.1vh, 29px);
  }
  .dieface {
    font-size: clamp(22px, 3.2vh, 28px);
  }
  .dice {
    gap: 16px;
    margin: 6px 0 10px;
  }
}

/* Tablet Portrait Screens (681px - 860px, e.g. iPad Mini, iPad Air) */
@media (max-width: 860px) and (min-width: 681px) {
  .shell {
    padding: 8px 12px;
  }
  .top {
    margin-bottom: 6px;
    min-height: 36px;
  }
  .brand h1 {
    font-size: 22px;
  }
  .pill {
    padding: 6px 10px;
    font-size: 11.5px;
  }
  .layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    gap: 6px;
    overflow: hidden;
  }
  .layout > section {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  .boardcard {
    flex: 1 1 auto;
    min-height: 0;
    padding: 8px;
    border-radius: 18px;
  }
  .boardwrap {
    height: min(88vw, calc(100dvh - 290px));
    width: min(88vw, calc(100dvh - 290px));
    max-height: 56vh;
    max-width: 56vh;
  }
  .boardlegend {
    display: flex;
    font-size: 11px;
    padding: 3px 8px;
    margin-top: 5px;
  }
  .controls {
    flex: 0 0 auto;
    margin-top: 6px;
    grid-template-columns: 1fr auto;
    gap: 8px;
  }
  .side {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 8px;
    max-height: 165px;
    overflow: hidden;
  }
  .side .panel {
    padding: 8px 10px;
    border-radius: 12px;
  }
  #players {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    max-height: 120px;
    overflow-y: auto;
  }
  .player {
    padding: 4px 6px;
    gap: 6px;
  }
  .avatar {
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
    font-size: 13px;
  }
  .die {
    --die-size: 46px;
    --cube-size: 38px;
    --cube-depth: 19px;
  }
  .dieface {
    font-size: 20px;
  }
}

/* Phones & Small Touchscreens (<= 680px) */
@media (max-width: 680px) {
  .shell {
    padding: 4px 6px;
  }
  .top {
    margin-bottom: 3px;
    min-height: 32px;
  }
  .brand h1 {
    font-size: 18px;
  }
  .sub {
    display: none;
  }
  .logo {
    width: 30px;
    height: 30px;
    font-size: 18px;
  }
  .pill {
    padding: 4px 7px;
    font-size: 10px;
  }
  .layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    gap: 4px;
    overflow: hidden;
  }
  .layout > section {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  .boardcard {
    flex: 1 1 auto;
    min-height: 0;
    padding: 4px;
    border-width: 3px;
    border-radius: 14px;
  }
  .boardwrap {
    height: min(92vw, calc(100dvh - 250px));
    width: min(92vw, calc(100dvh - 250px));
    max-height: 46vh;
    max-width: 46vh;
  }
  .boardlegend {
    display: none;
  }
  .cell.legal:after {
    display: none;
  }
  .controls {
    flex: 0 0 auto;
    margin-top: 3px;
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .controlactions {
    display: flex;
    width: 100%;
  }
  .controlactions .btn {
    flex: 1;
    min-height: 38px;
  }
  .side {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 4px;
    max-height: 125px;
    overflow: hidden;
  }
  .side .panel {
    padding: 5px 6px;
    border-radius: 10px;
  }
  .side .panel h2 {
    font-size: 10.5px;
    margin: 0 0 2px;
  }
  #players {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5px;
    max-height: 80px;
    overflow-y: auto;
  }
  .player {
    padding: 2.5px 4px;
    gap: 4px;
  }
  .avatar {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    font-size: 10px;
    border-radius: 5px;
  }
  .pname {
    font-size: 10px;
  }
  .pmeta, .piecestatus {
    display: none;
  }
  .die {
    --die-size: 38px;
    --cube-size: 31px;
    --cube-depth: 15.5px;
    --cube-inset: 3px;
  }
  .dice {
    margin: 2px 0;
    gap: 8px;
    padding: 2px;
  }
  .dieface {
    font-size: 16px;
    border-radius: 5px;
  }
  .side .helper, .side .divider {
    display: none;
  }
  .lastroll-container {
    margin-top: 1px;
    padding: 1px 4px;
    background: transparent;
    border: none;
  }
  .lastroll-header, .lastroll-helper-init {
    display: none;
  }
  .lastroll-number {
    font-size: 16px;
  }
  .lastroll-name {
    font-size: 11px;
  }
  .lastroll-status {
    font-size: 8.5px;
    padding: 1px 5px;
    margin-top: 1px;
  }
  #editPlayersBtn, #copyAuditBtn, #audioToggle {
    display: none;
  }
  #resetBtn {
    padding: 3px 6px;
    font-size: 9.5px;
  }
}

/* Very Compact Phones (<= 390px, e.g. iPhone SE, Galaxy S20) */
@media (max-width: 390px) {
  .shell {
    padding: 3px 4px;
  }
  .top {
    min-height: 28px;
  }
  .brand h1 {
    font-size: 16px;
  }
  .logo {
    width: 26px;
    height: 26px;
    font-size: 15px;
  }
  .pill {
    padding: 3px 5px;
    font-size: 9.5px;
  }
  .boardwrap {
    height: min(94vw, calc(100dvh - 240px));
    width: min(94vw, calc(100dvh - 240px));
    max-height: 44vh;
    max-width: 44vh;
  }
  .side {
    max-height: 115px;
  }
  #players {
    max-height: 70px;
  }
  .die {
    --die-size: 34px;
    --cube-size: 28px;
    --cube-depth: 14px;
  }
  .dieface {
    font-size: 14px;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation: none !important;
    transition: none !important;
  }
}
