/* ===== portrait phones only (< 600px wide, portrait). Desktop, tablets and landscape are untouched. ===== */
#rotnote{display:none}
html.norot #rotnote{display:none!important}
/* v53: only for a landscape box too small for the wide layout (under 600x300) */
@media (orientation:landscape) and (max-height:299px),(orientation:landscape) and (max-width:599px){
 #rotnote{display:flex;position:fixed;inset:0;z-index:9999;align-items:center;justify-content:center;background:#1b120b url(img/art/bg-desk.webp) center/cover;color:#f1e3bd;text-align:center;padding:20px}
 #rotnote>div{background:var(--paper) center/220px,#e6d7b1;color:#231a12;border:1px solid #2a180a;outline:1px solid rgba(35,26,18,.45);outline-offset:-6px;padding:18px 26px;max-width:420px;box-shadow:0 8px 24px rgba(0,0,0,.6)}
 #rotnote svg{width:54px;height:54px;color:#8b2a1c;display:block;margin:0 auto 6px;animation:rotph 2.4s ease-in-out infinite}
 #rotnote b{display:block;font:22px 'IM Fell English SC',serif;color:#8b2a1c}#rotnote p{margin:6px 0 0;font:15px 'IM Fell English',Georgia,serif}
 @keyframes rotph{0%,30%{transform:rotate(-90deg)}60%,100%{transform:rotate(0)}}
 @media (prefers-reduced-motion:reduce){#rotnote svg{animation:none}}
}
@media (max-width:599px) and (orientation:portrait){
 /* --- combat: compact detail, single-row fanned hand, icon tags --- */
 html body.phone #app[data-screen=combat] #detail .hint{display:none}
 html body.phone #app[data-screen=combat] #detail.empty{min-height:0}
 html body.phone #app[data-screen=combat] #detail.empty p.lg1{margin:0}
 html body.phone #app[data-screen=combat]>.scr>.tray{flex:none;height:auto;min-height:0;overflow:hidden;padding:0}
 html body.phone #app[data-screen] #hand.fan{--cw:min(98px,26.5vw);display:flex!important;flex-wrap:nowrap;justify-content:center;align-items:flex-end;height:calc(var(--cw)*1.26 + 32px);padding:26px 8px 6px;box-sizing:border-box;overflow:visible;gap:0}
 html body.phone #app[data-screen] #hand.fan>.card{flex:none;width:var(--cw)!important;height:calc(var(--cw)*1.26)!important;min-height:0!important;max-height:none!important;max-width:none;min-width:0;margin:0 0 0 min(4px,calc((100% - var(--cw) - 18px) / max(var(--n) - 1,1) - var(--cw)))!important;
  transform:rotate(calc((var(--i) - (var(--n) - 1) / 2) * 1.3deg)) translateY(calc((var(--i) - (var(--n) - 1) / 2) * (var(--i) - (var(--n) - 1) / 2) * .45px))!important;transform-origin:50% 110%;transition:transform .15s ease,box-shadow .15s ease;z-index:calc(1 + var(--i));box-shadow:-2px 2px 6px rgba(0,0,0,.45)}
 html body.phone #app[data-screen] #hand.fan{--n:1}html body.phone #app[data-screen] #hand.fan>.card{--i:0}
 html body.phone #app[data-screen] #hand.fan:has(>.card:nth-child(2)){--n:2}html body.phone #app[data-screen] #hand.fan:has(>.card:nth-child(3)){--n:3}html body.phone #app[data-screen] #hand.fan:has(>.card:nth-child(4)){--n:4}html body.phone #app[data-screen] #hand.fan:has(>.card:nth-child(5)){--n:5}html body.phone #app[data-screen] #hand.fan:has(>.card:nth-child(6)){--n:6}html body.phone #app[data-screen] #hand.fan:has(>.card:nth-child(7)){--n:7}html body.phone #app[data-screen] #hand.fan:has(>.card:nth-child(8)){--n:8}html body.phone #app[data-screen] #hand.fan:has(>.card:nth-child(9)){--n:9}html body.phone #app[data-screen] #hand.fan:has(>.card:nth-child(10)){--n:10}html body.phone #app[data-screen] #hand.fan:has(>.card:nth-child(11)){--n:11}html body.phone #app[data-screen] #hand.fan:has(>.card:nth-child(12)){--n:12}
 html body.phone #app[data-screen] #hand.fan>.card:nth-child(2){--i:1}html body.phone #app[data-screen] #hand.fan>.card:nth-child(3){--i:2}html body.phone #app[data-screen] #hand.fan>.card:nth-child(4){--i:3}html body.phone #app[data-screen] #hand.fan>.card:nth-child(5){--i:4}html body.phone #app[data-screen] #hand.fan>.card:nth-child(6){--i:5}html body.phone #app[data-screen] #hand.fan>.card:nth-child(7){--i:6}html body.phone #app[data-screen] #hand.fan>.card:nth-child(8){--i:7}html body.phone #app[data-screen] #hand.fan>.card:nth-child(9){--i:8}html body.phone #app[data-screen] #hand.fan>.card:nth-child(10){--i:9}html body.phone #app[data-screen] #hand.fan>.card:nth-child(11){--i:10}html body.phone #app[data-screen] #hand.fan>.card:nth-child(12){--i:11}
 html body.phone #app[data-screen] #hand.fan>.card:first-child{margin-left:0!important}
 html body.phone #app[data-screen] #hand.fan>.card.sel{transform:translateY(-12px) scale(1.07)!important;z-index:50;box-shadow:0 8px 18px rgba(0,0,0,.7),0 0 0 2px #e8c76a}
 html body.phone #app[data-screen] #hand.fan>.card .nm{font-size:13px;line-height:1.05}
 html body.phone .topline .phic{padding:3px 6px!important;min-width:0;font-size:0!important;line-height:0;display:inline-flex;align-items:center;gap:0}
 html body.phone .topline .phic .ic{width:18px!important;height:18px!important;display:inline-block!important;margin:0}
 html body.phone .topline .deckchip.phic{font-size:0!important}
 /* --- end screen: short banner, stats + silver in one row, Renown details on tap --- */
 html body.phone #app[data-screen=end]>.scr.endscr{gap:6px;justify-content:flex-start}
 html body.phone .endscr>h1{font-size:26px;margin:2px 0}
 html body.phone .endscr>img.banner{height:96px!important;max-height:96px;width:100%;object-fit:cover;object-position:center 40%;flex:none}
 html body.phone .endscr>p.center{font-size:14px;line-height:1.25;padding:6px 10px}
 html body.phone .endscr .stats.st5{grid-template-columns:repeat(5,1fr);gap:4px;margin:0}
 html body.phone .endscr .stats.st5>div{padding:4px 1px}
 html body.phone .endscr .stats.st5 b{font-size:17px}html body.phone .endscr .stats.st5 small{font-size:11px;letter-spacing:-.1px}
 html body.phone .phrank{border:1px solid #6b4a1e;background:rgba(0,0,0,.3);border-radius:6px;color:var(--cream,#f1e3bd)}
 html body.phone .phrank>summary{cursor:pointer;list-style:none;padding:8px 10px;display:flex;align-items:baseline;gap:6px;min-height:28px}
 html body.phone .phrank>summary::-webkit-details-marker{display:none}
 html body.phone .phrank>summary b{color:#e8c76a}html body.phone .phrank>summary .more{margin-left:auto;font-size:12px;opacity:.8;text-decoration:underline}
 html body.phone .phrank[open]>summary .more{visibility:hidden}
 html body.phone .phrank>.rankbox{margin:0 6px 6px;border:0;background:none;padding:0 4px}html body.phone .phrank>.rankbox>div:first-child{display:none}
 html body.phone .phrank>p{margin:0 6px 8px;font-size:13px}
 html body.phone .endscr .lbsign{margin:2px 0 0;padding:8px 12px}
 html body.phone .endscr .lbsign .lbh{font-size:17px}
 html body.phone .endscr .lbsign p.small{font-size:12.5px;margin:1px 0}
 /* --- Nassau hub: one panel at a time, tab bar in thumb reach --- */
 html body.phone .nassauscr>img.banner{max-height:120px;object-fit:cover}
 html body.phone .nassauscr[data-tab=port]>[data-tab]:not([data-tab=port]),html body.phone .nassauscr[data-tab=ship]>[data-tab]:not([data-tab=ship]),html body.phone .nassauscr[data-tab=crew]>[data-tab]:not([data-tab=crew]){display:none!important}
 html body.phone #app[data-screen=nassau]>.actions.ntabact{flex-direction:column;gap:6px;height:auto}
 html body.phone .ntabbar{display:flex;gap:4px;width:100%}
 html body.phone .ntabbar button{flex:1;min-height:50px;margin:0;padding:4px 2px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;font-size:13px}
 html body.phone .ntabbar button .ic{width:20px;height:20px}
 html body.phone .ntabbar button.on{background:var(--paper) center/170px,#e8c76a!important;color:#231a12!important;box-shadow:inset 0 0 0 2px #8b2a1c}
 html body.phone #app[data-screen=nassau]>.actions.ntabact>#back{width:100%;min-height:46px}
 /* --- Hall of Captains: list as tall as its rows; formula behind a toggle --- */
 html body.phone .hallscr .lbwrap{flex:0 1 auto}
 html body.phone .lbhow{margin:8px 2px 0}html body.phone .lbhow>summary{cursor:pointer;font-size:14px;color:#e8c76a;padding:6px 0}
 html body.phone .lbhow>.lbform{margin-top:2px}
}
/* iPhone safe areas: #app already pads max(6px,inset) top/bottom; drop the duplicate body padding so nothing is clipped under the home indicator */
@media (max-width:599px) and (orientation:portrait){
 html body.phone{box-sizing:border-box;padding-top:0;padding-bottom:0}
}
/* short visible heights (Safari toolbars shown, iPhone SE) */
@media (max-width:599px) and (orientation:portrait) and (max-height:680px){
 html body.phone .titlescr .choices{gap:6px!important}
 html body.phone .titlescr .choices>button{min-height:46px!important;height:auto!important;padding-top:4px;padding-bottom:4px}
 html body.phone .titlescr>.tagl{margin:6px 0 2px}
 html body.phone .endscr>img.banner{height:64px!important;max-height:64px}
 html body.phone .nassauscr>img.banner{max-height:80px}
}
@media (max-width:599px) and (orientation:portrait) and (max-height:600px){
 html body.phone .titlescr>.platecap{display:none}
 html body.phone .titlescr>img.banner{margin-top:4px}
 html body.phone .endscr>img.banner{height:48px!important;max-height:48px}
}
/* itch build only (#pdlink exists off piratedeck.org): make room for the home link on short phones */
@media (max-width:599px) and (orientation:portrait) and (max-height:600px){
 html body.phone .titlescr:has(#pdlink)>h3{display:none}
 html body.phone .titlescr:has(#pdlink)>.tagl{margin:4px 0 0}
 html body.phone .titlescr:has(#pdlink) .choices{gap:5px!important}
 html body.phone .titlescr:has(#pdlink) .choices>button{min-height:42px!important}
 html body.phone #pdlink{margin:2px 0 0!important;font-size:12px!important}
}
/* v33: the turn note only appears while a card or move is selected, as a panel over the foot of the sea (no layout jump) */
@media (max-width:599px) and (orientation:portrait){
 html body.phone #app[data-screen=combat]>.scr>#detail{position:absolute;left:4px;right:4px;z-index:6;margin:0}
 html body.phone #app[data-screen=combat]>.scr>#detail.empty{display:none}
 html body.phone .mine .logbtn{min-width:40px;margin-left:6px}
 html body.phone .log.open{left:8px;right:8px;bottom:calc(84px + env(safe-area-inset-bottom));max-height:46vh}
 /* title plate: never let the button stack squash the picture */
 html body.phone .titlescr>img.banner{flex:none!important;height:clamp(96px,18vh,150px)!important;min-height:96px;max-height:none!important}
}
@media (max-width:599px) and (orientation:portrait) and (max-height:700px){
 html body.phone .titlescr>.platecap{display:none}
 html body.phone .titlescr .choices>button{min-height:42px!important}
 html body.phone .titlescr>h1{margin-bottom:0}
}

/* v44: end screen: the Share / Back buttons follow the Hall of Captains box instead of sinking to the bottom */
html #app[data-screen=end]>.scr.endscr{flex:0 1 auto!important}
html #app[data-screen=end]>.actions{margin-top:12px}
