/* One viewport owner: every dimension derives from PirateViewport's game rem. */
#ph-profile-button{position:fixed;left:calc(1.2 * var(--game-rem));top:calc(1.15 * var(--game-rem));z-index:8;width:calc(2.5 * var(--game-rem));height:calc(2.5 * var(--game-rem));padding:0;border-radius:50%;border:calc(.0625 * var(--game-rem)) solid #ffe476;background:#052f46;color:#ffe476;display:grid;place-items:center;cursor:pointer}
#ph-profile-button[hidden]{display:none}#ph-profile-button svg{width:65%;height:65%;fill:currentColor}
#ph-account-dialog,#ph-password-dialog,#ph-reward-dialog{font:400 var(--game-rem)/1.45 Inter,ui-sans-serif,system-ui,sans-serif;box-sizing:border-box;width:44em;max-width:none;max-height:43em;padding:1.5em 2em;border:.0625em solid #ffe476;border-radius:.9em;background:#052f46;color:white;box-shadow:0 1.5em 4em #0007;animation:none;transform:none;overflow:hidden}
#ph-account-dialog::backdrop,#ph-password-dialog::backdrop,#ph-reward-dialog::backdrop{background:#001722a6;backdrop-filter:blur(5px)}
#ph-account-dialog[data-page="connect"],#ph-account-dialog[data-page="login"],#ph-account-dialog[data-page="signout"]{width:30em}
#ph-account-dialog h2,#ph-password-dialog h2,#ph-reward-dialog h2{font:400 1.8em/1.2 Caribbean,Georgia,serif;color:#ffe476;text-align:center;margin:.3em 0 1em}
#ph-account-dialog h3,#ph-account-dialog .ph-username{font:850 1.2em/1.3 Caribbean,Georgia,serif;margin:0 0 .7em}
#ph-account-body{max-height:33em;overflow:auto;overscroll-behavior:contain;padding:0 .4em}
#ph-account-dialog[data-page="register"] #ph-account-body{max-height:32em}
#ph-account-dialog section{padding:1em 0;border-bottom:.0625em solid #75b0c65c;text-align:left}
#ph-account-dialog .ph-summary{display:flex;align-items:flex-start;gap:1.3em;padding-top:0}.ph-summary p{margin:.25em 0}
.ph-avatar{width:6em;height:6em;object-fit:cover;border:.0625em solid #ffe476;border-radius:.6em;background:#031e2e;flex-shrink:0}.ph-avatar-placeholder{display:grid;place-items:center;font-size:1em;color:#ffe476}.ph-avatar-placeholder svg{width:65%;fill:currentColor}
.ph-rank{display:flex;align-items:center;justify-content:space-between;gap:2em;margin:.8em 0}.ph-rank span:last-child{text-align:right}.ph-current{color:#ffe476}
.ph-achievement{display:grid;grid-template-columns:1.5em 1fr;gap:.7em;margin:1em 0;align-items:start}.ph-achievement input{width:1.1em;height:1.1em;accent-color:#ffe476;opacity:1;margin:.3em 0}.ph-achievement strong{color:#ffe476;font-weight:700}.ph-achievement p{margin:.25em 0;font-size:.95em}
#ph-account-dialog .button,#ph-password-dialog .button,#ph-reward-dialog .button{font:850 1.1em/1.25 Caribbean,Georgia,serif;min-height:2.8em;padding:.65em 1.2em;min-width:9em;border-radius:.5em;border:.0625em solid #ffe476;box-shadow:none;letter-spacing:.03em;cursor:pointer}
#ph-account-dialog .button-primary,#ph-password-dialog .button-primary,#ph-reward-dialog .button-primary{background:#ffe476;color:#052f46}#ph-account-dialog .button-ghost,#ph-password-dialog .button-ghost{background:rgba(0,48,86,.68);color:#fff0b4}
#ph-account-dialog button:disabled{opacity:.5;cursor:wait}.ph-account-actions{display:flex;justify-content:center;gap:1em;margin-top:1.2em}.ph-stack{display:grid;gap:1em}.ph-stack .button{width:100%}.ph-separator{border:0;border-top:.0625em solid #75b0c6;margin:1em 0}
#ph-account-dialog label,#ph-password-dialog label{display:grid;gap:.3em;text-align:left;margin:.65em 0}
#ph-account-dialog input:not([type=checkbox]),#ph-account-dialog select,#ph-password-dialog input{font:inherit;width:100%;background:#031e2e;color:white;border:.0625em solid #75b0c6;border-radius:.4em;padding:.55em .7em;min-height:2.4em;box-sizing:border-box}
#ph-account-dialog small{display:block;font-size:.8em;color:#d4e7ed;margin:.25em 0}.ph-text-button{border:0;background:none;color:#ffe476;font:inherit;text-decoration:underline;padding:.2em;cursor:pointer}.ph-edit-row{display:grid;grid-template-columns:10em 1fr;gap:1em;align-items:center;padding:.65em 0}.ph-edit-row>label{margin:0!important}.ph-edit-row>div{text-align:right}.ph-edit-row .ph-avatar{width:4em;height:4em}.ph-edit-row button:not(.ph-avatar){color:#ffe476}
#ph-account-gear{position:absolute;left:1.5em;top:1.3em;width:2em;height:2em;padding:.2em;border:0;background:none;color:#ffe476;cursor:pointer}#ph-account-gear svg{width:100%;fill:currentColor}#ph-account-gear[hidden]{display:none}
#ph-account-status{color:#ffd49c;font-size:.9em;min-height:1.5em;margin:.6em 0 0;text-align:center}#ph-account-dialog .ph-history{list-style:none;padding:0;margin:0}#ph-account-dialog .ph-history li{margin:.5em 0}#ph-password-dialog{width:28em}#ph-password-status{color:#ffd49c}
#ph-account-dialog[open],#ph-password-dialog[open]{display:flex;flex-direction:column}#ph-account-body{min-height:0;flex-shrink:1}#ph-account-title,#ph-account-footer,#ph-account-status{flex-shrink:0}#ph-account-dialog .button-primary,#ph-password-dialog .button-primary,#ph-reward-dialog .button-primary{background:linear-gradient(135deg,#ffd15e,var(--gold) 62%,#df9118);color:#231403;box-shadow:0 .625em 1.5em #f4b72d38,inset 0 .0625em #ffffff59}#ph-account-dialog input[hidden]{display:none}
/* Account identity, shared SVG flags, and provider-standard sign-in controls. */
#ph-profile-button.ph-has-account{width:auto;max-width:calc(22 * var(--game-rem));height:calc(2.5 * var(--game-rem));display:flex;gap:calc(.55 * var(--game-rem));border:0;border-radius:0;background:transparent;font:850 calc(1.1 * var(--game-rem))/1.2 Caribbean,Georgia,serif;color:#ffe476}
#ph-profile-button.ph-has-account .ph-avatar{width:calc(2.5 * var(--game-rem));height:calc(2.5 * var(--game-rem));border-radius:calc(.25 * var(--game-rem));box-sizing:border-box}
#ph-profile-button .ph-menu-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ph-country-flag{display:inline-block;width:1.5em;height:1.125em;object-fit:contain;vertical-align:middle;flex-shrink:0}
#ph-profile-button .ph-country-flag{width:calc(1.5 * var(--game-rem));height:calc(1.125 * var(--game-rem))}
#ph-account-dialog .ph-google-button{display:flex;align-items:center;justify-content:center;gap:.75em;width:100%;min-height:2.85em;box-sizing:border-box;padding:.65em .85em;background:#fff;border:.0715em solid #747775;border-radius:.2857em;color:#1f1f1f;font:500 1em/1.4 Arial,sans-serif;letter-spacing:.015em;text-transform:none;box-shadow:none;cursor:pointer}
#ph-account-dialog .ph-google-button img{width:1.4286em;height:1.4286em;object-fit:contain;flex-shrink:0}
#ph-account-dialog .ph-google-button:hover{background:#f8faff;box-shadow:0 .08em .2em #0003}
#ph-account-dialog[data-page="registerChoice"]{width:30em}
#ph-account-dialog .ph-edit-row{grid-template-columns:10em minmax(0,1fr);text-align:left}
#ph-account-dialog .ph-edit-row>span:first-child,#ph-account-dialog .ph-edit-row>label:first-child{display:block;justify-self:stretch;text-align:left;padding:0;margin:0;line-height:1.45}
#ph-account-dialog .ph-edit-row>input{min-width:0}
#ph-account-dialog #ph-sign-out{position:absolute;top:1.5em;right:1.5em;font-size:.9em;z-index:2}
#ph-account-dialog #ph-sign-out[hidden]{display:none}
#ph-account-dialog[data-page="profile"] h2,#ph-account-dialog[data-page="edit"] h2{padding:0 3.4em}
#ph-account-dialog #ph-account-gear{width:2em;height:2em;display:grid;place-items:center}
#ph-account-dialog #ph-account-gear[hidden]{display:none}
#ph-account-dialog #ph-account-gear svg{width:100%;height:100%}
#ph-account-dialog .ph-country-picker{position:relative;min-width:0;text-align:left}
.ph-country-control{position:relative}
#ph-account-dialog #ph-country{padding-right:4em}
#ph-country-flag{position:absolute;right:1.7em;top:50%;transform:translateY(-50%);pointer-events:none;line-height:1}
.ph-country-chevron{position:absolute;right:.6em;top:50%;transform:translateY(-50%);pointer-events:none}
#ph-country-list{position:absolute;top:calc(100% + .2em);left:0;right:0;max-height:10em;overflow-y:auto;overscroll-behavior:contain;border:.0625em solid #75b0c6;border-radius:.4em;background:#031e2e;box-shadow:0 .4em 1em #0006;z-index:6;padding:.2em}
#ph-country-list[hidden]{display:none}
#ph-account-dialog #ph-country-list button{display:flex;align-items:center;justify-content:space-between;gap:.5em;width:100%;padding:.5em .6em;border:0;border-radius:.2em;background:transparent;color:white;text-align:left;font:inherit;cursor:pointer}
#ph-account-dialog #ph-country-list button:hover,#ph-account-dialog #ph-country-list button.ph-country-active{background:#15536a;color:#ffe476}
#ph-account-dialog #ph-country-list button[aria-selected="true"]{color:#ffe476}
#ph-country-list p{padding:.3em .6em;margin:0}

/* Compact profile overview and achievement list, using the shared dialog scale. */
#ph-account-dialog .ph-summary{gap:1em}
#ph-account-dialog .ph-summary-details{flex:1;min-width:0;text-align:left;align-self:stretch;display:flex;flex-direction:column;justify-content:space-between}
#ph-account-dialog .ph-summary-heading{display:flex;align-items:baseline;justify-content:space-between;gap:1em}
#ph-account-dialog .ph-summary .ph-username{font-weight:850;margin:0;white-space:nowrap;line-height:1.25}
#ph-account-dialog .ph-summary-details>p{font-weight:700;margin:0;line-height:1.3}
#ph-account-dialog .ph-summary .ph-joined{margin:0;text-align:right;font-weight:400;font-size:.85em;white-space:nowrap;line-height:1.3}
#ph-account-dialog .ph-rank{font-weight:700}
#ph-account-dialog .ph-achievement{margin:.9em 0;row-gap:0}
#ph-account-dialog .ph-achievement strong{display:block;margin:0;font-weight:700;line-height:1.25}
#ph-account-dialog .ph-achievement p{margin:.2em 0 0;font-weight:700;line-height:1.3}

/* Post-victory celebrations share the profile dialog scale and menu backdrop. */
#ph-reward-dialog{width:34em;text-align:center}
#ph-reward-dialog[open]{display:flex;flex-direction:column}
#ph-reward-dialog h2,#ph-reward-dialog .ph-account-actions{flex-shrink:0}
#ph-reward-body{min-height:0;max-height:27em;overflow:auto}
#ph-reward-body p{margin:.5em 0}
.ph-earned-achievements{list-style:none;margin:0;padding:0;font-weight:700;color:#ffe476}
.ph-earned-achievements li{margin:.7em 0}
#ph-reward-body .ph-earned-rank{font:850 1.3em/1.3 Caribbean,Georgia,serif;color:#ffe476;margin-top:.6em}

.ph-rank-name{display:inline-flex;align-items:center;gap:.35em}
#ph-profile-button .ph-identity-marks{margin-left:0}
#ph-reward-body .ph-earned-rank-image{margin:.4em auto .8em}
#ph-reward-body .ph-earned-rank-image img{display:block;width:5.25em;height:5.25em;margin:auto}

/* Keep full Caribbean glyph overhang clear of the identity badges. */
#ph-profile-button.ph-has-account[hidden]{display:none!important}
#ph-profile-button .ph-menu-name{overflow:visible;flex-shrink:0;padding-right:.15em}
#ph-profile-button .ph-identity-marks{flex-shrink:0}
#ph-account-dialog .ph-achievement input:checked{appearance:none;background:transparent;border:0;position:relative}
#ph-account-dialog .ph-achievement input:checked::after{content:'✓';display:block;color:#43d46b;font-weight:900;font-size:1.15em;line-height:1}
#ph-reward-body .ph-earned-rank-image img{width:7.875em;height:7.875em}
#ph-reward-dialog[open]{--popup-base-transform:translate(0,0);animation:popup-zoom-pulse-in .24s cubic-bezier(.16,.85,.3,1) both}

@media(prefers-reduced-motion:reduce){#ph-reward-dialog[open]{animation:none}}

#ph-account-dialog .ph-summary-rank-row{display:flex;align-items:center;justify-content:space-between;gap:1em}
#ph-account-dialog .ph-summary-victories,#ph-account-dialog .ph-summary-rank-row p{font:700 1em/1.3 Inter,ui-sans-serif,system-ui,sans-serif;margin:0;white-space:nowrap}
#ph-account-dialog .ph-summary-victories,#ph-account-dialog .ph-summary-achievements{text-align:right}
#ph-account-dialog .ph-summary-details>p.ph-summary-joined{font-weight:400;font-size:.85em;line-height:1.3}

#ph-reward-body .ph-reward-congratulation{font-weight:700}

/* Three text rows fit the photo; the date has its own row below it. */
#ph-account-dialog .ph-summary{display:grid;grid-template-columns:6em minmax(0,1fr);gap:.35em 1.3em;align-items:start}
#ph-account-dialog .ph-summary>.ph-avatar{box-sizing:border-box;width:6em;height:6em}
#ph-account-dialog .ph-summary>.ph-summary-joined{grid-column:1/-1;margin:0;font-size:.85em;line-height:1.3;font-weight:400}
#ph-account-dialog .ph-profile-grid{display:grid;grid-template-columns:max-content 5em minmax(0,1fr);gap:.65em;min-width:0;height:6em;align-items:stretch}
#ph-account-dialog .ph-profile-left,#ph-account-dialog .ph-profile-discovery{display:grid;grid-template-rows:1.3em 1fr 1.17em;align-items:center;font-weight:700;min-width:0}
#ph-account-dialog .ph-profile-grid p{margin:0;font-size:.9em;line-height:1.3}
#ph-account-dialog .ph-profile-left .ph-username{white-space:normal;overflow-wrap:anywhere;font-size:1em;line-height:1.3;margin:0}
#ph-account-dialog .ph-profile-discovery{text-align:right}
#ph-account-dialog .ph-profile-discovery strong{white-space:nowrap;font-size:1em;line-height:1.3}
#ph-account-dialog .ph-profile-rank{display:flex;align-items:center;justify-content:center}
#ph-account-dialog .ph-profile-emblem img{width:5em;height:5em;object-fit:contain;display:block}

/* Close atomically: shared discrete transitions otherwise retain a non-flex dialog. */
#ph-account-dialog{transition:none}
#ph-account-dialog:not([open]){display:none!important;animation:none!important}
#ph-account-dialog::backdrop{transition:none}
.ph-legend-row{display:flex;align-items:center;justify-content:space-between;gap:1em}
.ph-legend-row strong{font:700 1em/1.45 Inter,ui-sans-serif,system-ui,sans-serif;color:#ffe476}
.ph-legend-star{width:2em;height:2em;flex-shrink:0;fill:#667784;stroke:#8a9aa6;stroke-width:1}
.ph-legend-star.is-earned{fill:#ffe476;stroke:#e4ad2c}
/* Legend completion stays checked even when its cosmetic badge is hidden. */
#ph-account-dialog .ph-legend-completion{margin:0;display:grid;grid-template-columns:1.5em 1fr;gap:.7em;align-items:center;min-width:0}
#ph-account-dialog .ph-legend-completion input{width:1.1em;height:1.1em;margin:0;opacity:1;accent-color:#43d46b}
#ph-account-dialog .ph-legend-completion input:checked{appearance:none;background:transparent;border:0;position:relative}
#ph-account-dialog .ph-legend-completion input:checked::after{content:'✓';display:block;color:#43d46b;font-weight:900;font-size:1.15em;line-height:1}
.ph-legend-display{display:inline-flex;align-items:center;gap:.65em;flex-shrink:0}
#ph-account-dialog .ph-legend-toggle{display:inline-flex;align-items:center;box-sizing:border-box;width:2.6em;height:1.4em;min-height:0;padding:.15em;border:.1em solid #8a9aa6;border-radius:1em;background:#344954;cursor:pointer;font-size:inherit}
.ph-legend-toggle span{display:block;width:.9em;height:.9em;border-radius:50%;background:#d4e1e8;transition:transform .15s}
#ph-account-dialog .ph-legend-toggle[aria-checked="true"]{background:#23783c;border-color:#43d46b}
.ph-legend-toggle[aria-checked="true"] span{transform:translateX(1.1em);background:#ffe476}
.ph-legend-toggle:focus-visible{outline:.15em solid #ffe476;outline-offset:.15em}
.ph-legend-toggle:disabled{opacity:.6;cursor:wait}

/* Picture actions keep the common text-link style and viewport scale. */
#ph-account-dialog #ph-avatar-delete {font-size:.9em}
#ph-account-dialog .ph-avatar-controls {display:flex;justify-content:flex-end;align-items:center;gap:1em}
#ph-picture-delete-dialog {font:400 var(--game-rem)/1.45 Inter,ui-sans-serif,system-ui,sans-serif;box-sizing:border-box;width:30em;max-width:none;padding:1.5em 2em;border:.0625em solid #ffe476;border-radius:.9em;background:#052f46;color:white;box-shadow:0 1.5em 4em #0007;animation:none;transition:none;transform:none;text-align:center}
#ph-picture-delete-dialog::backdrop {background:#001722a6;backdrop-filter:blur(5px)}
#ph-picture-delete-dialog:not([open]) {display:none!important}
#ph-picture-delete-dialog h2 {font:400 1.8em/1.2 Caribbean,Georgia,serif;color:#ffe476;margin:.3em 0 1em}
#ph-picture-delete-dialog .button {font:850 1.1em/1.25 Caribbean,Georgia,serif;min-height:2.8em;padding:.65em 1.2em;min-width:9em;border-radius:.5em;border:.0625em solid #ffe476;letter-spacing:.03em;cursor:pointer}
#ph-picture-delete-dialog .button-primary {background:linear-gradient(135deg,#ffd15e,var(--gold) 62%,#df9118);color:#231403}
#ph-picture-delete-dialog .button-ghost {background:rgba(0,48,86,.68);color:#fff0b4}
#ph-picture-delete-dialog button:disabled {opacity:.5;cursor:wait}
#ph-picture-delete-status {color:#ffd49c;font-size:.9em}
#ph-picture-delete-status:empty {display:none}

/* Registration confirmation stays within the existing shared-scale account dialog. */
#ph-account-dialog .ph-registration-check{display:grid;grid-template-columns:1.2em minmax(0,1fr);gap:.8em;align-items:start;margin:1em 0 1.4em;text-align:left}
#ph-account-dialog .ph-registration-check input{width:1.15em;height:1.15em;margin:.2em 0 0;accent-color:#ffe476;cursor:pointer}
#ph-account-dialog .ph-registration-check label{display:block;margin:0;line-height:1.5;cursor:pointer}
#ph-account-dialog .ph-registration-check a{font-weight:700;color:inherit;text-decoration:underline;text-underline-offset:.15em}
#ph-account-dialog .ph-registration-check a:focus-visible{outline:2px solid #ffe476;outline-offset:2px}
#ph-consent-continue:disabled{background:#67747b!important;color:#d4d9dc!important;box-shadow:none!important;cursor:not-allowed!important}
