/* Moonhowl shell extras (SHELL): topbar bits, home hero, mode cards, guide, auth, profile, leaderboard.
   Only .shell-* classes. Colours lean on base.css variables when present, with safe fallbacks,
   and on currentColor so every theme (night / day / dusk) keeps working. Logical properties for RTL. */

.shell-main { padding-block-end: max(2rem, env(safe-area-inset-bottom)); }

/* ---------- topbar ---------- */
.shell-topbar { gap: 0.5rem; }
.shell-brand-moon { display: inline-block; }
.shell-brand-name { white-space: nowrap; }
.shell-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-inline-start: auto;
  min-width: 0;
}
.shell-nav .btn { min-height: 44px; }
.shell-nav-guide { gap: 0.35rem; }
.shell-nav-icon { font-size: 1.1em; line-height: 1; }
.shell-nav-label { white-space: nowrap; }
.shell-nav [aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 0.3em;
  text-decoration-thickness: 2px;
}
.shell-lang {
  width: auto;
  max-width: 7.5rem;
  min-height: 44px;
  padding-block: 0.35rem;
  text-overflow: ellipsis;
}
.shell-account { gap: 0.4rem; max-width: 12rem; min-width: 44px; justify-content: center; }
.shell-account.is-pending { visibility: hidden; }
.shell-account-avatar { font-size: 1.25em; line-height: 1; }
.shell-account-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 7rem;
}

@media (max-width: 479px) {
  .shell-nav-label { display: none; }
  .shell-nav-guide { padding-inline: 0.6rem; }
}
@media (max-width: 379px) {
  .shell-brand-name { display: none; }
  .shell-account-name { max-width: 4.5rem; }
}

/* ---------- shared bits ---------- */
.shell-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.25em;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 0.25rem;
}
.shell-link:hover { color: var(--accent, inherit); }
.shell-page-head { margin-block-end: 0.25rem; }
.shell-page-head .title { margin: 0; }
.shell-lead { font-size: 1.08rem; line-height: 1.6; margin: 0; }
.shell-field-label { font-weight: 600; }
.shell-error { padding-block: 2rem; }

.shell-loading {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 2.5rem 0;
}
.shell-loading span {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.3;
  animation: shell-pulse 1.1s ease-in-out infinite;
}
.shell-loading span:nth-child(2) { animation-delay: 0.18s; }
.shell-loading span:nth-child(3) { animation-delay: 0.36s; }
@keyframes shell-pulse { 0%, 100% { opacity: 0.25; transform: scale(0.85); } 50% { opacity: 0.9; transform: scale(1); } }

/* ---------- home hero ---------- */
.shell-hero { padding-block: 1rem 0.5rem; text-align: center; }
.shell-sky {
  position: relative;
  width: min(100%, 22rem);
  height: clamp(150px, 46vw, 210px);
  margin-inline: auto;
}
.shell-moon {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 50%;
  width: clamp(110px, 34vw, 160px);
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(circle at 36% 34%, #fffdf2 0%, #f6edc8 45%, #e2d39b 100%);
  box-shadow:
    0 0 30px 6px rgba(255, 244, 200, 0.45),
    0 0 90px 26px rgba(190, 205, 255, 0.22),
    inset -14px -12px 28px rgba(150, 130, 80, 0.35);
  animation: shell-float 7s ease-in-out infinite;
}
[dir="rtl"] .shell-moon { transform: translate(50%, -50%); animation-name: shell-float-rtl; }
.shell-crater {
  position: absolute;
  border-radius: 50%;
  background: rgba(170, 150, 95, 0.32);
  box-shadow: inset 2px 2px 4px rgba(120, 100, 60, 0.35);
}
.shell-crater.c1 { width: 22%; height: 22%; inset-block-start: 22%; inset-inline-start: 56%; }
.shell-crater.c2 { width: 14%; height: 14%; inset-block-start: 58%; inset-inline-start: 30%; }
.shell-crater.c3 { width: 9%; height: 9%; inset-block-start: 66%; inset-inline-start: 62%; }
.shell-hero-wolf {
  position: absolute;
  inset-block-end: 4%;
  inset-inline-start: calc(50% - clamp(70px, 22vw, 105px));
  font-size: clamp(2.6rem, 12vw, 3.6rem);
  line-height: 1;
  filter: brightness(0) drop-shadow(0 0 6px rgba(200, 215, 255, 0.35));
  opacity: 0.88;
}
.shell-star {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #f3f6ff;
  box-shadow: 0 0 6px 1px rgba(220, 230, 255, 0.8);
  animation: shell-twinkle 3.2s ease-in-out infinite;
}
.shell-star.s1 { inset-block-start: 10%; inset-inline-start: 8%; }
.shell-star.s2 { inset-block-start: 24%; inset-inline-start: 86%; animation-delay: 0.8s; }
.shell-star.s3 { inset-block-start: 70%; inset-inline-start: 92%; animation-delay: 1.6s; width: 3px; height: 3px; }
.shell-star.s4 { inset-block-start: 6%; inset-inline-start: 64%; animation-delay: 2.2s; width: 3px; height: 3px; }
.shell-star.s5 { inset-block-start: 48%; inset-inline-start: 4%; animation-delay: 1.1s; }
body[data-theme="day"] .shell-star { opacity: 0.4; }

@keyframes shell-float {
  0%, 100% { transform: translate(-50%, -50%); }
  50% { transform: translate(-50%, calc(-50% - 6px)); }
}
@keyframes shell-float-rtl {
  0%, 100% { transform: translate(50%, -50%); }
  50% { transform: translate(50%, calc(-50% - 6px)); }
}
@keyframes shell-twinkle { 0%, 100% { opacity: 0.9; } 50% { opacity: 0.25; } }

.shell-hero-title {
  font-size: clamp(2.4rem, 11vw, 3.6rem);
  margin: 0.25rem 0 0;
  letter-spacing: 0.02em;
}
.shell-hero-tagline { margin: 0.25rem 0 0; }

/* ---------- mode cards ---------- */
.shell-modes {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}
@media (min-width: 640px) {
  .shell-modes { grid-template-columns: 1fr 1fr; }
}
.shell-mode {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 7rem;
  color: inherit;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.shell-mode::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 5px;
  background: var(--shell-mode-accent);
}
.shell-mode.is-local { --shell-mode-accent: var(--day-accent, #e2a548); }
.shell-mode.is-online { --shell-mode-accent: var(--accent, #7fa6ff); }
.shell-mode:hover { transform: translateY(-2px); }
.shell-mode:focus-visible { outline: 3px solid var(--focus, var(--accent, #9fbcff)); outline-offset: 3px; }
.shell-mode-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 50%;
  font-size: 1.8rem;
  background: color-mix(in srgb, var(--shell-mode-accent) 22%, transparent);
}
.shell-mode-body { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; flex: 1; }
.shell-mode-title { font-size: 1.3rem; font-weight: 700; font-family: var(--font-display, inherit); }
.shell-mode-desc { line-height: 1.45; opacity: 0.85; }
.shell-mode-players { align-self: flex-start; margin-block-start: 0.2rem; }
.shell-mode-arrow { flex: none; font-size: 2rem; line-height: 1; opacity: 0.55; }
[dir="rtl"] .shell-mode-arrow { transform: scaleX(-1); }

.shell-guide-cta { text-align: center; justify-content: center; }
.shell-home-links { margin: 0; }

/* ---------- guide ---------- */
.shell-toc { gap: 0.4rem; }
.shell-toc-chip {
  min-height: 44px;
  cursor: pointer;
  font: inherit;
}
.shell-guide-section { scroll-margin-block-start: 5rem; }
.shell-guide-section > .subtitle:focus { outline: none; }
.shell-guide-section p { line-height: 1.6; }
.shell-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.shell-step {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--r-md, 12px);
  background: color-mix(in srgb, currentColor 6%, transparent);
}
.shell-step-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  font-size: 1.35rem;
  background: color-mix(in srgb, currentColor 10%, transparent);
}
.shell-step-text { margin: 0; line-height: 1.55; }
.shell-guide-team { margin-block-start: 0.75rem; }
.shell-guide-team-title { margin: 0; font-size: 1rem; }
.shell-tips { margin: 0; padding: 0; }
.shell-tips .list-item { line-height: 1.5; }
.shell-guide-end { justify-content: center; }

/* ---------- auth ---------- */
.shell-auth {
  max-width: 28rem;
  margin-inline: auto;
}
.shell-auth-icon {
  font-size: 3rem;
  line-height: 1.1;
  margin-inline: auto;
}
.shell-auth-form .input { width: 100%; }
.shell-auth-avatar { gap: 0.5rem; }
.shell-avatar-btn {
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
}
.shell-avatar-btn:disabled { cursor: default; opacity: 0.6; }

/* ---------- profile ---------- */
.shell-profile-head {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.shell-profile-avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 4.25rem;
  height: 4.25rem;
  border-radius: 50%;
  font-size: 2.4rem;
  background: color-mix(in srgb, currentColor 10%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #9fbcff) 55%, transparent);
}
.shell-profile-id { min-width: 0; }
.shell-profile-id p { margin: 0; }
.shell-profile-name {
  font-weight: 700;
  overflow-wrap: anywhere;
}
.shell-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}
.shell-no-games {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.shell-team-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.shell-team-row { --shell-team: var(--village, #3fa37f); }
.shell-team-row[data-team="wolves"] { --shell-team: var(--wolves, #c8364f); }
.shell-team-row[data-team="neutral"] { --shell-team: var(--neutral, #9364d8); }
.shell-team-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-block-end: 0.35rem;
}
.shell-team-nums { margin: 0; }
.shell-bar {
  height: 0.7rem;
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 12%, transparent);
  overflow: hidden;
}
.shell-bar-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--shell-team);
  transition: width 0.5s ease;
}
.shell-role-list { margin: 0; padding: 0; }
.shell-role-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.shell-role-icon { font-size: 1.5rem; line-height: 1; flex: none; }
.shell-role-name { flex: 1; min-width: 6rem; font-weight: 600; }
.shell-role-nums { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.shell-role-row[data-team="village"] .shell-role-name { color: var(--village-ink, inherit); }
.shell-role-row[data-team="wolves"] .shell-role-name { color: var(--wolves-ink, inherit); }
.shell-role-row[data-team="neutral"] .shell-role-name { color: var(--neutral-ink, inherit); }
.shell-profile-actions { align-items: center; }

/* ---------- leaderboard ---------- */
.shell-lb { margin: 0; padding: 0; list-style: none; }
.shell-lb-item {
  display: grid;
  grid-template-columns: 2.25rem 2rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.6rem;
  min-height: 3.25rem;
}
.shell-lb-rank {
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
}
.shell-lb-item.is-top1 .shell-lb-rank,
.shell-lb-item.is-top2 .shell-lb-rank,
.shell-lb-item.is-top3 .shell-lb-rank { font-size: 1.5rem; }
.shell-lb-avatar { font-size: 1.5rem; line-height: 1; text-align: center; }
.shell-lb-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shell-lb-nums {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  text-align: end;
}
.shell-lb-item.is-me {
  outline: 2px solid var(--accent, #9fbcff);
  outline-offset: -2px;
}
.shell-lb-empty { padding-block: 2rem; }

/* ---------- motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .shell-moon,
  .shell-star,
  .shell-loading span { animation: none; }
  .shell-mode,
  .shell-bar-fill { transition: none; }
  .shell-mode:hover { transform: none; }
}
