.homepage-lobby {
  --home-gutter: clamp(14px, 3vw, 32px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  min-height: 100dvh;
  padding: max(14px, env(safe-area-inset-top)) var(--home-gutter) max(22px, env(safe-area-inset-bottom));
  text-align: center;
}
.screen-center.homepage-lobby { display: flex; align-items: center; }
.home-group-photo {
  position: relative;
  isolation: isolate;
  width: min(100%, 1100px);
  aspect-ratio: 16 / 10;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid #806526;
  border-radius: clamp(12px, 2vw, 22px);
  background: #070908;
  box-shadow: 0 18px 42px #0007;
  text-align: left;
}
.home-group-photo > picture {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}
.home-group-photo > picture > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}
.home-group-photo::after {
  position: absolute;
  z-index: 0;
  inset: 0;
  background: linear-gradient(180deg, #0008 0%, transparent 34%, transparent 53%, #0004 70%, #020807ed 100%);
  content: "";
  pointer-events: none;
}
.home-group-photo-title {
  position: absolute;
  z-index: 1;
  top: 14px;
  left: 14px;
  display: grid;
  gap: 1px;
  padding: 4px 9px 6px;
  border-radius: 10px;
  background: linear-gradient(90deg, #050504dc, #05050484 82%, transparent);
  text-shadow: 0 2px 10px #000;
}
.home-group-photo-title span { color: #f1cf75; font-size: 11px; font-weight: 900; letter-spacing: .16em; }
.home-group-photo-title strong { color: #fff0bd; font-family: "BiauKai", "DFKai-SB", "Noto Serif TC", serif; font-size: clamp(40px, 4vw, 46px); line-height: 1; letter-spacing: .1em; }
.home-group-photo-title small { color: #f5dfab; font-size: 10px; letter-spacing: .06em; }
.home-group-photo-seal {
  position: absolute;
  z-index: 1;
  top: clamp(12px, 2.4vw, 24px);
  right: clamp(12px, 2.4vw, 24px);
  display: grid;
  place-items: center;
  width: clamp(27px, 3.1vw, 36px);
  height: clamp(34px, 4vw, 44px);
  transform: rotate(-7deg);
  border: 2px solid #e21c54;
  border-radius: 7px;
  background: #ce1649;
  color: #20080e;
  font-family: "BiauKai", "DFKai-SB", serif;
  font-size: 13px;
  font-weight: 900;
  writing-mode: vertical-rl;
  box-shadow: 0 0 18px #e21c5480;
}
.home-music-start {
  position: absolute;
  z-index: 3;
  top: clamp(12px, 2.4vw, 24px);
  right: clamp(55px, 6vw, 70px);
  min-height: 44px;
  padding: 7px 12px;
  border: 1px solid #e9c36b;
  border-radius: 999px;
  background: #071a16e8;
  color: #ffe9af;
  font: 700 13px/1.2 system-ui, sans-serif;
  cursor: pointer;
}
.home-music-start[hidden] { display: none; }
.home-music-start:focus-visible { outline: 3px solid #fff0bb; outline-offset: 2px; }
.home-game-actions {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 8px;
  padding: 12px clamp(12px, 2.4vw, 24px) 14px;
}
.home-game-actions > * {
  display: grid;
  min-width: 0;
  min-height: 44px;
  place-items: center;
  margin: 0;
  padding: 7px 5px;
  border: 1px solid #c8a85e;
  border-radius: 10px;
  background: #0d211feb;
  color: #f1e4c6;
  font-size: clamp(11px, 1.1vw, 13px);
  font-weight: 850;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.home-game-actions > .is-selected {
  width: auto;
  max-width: none;
  border-color: #ffe7a4;
  background: linear-gradient(#ffe28d, #d69a31);
  color: #2b1b0b;
  box-shadow: 0 3px 10px #0008, inset 0 1px #fff8d8;
  animation: home-mode-float 2.8s ease-in-out infinite;
}
.home-game-actions > .is-selected:hover { background: linear-gradient(#ffe28d, #d69a31); }
.home-game-actions > .primary-button:not(.is-selected),
.home-game-actions > .secondary-button:not(.is-selected) {
  border: 1px solid #c8a85e;
  background: #0d211feb;
  color: #f1e4c6;
  box-shadow: none;
}
@keyframes home-mode-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .home-game-actions > .is-selected { animation: none; } }
.home-game-actions > *:focus-visible { outline: 3px solid #fff0bb; outline-offset: 2px; }
.home-game-actions > :not(:disabled):not([aria-disabled="true"]):focus-visible {
  border-color: #ffe7a4;
  background: linear-gradient(#ffe28d, #d69a31);
  color: #2b1b0b;
  box-shadow: 0 3px 10px #0008, inset 0 1px #fff8d8;
}
@media (hover: hover) and (pointer: fine) {
  .home-game-actions > :not(:disabled):not([aria-disabled="true"]):hover {
    border-color: #ffe7a4;
    background: linear-gradient(#ffe28d, #d69a31);
    color: #2b1b0b;
    box-shadow: 0 3px 10px #0008, inset 0 1px #fff8d8;
  }
}
.home-utility-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(100%, 1100px);
  margin: 8px auto 0;
}
.home-utility-row > .home-hints {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "label" "text";
  align-content: center;
  gap: 3px;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 4px 8px;
  color: #f4ecd9;
  text-align: left;
}
.home-utility-row .home-hints-label { grid-area: label; color: #f0c978; font-size: 12px; white-space: nowrap; }
.home-utility-row .home-hints p { grid-area: text; min-width: 0; margin: 0; line-height: 1.4; overflow-wrap: anywhere; }
.home-utility-row > .lobby-settings { flex: 0 0 auto; margin: 0; }
.home-utility-row > .lobby-settings > summary { min-width: 56px; min-height: 44px; }
.home-utility-row .lobby-settings .settings-card {
  top: auto;
  right: 0;
  bottom: calc(100% + 6px);
  left: auto;
  transform: none;
}
.homepage-lobby > .select-panel { width: min(100%, 1060px); }
.homepage-lobby > .lobby-learning { width: min(100%, 680px); margin-top: 12px; }
.homepage-lobby > #beginner-village:not([open]) { display: none; }
#beginner-village > .commit-card { margin: 0 12px 12px; }
.homepage-lobby > .lobby-settings { margin-top: 10px; }
.home-account-link { appearance: none; }
.home-account-panel {
  width: min(100%, 1060px);
  margin: 14px auto 0;
  padding: 14px;
  border: 1px solid #d5b65e80;
  border-radius: 14px;
  background: #061d19d9;
  color: #f5ecd8;
  text-align: left;
}
.home-account-panel:not([open]) { display: none; }
.home-account-panel > summary { cursor: pointer; color: #ffe19a; font-weight: 800; }
.home-account-panel #home-account-message { color: #ffb6a8; }
.home-account-panel > details { margin-top: 10px; }
.home-ranking-panel {
  width: min(100%, 1060px);
  margin: 14px auto 0;
  padding: clamp(14px, 2vw, 24px);
  border: 1px solid #d5b65e80;
  border-radius: 16px;
  background: #071c19ef;
  color: #f5ecd8;
  text-align: left;
  scroll-margin-top: 16px;
}
.home-ranking-panel:not([open]) { display: none; }
.home-ranking-panel > summary { cursor: pointer; color: #ffe19a; font-size: clamp(18px, 2.2vw, 24px); font-weight: 850; }
.home-ranking-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 10px 0 16px; }
.home-ranking-heading p { margin: 0; color: #c6d5ca; }
.home-ranking-heading button { min-height: 44px; padding: 8px 16px; border: 1px solid #d5b65e; border-radius: 10px; background: #173e35; color: #fff0bd; font: inherit; cursor: pointer; }
.home-ranking-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; max-width: 720px; margin-inline: auto; }
.home-ranking-grid > section { min-width: 0; padding: 18px; border: 1px solid #d6bd81; border-radius: 13px; background: #fffaf0; color: #193b32; }
.home-ranking-grid h2 { margin: 0; color: #193b32; font-size: clamp(18px, 2vw, 22px); }
.home-ranking-grid section > p { margin: 4px 0 12px; color: #5a6d63; font-size: 14px; }
.home-ranking-grid section > p[role=status] { color: #7d5932; }
.home-ranking-grid .rank-entry { display: grid; grid-template-columns: 2rem 44px minmax(0, 1fr); align-items: center; gap: 10px; min-height: 64px; padding: 10px 0; border-bottom: 1px solid #e7ddc8; }
.home-ranking-grid .rank-position { text-align: center; font-weight: 900; font-variant-numeric: tabular-nums; }
.home-ranking-grid .rank-avatar { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 50%; background: #eadfca; color: #163f36; object-fit: cover; font-weight: 800; }
.home-ranking-grid .rank-copy { display: flex; min-width: 0; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 2px 12px; }
.home-ranking-grid .rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-ranking-grid .rank-stats { color: #465b50; font-size: 13px; font-variant-numeric: tabular-nums; }
.home-footer { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; width: 100%; padding: 14px 0 0; color: #b9c9c3; font-size: 12px; }
.home-footer a { color: #ffe19a; }
.home-group-photo-fallback { display: grid; width: 100%; height: 100%; place-items: center; color: #ffe19a; font-size: 32px; }
.international-home .home-group-photo-title { top: clamp(10px, 2vw, 20px); left: clamp(10px, 2vw, 20px); padding: 7px 11px; background: linear-gradient(90deg, #050504dc, #05050484 82%, transparent); }
.international-home .home-group-photo-title span { font-size: clamp(13px, 1.5vw, 18px); letter-spacing: .02em; }
.international-home .home-group-photo-title strong { font: 700 clamp(14px, 1.5vw, 18px)/1.2 "Nunito Sans", system-ui, sans-serif; letter-spacing: 0; }
.international-home .home-group-photo-title small { font-size: clamp(11px, 1.1vw, 13px); }
.international-home #international-locale-picker { position: absolute; z-index: 4; top: clamp(10px, 2vw, 20px); right: clamp(10px, 2vw, 20px); }
.international-home #international-locale-picker .locale-picker { display: flex; align-items: center; gap: 7px; min-height: 44px; box-sizing: border-box; padding: 4px 8px; border: 1px solid #fff8; border-radius: 10px; background: #071a16e8; color: #fff; }
.international-home #international-locale-picker select { min-height: 34px; border: 0; border-radius: 6px; background: #fffaf0; color: #163f36; font: 700 14px "Nunito Sans", system-ui, sans-serif; }
.international-home .home-group-photo-seal { display: none; }
.international-home .home-game-actions { z-index: 2; }
.international-home .home-game-actions > * {
  font-family: "Nunito Sans", system-ui, sans-serif;
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
  line-height: 1.15;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  padding-inline: 8px;
}
@media (max-width: 700px) {
  .homepage-lobby { padding-inline: max(10px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-right)); }
  .home-group-photo { aspect-ratio: auto; border-radius: 14px; }
  .home-group-photo > picture { position: relative; inset: auto; display: block; width: 100%; height: auto; }
  .home-group-photo > picture > img { width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: contain; }
  .home-group-photo::after { display: none; }
  .home-group-photo-title { top: 6px; left: 6px; gap: 0; padding: 2px 4px 3px; }
  .home-group-photo-title span { font-size: 8px; }
  .home-group-photo-title strong { font-size: 18px; line-height: 1; }
  .home-group-photo-title small { font-size: 7px; }
  .home-group-photo-seal { top: 10px; right: 10px; }
  .home-utility-row { align-items: stretch; gap: 6px; margin-top: 7px; }
  .home-utility-row > .home-hints { gap: 2px; padding: 2px 4px; }
  .home-utility-row .home-hints-label { grid-area: label; font-size: 10px; }
  .home-utility-row .home-hints p { min-height: 4.1em; line-height: 1.3; }
  .home-utility-row > .lobby-settings { align-self: stretch; }
  .home-utility-row > .lobby-settings > summary { min-width: 56px; min-height: 44px; padding: 0 10px; }
  .home-utility-row .lobby-settings .settings-card { width: min(260px, calc(100vw - 28px)); }
  .home-game-actions { position: relative; inset: auto; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding: 8px; }
  .home-game-actions > * { min-height: 44px; padding: 5px 3px; font-size: clamp(10px, 2.8vw, 12px); }
  .home-account-panel { padding: 11px; }
  .home-ranking-heading { align-items: flex-start; }
  .home-ranking-grid { grid-template-columns: 1fr; }
  .international-home .home-group-photo > picture > img { aspect-ratio: 16 / 9; object-fit: contain; background: #07110e; }
  .international-home .home-group-photo::after { display: block; }
  .international-home .home-game-actions { padding-top: 10px; background: linear-gradient(180deg, transparent, #020807ed 9px); }
  .international-home .home-game-actions > * { min-height: 52px; padding-inline: 8px; font-size: 14px; }
}
@media (max-width: 500px) {
  /* Keep the compact title above the full eighteen-person portrait. */
  .home-game-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .home-game-actions > :last-child { grid-column: auto; }
  .home-game-actions > * { font-size: 13px; }
  .home-ranking-heading { display: grid; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .homepage-lobby { padding-top: max(8px, env(safe-area-inset-top)); }
  .home-group-photo { width: min(100%, 980px); max-height: none; }
  .home-group-photo-title { top: 6px; left: 6px; gap: 0; padding: 2px 6px 4px; }
  .home-group-photo-title span { font-size: 9px; }
  .home-group-photo-title strong { font-size: 34px; line-height: 1; }
  .home-group-photo-title small { font-size: 8px; }
  .home-game-actions { grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; padding: 8px 12px; }
  .home-game-actions > * { min-height: 44px; font-size: 11px; }
}
@media (orientation: landscape) and (max-height: 500px) and (min-width: 700px) {
  .home-game-actions { grid-template-columns: repeat(9, minmax(0, 1fr)); }
}
@media (orientation: landscape) and (max-height: 500px) and (min-width: 700px) and (max-width: 1040px) {
  .international-home .home-game-actions { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
  .international-home .home-game-actions > * { min-height: 48px; padding-inline: 8px; font-size: 14px; }
}
