/* Short phone viewports: prioritize the table, the complete hand and actions.
   Keep the usual branding and larger cards when vertical space permits. */
@media(max-width:650px) and (max-height:740px){
 .in-game:has(.cacheta-play-area,.play-column) .masthead{display:none}
 .in-game .game-cacheta .table-toolbar{grid-template-columns:minmax(0,1fr) auto;gap:8px;min-height:44px}
 .in-game .game-cacheta .table-toolbar>div:first-child{display:block}
 .in-game .game-cacheta .table-toolbar .eyebrow{font-size:8px;letter-spacing:.7px;margin-bottom:3px}
 .in-game .game-cacheta .table-toolbar h1{font-size:14px}
 .in-game .game-cacheta .toolbar-buttons{width:auto;gap:4px}
 .in-game .game-cacheta .toolbar-buttons button{font-size:12px;padding:8px;flex:none}
 .game-cacheta .cacheta-score-player{padding:5px 6px}
 .game-cacheta .cacheta-felt{padding-top:7px;padding-bottom:7px}
 .game-cacheta .cacheta-board{padding-top:7px;gap:16px}
 .game-cacheta .cacheta-pile>.card,.game-cacheta .cacheta-pile>.cacheta-wild-wrap>.card,.game-cacheta .cacheta-empty-discard{width:36px}
 .game-cacheta .cacheta-hand>.card,.game-cacheta .cacheta-hand>.cacheta-wild-wrap{max-width:54px}
 .game-cacheta .cacheta-hand-section{margin-top:7px;padding-top:5px}
 .game-cacheta .cacheta-hand{gap:7px;padding-top:5px}
 .game-scopa .opponents .avatar,.game-bisca .opponents .avatar{display:none}
 .game-scopa .hand,.game-bisca .hand,.game-scopa .hand:has(.art-card-spanish),.game-bisca .hand:has(.art-card-spanish){height:112px;min-height:112px;max-height:none;padding-top:12px;padding-bottom:8px}
 .game-scopa .hand .card:has(.art-card-spanish),.game-bisca .hand .card:has(.art-card-spanish){width:60px}

}
@media(max-width:650px){
 .in-game .game-scopa .hand-section,.in-game .game-bisca .hand-section{position:static;bottom:auto}
 .game-scopa .table-cards,.table-public-accusi,.public-tressette-events{overscroll-behavior:contain}
}

/* One-screen Tressette: navigation, live score, flexible table, complete hand,
   then two rows of 44px actions. Expanded history/chat and results are overlays. */
@media(max-width:650px){
 body.in-game.game-tressette-active{height:100dvh;min-height:0;overflow:hidden;display:grid;grid-template-rows:44px minmax(0,1fr)}
 body.in-game.game-tressette-active>.masthead{display:flex;height:44px;min-height:44px;padding:0 58px 0 10px;gap:8px}
 .game-tressette-active .brand{font-size:23px;letter-spacing:-1px;gap:5px;min-width:0}.game-tressette-active .brand-seal{width:26px;height:26px;line-height:24px;font-size:19px;flex-shrink:0}
 .game-tressette-active .brand small,.game-tressette-active .connection,.game-tressette-active>footer{display:none}
 .game-tressette-active .profile-chip{margin-left:auto;min-height:44px;padding:4px 6px;max-width:112px;font-size:10px}
 .game-tressette-active>#app{height:100%;min-height:0;overflow:hidden;padding-bottom:env(safe-area-inset-bottom)}
 .game-tressette-active .game-tressette{height:100%;min-height:0;position:relative;display:flex;flex-direction:column;gap:3px;padding:0 8px 5px}
 .game-tressette-active .game-tressette>.table-toolbar{display:grid;grid-template-columns:minmax(0,1fr) auto;flex:0 0 44px;min-height:44px;margin:0;gap:6px;align-items:center;flex-wrap:nowrap}
 .game-tressette-active .table-toolbar>div:first-child{min-width:0}.game-tressette-active .table-toolbar .eyebrow{font-size:8px;line-height:10px;letter-spacing:1px;max-width:none}.game-tressette-active .table-toolbar h1{font-size:12px;line-height:16px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
 .game-tressette-active .toolbar-buttons{display:flex;gap:3px;flex-wrap:nowrap}.game-tressette-active .toolbar-buttons button{min-width:44px;height:44px;min-height:44px;padding:4px 6px;font-size:10px}.game-tressette-active .toolbar-buttons #invite{max-width:96px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
 .game-tressette-active .game-tressette>.table-profile-strip{display:none}
 .game-tressette-active .tressette-live-score{flex:0 0 auto;padding:3px 5px;gap:1px 10px;font-size:10px;line-height:12px}.game-tressette-active .tressette-score-side{gap:1px}.game-tressette-active .tressette-score-side>span{gap:4px;white-space:nowrap}.game-tressette-active .tressette-live-score strong{font-size:19px;line-height:19px}.game-tressette-active .tressette-live-score small{font-size:8px;line-height:10px}.game-tressette-active .tressette-live-score .live-hand-points{font-size:10px;line-height:12px}.game-tressette-active .tressette-score-meta{font-size:8px;line-height:10px}
 .game-tressette-active .table-public-accusi{flex:0 0 44px;height:44px;max-height:44px;min-height:0;margin:0;padding:0 6px;overflow:visible}.game-tressette-active .tressette-accuso-history>summary{height:42px;min-height:44px;gap:4px;font-size:9px}.game-tressette-active .tressette-accuso-history>summary>small{font-size:8px}
 .game-tressette-active .tressette-accuso-history[open] .tressette-accuso-records{position:fixed;z-index:12;inset:100px 12px auto;max-height:45dvh;overflow:auto;padding:12px;background:#20291f;border:1px solid var(--gold);border-radius:8px;box-shadow:0 12px 40px #000a}
 .game-tressette-active .game-tressette>.turn-note{flex:0 0 20px;min-height:20px;height:20px;margin:0;padding:1px 6px;font-size:10px;line-height:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
 .game-tressette-active .game-tressette>.table-layout{display:flex;flex:1 1 0;min-height:0;gap:0}.game-tressette-active .play-column{display:flex;flex-direction:column;flex:1 1 0;min-height:0;gap:4px}.game-tressette-active .side-score{display:none}
 .game-tressette-active .side-felt{display:flex;flex-direction:column;flex:1 1 104px;min-height:104px;padding:4px 6px;border-width:3px;border-radius:17px;box-shadow:0 0 0 1px #8c6b45,inset 0 0 30px #0003}
 .game-tressette-active .opponents{flex:0 0 auto;grid-template-columns:repeat(3,minmax(0,1fr));gap:3px}.game-tressette-active .opponents .seat{font-size:9px;gap:0;line-height:10px}.game-tressette-active .opponents .seat .avatar{display:none}.game-tressette-active .opponents .seat>span:last-child{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.game-tressette-active .opponents .seat small{font-size:7px;margin-top:1px;line-height:8px}.game-tressette-active .team-tag{font-size:6px;letter-spacing:.4px;line-height:8px;margin-top:1px}
 .game-tressette-active .trick-board{display:flex;flex:1 1 0;flex-direction:column;min-height:0}.game-tressette-active .side-felt .board-heading{margin:3px 0 1px;font-size:7px;line-height:9px;letter-spacing:.5px}.game-tressette-active .trick-cards{flex:1 1 0;min-height:0;gap:7px;flex-wrap:nowrap;align-items:center}.game-tressette-active .trick-play{min-width:0;gap:2px;position:relative}.game-tressette-active .trick-play>.card,.game-tressette-active .trick-play>.card:has(.art-card-spanish){width:clamp(30px,5.3dvh,42px);height:auto;aspect-ratio:208/319}.game-tressette-active .trick-play>small{font-size:7px;line-height:8px;max-width:65px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.game-tressette-active .signal-badge{position:absolute;bottom:10px;left:50%;transform:translateX(-50%);font-size:7px;padding:2px 3px;line-height:9px;max-width:90px}
 .game-tressette-active .side-felt .self-seat,.game-tressette-active .side-felt .last-move{display:none}
 .game-tressette-active .hand-section{flex:0 0 auto;min-height:0;margin:0;position:static}.game-tressette-active .hand-heading{margin:0 1px;height:14px;line-height:14px;font-size:8px}
 .game-tressette-active .hand,.game-tressette-active .hand:has(.art-card-spanish){display:grid;grid-template-columns:repeat(5,minmax(0,1fr));justify-items:center;align-content:start;height:auto;min-height:0;max-height:none;gap:5px 4px;padding:3px;overflow:visible}
 .game-tressette-active .hand .card,.game-tressette-active .hand .card:has(.art-card-spanish){width:clamp(44px,7dvh,60px);max-width:100%;min-width:44px;height:auto;aspect-ratio:208/319;transform:none;border-radius:4px}.game-tressette-active .hand .card.selected{transform:none;outline:3px solid var(--gold);outline-offset:0;box-shadow:0 0 0 1px #193326}.game-tressette-active .hand .card:hover{transform:none}
 .game-tressette-active .actions{display:flex;flex-direction:column;gap:2px;margin:0;padding:2px 0 0;position:static}.game-tressette-active .selected-play-card{font-size:9px;line-height:12px;min-height:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
 .game-tressette-active .tressette-play-actions,.game-tressette-active .tressette-play-actions.with-signals{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px}.game-tressette-active .tressette-play-actions:not(.with-signals){grid-template-columns:repeat(2,minmax(0,1fr))}
 .game-tressette-active .tressette-play-actions .play-choice,.game-tressette-active .tressette-play-actions.with-signals .play-choice,.game-tressette-active .tressette-play-actions.with-signals .compound-signal{grid-column:auto;min-width:0}
 .game-tressette-active .tressette-play-actions .play-choice button,.game-tressette-active .actions #declare-accuso{width:100%;height:44px;min-height:44px;min-width:44px;margin:0;padding:3px 2px;font-size:11px;line-height:13px;white-space:normal}.game-tressette-active .signal-action-status{font-size:8px;line-height:10px;min-height:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
 .game-tressette-active .round-finished>.turn-note,.game-tressette-active .round-finished>.table-layout{visibility:hidden}.game-tressette-active .round-banner{position:absolute;z-index:4;inset:100px 8px 6px;display:flex;flex-wrap:wrap;align-content:center;justify-content:center;gap:8px;padding:14px;overflow:auto}.game-tressette-active .round-banner h2{flex-basis:100%;font-size:25px;margin:0}.game-tressette-active .round-banner p{flex-basis:100%;font-size:12px;margin:0;line-height:1.5}.game-tressette-active .round-banner button{flex:1 1 120px;min-height:44px;font-size:13px}
 .game-tressette-active>#social-root{position:fixed;z-index:9;right:6px;top:0;width:44px;height:44px;margin:0;padding:0}.game-tressette-active #social-root>details{border:0;background:#252d22}.game-tressette-active #social-root>details>summary{height:44px;min-height:44px;padding:0;display:grid;place-items:center;font-size:0;list-style:none}.game-tressette-active #social-root>details>summary:after{content:'Conversa';font-size:8px;color:var(--gold)}
 .game-tressette-active #social-root:has(>details[open]){inset:0 6px 6px;width:auto;height:auto;max-height:100dvh;overflow:auto;background:#20261e;border:1px solid var(--gold);border-radius:8px}.game-tressette-active #social-root>details[open]>summary{font-size:13px;display:flex;justify-content:space-between;padding:0 12px}.game-tressette-active #social-root>details[open]>summary:after{content:'Fechar';font-size:12px}
 .game-tressette-active #social-root>details:not([open]) #social-unread{position:absolute;top:1px;right:0;max-width:44px;font-size:8px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
 .game-tressette-active dialog{max-height:calc(100dvh - 16px);overflow-y:auto;overscroll-behavior:contain}
 .game-tressette-active>.update-notice{position:fixed;top:44px;z-index:11}.game-tressette-active>#toast{top:48px;bottom:auto;font-size:11px;padding:8px 12px}
}

@media(max-width:650px) and (max-height:700px){.game-tressette-active .game-tressette{gap:2px;padding-bottom:2px}}

/* Small iPhones merge navigation into the existing 44px table toolbar rather
   than clipping the second action row. Card and button targets stay unchanged. */
@media(max-width:650px) and (max-height:620px) and (orientation:portrait){
 body.in-game.game-tressette-active{grid-template-rows:minmax(0,1fr)}
 body.in-game.game-tressette-active>.masthead{display:none}
 .game-tressette-active .table-toolbar>div:first-child{padding-left:48px}
 .game-tressette-active>#social-root{left:8px;right:auto}
}
