.heading { align-items: center; }
.mode { margin: 4px 0 0; color: var(--secondary); font-size: 13px; }
#music, .controls button {
  min-height: 44px; padding: 4px 12px; color: inherit; background: var(--soft);
  border: 1px solid var(--line); border-radius: 7px; font-weight: 740; font-size: 13px;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
#music[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.controls { display: flex; flex-wrap: wrap; gap: 6px; }
.controls button { flex: 1; }
.controls button:disabled { opacity: .5; cursor: default; }
.controls .primary { background: #07513d; border-color: #07513d; color: #fff; }
[data-theme="dark"] .controls .primary { background: #a7e4c8; border-color: #a7e4c8; color: #102c21; }
.table-top { display: flex; justify-content: space-between; align-items: center; gap: 7px; font-size: 13px; }
.table-top + .table-top { margin-top: 5px; }
.opponents, #scores { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.opponents { margin-top: 8px; }
.seat, .score { min-width: 0; padding: 6px; border: 1px solid #8ba89770; border-radius: 6px; }
.seat[data-turn] { border-color: #e6c97f; background: #326853; }
.seat span, .score span { display: block; font-size: 12px; }
.seat strong { font-size: 13px; }
.center { min-height: 73px; display: grid; place-content: center; gap: 5px; text-align: center; }
#lead-label { margin: 0; font-size: 13px; font-weight: 720; }
.mini-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; }
.mini-card { display: inline-grid; place-content: center; min-width: 23px; min-height: 28px; padding: 1px 3px;
  border-radius: 4px; border: 1px solid #afbdac; color: #152922; background: #fffdf4; font-size: 11px; font-weight: 760; }
.mini-card[data-back] { background: #2c654f; color: #e1d49a; }
.mini-card[data-red], .hand-card[data-red] { color: #a52336; }
.panel, #play-panel { margin-block: 8px; }
.panel h2, .result h2 { margin: 0 0 5px; font-size: 14px; }
.panel-title { display: flex; justify-content: space-between; align-items: baseline; gap: 7px; }
#hand-info { color: var(--secondary); font-size: 12px; }
.hand { display: grid; grid-template-columns: repeat(10, minmax(0, 49px)); gap: 4px; }
.hand-card {
  min-width: 0; min-height: 54px; padding: 1px; display: grid; place-content: center; gap: 0;
  border: 1px solid #adbdad; border-radius: 5px; color: #152922; background: #fffdf4;
  font: 760 14px/1.06 system-ui, sans-serif; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.hand-card:disabled { cursor: default; }
.hand-card[aria-pressed="true"] { border-color: #8d6824; background: #ffedb7; box-shadow: inset 0 0 0 1px #8d6824; }
.hand-card span:last-child { font-size: 14px; }
.result { margin-bottom: 8px; padding: 8px; background: var(--soft); border: 1px solid var(--line); border-radius: 7px; }
#scores { grid-template-columns: repeat(3,minmax(0,1fr)); }
.score { background: var(--surface); }
.score strong { color: var(--accent); }
.actions button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
@media(max-width:560px) {
  .hand { grid-template-columns: repeat(7,minmax(0,1fr)); gap: 3px; }
  .hand-card { min-height: 44px; }
  .guide { padding: 8px 10px; }
  .seat span { font-size: 11px; }
  .center { min-height: 66px; }
}

.seat-play .play-owner {
  flex: 0 0 100%;
  color: #f4e5c5;
  text-align: center;
  font-size: 11px;
  font-weight: 650;
}
.seat-play[data-play-seat="2"] .play-owner { text-align: start; }
.seat-play[data-play-seat="1"] .play-owner { text-align: end; }

.landlord-flow .card-room .controls button,
.landlord-flow .card-room .flow-actions button { min-height: 44px; }
.landlord-flow #round-actions { justify-content: center; }
.landlord-flow .flow-score .mini-card { min-height: 25px; }
.landlord-flow:has(#result:not([hidden])) .rotate-hint { display: none; }
@media (orientation: landscape) and (max-height: 550px) {
  .landlord-flow.game-flow .card-room .hand {
    --card-step: clamp(28px, calc((90vw - 22px - env(safe-area-inset-left) - env(safe-area-inset-right) - var(--card-width)) / 19), 45px);
  }
}
@media (orientation: landscape) and (max-width: 650px) and (max-height: 550px) {
  .landlord-flow.game-flow .card-room .hand {
    --card-step: 28px;
    display: flex;
    flex-wrap: wrap;
    row-gap: 4px;
    max-width: 345px;
  }
  .landlord-flow.game-flow .card-room .hand-card:nth-child(10n + 1) { margin-inline-start: 0; }
}
.landlord-flow [data-dealing] .card-room :is(.turn-area,.hand-panel,.actions) { visibility: hidden; }
.landlord-flow [data-dealing] .self-seat { visibility: hidden; }
.landlord-flow [data-dealing] :is(.seat-meta,.seat-action,#center,#phase,#multiplier) { visibility: hidden; }

/* Keep the table footprint when a cut follows settlement or a fresh visit. */
.landlord-flow [data-predeal] .card-room { display: block !important; min-height: min(500px, 74dvh); }
.landlord-flow [data-predeal] .card-room > :not(.flow-deal) { visibility: hidden; }

.landlord-recap { margin-block: 12px; border-top: 1px solid #809b8580; padding-block-start: 10px; }
.landlord-recap h3 { margin: 0 0 4px; font-size: 16px; color: #ffdf9d; }
.landlord-recap p { margin: 4px 0; font-size: 13px; }
.landlord-recap .mini-cards { justify-content: flex-start; }
#multiplier[data-boost] { color:#ffe09a; font-weight:800; }
.landlord-flow #center-cards .seat-play.is-leading .play-owner { color:#ffdf9d; }
.landlord-flow #action-history { margin:4px auto 0; width:min(100%,560px); }
.landlord-flow #action-history:has([hidden]) { display:none; }
.landlord-flow .flow-result .flow-formula { color:#ffdf9d; }
@media (orientation:landscape) and (max-height:480px) {
  .landlord-flow .flow-optional-cut small { font-size:11px; }
}

/* English joker faces: vertical JOKER in the corner, tiny word on played-card chips. */
.hand-card[data-joker] .card-corner.joker-word { writing-mode: vertical-lr; text-orientation: upright; letter-spacing: -1px; font-size: 10px; }
.mini-card[data-joker] { font-size: 9px; letter-spacing: -.2px; }
.card-room .hand-card[data-joker]:has(.joker-word) .card-pip { top: auto; bottom: 4px; left: auto; right: 5px; }

/* Character avatars: a distinct face per computer player, a gold badge for you, a crown on the landlord. */
.landlord-flow #opponents .seat-avatar, .landlord-flow .self-seat .seat-avatar,
#opponents .seat-avatar, .self-seat .seat-avatar { position: relative; border: 2px solid #f4e7c4; background: none; padding: 0; overflow: visible; box-shadow: 0 2px 6px #00000040; }
#opponents .seat-avatar svg:not(.crown), .self-seat .seat-avatar svg:not(.crown) { width: 100%; height: 100%; border-radius: 50%; }
#opponents .seat-avatar { width: 42px; }
.self-seat .seat-avatar { width: 30px; }
.seat-avatar .crown { position: absolute; top: -7px; right: -7px; width: 18px; height: 18px; display: none; filter: drop-shadow(0 1px 1px #0006); }
:is(.seat, .self-seat)[data-landlord] .seat-avatar .crown { display: block; }
:is(.seat, .self-seat)[data-landlord] .seat-avatar { border-color: var(--gold); }
@media (max-width: 600px), (orientation: landscape) and (max-height: 480px) {
  #opponents .seat-avatar { width: 32px; }
  .self-seat .seat-avatar { width: 24px; }
  .seat-avatar .crown { width: 14px; height: 14px; top: -5px; right: -5px; }
}
/* Phone portrait: hold the hand like a real fan of cards, overlapped in rows of ten, instead of a grid of
   separate tiles (owner feedback 11-16: "not made for people to play"). Grid cells are one "step" wide and each
   card is wider than its cell, so every card shows its corner and the last card of a row shows in full. */
@media (orientation: portrait) and (max-width: 700px) {
  .landlord-flow.game-flow .card-room .hand {
    --card-width: clamp(50px, 14.5vw, 68px);
    --card-step: calc((min(100vw, 700px) - 48px - var(--card-width)) / 9);
    display: grid; grid-template-columns: repeat(var(--cols, 10), var(--card-step)); justify-content: start; gap: 0;
    width: calc(var(--card-step) * (var(--cols, 10) - 1) + var(--card-width)); max-width: none; margin-inline: auto;
    padding-block: 14px 4px;
  }
  .landlord-flow.game-flow .card-room .hand-card,
  .landlord-flow.game-flow .card-room .hand-card + .hand-card {
    width: var(--card-width); height: calc(var(--card-width) * 1.42); min-height: 0; margin: 0;
  }
  /* Later rows tuck under the row above so the whole hand reads as one fan. */
  .landlord-flow.game-flow .card-room .hand-card:nth-child(n + 11) { margin-block-start: calc(var(--card-width) * -0.6); }
  .landlord-flow.game-flow .card-room .hand-card[aria-pressed="true"] { transform: translateY(-12px); }
  .landlord-flow.game-flow .card-room .hand-card .card-corner { top: 4px; left: 5px; font-size: clamp(17px, 4.6vw, 22px); }
  .landlord-flow.game-flow .hand-card[data-joker] .card-corner { font-size: 11px; }
}
/* Table feel (owner feedback 11-16): cards that are played look like cards on the table and land from the
   player's side; whoever is to act has a pulsing ring; no "turn your phone" tip now that the hand fans in portrait. */
.landlord-flow .rotate-hint { display: none; }
.landlord-flow #center-cards .mini-card { min-width: 34px; min-height: 48px; font-size: 15px; font-weight: 750; border-radius: 5px; box-shadow: 0 2px 4px #071d1499; }
.landlord-flow #center-cards .mini-cards { gap: 2px; }
.landlord-flow #center-cards .seat-play[data-play-seat="0"] .mini-card[data-arrived] { animation: lp-land-up 240ms cubic-bezier(.2,.8,.2,1) both; }
.landlord-flow #center-cards .seat-play[data-play-seat="2"] .mini-card[data-arrived] { animation: lp-land-left 240ms cubic-bezier(.2,.8,.2,1) both; }
.landlord-flow #center-cards .seat-play[data-play-seat="1"] .mini-card[data-arrived] { animation: lp-land-right 240ms cubic-bezier(.2,.8,.2,1) both; }
@keyframes lp-land-up { from { transform: translateY(70px) scale(1.25); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes lp-land-left { from { transform: translate(-60px,-30px) scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes lp-land-right { from { transform: translate(60px,-30px) scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }
.landlord-flow :is(.seat, .self-seat)[data-turn] .seat-avatar { animation: lp-turn-pulse 1.1s ease-in-out infinite; }
@keyframes lp-turn-pulse { 0%, 100% { box-shadow: 0 0 0 0 #f3d17ccc; } 50% { box-shadow: 0 0 0 7px #f3d17c00; } }
.landlord-flow .card-room .status { font-size: 15px; font-weight: 750; }
.landlord-flow .card-room .hand-card { transition: transform 110ms ease-out; }
@media (prefers-reduced-motion: reduce) {
  .landlord-flow #center-cards .mini-card[data-arrived], .landlord-flow :is(.seat, .self-seat)[data-turn] .seat-avatar { animation: none; }
  .landlord-flow .card-room .hand-card { transition: none; }
}
/* Sideways phones are short: keep the compact table cards and status there so the hand stays on screen
   (regression from the 11-16 "table feel" sizes, found 11-17 at 667x375). */
@media (orientation: landscape) and (max-height: 550px) {
  .landlord-flow #center-cards .mini-card { min-width: 22px; min-height: 26px; font-size: 10px; box-shadow: none; }
  .landlord-flow .card-room .status { font-size: 12px; font-weight: 700; }
}
