/* Card artwork is a personal preference; the server still owns the same 40 cards. */
.table-home { display: inline-flex; align-items: center; justify-content: center; width: 44px; min-height: 44px; flex-shrink: 0; }
.table-home img { width: 36px; height: 36px; object-fit: contain; }
.room-bar .table-title { margin-right: auto; }
.card-face:has(> .card-art[data-card-pack="modern"]),
.card-face:has(> .card-art[data-card-pack="four-families"]),
.card-pack-preview > img[data-pack-preview="modern"],
.card-pack-preview > img[data-pack-preview="four-families"] {
  background: #fff;
}
.card-pack-picker {
  border: 0;
  padding: 0;
  margin: 20px 0;
  min-width: 0;
}
.card-pack-picker legend {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}
.card-pack-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.card-pack-options label {
  display: block;
  position: relative;
  cursor: pointer;
  margin: 0;
}
.exclusive-pack {
  grid-column: 1 / -1;
}
.exclusive-pack .card-pack-preview {
  border-color: #b4a47b;
}
.pack-badge {
  display: inline-block;
  font-size: 9px;
  letter-spacing: 0.07em;
  margin-left: 6px;
  color: var(--muted);
}
.pack-unlock {
  min-height: 44px;
  margin-top: 4px;
}
.card-pack-options input:disabled + .card-pack-preview {
  cursor: default;
}
.card-pack-options input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.card-pack-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: var(--surface);
  height: 100%;
}
.card-pack-preview > img {
  width: 40px;
  height: 62px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
}
.card-pack-preview b {
  display: block;
  font-size: 14px;
}
.card-pack-preview small {
  display: block;
  font-size: 10px;
  line-height: 1.4;
  color: var(--muted);
  margin-top: 3px;
}
.card-pack-options input:checked + .card-pack-preview {
  border-color: #568677;
  background: #edf1e9;
  box-shadow: inset 0 0 0 1px #568677;
}
.card-pack-options input:focus-visible + .card-pack-preview {
  outline: 3px solid var(--action-red);
  outline-offset: 3px;
}
.pack-help {
  font-size: 11px;
  color: var(--muted);
  margin: 10px 0 0;
  line-height: 1.5;
}
.card-room-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}
.table-options-trigger {
  display: grid;
  place-items: center;
  padding: 0;
  width: 44px;
  height: 44px;
  min-width: 44px;
}
.table-option-actions {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}
#table-options-dialog {
  overflow: auto;
}

/* On phones the entire viewport is felt. Scores and the hand sit on that table. */
@media (max-width: 900px), (max-height: 600px) and (pointer: coarse) {
  body.is-card-table {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    background: #193c52;
  }
  body.is-card-table > .masthead,
  body.is-card-table > footer {
    display: none;
  }
  body.is-card-table #app {
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
  }
  body.is-card-table .game-shell {
    --card-w: clamp(76px, min(26vw, 19dvh), 108px);
    --hand-h: calc(var(--card-w) * 1.55 + 68px);
    --hud-h: 114px;
    --played-w: clamp(62px, 19vw, 86px);
    --play-center: calc(
      (100% + var(--hud-h) - var(--hand-h) - 28px) / 2 + 12px
    );
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
    isolation: isolate;
  }
  body.is-card-table .game-shell > .felt-table {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    z-index: 0;
  }
  body.is-card-table .game-shell > .room-bar {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 4px);
    left: max(56px, calc(env(safe-area-inset-left) + 48px));
    right: max(8px, env(safe-area-inset-right));
    height: 44px;
    min-height: 44px;
    margin: 0;
    z-index: 6;
  }
  body.is-card-table .table-title {
    margin: 0;
    gap: 0;
    min-width: 0;
  }
  body.is-card-table .table-title .eyebrow {
    color: var(--cream);
    font-size: 11px;
  }
  body.is-card-table .table-title small,
  body.is-card-table .connection {
    display: none;
  }
  body.is-card-table .room-code,
  body.is-card-table .solo-table-tag,
  body.is-card-table .table-options-trigger {
    background: #ffffff0d;
    border-color: #f5ead530;
    color: var(--cream);
    border-radius: 9px;
  }
  body.is-card-table .room-code {
    gap: 5px;
    padding: 0 8px;
  }
  body.is-card-table .room-code strong {
    font-size: 12px;
  }
  body.is-card-table .room-code > span,
  body.is-card-table .room-code .copy-icon {
    color: #c1d4d4;
  }
  body.is-card-table .room-code > span:first-child {
    display: none;
  }
  body.is-card-table .solo-table-tag {
    font-size: 9px;
    padding: 0 8px;
  }
  body.is-card-table .game-shell > .game-aside {
    display: block;
    position: absolute;
    top: calc(env(safe-area-inset-top) + 52px);
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    height: 58px;
    z-index: 5;
  }
  body.is-card-table .table-people {
    display: none;
  }
  body.is-card-table .game-aside .scoreboard {
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr);
    grid-template-rows: 32px 24px;
    background: #102b3da6;
    border: 1px solid #f5ead526;
    border-radius: 10px;
  }
  body.is-card-table .score-team {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 5px;
    padding: 3px 9px;
    color: var(--cream);
  }
  body.is-card-table .score-label {
    font-size: 9px;
    gap: 5px;
  }
  body.is-card-table .team-color {
    width: 5px;
    height: 5px;
  }
  body.is-card-table .score-value {
    margin: 0;
    gap: 3px;
  }
  body.is-card-table .score-value strong {
    font-size: 23px;
    letter-spacing: 0;
  }
  body.is-card-table .score-value > span {
    font-size: 8px;
    color: #c1d4d4;
  }
  body.is-card-table .score-team small,
  body.is-card-table .score-team progress,
  body.is-card-table .score-middle > span {
    display: none;
  }
  body.is-card-table .score-middle {
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    border-inline: 1px solid #f5ead51a;
  }
  body.is-card-table .score-middle > b {
    margin: 0;
    font-size: 18px;
    color: var(--gold);
  }
  body.is-card-table .score-middle > b + span {
    display: block;
    color: #c1d4d4;
    font-size: 6px;
  }
  body.is-card-table .score-footnote {
    border-color: #f5ead51a;
    padding: 0 8px;
  }
  body.is-card-table .score-footnote > span {
    color: #c1d4d4;
    font-size: 8px;
  }
  body.is-card-table .score-footnote .text-button {
    color: var(--cream);
    font-size: 9px;
    min-height: 24px;
    height: 24px;
  }
  body.is-card-table .table-footer {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 4px);
    left: max(8px, env(safe-area-inset-left));
    z-index: 7;
    margin: 0;
  }
  body.is-card-table .table-footer > span {
    display: none;
  }
  body.is-card-table .table-footer .text-button {
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;
    font-size: 0;
    border: 1px solid #f5ead530;
    border-radius: 9px;
    background: #ffffff0d;
  }
  body.is-card-table .table-footer .text-button::before {
    content: "‹";
    font-size: 30px;
    color: var(--cream);
  }
  body.is-card-table .player-top {
    top: calc(env(safe-area-inset-top) + var(--hud-h) + 6px);
    grid-template-columns: 28px auto;
    min-width: 0;
    gap: 3px 7px;
  }
  body.is-card-table .player .avatar {
    width: 28px;
    height: 28px;
  }
  body.is-card-table .player .mini-hand {
    display: none;
  }
  body.is-card-table .player strong {
    font-size: 10px;
    max-width: 110px;
  }
  body.is-card-table .player > span {
    font-size: 8px;
  }
  body.is-card-table .player-left,
  body.is-card-table .player-right {
    top: var(--play-center);
    width: 54px;
    gap: 5px;
  }
  body.is-card-table .player-left {
    left: max(5px, env(safe-area-inset-left));
  }
  body.is-card-table .player-right {
    right: max(5px, env(safe-area-inset-right));
  }
  body.is-card-table .scopa-room .felt-table .player-left,
  body.is-card-table .scopa-room .felt-table .player-right {
    top: var(--play-center);
  }
  body.is-card-table .trick-area {
    width: calc(var(--played-w) * 2.6);
    height: calc(var(--played-w) * 2.7);
    top: var(--play-center);
    transform: translate(-50%, -50%);
  }
  body.is-card-table .played-card {
    width: var(--played-w);
    height: calc(var(--played-w) * 1.55);
  }
  body.is-card-table .played-top {
    left: calc(50% - var(--played-w) / 2);
    top: 0;
  }
  body.is-card-table .played-left {
    left: 0;
    top: 27%;
  }
  body.is-card-table .played-right {
    left: auto;
    right: 0;
    top: 27%;
  }
  body.is-card-table .played-bottom {
    left: calc(50% - var(--played-w) / 2);
    top: auto;
    bottom: 0;
  }
  body.is-card-table .deck-area {
    left: max(12px, env(safe-area-inset-left));
    bottom: calc(var(--hand-h) + 38px + env(safe-area-inset-bottom));
    gap: 5px;
    align-items: flex-end;
  }
  body.is-card-table .stock-cards {
    transform: scale(0.85);
    width: 58px;
    height: 62px;
    transform-origin: left bottom;
  }
  body.is-card-table .deck-label {
    display: none;
  }
  body.is-card-table .deck-area b {
    font-size: 11px;
  }
  body.is-card-table .deck-area > div:last-child > span:last-child {
    font-size: 9px;
  }
  body.is-card-table .trick-pot {
    bottom: calc(var(--hand-h) + 40px + env(safe-area-inset-bottom));
    right: max(14px, env(safe-area-inset-right));
  }
  body.is-card-table .trick-pot > b {
    font-size: 25px;
  }
  body.is-card-table .trick-pot > span {
    font-size: 7px;
  }
  body.is-card-table .game-shell > .hand-area {
    position: absolute;
    bottom: env(safe-area-inset-bottom);
    left: 0;
    right: 0;
    height: var(--hand-h);
    z-index: 4;
    padding: 6px max(12px, env(safe-area-inset-right)) 4px
      max(12px, env(safe-area-inset-left));
    border: 0;
    border-top: 1px solid #f5ead51a;
    border-radius: 0;
    background: linear-gradient(#102b3d33, #102b3d99);
  }
  body.is-card-table .hand-title {
    height: 26px;
  }
  body.is-card-table .self-player > span:last-child,
  body.is-card-table .hand-title > span {
    color: #e7ece5;
  }
  body.is-card-table .self-player > span:last-child {
    max-width: 130px;
  }
  body.is-card-table .self-player small {
    display: none;
  }
  body.is-card-table .hand-active .hand-title > span {
    color: #f2cf87;
  }
  body.is-card-table .hand {
    gap: 10px;
    padding: 8px 0 4px;
    min-height: 0;
  }
  body.is-card-table .play-card {
    width: var(--card-w);
    height: calc(var(--card-w) * 1.55);
  }
  body.is-card-table .hand .card-face {
    box-shadow: 0 6px 16px #071b2a70;
  }
  body.is-card-table .last-trick,
  body.is-card-table .scopa-room .last-trick {
    min-height: 20px;
    height: 20px;
    padding: 0;
    font-size: 10px;
    color: #c1d4d4;
  }
  body.is-card-table .points-gain,
  body.is-card-table .scopa-announcement {
    color: var(--gold);
  }
  body.is-card-table .game-shell > .turn-banner {
    position: absolute;
    bottom: calc(var(--hand-h) + env(safe-area-inset-bottom));
    left: 0;
    right: 0;
    height: 28px;
    z-index: 5;
    border-radius: 0;
    background: #102b3d;
    color: #c1d4d4;
    font-size: 11px;
  }
  body.is-card-table .game-shell > .turn-banner.your-turn {
    background: #2c5a50;
    color: #fff0c8;
  }
  body.is-card-table .game-shell > .turn-banner.is-offline {
    background: #713e3e;
    color: #fff2e7;
  }
  body.is-card-table .game-shell > .results {
    position: absolute;
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 6;
    padding: 16px;
    max-height: calc(100% - 130px);
    overflow: auto;
  }
  body.is-card-table .scopa-board-heading {
    top: calc(env(safe-area-inset-top) + var(--hud-h) + 48px);
  }
  body.is-card-table .scopa-board {
    top: calc(env(safe-area-inset-top) + var(--hud-h) + 68px);
    bottom: calc(var(--hand-h) + 32px + env(safe-area-inset-bottom));
    left: 64px;
    right: 64px;
  }
  body.is-card-table .scopa-layout {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px 6px;
  }
  body.is-card-table .scopa-table-card {
    max-width: min(
      84px,
      calc((100dvh - var(--hud-h) - var(--hand-h) - 120px) / 3.1)
    );
  }
  body.is-card-table .scopa-layout:not(:has(.scopa-table-card:nth-child(5))) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  body.is-card-table .scopa-played {
    bottom: calc(var(--hand-h) + 36px + env(safe-area-inset-bottom));
    width: 38px;
    height: 59px;
  }
  body.is-card-table .scopa-room .deck-area .stock-cards {
    width: 36px;
  }
  body.is-card-table .scopa-room .deck-area > div:last-child {
    display: none;
  }
}

/* Landscape phones keep the hand alongside the table instead of taking its height. */
@media (max-height: 600px) and (orientation: landscape) and (max-width: 900px),
  (max-height: 600px) and (orientation: landscape) and (pointer: coarse) {
  body.is-card-table .game-shell {
    --rail-w: calc(clamp(200px, 31vw, 270px) + env(safe-area-inset-right));
    --card-w: clamp(
      56px,
      calc((var(--rail-w) - env(safe-area-inset-right) - 32px) / 3),
      80px
    );
    --played-w: clamp(52px, 18dvh, 72px);
    --play-center: calc((100% + var(--hud-h)) / 2);
  }
  body.is-card-table .game-shell > .room-bar {
    right: calc(var(--rail-w) + 8px);
  }
  body.is-card-table .game-shell > .game-aside {
    right: calc(var(--rail-w) + 8px);
  }
  body.is-card-table .game-shell > .hand-area {
    left: auto;
    width: var(--rail-w);
    height: 100%;
    padding: max(8px, env(safe-area-inset-top)) 10px
      max(8px, env(safe-area-inset-bottom));
    padding-right: calc(10px + env(safe-area-inset-right));
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-top: 0;
    border-left: 1px solid #f5ead51a;
    background: linear-gradient(90deg, #102b3d33, #102b3d99);
  }
  body.is-card-table .hand-title {
    height: 30px;
    flex-shrink: 0;
  }
  body.is-card-table .hand-title > span {
    display: none;
  }
  body.is-card-table .hand {
    gap: 5px;
  }
  body.is-card-table .last-trick,
  body.is-card-table .scopa-room .last-trick {
    height: auto;
    min-height: 30px;
    text-align: center;
    line-height: 1.4;
  }
  body.is-card-table .game-shell > .turn-banner {
    left: auto;
    right: calc(env(safe-area-inset-right) + 8px);
    width: calc(var(--rail-w) - env(safe-area-inset-right) - 16px);
    bottom: max(8px, env(safe-area-inset-bottom));
    height: 34px;
    border-radius: 8px;
    padding: 0 8px;
    text-align: center;
    font-size: 10px;
  }
  body.is-card-table .player-top,
  body.is-card-table .trick-area {
    left: calc((100% - var(--rail-w)) / 2);
  }
  body.is-card-table .player-right {
    right: calc(var(--rail-w) + 5px);
  }
  body.is-card-table .deck-area {
    bottom: max(8px, env(safe-area-inset-bottom));
  }
  body.is-card-table .trick-pot {
    right: calc(var(--rail-w) + 14px);
    bottom: max(12px, env(safe-area-inset-bottom));
  }
  body.is-card-table .game-shell > .results {
    right: calc(env(safe-area-inset-right) + 8px);
    left: auto;
    width: calc(var(--rail-w) - env(safe-area-inset-right) - 16px);
    max-height: calc(100% - 16px);
    bottom: 8px;
    padding: 12px;
  }
  body.is-card-table .results h2 {
    font-size: 24px;
  }
  body.is-card-table .scopa-board-heading {
    left: calc((100% - var(--rail-w)) / 2);
    top: calc(var(--hud-h) + 40px);
  }
  body.is-card-table .scopa-board {
    left: 64px;
    right: calc(var(--rail-w) + 64px);
    top: calc(var(--hud-h) + 62px);
    bottom: 68px;
  }
  body.is-card-table .scopa-layout {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  body.is-card-table .scopa-layout:not(:has(.scopa-table-card:nth-child(5))) {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  body.is-card-table .scopa-table-card {
    max-width: min(84px, calc((100dvh - var(--hud-h) - 140px) / 1.55));
  }
  body.is-card-table .scopa-played {
    left: calc((100% - var(--rail-w)) / 2);
    bottom: 8px;
  }
}
