/* Two illustrated tables share controls, player portraits and responsive geometry. */
:root {
  --gold: #ecd398;
  --us: #a2d9d2;
  --them: #f2b59a;
  --red: #a52632;
  --serif: "Songti SC", "STSong", "SimSun", Georgia, serif;
  --hairline: rgb(234 205 141 / 38%);
}

#app {
  background: linear-gradient(180deg, transparent 65%, rgb(0 0 0 / 25%)),
              var(--landscape) center / cover, var(--felt3);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
#topbar {
  background: var(--lacquer);
  border-bottom: 1px solid var(--hairline);
  padding: 10px clamp(12px, 2.4vw, 38px);
  align-items: center;
}
.brand, .panel h1, .panel h2, .modal h2 { font-family: var(--serif); }
.brand {
  display: block;
  flex: none;
  color: #f5dfac;
  font-size: clamp(20px, 2.3vw, 32px);
  font-weight: 700;
  letter-spacing: .14em;
}
.brand::before { content: '♦'; margin-right: .45em; color: #d6ac66; font-size: .68em; }
.btn { border-radius: 8px; min-height: 40px; background: var(--lacquer); box-shadow: inset 0 0 0 1px var(--hairline); }
.btn.primary, .level-now, .trump-chip {
  color: #342710;
  background: linear-gradient(135deg, #f4e4b7, #d9b273);
  box-shadow: inset 0 1px 0 #ffeece, 0 2px 4px #0003;
}
.btn.ghost { background: transparent; min-height: 34px; }
.btn.primary:disabled { opacity: .48; }
.scoreboard { justify-content: center; }
.team-chip, .level-now, .trump-chip, .points-chip { border-radius: 6px; }
.team-chip, .points-chip { background: rgb(255 255 255 / 7%); }
#arena { min-height: 0; isolation: isolate; }
#arena::before {
  inset: 10px; border: 1px solid var(--hairline); border-radius: 10px;
  box-shadow: inset 0 0 28px rgb(3 17 18 / 16%);
}
.seat { gap: 6px; }
.pos-top { top: 18px; }
.pos-left { left: clamp(14px, 2.5vw, 42px); }
.pos-right { right: clamp(14px, 2.5vw, 42px); }
.avatar {
  width: clamp(48px, 5.2vw, 72px); height: auto; aspect-ratio: 1;
  background: url("players.webp") left center / 300% 100%;
  border-width: 2px;
}
.pos-left .avatar { background-position: center; }
.pos-right .avatar { background-position: right; }
.avatar .ch { display: none; }
.meta { text-shadow: 0 1px 3px #000; }
.name { background: var(--lacquer); border-radius: 5px; padding: 2px 6px; }
.name small { opacity: .85; }
.count { margin-top: 2px; background: var(--lacquer); }
.seat.active .avatar { animation: none; outline: 3px solid #ffe1a0; outline-offset: 2px; }
#play-2 { top: clamp(80px, 8vw, 106px); }
#play-1 { right: clamp(85px, 11vw, 160px); }
#play-3 { left: clamp(85px, 11vw, 160px); }
#play-0 { bottom: 15px; }
.play { max-width: 40%; }
.play .cards {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, calc(var(--cw) * .5));
  padding-right: calc(var(--cw) * .5); max-width: 100%;
}
.play .cards .card + .card { margin-left: 0; }
#me {
  background: var(--lacquer); border-top: 1px solid var(--hairline);
  padding: 7px max(10px, 2vw) calc(8px + env(safe-area-inset-bottom));
}
#status { color: #f4e8cd; }
#hint-reason { color: var(--gold); text-align: center; font-size: 13px; line-height: 1.45; }
#hint-reason:not(:empty) { padding: 2px 6px; }
@media (max-height: 510px) { #hint-reason { font-size: 12px; } }
#me-bar { min-height: 45px; }
#hand { transition: none; margin-top: 20px; }
.card { border: 1px solid #bbab8b; color: #1b2c32; }
.card .r, .card .pip { font-family: Georgia, "Times New Roman", serif; }
.card .pip { opacity: .88; }
.modal { background: var(--panel); max-height: 87dvh; border-color: var(--hairline); }

@media (max-width: 740px) and (orientation: portrait) {
  #app { background-position: center, 29% center; }
  #topbar {
    display: grid; grid-template-columns: 1fr auto; gap: 6px;
    padding: 6px 10px 8px;
  }
  .brand { display: block; grid-column: 1; grid-row: 1; }
  .top-actions { grid-column: 2; grid-row: 1; max-width: none; gap: 4px; }
  .scoreboard { grid-column: 1 / -1; grid-row: 2; gap: 4px; }
  .team-chip, .level-now, .trump-chip, .points-chip { padding: 2px 6px; }
  .level-now { flex-wrap: nowrap; gap: 4px; }
  .wild-chip { margin-left: 2px; }
  .avatar { width: 43px; }
  .pos-top { top: 12px; }
  .pos-left, .pos-right { top: 46%; }
  .pos-left { left: 8px; }
  .pos-right { right: 8px; }
  .pos-left .name, .pos-right .name { max-width: 5.1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pos-left .name small, .pos-right .name small { display: block; margin: 0; }
  #play-1, #play-3 { top: 46%; max-width: calc(50% - 59px); }
  #play-1 { right: 58px; }
  #play-3 { left: 58px; }
  #play-2 { top: 68px; }
  #arena::before { inset: 5px; }
  #me { padding-inline: 8px; }
  #me-bar { gap: 5px; }
  #me-chip { position: static; flex: 0 1 auto; padding: 4px 6px; margin: 0; gap: 4px; }
  #actions { gap: 5px; }
  #actions .btn { padding-inline: clamp(9px, 3.4vw, 18px); }
  .play { --cw: 34px; }
}

@media (orientation: landscape) and (max-height: 550px) {
  #topbar { padding: 3px 10px; gap: 5px; }
  .brand { display: block; font-size: 19px; }
  .scoreboard, .top-actions { flex-wrap: nowrap; gap: 4px; }
  .team-chip, .level-now, .trump-chip, .points-chip { padding: 2px 5px; font-size: 12px; }
  .btn.ghost { min-height: 30px; padding: 3px 7px; }
  #arena::before { inset: 3px 8px; }
  .seat { gap: 3px; }
  .avatar { width: 34px; }
  .pos-top { top: 5px; }
  .pos-left, .pos-right { top: 50%; flex-direction: row; }
  .pos-right { flex-direction: row-reverse; }
  .meta { font-size: 11px; }
  .play { --cw: 30px; gap: 1px; }
  .play .cap { font-size: 10px; }
  #play-2 { top: 8px; left: 38%; }
  #play-0 { bottom: 5px; left: 60%; }
  #play-3, #play-1 { top: 55%; max-width: 24%; }
  #play-3 { left: 16%; }
  #play-1 { right: 16%; }
  #me { padding-top: 3px; padding-bottom: max(4px, env(safe-area-inset-bottom)); }
  #status { min-height: 15px; font-size: 12px; }
  #me-bar { min-height: 33px; }
  #actions .btn { min-height: 32px; padding: 5px 18px; font-size: 13px; }
  #hand { --cw: clamp(37px, 5vw, 47px); margin-top: 13px; }
}
@media (orientation: landscape) and (max-height: 550px) and (max-width: 700px) {
  .brand::before { display: none; }
  .top-actions .btn { font-size: 11px; }
  .name small { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.sound-toggle.btn { padding-inline: 9px; font-size: 17px; line-height: 1; }
.sound-link { color: #cfe8ff; background: transparent; border: 0; padding: 0; font: inherit; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }
.sound-settings {
  width: min(340px, 92vw); max-height: 88dvh; padding: 20px; border-radius: 12px;
  background: var(--panel); color: #f8edda; border: 1px solid var(--hairline);
}
.sound-settings::backdrop { background: rgb(3 12 19 / 68%); }
.sound-settings h2 { margin: 0 0 12px; color: var(--gold); font: bold 22px var(--serif); }
.sound-settings label {
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  padding: 10px 1px; border-bottom: 1px solid var(--hairline); cursor: pointer;
}
.sound-settings input[type=checkbox] { width: 22px; height: 22px; margin: 0; padding: 0; accent-color: #d9bb83; }
.now-playing { color: #e3d6be; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.sound-buttons { display: flex; gap: 7px; }
.sound-buttons .btn { flex: 1; padding-inline: 6px; }
@media (orientation: landscape) and (max-width: 700px) and (max-height: 550px) {
  #topbar:has(#btn-kitty:not([hidden])) { flex-wrap: wrap; justify-content: space-around; }
}
