/* Player controllers only. The host's TV layout and quiz dialog are independent. */
body.player{height:100dvh;overflow:hidden}
body.player #lobbyApp{width:100%;max-width:560px;height:100dvh;margin:auto;padding:max(8px,env(safe-area-inset-top)) 12px max(8px,env(safe-area-inset-bottom));display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:32px minmax(0,1fr) 36px;gap:8px}
body.player header.logo{grid-row:1;font-size:clamp(23px,6.2vw,31px);line-height:30px;letter-spacing:-1px;-webkit-text-stroke:1px #a84014;margin:0;white-space:nowrap}
body.player .screenPanel{grid-column:1;grid-row:2;min-height:0;min-width:0;width:100%;max-width:none;margin:0}
body.player #playerTools{position:static;grid-column:1;grid-row:3;align-self:center;justify-self:start;z-index:15}
body.player #playerTools button{min-height:34px;font-size:11px;padding:7px 12px}
body.player .musicToggle{position:static;grid-column:1;grid-row:3;align-self:center;justify-self:end;min-height:34px;font-size:11px;z-index:15}
body.player #connectionError:empty{display:none}
body.player #connectionError:not(:empty){position:absolute;bottom:50px;left:12px;right:12px;margin:0;padding:10px;background:#451f29;border:1px solid #ffb0b0;border-radius:10px;font-size:13px;z-index:99}
/* Avatar and die share an upper row; the ranking always follows below. */
body.player #playerScreen{display:flex;flex-direction:column;gap:6px}
body.player #playerName{flex:none;font-size:clamp(22px,6vw,30px);line-height:1.12;margin:0;overflow-wrap:anywhere}
body.player .playerHero{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);height:clamp(100px,23dvh,190px);flex:none;gap:10px;align-items:center;background:radial-gradient(ellipse at center,#183049,transparent 70%);border-radius:18px}
body.player .playerHero:has(#phoneDie[hidden]){grid-template-columns:1fr}
body.player #idleCanvas{display:block;min-width:0;width:100%;max-width:250px;height:100%;min-height:0;justify-self:center}
body.player #phoneDie{position:relative;inset:auto;width:100%;padding:6px;border:1px solid #efd18155;background:#13263be8;align-self:center;z-index:auto}
body.player #phoneDieStage{height:clamp(65px,13dvh,110px)}
body.player #phoneDie canvas{height:clamp(65px,13dvh,110px)!important;width:clamp(65px,13dvh,110px)!important}
body.player #phoneDie .goldButton{font-size:14px;line-height:1.2;padding:10px 6px;min-height:44px;margin:3px 0;width:100%}
body.player #phoneDie p{font-size:12px;margin:3px 0}
body.player #playerMessage{flex:none;margin:0;font-size:12px;line-height:1.25;min-height:16px}
body.player .phoneLeaderboard{display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden;border-top:1px solid #344354;padding-top:6px;text-align:left}
body.player .phoneLeaderboard h2{flex:none;font-size:16px;margin:0 0 5px;color:#ffdf8c}
body.player #liveRanking{display:flex;flex-direction:column;gap:4px;min-height:0;overflow:auto;overscroll-behavior:contain;margin:0;padding:0}
body.player #liveRanking li{flex:none;margin:0;padding:5px 10px;min-height:27px;font-size:13px;gap:8px;align-items:center;line-height:1.15}
body.player #liveRanking li span{min-width:0;overflow-wrap:anywhere}
body.player #liveRanking li b{white-space:nowrap;flex:none;font-size:12px}
/* One question at a time; the response actions remain outside the scrollable area. */
body.player #phoneQuestion{display:grid;grid-template-rows:auto minmax(0,1fr) auto auto;gap:8px;overflow:hidden}
body.player .phoneQuestionTop{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px;align-items:start}
body.player #phonePrompt{font-size:clamp(17px,4.4vw,22px);line-height:1.22;margin:0;max-height:24dvh;overflow:auto;overflow-wrap:anywhere;text-align:left}
body.player #phoneTimer{font-size:20px;min-width:46px;padding:6px;border-radius:9px;background:#27364a;line-height:1.2;white-space:nowrap}
body.player .phoneQuestionGrid{display:flex;flex-direction:column;align-items:stretch;justify-content:center;gap:10px;min-height:0;overflow:auto;overscroll-behavior:contain;padding:2px}
body.player #phonePhoto{flex:0 1 auto;width:100%;height:clamp(75px,21dvh,190px);min-height:65px;max-height:30%;object-fit:contain;border-radius:10px}
body.player #phoneAnswers{display:grid;grid-template-columns:minmax(0,1fr);gap:9px;flex:0 0 auto;min-width:0;width:100%}
body.player #phoneAnswers>button{min-height:48px;font-size:16px;line-height:1.22;text-align:left;padding:12px;border-radius:12px;white-space:normal;overflow-wrap:anywhere}
body.player #phoneQuestion:is([data-mode=photo],[data-mode=reveal],[data-mode=wager]) #phoneAnswers{grid-template-columns:repeat(2,minmax(0,1fr))}
body.player #phoneQuestion:is([data-mode=photo],[data-mode=reveal],[data-mode=wager]) #phoneAnswers>button{font-size:14px;min-height:52px;padding:10px}
body.player .phoneActions{display:flex;gap:8px;align-items:stretch;flex:none}
body.player #phoneValidate,body.player #phonePass{margin:0;min-height:44px;padding:10px 12px;line-height:1.15;font-size:14px;white-space:normal}
body.player #phoneValidate{flex:1}body.player #phonePass{margin-left:auto}
body.player #phoneNotice{font-size:11px;line-height:1.2;margin:0;color:#c3cfdd}
body.player #phoneAnswers.estimateControl{display:flex;flex-direction:column;gap:12px;margin:0}
body.player #phoneAnswers .estimateValue{font-size:clamp(26px,8vw,40px);overflow-wrap:anywhere}
body.player #phoneAnswers .estimateAdjust{gap:8px}
body.player #phoneAnswers .estimateAdjust button{flex-basis:52px;min-height:48px;font-size:17px}
body.player #phoneAnswers #estimateSlider{height:48px}
body.player #phoneAnswers .estimateTicks{font-size:11px;color:#d0dae8}
body.player #phoneAnswers .estimateHint{font-size:12px;line-height:1.3}
body.player #phoneAnswers.rankingControl{display:block;flex:none;margin:0;min-height:0}
body.player #phoneAnswers .rankBoard{height:auto;min-height:0;max-height:none;grid-template-rows:repeat(4,minmax(50px,auto));gap:8px}
body.player #phoneAnswers .rankTile{min-height:50px;font-size:15px;line-height:1.2;padding:10px;overflow-wrap:anywhere}
body.player #phoneAnswers .rankNumber{color:#4d3a72;flex-basis:28px;font-size:17px}
/* Registration stays vertical, including the optional photo. */
body.player #registerScreen{overflow:auto;overscroll-behavior:contain;display:flex;flex-direction:column;gap:10px}
body.player .registerGrid{display:flex;flex-direction:column;gap:10px}
body.player .pseudoLabel{font-size:20px;margin-bottom:5px}
body.player #pseudo{font-size:16px;padding:10px}
body.player .photoActions{gap:8px;margin:8px 0}
body.player .photoActions button{min-height:42px;font-size:12px;flex:1}
body.player .registerGrid small{display:block;font-size:10px;line-height:1.3}
body.player .avatarGrid{grid-template-columns:repeat(5,minmax(0,1fr));gap:5px}
body.player .avatarGrid img{height:clamp(62px,12dvh,100px)}
body.player .avatarGrid span{font-size:10px;overflow-wrap:anywhere}
body.player #register{position:sticky;bottom:0;flex:none;width:100%;font-size:14px;line-height:1.2;margin:4px 0;min-height:46px;padding:12px;z-index:3}
body.player #waitingScreen{position:relative;grid-column:1;grid-row:2;min-height:0;border-radius:18px;overflow:hidden;background:#102535}
body.player .waitingScreen img{object-fit:cover;object-position:center;width:100%;height:100%;opacity:.85}
body.player .waitingScreen strong{top:45%;left:5%;width:90%;font-size:22px;padding:18px 12px;line-height:1.3}
/* Portrait crop: preview flexes, controls and validation stay visible. */
@media(orientation:portrait){body.player #cropDialog[open]{display:flex;flex-direction:column;width:94vw;height:92dvh;max-height:92dvh;overflow:hidden}body.player .cropHeader{padding:12px 16px 8px;flex:none}body.player .cropHeader h2{font-size:20px;margin:3px 0}body.player .cropHeader p{font-size:11px;line-height:1.3}body.player .cropHeader .eyebrow{display:none}body.player .cropView{flex:1;min-height:0;overflow:hidden}body.player #cropCanvas{height:100%;width:auto;max-width:100%;min-height:0;object-fit:contain}body.player .cropControls{flex:none;padding:10px 16px 12px}body.player .cropControls input{margin:5px 0}body.player .cropButtons button{min-height:44px;padding:10px}body.player .cropTip{font-size:10px}}
@media(max-height:680px){body.player #lobbyApp{gap:5px;grid-template-rows:28px minmax(0,1fr) 34px;padding-top:5px;padding-bottom:5px}body.player header.logo{font-size:24px;line-height:27px}body.player .playerHero{height:110px}body.player #playerName{font-size:23px}body.player #liveRanking{gap:3px}body.player #liveRanking li{padding:4px 8px;min-height:24px;font-size:12px}body.player .phoneLeaderboard h2{font-size:14px;margin-bottom:4px}body.player #phonePhoto{height:90px;max-height:28%}body.player #phoneAnswers>button{font-size:14px;min-height:44px;padding:10px}body.player #phoneAnswers{gap:7px}body.player #phonePrompt{font-size:17px}body.player #phoneAnswers .rankTile{font-size:14px;min-height:46px}body.player #phoneAnswers .rankBoard{grid-template-rows:repeat(4,minmax(46px,auto));gap:6px}body.player #phoneDieStage,body.player #phoneDie canvas{height:65px!important}body.player #phoneDie canvas{width:65px!important}}
/* Landscape remains usable without an orientation wall; portrait is the primary layout. */
@media(orientation:landscape) and (max-height:550px){body.player #lobbyApp{max-width:none}body.player #playerScreen{display:grid;grid-template-columns:42% minmax(0,1fr);grid-template-rows:auto minmax(0,1fr) auto}body.player #playerName{grid-column:1}body.player .playerHero{grid-column:1;grid-row:2;height:100%;min-height:0}body.player #playerMessage{grid-column:1;grid-row:3}body.player .phoneLeaderboard{grid-column:2;grid-row:1/4}body.player #phoneQuestion{grid-template-columns:minmax(0,.8fr) minmax(0,1.2fr);grid-template-rows:minmax(0,1fr) auto}body.player .phoneQuestionTop{grid-column:1;grid-row:1}body.player #phonePrompt{max-height:100%}body.player .phoneQuestionGrid{grid-column:2;grid-row:1/3;justify-content:flex-start}body.player #phoneNotice{display:none}body.player .phoneActions{grid-column:1;grid-row:2}body.player #phonePhoto{height:80px;min-height:65px}body.player #phoneAnswers{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(orientation:portrait) and (max-height:680px){body.player #liveRanking{gap:2px}body.player #liveRanking li{min-height:22px;padding:3px 8px}body.player #playerMessage{font-size:11px}body.player .phoneLeaderboard{padding-top:4px}}
@media(orientation:portrait) and (max-height:560px){body.player .playerHero{height:85px}body.player #playerScreen{gap:4px}body.player #phoneDieStage{height:48px}body.player #phoneDie .goldButton{font-size:12px;padding:8px 4px}body.player #liveRanking li{min-height:20px;padding:3px 7px;font-size:11px}body.player #liveRanking li b{font-size:11px}body.player .phoneLeaderboard h2{font-size:13px}}

/* Give question photos the remaining portrait height, with answers below. */
@media(orientation:portrait){
 body.player .phoneQuestionGrid:has(#phonePhoto:not([hidden])){display:grid;grid-template-rows:minmax(140px,1fr) auto;align-content:stretch;justify-content:stretch;gap:8px}
 body.player #phonePhoto{width:100%;height:100%;min-height:0;max-height:none;object-fit:contain}
 body.player .phoneQuestionGrid:has(#phonePhoto:not([hidden])) #phoneAnswers{grid-template-columns:repeat(2,minmax(0,1fr))}
}
/* Explicit rows prevent intrinsic image sizing from overlapping touch targets. */
body.player #lobbyApp{height:100dvh;padding-top:calc(22px + env(safe-area-inset-top,0px));grid-template-rows:34px minmax(0,1fr) 36px;isolation:isolate}
body.player .musicToggle{display:none!important}
body.player #phoneDie{background:transparent;border:0;box-shadow:none;padding:0}
body.player #phoneDieStage:empty{display:none;height:0!important}
body.player #phoneQuestion{position:relative;min-height:0;overflow:hidden}
body.player .phoneQuestionGrid,body.player .phoneQuestionGrid:has(#phonePhoto:not([hidden])){display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;gap:8px;overflow-y:auto;overflow-x:hidden;min-height:0;position:relative;isolation:isolate;touch-action:pan-y;-webkit-overflow-scrolling:touch}
body.player #phonePhoto{display:block;flex:0 0 auto;width:100%;height:clamp(95px,24dvh,240px);min-height:0;max-height:240px;object-fit:contain;position:relative;pointer-events:none;z-index:0}
body.player #phoneAnswers{position:relative;z-index:1;flex:0 0 auto;min-height:min-content;touch-action:pan-y}
body.player #phoneAnswers>button{position:relative;touch-action:manipulation;pointer-events:auto;-webkit-tap-highlight-color:#ffdf7040}
body.player #phoneAnswers>button[aria-pressed=true]{background:#70551c;border:2px solid #ffe389;box-shadow:inset 0 0 0 1px #ffe389}
body.player .phoneActions{position:relative;z-index:4;background:#000;padding:3px 0}
body.player #phoneResults{display:flex;flex-direction:column;gap:8px;overflow:auto;text-align:left}
body.player #phoneResultPrompt{font-size:19px;margin:0;line-height:1.25}
body.player #phoneCorrect{font-size:21px;color:#9cf1b9}
body.player #phoneExplanation{font-size:13px;margin:0}
body.player #phoneResultAvatar{width:130px;height:135px;flex:0 0 135px;align-self:center}
body.player #phoneResultRows{display:grid;gap:6px}
.phoneResultRow{display:flex;flex-direction:column;gap:4px;border:1px solid #6d8195;border-radius:10px;padding:9px;background:#162738;font-size:14px}
.phoneResultRow.right{border-color:#69d89b}.phoneResultRow.wrong{border-color:#e39797}
body.player #phoneFinalReady{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:18px}body.player #finalReadyStatus{font-size:18px;line-height:1.5}
@media(orientation:landscape) and (max-height:550px){body.player #phonePhoto{height:100px}body.player #lobbyApp{padding-top:calc(12px + env(safe-area-inset-top,0px))}}

/* Readable player controls and a slightly larger portrait. */
body.player .playerHero{height:clamp(110px,26dvh,215px)}
body.player #idleCanvas{max-width:275px}
body.player #phoneResultAvatar{width:155px;height:170px;flex-basis:170px}
body.player #liveRanking li{font-size:16px;min-height:32px;padding:6px 10px}
body.player #liveRanking li b{font-size:15px}
body.player #phoneAnswers>button{font-size:18px;text-align:center;line-height:1.25;min-height:52px}
body.player #phoneAnswers .rankTile{font-size:17px;text-align:center}
body.player #phoneDie .goldButton{font-size:19px;min-height:62px;padding:13px 8px;border:2px solid #ffe9a2}
body.player #rollPhone.rollAttention:not(:disabled){animation:rollAttention 1.4s ease-in-out infinite}
@keyframes rollAttention{0%,100%{box-shadow:0 0 0 2px #ffdc7055,0 0 8px #ffc54e66;filter:brightness(1)}50%{box-shadow:0 0 0 5px #ffdc7088,0 0 22px #ffc54ecc;filter:brightness(1.2)}}
@media(prefers-reduced-motion:reduce){body.player #rollPhone.rollAttention:not(:disabled){animation:none;box-shadow:0 0 0 4px #ffdc7088,0 0 18px #ffc54e99}}
body.player #phoneQuestion[data-mode=final] #phoneAnswers{grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
body.player #phoneQuestion[data-mode=final] #phoneAnswers>button{min-height:44px;font-size:clamp(15px,4vw,18px);padding:6px;text-align:center}

#avatarGrid button:disabled:not([aria-pressed="true"]) img{filter:grayscale(1)}
#registrationStatus:empty{display:none}
