#identity-dialog {
  width: min(440px, calc(100% - 32px));
  box-shadow: 0 30px 90px #20382f30;
}
#identity-dialog [hidden], #join-panel[hidden], .creator-credit[hidden] { display: none; }
#identity-dialog h2 { margin: 1rem 0 .35rem; }
#identity-dialog p { color: #495e4b; }
.identity-close { position: absolute; top: 16px; right: 16px; }
#identity-dialog label, #identity-dialog small { display: block; }
#identity-dialog label { font-weight: 700; margin: .8rem 0 .4rem; }
#identity-agreement-row { margin: 1rem 0; }
#identity-dialog .adult-agreement { display: flex; align-items: flex-start; gap: .5rem; }
#identity-dialog #identity-agreement { flex: none; width: 19px; height: 19px; padding: 0; margin: 0; accent-color: #246653; }
#identity-agreement-row a { color: #18594b; text-decoration: underline; text-underline-offset: 2px; }
#identity-dialog input {
  width: 100%; padding: .8rem 1rem; font: inherit; font-size: 16px;
  color: var(--ink); background: white; border: 1px solid #98ab96; border-radius: 8px;
}
#identity-dialog input:focus-visible { outline: 2px solid #397853; }
#identity-dialog small { margin: .4rem 0 .7rem; color: #59695a; }
#identity-dialog .button { display: flex; justify-content: center; width: 100%; }
#identity-dialog .text-button { text-decoration: underline; text-underline-offset: 3px; }
#identity-status { font-size: .83rem; margin: .7rem 0; }
#identity-status:empty { display: none; }
#identity-switch, #copy-code { margin-top: 1rem; }
#backup-code { font-family: monospace !important; }
.join-panel {
  padding: 1.1rem; max-width: 370px; margin: 0 auto 1.25rem;
  border: 1px solid #c7d9c3; background: #f2f7eb; border-radius: 12px;
}
.join-panel strong { font: 800 1rem Manrope, sans-serif; }
.join-panel p { margin: .45rem 0 .8rem; line-height: 1.5; color: #516551; }
.join-panel button { padding: .7rem 1rem; }
.creator-credit {
  margin: 0 auto 1rem; max-width: 370px; border-inline-start: 4px solid #bd9544;
  border-radius: 7px; background: #fff5d8; padding: .8rem 1rem; line-height: 1.5;
}
#play .key:disabled { cursor: default; }
#play .next:disabled { opacity: .7; }
#save-status { color: #4e6754; overflow-wrap: anywhere; }
.puzzle-heading, .play-session { flex-wrap: wrap; }
.play-session { display: flex; align-items: center; gap: .55rem; }
#sign-out { min-height: 44px; }
#sign-out[hidden] { display: none; }
#club { padding-top: 44px; }

.player-portrait {
  display: inline-block;
  flex: none;
  width: 40px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #b6dbca var(--companion-image, url("player-portraits.webp")) no-repeat;
  background-size: 500% 400%;
}
.profile-face:has(.player-portrait) { background-image: none; }
.profile-face > .player-portrait { display: block; width: 100%; height: 100%; }
#identity-dialog:has(#portrait-picker:not([hidden])) { width: min(650px, calc(100% - 24px)); max-width: 650px; }
#portrait-picker {
  min-width: 0; margin: 1em 0 .6em; padding: .75rem clamp(.65rem, 2vw, 1.2rem) 1rem;
  background: #fffdf4; border: 1px solid #bfd6c7; border-radius: 15px; box-shadow: 0 3px 0 #dae5d8;
}
#portrait-picker legend { padding: 0 .4em; font: 750 1.15rem var(--display); }
#portrait-picker label[for="portrait-country"] { margin: 0 0 .4rem; font-size: .88rem; }
#identity-dialog .country-search { min-height: 44px; border-radius: 11px; background: #fbfdf7; }
.country-paging { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 8px 0; }
#country-announcement { color: #426152; font-weight: 650; font-size: .8rem; line-height: 1.4; }
#country-page-controls { display: inline-flex; gap: 6px; }
#country-page-controls button {
  display: grid; place-items: center; flex: none; min-width: 44px; min-height: 44px; padding: 0;
  background: #edf4e8; border: 1px solid #b4c8b8; border-radius: 10px; color: #235343;
  box-shadow: 0 2px 0 #b6cbb9; font: 700 20px/1 var(--display);
}
#country-page-controls button:disabled { color: #687e70; background: #f6f6ec; box-shadow: none; opacity: .6; cursor: default; }
#country-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.country-choice {
  position: relative; display: flex; align-items: center; gap: 7px; min-width: 0; min-height: 48px;
  padding: 5px 9px 5px 5px; background: #f8faf1; border: 1px solid #c4d5c5; border-radius: 10px;
  box-shadow: 0 2px 0 #d1ddd0; color: #234c3e; text-align: left;
}
.country-choice:hover { background: #edf4e6; border-color: #9fbda8; }
.country-choice[aria-pressed="true"] { background: #dfefdf; border-color: #43806c; box-shadow: inset 0 0 0 1px #43806c; }
.country-choice[aria-pressed="true"]::after {
  content: "✓"; flex: none; margin-inline-start: auto; color: #245c45; font: 800 .76rem/1 var(--display);
}
.country-choice .player-portrait { width: 33px; border-radius: 8px; box-shadow: 0 1px 1px #315c482b; }
.country-choice-text { display: grid; min-width: 0; overflow-wrap: anywhere; line-height: 1.18; }
.country-choice strong { font-size: .84rem; }
.country-detail { color: #49604e; font-size: .7rem; line-height: 1.2; margin-top: 2px; }
#identity-dialog #portrait-collection { margin: 16px 0 7px; color: #2b5141; font-size: .96rem; font-weight: 750; }
.companion-kind { color: #446352; font: 550 10px/1.2 var(--display); }
#portrait-choices {
  margin-top: .4rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 105px), 1fr)); gap: .55rem;
}
#portrait-choices label { position: relative; margin: 0; min-width: 0; cursor: pointer; }
#portrait-choices input {
  position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%);
}
.portrait-card {
  display: flex; flex-direction: column; align-items: center; gap: 5px; position: relative;
  height: 100%; padding: 6px; color: #214b3f; font: 600 .82rem/1.2 var(--display); text-align: center;
  background: #f0f7ed; border: 1px solid #b6d0bf; border-radius: 10px;
}
.portrait-card .player-portrait {
  width: min(100%, 84px); height: auto; border-radius: 13px;
}
#identity-dialog [hidden] { display: none !important; }
#portrait-choices input:checked + .portrait-card {
  border-color: #3c5746; box-shadow: inset 0 0 0 1px #3c5746; background-color: #dfefde;
}
#portrait-choices input:checked + .portrait-card::after {
  content: "✓"; position: absolute; top: 4px; right: 4px; padding: 3px 4px;
  background: #354e3c; color: white; border-radius: 50%; line-height: 1;
}
#portrait-choices input:focus-visible + .portrait-card {
  outline: 3px solid #186c5f; outline-offset: 2px;
}

@media (max-width: 480px) {
  #identity-dialog:has(#portrait-picker:not([hidden])) { padding: 17px; }
  #country-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #country-list .country-choice { gap: 5px; padding-inline-end: 6px; }
  #country-list .player-portrait { width: 29px; }
}
