/* ==========================================================================
   Page-level layout: auth, home, explore, create, profile, room cards.
   ========================================================================== */

/* -------------------------------------------------------------------- auth */
.auth {
  min-height: 100dvh;
  padding: 40px 22px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.auth__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  color: var(--accent-soft);
  font-size: 20px;
  font-weight: 700;
}

.auth__title {
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth__subtitle {
  color: var(--text-muted);
  margin-bottom: 20px;
}

.auth__form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.auth__form .button {
  margin-top: 6px;
}

.auth__switch {
  margin-top: 18px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* -------------------------------------------------------------------- head */
.page-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-head--profile {
  justify-content: space-between;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title {
  font-size: 19px;
  font-weight: 700;
}

/* -------------------------------------------------------------------- home */
.page > .page-head, .home__header {
  position: sticky;
  top: 0;
  z-index: 5;
  margin-inline: calc(-1 * var(--page-gutter, 18px));
  padding: calc(env(safe-area-inset-top, 0px) + 6px) var(--page-gutter, 18px) 6px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-soft);
}

.page:has(> .page-head), .page--discovery { padding-top: 0; }

.home__header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
}

.home__greeting, .brand-sound, .featured__join, .recent-link, .home-search {
  display: flex;
  align-items: center;
}

.home__greeting {
  gap: 8px;
  min-width: 0;
}
.player-level-badge {
  text-align: center;
  position: absolute;
  right: -3px;
  bottom: -3px;
  min-width: 18px;
  padding: 0 3px;
  border: 1px solid var(--action-rim);
  border-radius: 4px 4px 8px 8px;
  background: var(--accent);
  color: var(--text);
  font: 700 11px/16px var(--font);
}
.home__header .avatar-button {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-raised);
}
.home__header .avatar,
.home__header .avatar__media { border-radius: 9px; }
.home__player { min-width: 0; width: min(100%, 160px); }
.profile__xp { padding: 12px; border-radius: var(--radius); background: var(--surface); }
.xp-heading { display: flex; justify-content: space-between; gap: 8px; }
.profile__xp p { margin: 0; color: var(--text-muted); font-size: 12px; }
.home__xp-row { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 5px; margin-top: 3px; }
.home__level { flex: none; color: var(--accent-soft); font-size: 12px; }
.home__xp-meter { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; }
.home__xp-meter > * { grid-area: 1 / 1; }
.home__xp-meter .xp-progress { height: 18px; min-width: 0; margin: 0; border-radius: 9px; }
.home__xp-meter .xp-progress::-webkit-progress-value { background: var(--accent); }
.home__xp-meter .xp-progress::-moz-progress-bar { background: var(--accent); }
.home__xp-label {
  justify-self: center;
  position: relative;
  color: white;
  font: 700 11px/14px var(--font);
  font-variant-numeric: tabular-nums;
}
.profile__xp .xp-progress { height: 7px; margin-block: 7px; }
.xp-progress {
  display: block;
  width: 100%;
  height: 5px;
  margin-block: 3px;
  appearance: none;
  border: 0;
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface-hover);
  color: var(--accent-soft);
}
.xp-progress::-webkit-progress-bar { background: var(--surface-hover); }
.xp-progress::-webkit-progress-value { background: var(--accent-soft); }
.xp-progress::-moz-progress-bar { background: var(--accent-soft); }
.home__name { font-size: 17px; font-weight: 700; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.brand-sound {
  width: 35px;
  height: 35px;
  border-radius: 12px;
  background: var(--brand-fill, linear-gradient(145deg, #337cff, #0072ff));
  justify-content: center;
  gap: 2px;
  transform: rotate(-5deg);
}
.brand-sound i { width: 3px; height: 8px; border-radius: 2px; background: var(--on-primary, #092441); }
.brand-sound i:nth-child(2) { height: 19px; }
.brand-sound i:nth-child(3) { height: 14px; }
.home-search { gap: 8px; }
.home-search .search { flex: 1; min-width: 0; }
.recent-link {
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
}

.home__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.featured {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: flex-end;
  min-height: clamp(185px, 50vw, 215px);
  padding: clamp(18px, 4vw, 28px);
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.featured > img, .featured::after { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; }
.featured > img { object-fit: cover; }
.featured::after {
  content: '';
  background: linear-gradient(90deg, #010817dc, transparent 90%),
    linear-gradient(0deg, #010817ba, transparent 80%);
}
.featured__body { display: grid; justify-items: start; gap: 5px; min-width: 0; }
.featured__category { color: #d7efff; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.featured__title { font-size: clamp(1.65rem, 7vw, 1.95rem); line-height: 1.1; letter-spacing: -.045em; overflow-wrap: anywhere; }
.featured__subtitle { font-size: .875rem; color: #f5edf8; overflow-wrap: anywhere; }
.featured__join {
  margin-top: 9px;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
  border: 0;
  border-radius: 30px;
  color: var(--on-primary, #fff);
  background: var(--action-fill);
  border: 1px solid var(--action-rim);
  font-size: .875rem;
  font-weight: 700;
}

/* -------------------------------------------------------------- room cards */
.room-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.room-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.room-card {
  padding: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: inherit;
  text-align: left;
  overflow: hidden;
  transition: transform 0.14s ease, border-color 0.16s ease;
}

.room-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.room-card--row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
}

.room-card--tile {
  display: flex;
  flex-direction: column;
  border-radius: 12px;
}

.room-card__cover-wrap {
  position: relative;
  display: block;
  width: 100%;
}

.room-cover {
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, hsl(var(--cover-hue, 265) 65% 45%), hsl(calc(var(--cover-hue, 265) + 45) 60% 28%));
  overflow: hidden;
}

.room-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.room-cover--row {
  width: 82px;
  height: 74px;
  flex: none;
  border-radius: 13px;
}

.room-cover--tile {
  width: 100%;
  aspect-ratio: 16 / 9;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
}



.room-card__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 12px 12px;
}

.room-card--row .room-card__body {
  padding: 0 4px 0 0;
}

.room-card__head,
.room-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.room-card__title {
  font-size: 15.5px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-card__meta {
  font-size: 12.5px;
  color: var(--text-muted);
}

.room-members {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.room-badge {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  background: rgba(11, 6, 32, 0.72);
  backdrop-filter: blur(6px);
  font-size: 11.5px;
  font-weight: 700;
}



.room-badge--closed {
  right: 8px;
  top: 8px;
  color: var(--text-muted);
}

/* Still readable — it is the user's history — but clearly not joinable. */
.room-card--tile.is-closed .room-cover {
  filter: grayscale(0.85) brightness(0.7);
}

.room-badge--lock {
  right: 8px;
  top: 8px;
  color: var(--text-muted);
}



@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}



/* ---------------------------------------------------------- explore: mine */
/* Both are display:flex, which beats the [hidden] attribute's UA style. */
.page--explore .search[hidden],
.page--explore .filter-rail[hidden] {
  display: none;
}

.my-rooms {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.my-rooms__section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.my-rooms__section .section-title {
  font-size: 17px;
}

/* ----------------------------------------------------------------- profile */
.profile__identity {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.profile__avatar {
  display: grid;
  position: relative;
  flex: none;
}

.profile__avatar .avatar,
.profile__avatar .avatar__media {
  border-radius: 10px;
}

.profile__avatar .avatar__status { left: 0; right: auto; }

.profile__avatar-edit {
  position: absolute;
  right: -2px;
  top: -2px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  color: #fff;
}

.profile__meta {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.profile__name {
  font-size: 21px;
  font-weight: 700;
}

.profile__handle {
  font-size: 13.5px;
  color: var(--text-dim);
}

.profile__bio {
  font-size: 14px;
  color: var(--text-muted);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 16px 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border-soft);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border-left: 1px solid var(--border-soft);
}

.stat:first-child {
  border-left: 0;
}

.stat__value {
  font-size: 20px;
  font-weight: 700;
}

.stat__label {
  font-size: 12.5px;
  color: var(--text-muted);
}

.room-card__foot { flex-wrap: wrap; gap: 2px 8px; }
.room-card--tile .room-card__body { width: 100%; gap: 2px; padding: 5px 8px 7px; }
.room-card--tile .room-card__title { font-size: 14px; }
.page--home .category-chip {
  flex: none;
  flex-direction: row;
  padding: 4px 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
}
.page--home .category-chip__icon {
  width: 20px;
  height: 24px;
  background: none;
  border: 0;
  font-size: 16px;
}

.page.page--discovery { --page-gutter: 12px; gap: 8px; padding-inline: var(--page-gutter); }
.page--discovery .room-grid { gap: 8px; }
.page--discovery .home__actions { gap: 6px; }
.page--discovery :is(.icon-button, .avatar-button) { min-width: 44px; min-height: 44px; }
.page--discovery :is(.tab, .pill) { min-height: 44px; }
.page--discovery > .tab-bar .tab {
  flex: 1 0 auto;
  padding-inline: 4px;
  font-size: clamp(12px, 3.4vw, 14px);
  white-space: nowrap;
}
.page.page--leaderboard { --page-gutter: 12px; gap: 12px; padding-inline: var(--page-gutter); }

.page--discovery .room-grid:empty { display: none; }
.page--discovery .empty-state { grid-column: 1 / -1; }
.page-head--profile .page-title { flex: 1; }

.home-shortcuts {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.home-shortcuts .create-my-room {
  flex-direction: column;
  gap: 2px;
  padding: 6px 9px;
  font-size: 12px;
}
.home-shortcuts .weekly-preview {
  min-width: 0;
  padding-inline: 8px;
  gap: 4px;
  font-size: 13px;
}

.create-my-room, .weekly-preview {
  background: linear-gradient(125deg, var(--accent), var(--surface-raised) 65%, var(--surface));
  padding: 10px 12px;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-weight: 700;
}
.create-my-room:not([hidden]), .weekly-preview:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 10px;
}
.create-my-room {
  justify-content: center;
  text-decoration: none;
}
.create-my-room__icon { display: grid; place-items: center; }
.home-shortcuts .weekly-preview {
  display: grid;
  grid-template-columns: 35px minmax(0, 1fr) 12px;
}
.weekly-preview__title, .weekly-preview__entry {
  display: grid;
  justify-items: center;
  align-content: center;
  text-align: center;
  gap: 3px;
}
.weekly-preview__title { font-size: 11px; line-height: 1.1; }
.weekly-preview__title svg { color: var(--accent-soft); }
.weekly-preview__faces {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
}
.weekly-preview__entry { min-width: 0; grid-template-columns: minmax(0, 1fr); --medal: #f6c453; }
.weekly-preview__entry:nth-child(2) { --medal: #cbd9eb; }
.weekly-preview__entry:nth-child(3) { --medal: #eda477; }
.weekly-preview__portrait {
  position: relative;
  width: min(100%, 44px);
  aspect-ratio: 1;
}
.weekly-preview__portrait > :is(img, .avatar) {
  position: absolute;
  inset: 0;
  max-width: 100%;
  max-height: 100%;
}
.weekly-preview__portrait > img, .weekly-preview__portrait .avatar__media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 2px solid var(--medal);
  border-radius: 10px;
}
.weekly-preview__badge {
  position: absolute;
  top: -3px;
  left: 0;
  display: grid;
  place-items: center;
  width: 16px;
  height: 18px;
  border-radius: 3px 3px 8px 8px;
  background: var(--medal);
  color: #101c33;
  font-size: 10px;
  font-weight: 800;
}
.weekly-preview__name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}
.room-card__cover-wrap > .room-members {
  position: absolute;
  top: 8px;
  left: 8px;
  border-radius: var(--radius-pill);
  padding: 3px 7px;
  background: #061128eb;
  color: white;
}

.country-heading { display: flex; align-items: center; justify-content: space-between; }
.country-heading h2, .country-dialog h3 { font-size: 16px; }
.country-heading .link { display: inline-flex; align-items: center; min-height: 44px; }
.country-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-raised);
}
.country-grid button, .country-results button:where([aria-pressed]) {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 4px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: clamp(11px, 3vw, 14px);
  text-align: left;
}
.country-grid button[aria-pressed=true], .country-dialog button[aria-pressed=true] { background: var(--accent); }
.country-filter > .link:not([hidden]) { min-height: 44px; }
.country-dialog {
  width: min(100%, 430px);
  max-height: 90dvh;
  padding: 0 12px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  color: var(--text);
  background: var(--bg);
}
.country-dialog::backdrop { background: #010915ba; }
.country-dialog__header { position: sticky; top: 0; padding-block: 8px; background: var(--bg); }
.country-dialog__header .input { width: 100%; }
.country-results button:where([aria-pressed]) { width: 100%; margin-bottom: 2px; padding-inline: 10px; background: var(--surface-raised); font-size: 15px; }

.country-recent-row { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 2px; }
.country-recent-remove {
  min-height: 44px;
  margin-bottom: 2px;
  border: 0;
  border-radius: 7px;
  color: var(--text);
  background: var(--surface-raised);
  font-size: 20px;
}
