html,
body {
  height: 100%;
  min-height: 0;
}

body {
  overflow: hidden;
}

.app-shell {
  isolation: isolate;
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  flex-direction: column;
  overflow: hidden;
  padding-inline: clamp(14px, 2.75vw, 44px);
}

.topbar {
  flex: 0 0 68px;
  height: 68px;
  min-height: 0;
  flex-wrap: nowrap;
  padding-block: 0;
}

.top-actions {
  width: auto;
  flex-wrap: nowrap;
  gap: clamp(5px, 1vw, 14px);
}

.game-layout {
  flex: 1 1 auto;
  min-height: 0;
  grid-template-columns: minmax(190px, 253px) minmax(0, 1fr);
  gap: clamp(12px, 2.2vw, 34px);
  overflow: hidden;
  padding-top: clamp(8px, 1.5vh, 18px);
}

.sidebar {
  min-height: 0;
  overflow-y: auto;
}

.table-area {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.table-topline {
  flex: 0 0 auto;
  margin-bottom: 6px;
}

.felt-table {
  height: auto;
  min-height: 180px;
  flex: 1 1 0;
}

.player-bar {
  flex: 0 0 auto;
  margin: 7px 2px 5px;
}

.score-breakdown,
.analysis-button,
.hand-area,
.action-dock,
.table-footer {
  flex: 0 0 auto;
}

.hand-area {
  min-height: 0;
}

.hand {
  min-height: 0;
  height: clamp(66px, 9vh, 94px);
  overflow: hidden;
  overflow-x: clip;
  overflow-y: visible;
}

.hand > .card {
  min-width: 0;
  height: 100%;
  flex-shrink: 1;
}

.hand.hand-scrollable > .card {
  flex-shrink: 0;
}

.action-dock {
  min-height: 56px;
}

.table-footer {
  height: 25px;
  flex-basis: 25px;
}

.modal-card {
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}

@media (max-width: 1050px) {
  .app-shell {
    padding-inline: 18px;
  }

  .game-layout {
    grid-template-columns: minmax(175px, 205px) minmax(0, 1fr);
    gap: 14px;
  }

  .round-indicator {
    display: none;
  }

  .player-mode {
    font-size: 0;
    letter-spacing: 0;
  }

  .player-mode select {
    width: 38px;
    padding: 3px;
    font-size: 9px;
  }

  .top-actions {
    gap: 5px;
  }

  .action-dock {
    align-items: center;
    flex-direction: row;
  }

  .bid-actions,
  .discard-actions {
    width: auto;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding-inline: 12px;
  }

  .topbar {
    flex-basis: 52px;
    height: 52px;
    min-height: 52px;
    gap: 8px;
  }

  .brand {
    gap: 6px;
    font-size: 10px;
    letter-spacing: 1px;
    white-space: nowrap;
  }

  .brand-mark {
    width: 29px;
    height: 29px;
    flex: 0 0 29px;
  }

  .brand small {
    font-size: 6px;
    letter-spacing: 1px;
  }

  .round-indicator {
    display: none;
  }

  .player-mode {
    font-size: 0;
    letter-spacing: 0;
  }

  .player-mode select {
    width: 38px;
    height: 28px;
    padding: 3px;
    font-size: 9px;
  }

  .top-actions {
    min-width: 0;
    flex: 1 1 auto;
    justify-content: flex-end;
    gap: 4px;
  }

  .icon-button {
    width: 27px;
    height: 27px;
    flex: 0 0 27px;
  }

  .online-button {
    width: 27px;
    height: 27px;
    padding: 0;
    overflow: hidden;
    font-size: 0;
  }

  .online-button::before {
    content: '⌁';
    font-size: 14px;
  }

  .membership-button {
    width: 27px;
    height: 27px;
    padding: 0;
    overflow: hidden;
    font-size: 0;
  }

  .membership-button::before {
    content: '✦';
    font-size: 14px;
  }

  .new-game-button {
    width: 27px;
    height: 27px;
    padding: 0;
    overflow: hidden;
    font-size: 0;
  }

  .new-game-button span {
    margin: 0;
    font-size: 16px;
  }

  .game-layout {
    display: flex;
    min-height: 0;
    flex-direction: column;
    gap: 6px;
    padding-top: 7px;
  }

  .sidebar {
    display: grid;
    min-height: 0;
    flex: 0 0 auto;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: 6px;
    overflow: hidden;
  }

  .sidebar > .section-label,
  .legend-card,
  .sidebar-footer {
    display: none;
  }

  .score-card {
    min-width: 0;
    margin: 0;
    padding: 7px 8px;
  }

  .score-heading {
    font-size: 7px;
  }

  .contract-name {
    margin: 3px 0 5px;
    font-size: 16px;
  }

  .score-rule {
    margin-bottom: 3px;
  }

  .score-row {
    gap: 3px;
    padding: 2px 0;
    font-size: 8px;
  }

  .score-row strong {
    font-size: 9px;
  }

  .table-note {
    min-width: 0;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 7px;
  }

  .table-note p {
    font-size: 9px;
    line-height: 1.3;
  }

  .table-area {
    width: 100%;
    flex: 1 1 0;
  }

  .table-topline {
    height: 19px;
    min-height: 19px;
    margin-bottom: 5px;
    font-size: 8px;
  }

  .turn-pill {
    padding: 4px 6px;
    font-size: 7px;
  }

  .felt-table {
    min-height: 145px;
    border-radius: 40% / 35%;
  }

  .player-bar {
    margin: 4px 2px;
    padding: 4px 7px;
  }

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

  .hand-heading {
    margin: 0 2px 4px;
    font-size: 7px;
  }

  .hand-area {
    min-height: 0;
  }

  .hand {
    height: clamp(58px, 9vh, 76px);
    overflow: hidden;
    overflow-x: clip;
    overflow-y: visible;
    padding: 0 4px 4px;
  }

  .hand .card {
    height: min(72px, 8.8vh);
  }

  .hand .card .card-center {
    font-size: clamp(12px, 4.6vw, 21px);
  }

  .hand .card.face-court .card-center {
    font-size: clamp(10px, 3.9vw, 18px);
  }

  .hand .card-corner,
  .hand .card-bottom {
    font-size: clamp(6px, 1.8vw, 9px);
  }

  .action-dock {
    min-height: 52px;
    align-items: center;
    padding: 5px;
  }

  .bid-actions {
    min-width: 0;
    flex: 1 1 auto;
    gap: 2px;
  }

  .bid-button {
    min-height: 40px;
    padding: 6px 4px;
    font-size: 7px;
  }

  .bid-button small {
    margin-left: 2px;
  }

  .pass-button {
    min-height: 40px;
    padding: 6px 4px;
    font-size: 8px;
  }

  .call-button,
  .discard-actions .confirm-button {
    min-height: 40px;
  }

  .action-dock .call-actions {
    width: 100%;
    min-width: 0;
    flex: 1 1 100%;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
  }

  .action-dock .call-button {
    min-width: 0;
    height: 53px;
    min-height: 36px;
    flex: 1 1 64px;
    padding: 4px 2px;
    font-size: 7px;
    text-align: center;
    white-space: normal;
  }

  .discard-actions {
    min-width: 0;
    flex: 1 1 auto;
    gap: 4px;
    font-size: 7px;
  }

  .confirm-button {
    padding: 7px 6px;
    font-size: 7px;
  }

  .table-footer {
    height: 20px;
    flex-basis: 20px;
    font-size: 6px;
  }
}

@media (min-width: 381px) and (max-width: 760px) {
  .top-actions {
    gap: 3px;
  }

  .topbar .icon-button,
  .topbar .home-button,
  .topbar .online-button,
  .topbar .membership-button,
  .topbar #new-game-button {
    width: 30px;
    height: 30px;
    min-height: 30px;
    flex-basis: 30px;
  }
}

@media (min-height: 781px) and (max-width: 760px) {
  .felt-table {
    flex: 0 0 clamp(220px, 70vw, 280px);
  }
}

@media (max-width: 520px) {
  .brand small,
  .player-mode {
    display: none;
  }

  .home-button {
    width: 27px;
    height: 27px;
    min-height: 27px;
    flex: 0 0 27px;
    padding: 0;
    overflow: hidden;
    font-size: 0;
  }

  .home-button b {
    display: none;
  }

  .online-button,
  .membership-button,
  #new-game-button {
    flex: 0 0 27px;
  }
}

@media (max-width: 360px) {
  .app-shell {
    padding-inline: 8px;
  }

  .topbar {
    gap: 4px;
  }

  .brand {
    gap: 4px;
    font-size: 9px;
  }

  .brand small {
    display: none;
  }

  .brand-mark {
    width: 25px;
    height: 25px;
    flex-basis: 25px;
  }

  .top-actions {
    gap: 2px;
  }

  #training-button,
  #stats-button,
  #rules-button {
    display: none;
  }

  .icon-button,
  .online-button,
  .membership-button,
  #new-game-button {
    width: 23px;
    height: 23px;
    flex-basis: 23px;
  }

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

@media (max-height: 700px) {
  .topbar {
    flex-basis: 56px;
    height: 56px;
  }

  .game-layout {
    padding-top: 6px;
  }

  .sidebar .legend-card,
  .sidebar .sidebar-footer {
    display: none;
  }

  .score-card {
    padding-block: 8px;
  }

  .felt-table {
    min-height: 130px;
  }

  .hand {
    height: 66px;
  }

  .hand .card {
    height: min(78px, 8.8vh);
  }

  .action-dock {
    min-height: 48px;
  }

  .table-footer {
    height: 20px;
    flex-basis: 20px;
  }
}

@media (max-height: 580px) {
  .brand small,
  .round-indicator {
    display: none;
  }

  .top-actions {
    gap: 4px;
  }

  .icon-button,
  .topbar .home-button,
  .online-button,
  .membership-button,
  #new-game-button {
    width: 30px;
    height: 30px;
    min-height: 30px;
    flex: 0 0 30px;
  }

  .topbar .home-button,
  .online-button,
  .membership-button,
  #new-game-button {
    overflow: hidden;
    padding: 0;
    font-size: 0;
  }

  .topbar .home-button b {
    display: none;
  }

  .online-button::before,
  .membership-button::before {
    font-size: 14px;
  }

  .online-button::before {
    content: '⌁';
  }

  .membership-button::before {
    content: '✦';
  }

  #new-game-button span {
    margin: 0;
    font-size: 16px;
  }

  .topbar {
    flex-basis: 44px;
    height: 44px;
    min-height: 44px;
  }

  .game-layout {
    padding-top: 4px;
  }

  .sidebar .legend-card,
  .sidebar .sidebar-footer {
    display: none;
  }

  .score-card {
    padding: 4px 6px;
  }

  .contract-name {
    margin: 2px 0 3px;
    font-size: 14px;
  }

  .score-row {
    padding: 1px 0;
  }

  .table-topline {
    min-height: 24px;
    margin-bottom: 3px;
  }

  .felt-table {
    min-height: 80px;
  }

  .player-bar {
    margin: 2px;
    padding: 2px 5px;
  }

  .hand {
    height: 58px;
  }

  .hand .card {
    height: 54px;
    padding: 2px;
  }

  .action-dock {
    min-height: 40px;
    padding: 3px;
  }

  .table-footer {
    height: 14px;
    flex-basis: 14px;
  }
}

@media (max-height: 580px) and (max-width: 760px) {
  .topbar {
    flex-basis: 44px;
    height: 44px;
    min-height: 44px;
  }

  .game-layout {
    gap: 4px;
    padding-top: 4px;
  }

  .score-card {
    padding: 4px 6px;
  }

  .contract-name {
    margin: 2px 0 3px;
    font-size: 14px;
  }

  .score-row {
    padding: 1px 0;
  }

  .table-topline {
    height: 16px;
    min-height: 16px;
    margin-bottom: 3px;
  }

  .felt-table {
    min-height: 50px;
  }

  .hand {
    height: 42px;
  }

  .hand .card {
    height: 42px;
    padding: 2px;
  }

  .player-bar {
    margin: 2px;
    padding: 2px 5px;
  }

  .action-dock {
    min-height: 40px;
    padding: 3px;
  }

  .table-footer {
    height: 14px;
    flex-basis: 14px;
  }
}

@media (min-height: 481px) and (max-height: 580px) and (max-width: 760px) {
  .hand {
    height: 58px;
  }

  .hand.hand-scrollable > .card {
    height: 58px;
  }
}

@media (min-height: 701px) and (max-height: 900px) and (max-width: 760px) {
  .hand.hand-grid {
    height: clamp(126px, 17vh, 146px);
    min-height: clamp(126px, 17vh, 146px);
  }

  .hand.hand-grid > .card,
  .hand.hand-grid > .card.suit-start:not(:first-child) {
    height: min(70px, 9vh);
  }
}

@media (min-height: 701px) and (max-height: 900px) and (min-width: 761px) {
  .hand {
    height: clamp(80px, 12vh, 100px);
  }

  .hand > .card {
    height: 100%;
  }
}
