/* Reusable components. */

.icon { flex: none; }

/* ---- Bottom navigation -------------------------------------------------- */
.bottom-nav {
  flex: none;
  position: relative;
  z-index: 10;
  background: linear-gradient(180deg, #071121 0%, var(--bg-nav) 100%);
  border-top: 1px solid var(--border);
  border-radius: 22px 22px 0 0;
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.35);
}

.bottom-nav__list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0;
  padding: 0 var(--space-2);
  list-style: none;
}

.bottom-nav__tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  min-height: var(--nav-height);
  padding: var(--space-2) 0 var(--space-2);
  color: var(--icon-inactive);
  border-radius: var(--radius-md);
  transition: color var(--dur-fast) var(--ease);
}

.bottom-nav__icon { position: relative; display: grid; place-items: center; }

.bottom-nav__label {
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.bottom-nav__tab.is-active { color: var(--accent-bright); }
.bottom-nav__tab.is-active .bottom-nav__label { color: var(--accent-bright); font-weight: 600; }

/* Pixel icons (assets/ui/nav-<tab>-on|off.webp): the glowing one shows on the active tab. */
.bottom-nav__img { width: 34px; height: 34px; object-fit: contain; image-rendering: pixelated; }
.bottom-nav__img--on, .bottom-nav__tab.is-active .bottom-nav__img--off { display: none; }
.bottom-nav__tab.is-active .bottom-nav__img--on { display: block; }

.bottom-nav__badge {
  position: absolute;
  top: -3px;
  right: -6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--notify);
  box-shadow: 0 0 0 2px var(--bg-nav);
}

.bottom-nav__tab:focus-visible { outline-offset: -4px; }

/* ---- Search bar --------------------------------------------------------- */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  height: var(--field-height);
  padding: 0 var(--space-1) 0 var(--space-3);
  background: var(--bg-field);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.18);
}

.search-bar__icon { display: grid; color: var(--text-secondary); margin-right: var(--space-3); }

.search-bar__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  padding: 0;
  font-size: var(--fs-body);           /* ≥16px stops iOS zoom-on-focus */
  font-weight: 400;
  letter-spacing: 0.01em;
  background: transparent;
  border: 0;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.search-bar__input::placeholder { color: var(--text-placeholder); opacity: 1; }
.search-bar__input::-webkit-search-cancel-button,
.search-bar__input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }

.search-bar__clear {
  display: grid;
  place-items: center;
  width: var(--touch-min);
  height: var(--touch-min);
  margin: -2px 0;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}
.search-bar__clear[hidden] { display: none; }
.search-bar__clear:hover { color: var(--text-secondary); }

/* ---- Filter pills ------------------------------------------------------- */
.filter-tabs {
  /* Pills size from the row width, so label and pill scale together. */
  container-type: inline-size;
  display: flex;
  gap: 6px;
  /* Safety net for very large accessibility text: scroll sideways rather than clip. */
  overflow-x: auto;
  scrollbar-width: none;
  margin: -6px calc(-1 * var(--gutter));
  padding: 6px var(--gutter) 10px;   /* room for the selected glow */
}
.filter-tabs::-webkit-scrollbar { display: none; }

.filter-tabs__pill {
  position: relative;
  flex: 1 0 auto;                    /* grow to fill the row, never shrink below the label */
  height: var(--pill-height);
  padding: 0 clamp(10px, 3.4cqi, 18px);
  font-size: clamp(13px, 4.6cqi, 16px);
  font-weight: 600;                  /* same weight selected or not, so width never jumps */
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #e9eef8;
  white-space: nowrap;
  background: rgba(9, 18, 34, 0.86);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

/* Enlarge the hit area to 44px without changing the drawn pill. */
.filter-tabs__pill::before {
  content: "";
  position: absolute;
  inset: calc((var(--pill-height) - var(--touch-min)) / 2) -3px;
}

.filter-tabs__pill:hover:not(.is-selected) { background: #102037; }

.filter-tabs__badge {
  position: absolute; top: -5px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px;
  display: grid; place-items: center; font-size: 0.75rem; font-weight: 700; color: #fff;
  background: var(--danger); border-radius: var(--radius-pill); box-shadow: 0 0 8px rgba(255, 77, 94, 0.6);
}
.filter-tabs__badge[hidden] { display: none; }

.filter-tabs__pill.is-selected {
  color: #fff;
  background: var(--accent-gradient);
  border-color: rgba(120, 190, 255, 0.35);
  box-shadow: 0 2px 10px rgba(10, 110, 245, 0.35);
}

/* ---- Empty state -------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-4) var(--space-5);
  text-align: center;
}

.empty-state__icon { color: var(--text-muted); margin-bottom: var(--space-1); }
.empty-state__title { margin: 0; font-size: var(--fs-name); font-weight: 600; }
.empty-state__message { margin: 0; max-width: 30ch; font-size: var(--fs-small); color: var(--text-secondary); }

/* ---- Toast -------------------------------------------------------------- */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + var(--space-4));
  z-index: 50;
  max-width: calc(100% - 2 * var(--gutter));
  padding: 10px 16px;
  font-size: var(--fs-small);
  font-weight: 500;
  color: #fff;
  background: #13233b;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  pointer-events: none;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---- Buttons ------------------------------------------------------------ */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch-min);
  padding: 0 var(--space-5);
  font-size: var(--fs-body);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  transition: filter var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.button--primary { color: #fff; background: var(--accent-gradient); border-color: rgba(120, 190, 255, 0.3); }
.button--secondary { color: var(--text); background: var(--bg-field); border-color: var(--border-strong); }
.button--danger { color: #fff; background: linear-gradient(180deg, #cf2a3c, #bf2436); }
.button--discord { color: #fff; background: #5865f2; border-color: rgba(255, 255, 255, 0.18); } /* Discord blurple */
.button__icon { flex: none; }
.button:hover { filter: brightness(1.08); }
.button:active { filter: brightness(0.94); }
.button:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.button--compact { min-height: 34px; padding: 0 var(--space-4); font-size: 15px; }
.button--small { min-height: 34px; padding: 0 var(--space-3); font-size: var(--fs-small); }
.button--block { width: 100%; }

/* Small buttons keep a 44px hit area. */
.button--compact, .button--small { position: relative; }
.button--compact::before, .button--small::before { content: ""; position: absolute; inset: -5px -2px; }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: var(--touch-min);
  height: var(--touch-min);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
}
.icon-button:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.icon-button--sm { width: 32px; height: 32px; position: relative; }
.icon-button--sm::before { content: ""; position: absolute; inset: -6px; }
.icon-button--lg { color: #e3e8f4; margin-right: -8px; }
.icon-button--square {
  flex: none;
  width: var(--touch-min);
  height: var(--field-height);
  color: #e3e8f4;
  background: var(--bg-field);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
}

/* ---- Avatar & status ---------------------------------------------------- */
.avatar {
  --avatar-size: 46px;
  position: relative;
  flex: none;
  width: var(--avatar-size);
  height: var(--avatar-size);
}
.avatar__img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar--ring .avatar__img { box-shadow: 0 0 0 3px var(--accent), 0 0 12px rgba(10, 132, 255, 0.35); }
/* Profile frames bought in the Shop (shop_items kind 'frame'): a coloured glowing ring. */
.avatar--framed { --frame: #4fd3ff; }
.avatar--frame-ice { --frame: #4fd3ff; }
.avatar--frame-toxic { --frame: #3cff6e; }
.avatar--frame-flame { --frame: #b46bff; }
.avatar--frame-gold { --frame: #ffc21a; }
.avatar--framed .avatar__img, .avatar--framed.avatar--ring .avatar__img { box-shadow: 0 0 0 3px var(--frame), 0 0 14px var(--frame) !important; }
.avatar__dot {
  position: absolute;
  right: 1%;
  bottom: 3%;
  width: 25%;
  height: 25%;
  border-radius: 50%;
  border: 3px solid var(--bg-surface);
}
.avatar__dot--online { background: var(--online); }
.avatar__dot--offline { background: var(--offline); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-tiny);
  font-weight: 500;
}
.status__dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.status--online { color: var(--online-text); }
.status--online .status__dot { background: var(--online); }
.status--playing { color: var(--accent-bright); }
.status--playing .status__dot { background: var(--accent-bright); box-shadow: 0 0 6px rgba(42, 168, 255, 0.6); }
.status--offline { color: var(--text-muted); }
.status--offline .status__dot { background: var(--offline); }

/* ---- Profile card ------------------------------------------------------- */
.profile-card {
  container-type: inline-size;
  padding: var(--space-3) var(--space-4) var(--space-1);
  background: linear-gradient(180deg, #0a1626 0%, var(--bg-surface) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.profile-card__top { display: flex; align-items: flex-start; gap: clamp(10px, 5cqi, 16px); }
.profile-card__top .avatar { --avatar-size: clamp(60px, 25cqi, 78px) !important; margin: 2px 0 0 2px; }
.profile-card__info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; padding-top: 2px; }
.profile-card__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px var(--space-2); }
.profile-card__name {
  flex: 1 1 6.5ch;   /* when name + button don't fit, the button wraps below instead of truncating the name */
  min-width: 0;
  margin: 0;
  font-size: clamp(18px, 7cqi, 22px);
  font-weight: 700;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-card__edit { flex: none; padding: 0 clamp(10px, 4.5cqi, 16px); font-size: clamp(13px, 4.8cqi, 15px); }
.profile-card__code {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 4px;
  margin: 0;
  font-size: clamp(13px, 4.8cqi, 15px);
  color: var(--text-secondary);
}
.profile-card__code > span { white-space: nowrap; }
.profile-card__code-value { letter-spacing: 0.02em; }
.profile-card__status { font-size: clamp(13px, 4.8cqi, 15px); }
.profile-card__status.status--online { color: #d9e2f2; }

.profile-card__stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: var(--space-3) 0 0;
  padding-top: 6px;
  border-top: 1px solid var(--divider);
}
.profile-card__stats > div {
  display: flex;
  flex-direction: column-reverse;     /* number above label, read as "Friends 7" */
  align-items: center;
  padding: 4px 0;
}
.profile-card__stats > div + div { border-left: 1px solid var(--divider); }
.profile-card__stats dd { margin: 0; font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.profile-card__stats dt { font-size: var(--fs-small); color: var(--text-secondary); }

/* ---- Player-code search ------------------------------------------------- */
.code-search__row { display: flex; gap: var(--space-2); }
.code-search__row .search-bar { flex: 1 1 auto; min-width: 0; container-type: inline-size; }
.search-bar__input--code { letter-spacing: 0.02em; }
.search-bar__input--code::placeholder { letter-spacing: 0; font-size: clamp(12px, 5cqi, 16px); }
.code-search__result:not(:empty) { margin-top: var(--space-2); }

.code-search__message {
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.code-search__message--warn { border-color: rgba(255, 163, 26, 0.45); }
.code-search__message-title { margin: 0; font-weight: 600; }
.code-search__message-detail { margin: 2px 0 0; font-size: var(--fs-small); color: var(--text-secondary); }

.code-result {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
}
.code-result__info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.code-result__name { font-size: var(--fs-name); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-result__code { font-size: var(--fs-tiny); color: var(--text-secondary); letter-spacing: 0.02em; }
.code-result__status { font-size: var(--fs-tiny); color: var(--text-muted); }
.code-result__status--friends { color: var(--online-text); }
.code-result__status--outgoing, .code-result__status--incoming { color: var(--pending); }
.code-result__status--blocked { color: var(--danger); }
.code-result__actions { display: flex; gap: 6px; flex: none; }
.code-result__dismiss { align-self: flex-start; color: var(--text-muted); }

/* ---- Friend rows -------------------------------------------------------- */
.friend-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }

.friend-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 66px;
  padding: 6px 8px 6px 8px;
  background: linear-gradient(90deg, rgba(14, 30, 58, 0.95) 0%, rgba(9, 20, 40, 0.95) 100%);
  border: 1px solid #1a3560;
  border-radius: var(--radius-md);
}
.friend-row .avatar { box-shadow: 0 0 0 2px #2a7fff; border-radius: 50%; }
.friend-row__info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.friend-row__name { font-size: 1.125rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-row__sub { font-size: var(--fs-small); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-row__sub.is-online { color: var(--online-text); }
.friend-row__game { font-size: 0.9375rem; font-weight: 500; color: var(--accent-bright); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-row__detail { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-tiny); color: var(--text-secondary); }
.friend-row__detail .icon { color: var(--text-muted); }
.friend-row__trailing { display: flex; align-items: center; gap: 6px; flex: none; }
.friend-row__action { min-width: 76px; min-height: 38px; font-size: var(--fs-body); }
.friend-row__action.button--primary { box-shadow: 0 0 12px rgba(20, 130, 255, 0.55); }
.friend-row__icon-action {
  display: grid; place-items: center; width: 48px; height: 38px; color: #fff;
  border-radius: 9px; border: 1px solid rgba(255, 255, 255, 0.25);
}
.friend-row__icon-action--accept { background: linear-gradient(180deg, #1fae4c, #12863a); box-shadow: 0 0 10px rgba(34, 214, 90, 0.5); }
.friend-row__icon-action--decline { background: linear-gradient(180deg, #e3283f, #b5162c); box-shadow: 0 0 10px rgba(255, 60, 80, 0.5); }
.friend-row__menu {
  display: grid; place-items: center; width: 38px; height: 38px; color: #e3e8f4;
  border: 1px solid #22406c; border-radius: 9px; background: rgba(4, 10, 22, 0.6);
}
.friend-row__menu:hover { background: rgba(255, 255, 255, 0.06); }

/* ---- Modal -------------------------------------------------------------- */
.modal {
  width: min(calc(100% - 2 * var(--gutter)), 420px);
  max-height: calc(100dvh - 48px);
  margin: auto;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  overflow: visible;
}
.modal::backdrop { background: var(--bg-overlay); backdrop-filter: blur(2px); }
.modal__panel {
  display: flex;
  flex-direction: column;
  max-height: inherit;
  background: #0b1626;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-2) var(--space-2) var(--space-5);
}
.modal__title { margin: 0; font-size: 1.25rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal__body { padding: 0 var(--space-5) var(--space-4); overflow-y: auto; overscroll-behavior: contain; }
.modal__message { margin: 0; color: var(--text-secondary); line-height: 1.45; }
.modal__actions {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5) calc(var(--space-4) + var(--safe-bottom) * 0);
  border-top: 1px solid var(--divider);
}
.modal__actions .button { flex: 1 1 0; }

.modal--sheet {
  width: min(100%, var(--app-max-width));
  max-width: 100%;
  margin: auto auto 0;
}
.modal--sheet .modal__panel {
  border-radius: 20px 20px 0 0;
  border-bottom: 0;
  padding-bottom: var(--safe-bottom);
}
.modal--sheet[open] { animation: sheet-in var(--dur) var(--ease); }
.modal--dialog[open] { animation: dialog-in var(--dur) var(--ease); }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
@keyframes dialog-in { from { transform: scale(0.97); opacity: 0; } }
:root[data-reduce-motion="true"] .modal[open] { animation: none; }
@media (prefers-reduced-motion: reduce) { .modal[open] { animation: none; } }

.action-list { margin: 0; padding: 0 0 var(--space-2); list-style: none; }
.action-list__item {
  width: 100%;
  min-height: 52px;
  padding: 0 var(--space-2);
  text-align: left;
  font-size: var(--fs-body);
  font-weight: 500;
  border-radius: var(--radius-sm);
}
.action-list li + li { border-top: 1px solid var(--divider); }
.action-list__item:hover { background: rgba(255, 255, 255, 0.04); }
.action-list__item--danger { color: var(--danger); }

/* ---- Forms -------------------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: var(--space-4); }
.form__field { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.form__field[hidden] { display: none; }
.form__label { font-size: var(--fs-small); font-weight: 600; color: var(--text-secondary); padding: 0; }
.form__optional { font-weight: 400; color: var(--text-muted); }
.form__input {
  width: 100%;
  min-height: var(--touch-min);
  padding: 10px 12px;
  font-size: var(--fs-body);
  background: var(--bg-field);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
}
.form__input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.18); }
.form__input[aria-invalid] { border-color: var(--danger); }
.form__textarea { resize: none; line-height: 1.35; }
.form__hint { margin: 0; font-size: var(--fs-tiny); color: var(--text-muted); }
.form__error { margin: 0; font-size: var(--fs-tiny); color: var(--danger); }
.form__error:empty { display: none; }
.form__readonly { display: flex; flex-direction: column; gap: 2px; }
.form__readonly-value { font-size: var(--fs-body); font-weight: 600; letter-spacing: 0.03em; }

.avatar-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-3); justify-items: center; }
.avatar-picker__option { position: relative; display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; cursor: pointer; }
.avatar-picker__option img { width: 56px; height: 56px; border-radius: 50%; }
.avatar-picker__option:has(input:checked) { box-shadow: 0 0 0 3px var(--accent); }
.avatar-picker__option:has(input:focus-visible) { outline: 2px solid var(--accent-bright); outline-offset: 4px; }

.switch { display: flex; align-items: center; gap: var(--space-3); cursor: pointer; }
.switch__text { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.switch__label { font-weight: 600; }
.switch__hint { font-size: var(--fs-tiny); color: var(--text-muted); }
.switch__input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track {
  position: relative;
  flex: none;
  width: 50px;
  height: 30px;
  background: #24324a;
  border-radius: var(--radius-pill);
  transition: background-color var(--dur-fast) var(--ease);
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--dur-fast) var(--ease);
}
.switch__input:checked + .switch__track { background: var(--accent); }
.switch__input:checked + .switch__track::after { transform: translateX(20px); }
.switch__input:focus-visible + .switch__track { outline: 2px solid var(--accent-bright); outline-offset: 2px; }

/* ---- Settings & player profile ------------------------------------------ */
.settings { display: flex; flex-direction: column; gap: var(--space-5); }

.player-profile { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: var(--space-2) 0 var(--space-2); text-align: center; }
.player-profile__name { margin: var(--space-2) 0 0; font-size: 1.5rem; font-weight: 700; }
.player-profile__code { display: flex; align-items: center; gap: 4px; margin: 0; color: var(--text-secondary); }
.player-profile__bio { margin: var(--space-2) 0 0; max-width: 32ch; color: var(--text-secondary); line-height: 1.4; }
.player-profile__muted { color: var(--text-muted); }

/* ---- Coins & achievements (shared) --------------------------------------- */
.coin-badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px 0 8px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
  background: rgba(7, 14, 28, 0.88); color: var(--text);
  font-weight: 700; font-size: 1.125rem; text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.coin-badge[hidden] { display: none; }
.coin-badge__icon { width: 24px; height: 24px; image-rendering: pixelated; }
.profile-card__coins .icon, .profile__coins .icon, .ach-coin { color: var(--coin); }
.coin-badge.is-bumped { animation: coin-bump 600ms var(--ease); }
@keyframes coin-bump {
  0% { transform: scale(1); } 30% { transform: scale(1.15); box-shadow: 0 0 16px rgba(255, 201, 60, 0.55); } 100% { transform: scale(1); }
}
.profile-card__coins, .profile__coins { display: inline-flex; align-items: center; gap: 4px; color: inherit; text-decoration: none; }

.tier-bronze { --tier: var(--tier-bronze); }
.tier-silver { --tier: var(--tier-silver); }
.tier-gold { --tier: var(--tier-gold); }
.tier-platinum { --tier: var(--tier-platinum); }
.tier-legendary { --tier: var(--tier-legendary); }

.ach-card__badge, .ach-toast__badge {
  display: grid; place-items: center; flex: none;
  border-radius: 50%; color: var(--tier);
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--tier) 28%, transparent), var(--bg-field) 70%);
  box-shadow: inset 0 0 0 2px var(--tier);
}
.ach-card__badge img, .ach-toast__badge img { border-radius: 50%; object-fit: cover; }
.ach-emoji { font-size: 1.5rem; line-height: 1; }
.tier-chip {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius-pill);
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase;
  color: var(--tier); border: 1px solid color-mix(in srgb, var(--tier) 60%, transparent);
  background: color-mix(in srgb, var(--tier) 12%, transparent);
}

.ach-toast {
  position: fixed; z-index: 60; left: 50%; top: calc(var(--safe-top) + 12px);
  width: min(440px, calc(100% - 24px));
  display: flex; align-items: center; gap: var(--space-3);
  padding: 10px 14px 10px 10px; border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #0d1c30, #07121f);
  border: 1px solid color-mix(in srgb, var(--tier) 70%, transparent);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 22px color-mix(in srgb, var(--tier) 35%, transparent);
  transform: translate(-50%, -140%) scale(0.92); opacity: 0;
  transition: transform 420ms cubic-bezier(0.2, 1.3, 0.3, 1), opacity 240ms ease;
}
.ach-toast--bronze { --tier: var(--tier-bronze); }
.ach-toast--silver { --tier: var(--tier-silver); }
.ach-toast--gold { --tier: var(--tier-gold); }
.ach-toast--platinum { --tier: var(--tier-platinum); }
.ach-toast--legendary { --tier: var(--tier-legendary); }
.ach-toast.is-in { transform: translate(-50%, 0) scale(1); opacity: 1; }
.ach-toast.is-out { transform: translate(-50%, -140%) scale(0.96); opacity: 0; transition-duration: 340ms; }
.ach-toast__badge { width: 52px; height: 52px; }
.ach-toast.is-in .ach-toast__badge { animation: ach-pop 700ms 120ms var(--ease) both; }
@keyframes ach-pop { 0% { transform: scale(0.4) rotate(-20deg); } 60% { transform: scale(1.15) rotate(6deg); } 100% { transform: none; } }
.ach-toast__text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ach-toast__kicker { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: var(--fs-tiny); color: var(--tier); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.ach-toast__title { font-size: var(--fs-name); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ach-toast__coins { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; color: var(--coin); font-variant-numeric: tabular-nums; }
.ach-toast.is-in .ach-toast__coins { animation: ach-coins 900ms 350ms var(--ease) both; }
@keyframes ach-coins { 0% { transform: translateY(8px); opacity: 0; } 100% { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .ach-toast, .ach-toast.is-out { transition: opacity 200ms ease; transform: translate(-50%, 0); }
  .ach-toast.is-in .ach-toast__badge, .ach-toast.is-in .ach-toast__coins, .coin-badge.is-bumped { animation: none; }
}

/* ---- Game tiles (Games screen rows and grid) ---------------------------- */
.tile-row, .tile-grid { margin: 0; padding: 0; list-style: none; }
.tile-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 3 * 10px) / 4.25);   /* four tiles and a peek of the next */
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  margin: 0 calc(-1 * var(--gutter));
  padding: 4px var(--gutter) 6px;
  scroll-padding-inline: var(--gutter);
}
.tile-row::-webkit-scrollbar { display: none; }
.tile-row > li { scroll-snap-align: start; }
.tile-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@container (max-width: 330px) { .tile-grid { grid-template-columns: repeat(3, 1fr); } }
@media (orientation: landscape) and (max-height: 500px) {
  .tile-grid { grid-template-columns: repeat(6, 1fr); }
  .tile-row { grid-auto-columns: calc((100% - 5 * 10px) / 6.25); }
}

.game-tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 32 / 49;              /* the tiles' own shape: the frame is never cropped */
  border-radius: 12px;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.55));
  transition: transform var(--dur-fast) var(--ease), filter var(--dur-fast) var(--ease);
}
.game-tile__art { width: 100%; height: 100%; object-fit: contain; border-radius: 12px; pointer-events: none; }
.game-tile:hover { filter: drop-shadow(0 4px 14px rgba(42, 168, 255, 0.35)) brightness(1.06); }
.game-tile:active { transform: scale(0.96); }
.game-tile:focus-visible { outline-offset: 3px; border-radius: 12px; }
.game-tile__name {
  position: absolute; inset: auto 6px 12% 6px; padding: 4px; text-align: center;
  font-family: var(--font-display); font-weight: 900; font-size: 0.875rem; line-height: 1.1;
  background: rgba(1, 6, 14, 0.75); border-radius: 8px;
}
.game-tile__tag {
  position: absolute; top: 8px; right: 8px; padding: 2px 7px;
  font-size: 0.6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: #111; background: var(--pending); border-radius: var(--radius-pill);
}
.game-tile__friends {
  position: absolute; left: 6px; bottom: 6px; display: flex; align-items: center;
  font-size: 0.75rem; font-weight: 700;
}
.game-tile__friends .avatar { margin-right: -8px; box-shadow: 0 0 0 2px var(--bg-app); border-radius: 50%; }
.game-tile__friends > span:last-child:not(.avatar) { margin-left: 12px; padding: 1px 5px; background: rgba(1, 6, 14, 0.8); border-radius: var(--radius-pill); }

/* ---- Featured Game spotlight -------------------------------------------- */
/* The art column is sized from the height so the whole tile (frame included) fits the marquee.
   The details panel is smaller and sits in front of the marquee's right edge, as in the mockup. */
.spotlight {
  --spot-h: min(84cqi, 400px);
  --tuck: 26px;
  display: grid;
  grid-template-columns: calc((var(--spot-h) - 30px) * 32 / 49 + 30px) 1fr;
  align-items: center;
  height: var(--spot-h);
}
.spotlight__art {
  position: relative;
  z-index: 1;
  height: 100%;
  min-height: 0;
  border: 15px solid transparent;
  /* Slice at the bulbs' inner edge (50 px on the art), so no dark ring sits between lights and tile. */
  border-image: url("../../assets/ui/frame-marquee.webp") 50 / 15px / 2px round;
  filter: drop-shadow(0 0 10px rgba(255, 140, 30, 0.45));
  animation: marquee-glow 1.6s steps(2, jump-none) infinite;
}
/* The picture runs a few px under the bulbs' inner edge: tile and lights touch. */
.spotlight__art img { position: absolute; inset: -3px; width: calc(100% + 6px); height: calc(100% + 6px); object-fit: fill; border-radius: 6px; }
@keyframes marquee-glow { 50% { filter: drop-shadow(0 0 16px rgba(255, 180, 40, 0.7)) brightness(1.08); } }
:root[data-reduce-motion="true"] .spotlight__art { animation: none; }
@media (prefers-reduced-motion: reduce) { .spotlight__art { animation: none; } }

.spotlight__panel {
  position: relative;
  z-index: 2;                       /* in front of the marquee, overlapping its right edge */
  display: flex; flex-direction: column; gap: 5px; min-width: 0;
  height: 84%;
  margin-left: calc(-1 * var(--tuck));
  padding: 4px 2px 2px 4px;
  border: 12px solid transparent;
  border-image: url("../../assets/ui/frame-panel.webp") 64 fill / 12px / 0 stretch;
  filter: drop-shadow(0 0 8px rgba(255, 40, 60, 0.35));
}
.spotlight__title { margin: 0; font-family: var(--font-display); font-weight: 900; font-size: clamp(1rem, 5.2cqi, 1.375rem); line-height: 1.05; }
.spotlight__facts { display: flex; flex-wrap: wrap; gap: 2px 8px; margin: 0; font-size: clamp(0.6875rem, 3.3cqi, 0.8125rem); color: var(--text-secondary); }
.spotlight__facts span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.spotlight__facts img { width: 15px; height: 15px; object-fit: contain; }
.spotlight__blurb {
  margin: 0; flex: 1 1 auto; font-size: clamp(0.6875rem, 3.3cqi, 0.8125rem); line-height: 1.3; color: #d5ddee;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.play-button {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 10px;
  font-family: var(--font-display); font-weight: 900; font-size: clamp(1rem, 5cqi, 1.25rem);
  text-transform: uppercase; letter-spacing: 0.04em; color: #1a0d00;
  background: linear-gradient(180deg, #ffe24a 0%, #ffc21a 55%, #f59b00 100%);
  border: 3px solid #ff8a00;
  border-radius: 10px;
  box-shadow: inset 0 -4px 0 rgba(150, 70, 0, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.55), 0 0 14px rgba(255, 170, 20, 0.55);
}
.play-button:hover { filter: brightness(1.06); }
.play-button:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 rgba(150, 70, 0, 0.45), 0 0 10px rgba(255, 170, 20, 0.5); }
@container (max-width: 300px) {
  .spotlight { grid-template-columns: 1fr; height: auto; }
  .spotlight__art { aspect-ratio: 32 / 49; }
  .spotlight__panel { height: auto; margin: -8px 0 0; padding-left: 2px; }
}
