/* Landscape stage and the account wardrobe. */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}
#app {
  height: 100dvh;
  height: var(--app-height, 100dvh);
  bottom: auto;
}
#sel-menu {
  display: none;
}
.lobby-menu-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.lobby-menu-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.lobby-menu-actions button {
  min-height: 44px;
}
.landing-art {
  width: min(430px, 42vw);
  aspect-ratio: 1;
  background: radial-gradient(ellipse, #a28fff25, transparent 70%);
}
.landing-art canvas {
  display: block;
  width: 100%;
  height: 100%;
}
#orientation-guard {
  position: fixed;
  inset: 0;
  margin: 0;
  border: 0;
  padding: 24px;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  background: #0b1020;
  color: #ecf5f4;
  text-align: center;
  z-index: 9999;
}
#orientation-guard::backdrop {
  background: #0b1020;
}
.rotate-content {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}
.rotate-content img {
  width: 170px;
}
.rotate-content h1 {
  font-size: 25px;
  line-height: 1.5;
}
.rotate-content p {
  font-size: 13px;
  line-height: 1.9;
  color: #9baac2;
}
.library-layout {
  grid-template-columns: minmax(175px, 0.7fr) minmax(310px, 1.5fr) minmax(
      175px,
      0.75fr
    );
  gap: 24px;
}
.lobby-avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  background: radial-gradient(ellipse at 50% 60%, #4c416541, transparent 70%);
  border: 1px solid #39445b;
  border-radius: 20px;
  padding: 14px;
  overflow: hidden;
}
.lobby-avatar canvas {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
}
.lobby-avatar > .muted {
  font-size: 8px;
  text-align: center;
}
.wallet-badge {
  font-size: 11px;
  color: #f4d494;
  white-space: nowrap;
  padding: 9px 12px;
  background: #f4d4940b;
  border: 1px solid #f4d49433;
  border-radius: 12px;
}
.head-actions .primary,
.head-actions .secondary {
  min-height: 38px;
  padding: 8px 14px;
  font-size: 11px;
}
.head-actions {
  align-items: center;
}
#screen-wardrobe {
  width: min(1050px, 96vw);
  max-height: 94dvh;
  padding: 20px;
}
.wardrobe-layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 24px;
  height: min(58vh, 420px);
}
.avatar-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  background: radial-gradient(ellipse, #7e6d9d33, transparent 70%);
  border: 1px solid #3b4660;
  border-radius: 20px;
  padding: 12px;
}
.avatar-preview canvas {
  flex: 1;
  width: 100%;
  min-height: 100px;
}
.avatar-preview > p {
  font-size: 10px;
  line-height: 1.6;
  color: var(--accent);
  min-height: 18px;
  text-align: center;
}
.wardrobe-items {
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.wardrobe-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.wardrobe-tabs .chip {
  min-height: 34px;
  padding: 6px 13px;
  font-size: 10px;
}
.wardrobe-mode {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.wardrobe-mode .text-button {
  font-size: 9px;
}
.cosmetic-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  overflow-y: auto;
  min-height: 0;
  padding-bottom: 12px;
}
.cosmetic-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  border: 1px solid #3e4962;
  border-radius: 15px;
  padding: 10px;
  background: #10182a;
}
.cosmetic-card b {
  font-size: 11px;
  line-height: 1.5;
}
.cosmetic-card small {
  font-size: 9px;
  color: var(--muted);
}
.cosmetic-card > .primary,
.cosmetic-card > .secondary {
  font-size: 10px;
  padding: 7px;
  min-height: 35px;
}
.item-preview {
  height: 95px;
  display: grid;
  place-items: center;
  width: 100%;
  background: #26344e;
}
.item-preview img {
  max-height: 90px;
  object-fit: contain;
  max-width: 100%;
  pointer-events: none;
}
.item-preview canvas {
  width: auto;
  height: 100%;
  max-width: 100%;
  aspect-ratio: 1;
  min-height: 0;
  pointer-events: none;
}
.cosmetic-card .item-preview img {
  width: auto;
}
#screen-account {
  width: min(680px, 94vw);
}
#account-form.auth-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
#account-form.auth-register {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.auth-submit {
  grid-column: 1/-1;
}
.auth-hint {
  grid-column: 1/-1;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}
.auth-form label {
  min-width: 0;
}
.auth-form input {
  width: 100%;
}
.account-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.account-actions .primary {
  grid-column: 1/-1;
}
.account-actions #sign-out {
  grid-column: 1/-1;
}
.hud-bottom {
  left: 18px;
  right: 35%;
}
.hud-score > span {
  font-size: 21px;
}
@media (orientation: landscape) {
  #screen-select {
    padding: 12px max(22px, env(safe-area-inset-right)) 0
      max(22px, env(safe-area-inset-left));
  }
  .library-head {
    margin-bottom: 12px;
    min-height: 42px;
  }
  .library-head h1 {
    font-size: 22px;
  }
  .library-head > .icon-button {
    width: 36px;
    height: 36px;
  }
  .library-layout {
    padding-bottom: 14px;
  }
  .featured .cover-wrap {
    max-width: 230px;
    margin: auto;
  }
  .feature-info {
    padding-top: 12px;
  }
  .feature-info h2 {
    font-size: 22px;
  }
  .feature-info p {
    font-size: 10px;
  }
  .feature-meta {
    margin-top: 12px;
    gap: 20px;
  }
  .feature-meta > span {
    font-size: 17px;
  }
  .library-tools input {
    padding: 10px 0;
  }
  .filter-row {
    margin: 12px 0 8px;
    flex-wrap: nowrap;
  }
  .chip {
    padding: 6px 11px;
    font-size: 9px;
    white-space: nowrap;
  }
  .list-heading {
    padding: 10px;
    font-size: 7px;
  }
  .track-select {
    padding: 12px 6px;
    gap: 12px;
  }
  .track-select > img {
    width: 44px;
    height: 44px;
  }
  .track-name b {
    font-size: 12px;
  }
  .track-name small {
    font-size: 9px;
  }
  .track-time {
    display: none;
  }
  .library-bottom {
    padding-top: 8px;
    justify-content: space-between;
    gap: 8px;
  }
  .library-bottom .text-button {
    font-size: 9px;
  }
  .play-dock {
    border-radius: 20px 20px 0 0;
    min-height: 82px;
    gap: 18px;
    padding: 12px 24px max(12px, env(safe-area-inset-bottom));
    margin: 0 -24px;
    flex-direction: row;
  }
  .dock-options {
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }
  .mode-control {
    flex-direction: column;
    gap: 6px;
  }
  .mode-control button {
    font-size: 7px;
    min-height: 24px;
    padding: 4px 6px;
  }
  .difficulty-control {
    gap: 5px;
  }
  .difficulty-control button {
    font-size: 9px;
    padding: 8px 9px;
    min-height: 36px;
  }
  .dock-actions {
    margin-left: 0;
  }
  .dock-actions > .primary {
    min-width: 140px;
    min-height: 43px;
  }
  .dock-actions > .secondary {
    min-height: 43px;
  }
  .sheet {
    max-height: 92dvh;
    margin: auto;
  }
  .sheet-header {
    margin-bottom: 15px;
  }
  .sheet-header h2 {
    font-size: 22px;
  }
  .sheet-header p {
    margin-top: 8px;
    font-size: 11px;
  }
  .result-content {
    padding: 22px;
  }
  .result-card {
    grid-template-columns: 1fr 1.7fr;
  }
  .result-art {
    height: auto;
  }
  .results-wrap {
    padding-top: 15px;
  }
  .landing {
    grid-template-columns: 1.2fr 1fr;
    padding: 15px 6vw;
    gap: 30px;
  }
  .landing h1 {
    font-size: clamp(30px, 4vw, 64px);
    margin: 12px 0 14px;
  }
  .landing-copy > p {
    font-size: 12px;
    margin-bottom: 18px;
  }
  .landing-stats {
    margin-top: 20px;
  }
  .landing-art {
    max-width: 430px;
    margin: auto;
  }
  .landing-footer {
    padding: 9px 0;
  }
  .brand-bar {
    padding: 15px 6vw;
  }
}
@media (orientation: landscape) and (max-height: 600px) {
  .landing-stats,
  .art-caption {
    display: none;
  }
  .landing-art {
    max-height: 58vh;
    max-width: 58vh;
  }
  .brand-bar {
    padding: 10px 5vw;
  }
  .landing-footer {
    padding: 7px 0;
  }
  .landing-copy > .text-button {
    margin-top: 3px;
  }
  .landing h1 {
    font-size: 32px;
  }
  .landing-copy > .eyebrow {
    font-size: 7px;
  }
  .library-head .eyebrow {
    font-size: 7px;
  }
  .feature-meta {
    display: none;
  }
  .lobby-avatar {
    padding: 9px;
  }
  .wardrobe-layout {
    height: 57vh;
    grid-template-columns: 170px 1fr;
    gap: 15px;
  }
  .wardrobe-tabs .chip {
    min-height: 30px;
    font-size: 9px;
    padding: 5px 10px;
  }
  .item-preview {
    height: 65px;
  }
  .item-preview img {
    max-height: 63px;
  }
  .cosmetic-card {
    padding: 8px;
    gap: 4px;
  }
  .cosmetic-card > .primary,
  .cosmetic-card > .secondary {
    min-height: 31px;
  }
  .avatar-preview > .wallet-badge {
    padding: 4px 10px;
  }
  .rotate-content h1 {
    font-size: 23px;
  }
}
@media (orientation: landscape) and (max-width: 1100px) {
  .library-layout {
    grid-template-columns: minmax(0, 1.9fr) minmax(160px, 0.8fr);
    gap: 18px;
  }
  .featured {
    display: none;
  }
  .dock-track {
    display: none;
  }
  .head-actions .secondary,
  .head-actions .primary {
    font-size: 10px;
    padding: 6px 11px;
  }
  .head-actions .icon-button {
    width: 36px;
    height: 36px;
  }
  .play-dock {
    justify-content: space-between;
  }
  .library-head {
    gap: 10px;
  }
  .wallet-badge {
    padding: 7px 9px;
  }
  .lobby-avatar > .muted {
    display: none;
  }
}
@media (orientation: landscape) and (max-width: 760px) {
  .library-head h1 {
    font-size: 18px;
  }
  .library-head > .icon-button,
  .library-head .eyebrow {
    display: none;
  }
  .head-actions {
    gap: 5px;
  }
  .head-actions .wallet-badge {
    font-size: 9px;
  }
  .head-actions .secondary,
  .head-actions .primary {
    padding: 6px 8px;
    font-size: 9px;
  }
  .library-layout {
    gap: 10px;
    grid-template-columns: minmax(0, 1.7fr) minmax(130px, 0.8fr);
  }
  .library-tools select {
    font-size: 10px;
    width: 105px;
  }
  .library-tools input {
    font-size: 13px;
  }
  .filter-row {
    gap: 4px;
  }
  .chip {
    font-size: 8px;
    padding: 5px 8px;
  }
  .track-select {
    padding: 8px 4px;
  }
  .track-name b {
    font-size: 11px;
  }
  .track-select > img {
    width: 38px;
    height: 38px;
  }
  .library-bottom .text-button {
    font-size: 8px;
  }
  .dock-options {
    gap: 5px;
  }
  .difficulty-control {
    gap: 3px;
  }
  .difficulty-control button {
    font-size: 8px;
    padding: 6px 7px;
  }
  .dock-actions {
    gap: 6px;
  }
  .dock-actions > .primary {
    min-width: 110px;
    font-size: 11px;
    padding: 10px 12px;
  }
  .dock-actions > .secondary {
    min-width: 75px;
    padding: 8px;
    font-size: 9px;
  }
  .play-dock {
    gap: 10px;
    padding: 9px 22px;
    min-height: 72px;
  }
  .cosmetic-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .wardrobe-layout {
    grid-template-columns: 145px 1fr;
  }
  .hud-title > span {
    font-size: 11px;
  }
  .hud-bottom {
    font-size: 8px;
  }
}
@media (orientation: landscape) {
  .library-main {
    overflow: hidden;
  }
  .track-list {
    min-height: 0;
  }
  .library-tools,
  .filter-row,
  .list-heading,
  .library-bottom {
    flex-shrink: 0;
  }
}

/* Compact landscape uses the visible viewport, with the song list as the flexible row. */
@media (orientation: landscape) {
  .library-layout {
    display: grid;
  }
  .play-dock {
    display: flex;
  }
}
@media (orientation: landscape) and (max-height: 600px) {
  #screen-select {
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 6px;
    padding: max(6px, var(--safe-top)) max(14px, var(--safe-right)) 0
      max(14px, var(--safe-left));
    overflow: hidden;
  }
  #screen-select.active {
    display: grid;
  }
  .library-head {
    min-height: 36px;
    margin: 0 auto;
    gap: 8px;
  }
  .library-head .eyebrow {
    display: none;
  }
  .library-head h1 {
    font-size: 20px;
    white-space: nowrap;
  }
  .head-actions {
    gap: 6px;
  }
  .head-actions .primary,
  .head-actions .secondary {
    min-height: 36px;
    padding: 6px 10px;
  }
  #sel-settings {
    display: none;
  }
  #sel-menu {
    display: grid;
  }
  .library-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(124px, 24%);
    gap: 12px;
    padding: 0;
    overflow: hidden;
  }
  .featured,
  .list-heading,
  .library-bottom,
  .dock-track {
    display: none;
  }
  .library-main {
    display: grid;
    grid-template-rows: 38px 32px minmax(0, 1fr);
    gap: 6px;
    overflow: hidden;
    min-height: 0;
  }
  .library-tools {
    height: 38px;
    gap: 8px;
    min-width: 0;
  }
  .search-box {
    padding: 0 10px;
  }
  .library-tools input {
    font-size: 16px;
    padding: 6px 0;
  }
  .library-tools select {
    font-size: 16px;
    width: 126px;
    min-height: 38px;
    padding: 5px 6px;
  }
  .filter-row {
    height: 32px;
    margin: 0;
    gap: 6px;
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  .filter-row .chip {
    flex: none;
    min-height: 32px;
    padding: 4px 10px;
    font-size: 9px;
  }
  #daily-challenge {
    margin-left: auto;
  }
  .track-list {
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .track {
    height: 54px;
    min-height: 54px;
    padding-right: 4px;
  }
  .track-select {
    height: 100%;
    padding: 5px 6px;
    gap: 8px;
  }
  .track-select > img {
    width: 38px;
    height: 38px;
    border-radius: 8px;
  }
  .track-index,
  .track-time {
    display: none;
  }
  .track-name b {
    font-size: 12px;
  }
  .track-name small {
    margin-top: 3px;
    font-size: 9px;
  }
  .track-bpm {
    font-size: 12px;
    width: 34px;
  }
  .favorite {
    min-width: 44px;
    height: 44px;
  }
  .lobby-avatar {
    min-width: 0;
    padding: 8px;
    border-radius: 15px;
  }
  .lobby-avatar .muted {
    display: none;
  }
  .lobby-avatar .eyebrow {
    font-size: 8px;
  }
  .play-dock {
    display: flex;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    min-height: 0;
    padding: 8px 10px max(8px, var(--safe-bottom));
    gap: 8px;
    border-radius: 14px 14px 0 0;
    justify-content: space-between;
  }
  .dock-options {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }
  .mode-control {
    flex-direction: row;
    gap: 4px;
  }
  .mode-control button {
    min-height: 34px;
    padding: 5px 7px;
    font-size: 7px;
  }
  .difficulty-control {
    gap: 4px;
  }
  .difficulty-control button {
    min-height: 34px;
    padding: 6px 8px;
    font-size: 9px;
  }
  .dock-actions {
    margin: 0;
    gap: 8px;
  }
  .dock-actions > .primary {
    min-width: 130px;
    min-height: 36px;
    padding: 8px 12px;
    font-size: 12px;
  }
  .dock-actions > .secondary {
    min-width: 86px;
    min-height: 36px;
    padding: 8px 10px;
    font-size: 10px;
  }
  .dock-actions .primary span {
    margin-left: 0;
  }
}
@media (orientation: landscape) and (max-height: 600px) and (max-width: 740px) {
  .library-head h1 {
    font-size: 17px;
  }
  .head-actions {
    gap: 4px;
  }
  .head-actions .primary,
  .head-actions .secondary {
    padding: 6px 8px;
    font-size: 9px;
  }
  .library-layout {
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) minmax(110px, 22%);
  }
  .mode-control {
    flex-direction: column;
    gap: 3px;
  }
  .mode-control button {
    min-height: 23px;
    padding: 3px 5px;
  }
  .difficulty-control {
    gap: 3px;
  }
  .difficulty-control button {
    font-size: 8px;
    min-height: 32px;
    padding: 5px 6px;
  }
  .dock-options,
  .dock-actions {
    gap: 6px;
  }
  .dock-actions > .primary {
    min-width: 110px;
    padding: 8px;
    font-size: 11px;
  }
  .dock-actions > .secondary {
    min-width: 76px;
    padding: 8px;
    font-size: 9px;
  }
}
@media (orientation: landscape) and (max-height: 600px) {
  :root.short-viewport .filter-row {
    display: none;
  }
  :root.short-viewport .library-main {
    grid-template-rows: 38px minmax(0, 1fr);
  }
}
@media (pointer: coarse) {
  .sheet input,
  .sheet select,
  .sheet textarea {
    font-size: 16px;
  }
}

/* 3D character collection. One animated preview, lightweight portrait cards. */
#screen-wardrobe {
  max-height: calc(
    var(--app-height, 100dvh) - var(--safe-top) - var(--safe-bottom) - 16px
  );
  overflow-y: auto;
}
.character-studio {
  height: min(58vh, 440px);
}
.character-studio .avatar-preview canvas {
  min-height: 0;
}
.character-studio .wardrobe-items {
  overflow-y: auto;
  gap: 10px;
}
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 12px;
}
.avatar-card {
  min-width: 0;
  border: 1px solid #3b4764;
  border-radius: 18px;
  padding: 12px;
  background: linear-gradient(150deg, #222d45, #101729);
}
.avatar-card.is-preview {
  border-color: #9aebe2;
  box-shadow: inset 0 0 0 1px #9aebe233;
}
.avatar-art {
  display: block;
  width: 100%;
  height: 160px;
  border: 0;
  padding: 0;
  background: radial-gradient(ellipse, #8b75c533, transparent 70%);
}
.avatar-art img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.avatar-card-info {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 8px;
}
.avatar-card-info b {
  font-size: 19px;
}
.avatar-card-info small {
  color: #a5c9d6;
  font-size: 10px;
}
.avatar-card-info p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  margin: 0;
}
.avatar-card-info button {
  width: 100%;
  min-height: 38px;
  font-size: 11px;
  margin-top: auto;
}
.studio-note {
  font-size: 10px;
  line-height: 1.7;
  color: var(--muted);
  margin: 0;
}
@media (max-height: 600px) and (orientation: landscape) {
  #screen-wardrobe {
    padding: 12px;
  }
  .character-studio {
    height: min(55vh, calc(var(--app-height, 100dvh) - 95px));
    gap: 12px;
  }
  .character-studio .avatar-preview {
    padding: 8px;
    border-radius: 14px;
  }
  .character-studio .avatar-preview > p {
    margin: 4px 0 0;
    font-size: 9px;
    line-height: 1.4;
  }
  .character-studio .avatar-preview .eyebrow {
    font-size: 7px;
  }
  .character-studio .wardrobe-mode {
    align-items: center;
    flex-wrap: wrap;
  }
  .avatar-grid {
    gap: 8px;
  }
  .avatar-card {
    display: grid;
    grid-template-columns: minmax(45px, 0.8fr) minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
    border-radius: 12px;
  }
  .avatar-art {
    height: 140px;
    align-self: center;
  }
  .avatar-card-info {
    padding: 0;
    gap: 5px;
  }
  .avatar-card-info b {
    font-size: 16px;
  }
  .avatar-card-info small {
    font-size: 9px;
    line-height: 1.5;
  }
  .avatar-card-info p {
    font-size: 9px;
  }
  .avatar-card-info button {
    font-size: 9px;
    padding: 7px 5px;
    min-height: 34px;
  }
}
@media (max-width: 700px) and (orientation: landscape) {
  .avatar-grid {
    grid-template-columns: 1fr;
  }
  .avatar-art {
    height: 120px;
  }
}
@media (max-height: 450px) and (orientation: landscape) {
  #screen-title.active {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  #screen-title .brand-bar {
    padding: 6px max(5vw, var(--safe-right)) 6px max(5vw, var(--safe-left));
  }
  .landing {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    min-height: 0;
    padding: 6px max(6vw, var(--safe-right)) 6px max(6vw, var(--safe-left));
    gap: 18px;
  }
  .landing h1 {
    font-size: 28px;
    margin: 8px 0 10px;
  }
  .landing-copy > p {
    font-size: 11px;
    line-height: 1.6;
    margin: 0 0 10px;
  }
  .landing-copy > .primary {
    min-height: 38px;
    padding: 8px 14px;
    max-width: 100%;
  }
  .landing-copy > .text-button {
    font-size: 9px;
    min-height: 28px;
    padding: 5px 0;
  }
  .landing-art {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    max-width: 300px;
    aspect-ratio: auto;
  }
  .landing-footer {
    margin: 0 max(6vw, var(--safe-right)) 0 max(6vw, var(--safe-left));
    padding: 4px 0;
  }
  .landing-footer > .text-button {
    min-height: 28px;
    padding: 4px 8px;
  }
  .character-studio .avatar-art {
    height: 110px;
  }
  .character-studio .avatar-card-info p {
    display: none;
  }
}
@media (max-height: 300px) and (orientation: landscape) {
  .landing h1 {
    font-size: 24px;
    margin: 6px 0;
  }
  .landing-copy > p,
  .landing-footer > span {
    display: none;
  }
}

/* Results stay over the final stage frame. Only the card body scrolls. */
#screen-results {
  position: fixed;
  top: var(--safe-top);
  bottom: calc(100% - var(--app-height, 100dvh) + var(--safe-bottom));
  left: max(12px, var(--safe-left));
  right: max(12px, var(--safe-right));
  margin: auto;
  height: fit-content;
  padding: 0;
  width: min(
    960px,
    calc(
      100% - max(12px, var(--safe-left)) - max(12px, var(--safe-right)) - 24px
    )
  );
  max-width: none;
  max-height: none;
  color: var(--ink);
  background: #111b2df5;
  border: 1px solid #83efda40;
  border-radius: 22px;
  box-shadow: 0 24px 100px #0009;
  overflow: hidden;
  pointer-events: auto;
}
#screen-results::backdrop {
  background: #050a16a6;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
#screen-results .results-wrap {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: calc(
    var(--app-height, 100dvh) - var(--safe-top) - var(--safe-bottom) - 32px
  );
  padding: 18px;
  gap: 12px;
}
#screen-results .result-top {
  flex-shrink: 0;
  margin: 0;
  gap: 12px;
}
#screen-results .result-card {
  display: grid;
  grid-template-columns: minmax(100px, 0.55fr) minmax(0, 1fr);
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 16px;
}
#screen-results .result-art {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 0;
  height: clamp(100px, calc(var(--app-height, 100dvh) - 180px), 360px);
}
#screen-results .result-art > img {
  position: absolute;
  inset: 0;
}
#screen-results .result-rank {
  font-size: clamp(64px, 10vw, 120px);
}
#screen-results .result-content {
  min-width: 0;
  padding: 20px;
}
#screen-results .result-content h1 {
  overflow-wrap: anywhere;
}
#screen-results .result-actions {
  flex-shrink: 0;
  margin: 0;
  justify-content: flex-end;
}
#screen-results .result-actions > button {
  min-height: 44px;
}
@media (max-height: 500px) and (orientation: landscape) {
  #screen-results .results-wrap {
    padding: 10px;
    gap: 8px;
  }
  #screen-results .result-content {
    padding: 14px;
  }
  #screen-results .result-content h1 {
    font-size: 19px;
    margin: 6px 0;
  }
  #screen-results .result-score {
    font-size: 30px;
    margin: 10px 0;
  }
  #screen-results .result-stats {
    padding-bottom: 10px;
  }
  #screen-results .judge-row {
    padding: 12px 0;
  }
  #screen-results .result-actions > button {
    font-size: 10px;
    padding: 8px 14px;
  }
  #play-hud .hud-top {
    gap: 5px;
    padding: 8px;
  }
  #play-hud .hud-score > span {
    font-size: 18px;
  }
}
@media (max-width: 600px) {
  #screen-results .result-card {
    grid-template-columns: 90px minmax(0, 1fr);
  }
  #screen-results .result-rank {
    padding: 0;
    place-items: center;
  }
  #screen-results .result-actions {
    gap: 6px;
  }
  #screen-results .result-actions > button {
    flex: 1;
    min-width: 0;
    padding: 8px;
  }
}

.wardrobe-tabs,
.outfit-genders,
.outfit-slots,
.outfit-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.wardrobe-tabs {
  flex: none;
}
.outfit-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.outfit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.outfit-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 9px;
  border: 1px solid #43516b;
  border-radius: 12px;
  background: #162137;
  color: #e7f2ff;
  text-align: center;
}
.outfit-card.active,
.outfit-none.active {
  background: #124c57;
  border-color: #8dffe8;
  box-shadow:
    inset 0 0 0 2px #8dffe855,
    0 0 14px #56efd42b;
}
.outfit-card img {
  width: 100%;
  height: 92px;
  object-fit: contain;
}
.outfit-card b {
  font-size: 12px;
}
.outfit-card small {
  font-size: 10px;
  color: #9ec9d2;
}
.outfit-save {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0 2px;
  background: #10182a;
}
.outfit-save button {
  flex: 1;
  min-width: 100px;
}
@media (orientation: landscape) and (max-height: 600px) {
  .wardrobe-tabs,
  .outfit-genders,
  .outfit-slots,
  .outfit-presets {
    gap: 5px;
  }
  .outfit-editor {
    gap: 7px;
  }
  .outfit-editor .chip,
  .wardrobe-tabs .chip {
    min-height: 30px;
    padding: 5px 8px;
    font-size: 9px;
  }
  .outfit-card {
    padding: 6px;
  }
  .outfit-card img {
    height: 64px;
  }
  .outfit-card b {
    font-size: 10px;
  }
  .outfit-card small {
    font-size: 9px;
  }
  .outfit-save button {
    min-height: 32px;
    padding: 6px 8px;
    font-size: 10px;
  }
}
#screen-wardrobe .outfit-card[aria-pressed="true"] {
  outline: 2px solid #98ffe9;
  outline-offset: -2px;
  background-color: #124c57;
}
#screen-wardrobe .outfit-selected {
  display: inline-block;
  border-radius: 8px;
  padding: 2px 7px;
  color: #082c33;
  background: #a3ffe9;
  font-size: 10px;
  font-weight: 700;
}
.avatar-preview .outfit-save-primary {
  width: 100%;
  flex: none;
  min-height: 32px;
  padding: 6px 8px;
  font-size: 11px;
}
.character-studio .avatar-preview #wardrobe-status {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: none;
}

/* Share one toolbar row; the original-look action must not cover item cards. */
.wardrobe-tabs > .outfit-genders {
  margin-left: auto;
}
.outfit-presets {
  flex-wrap: nowrap;
  overflow-x: auto;
  flex: none;
  padding-bottom: 2px;
}
.outfit-presets > button {
  flex: none;
}
@media (orientation: landscape) and (max-height: 360px) {
  .character-studio .wardrobe-items {
    gap: 5px;
  }
  .outfit-editor {
    gap: 5px;
  }
  .outfit-editor .chip,
  .wardrobe-tabs .chip {
    min-height: 26px;
    padding: 3px 6px;
  }
}

@media (orientation: landscape) and (max-height: 360px) {
  #wardrobe-panel.is-outfits .sheet-header {
    margin-bottom: 8px;
  }
  #wardrobe-panel.is-outfits .sheet-header p {
    display: none;
  }
  #wardrobe-panel.is-outfits .sheet-header h2 {
    font-size: 20px;
    margin-top: 3px;
  }
  #wardrobe-panel.is-outfits .character-studio {
    height: calc(
      var(--app-height, 100dvh) - var(--safe-top) - var(--safe-bottom) - 98px
    );
  }
}
