/* ═══════════════════════════════════════════
   GAME SHELL — full viewport, no scroll
═══════════════════════════════════════════ */

.body--game {
  height: 100dvh;
  overflow: hidden;
  overflow-x: hidden;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-shell {
  width: 100%;
  max-width: 1200px;
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: clip; /* clip horizontally so right-side content can't overflow viewport */
  overflow-y: visible;
}

/* ── TOP ZONE ──────────────────────── */
.game-top {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0.5rem 0.1rem;
  gap: 0.1rem;
  overflow: visible;
  position: relative;
  z-index: 100;
  background: var(--color-bg);
}

/* ── Collapsible header pull-tab (mobile/tablet only) ── */
.coins-and-pull {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.header-pull-tab {
  display: none;
}

@media (max-width: 899px) {
  .header-pull-tab {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 90;
    width: 48px;
    height: 18px;
    flex-shrink: 0;
    background: rgba(20, 18, 26, 0.8);
    border: 1px solid var(--color-border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    cursor: pointer;
    padding: 2px;
    align-items: center;
    justify-content: center;
    align-self: flex-start;
    margin-left: 0.5rem;
    margin-top: -1px;
  }

  .header-pull-tab:hover {
    background: rgba(232, 190, 142, 0.1);
    border-color: #e8be8e;
  }

  .header-pull-tab__chevron {
    width: 18px;
    height: 18px;
    filter: invert(80%) sepia(30%) saturate(400%) hue-rotate(5deg);
  }

  .game-top {
    max-height: 300px;
    overflow: visible;
    background: var(--color-bg);
  }

  .game-top--collapsed {
    max-height: 0 !important;
    overflow: hidden !important;
    opacity: 0;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }

  /* game-middle shows pull-tab before content */
  .game-middle {
    display: flex;
    flex-direction: column;
    padding-top: 0 !important;
  }

  .game-content {
    padding-top: 1.5rem;
  }
}

/* Row 1: Familiar · Clock · Avatar + Side panel */
.top-row-1 {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.top-row-1 .dusktime-block--borderless {
  align-self: flex-start;
}

.top-logo-emblem {
  width: 40px;
  height: 40px;
  object-fit: contain;
  opacity: 0.85;
  flex-shrink: 0;
}

.top-row-1__right {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* Row 2: Coins · flex space · Nav icons */
.top-row-2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.top-row-2__nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Nav icons */
.top-nav-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  text-decoration: none;
}

.top-nav-icon__circle {
  width: 48px;
  height: 40px;
  border-radius: var(--radius);
  border: 2px solid var(--color-border);
  background: rgba(232, 190, 142, 0.06);
  overflow: hidden;
  transition: border-color 0.2s, background 0.2s;
}

.top-nav-icon:hover .top-nav-icon__circle {
  border-color: #e8be8e;
  background: rgba(232, 190, 142, 0.12);
}

.top-nav-icon__label {
  font-family: var(--font-heading);
  font-variant: small-caps;
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  color: var(--color-text-heading);
}

.top-nav-icon:hover .top-nav-icon__label { color: #e8be8e; }

/* Wrap the familiar circle + label in a sub-column */
.familiar-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.familiar-circle {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 2px solid #e8be8e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.1rem;
  background: rgba(232, 190, 142, 0.08);
  overflow: hidden;
}

.familiar-circle-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}

.familiar-label {
  font-family: var(--font-heading);
  font-variant: small-caps;
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  color: #0a0a0f;
  background: #e8be8e;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  border: 1px solid #e8be8e;
  white-space: nowrap;
  font-weight: 700;
  margin-top: -0.85rem;
  position: relative;
  z-index: 1;
}

.nav-icon-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Right cluster — dusktime, then coins + avatar in a row */
.top-right-cluster {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
  flex-shrink: 1;
  min-width: 0;
}

.coins-and-avatar {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  position: relative;
}

/* ── Side panel (slide in from right of game-shell) ─── */
.side-panel-toggle {
  position: relative;
}

.side-panel-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  border: 2px solid #e8be8e;
  background: rgba(20, 18, 26, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  line-height: 1;
  color: #e8be8e;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  padding: 0;
}

.side-panel-btn:hover {
  border-color: #e8be8e;
  color: #e8be8e;
}

.side-panel {
  display: none;
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  width: max-content;
  min-width: 150px;
  height: auto;
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  z-index: 500;
  flex-direction: column;
  padding: 0.35rem 0;
  gap: 0;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.side-panel.sidebar-panel--open { display: flex; }

.side-panel-btn--close {
  align-self: flex-start;
  margin: 0 0 0.5rem 0.75rem;
  border: none;
  background: none;
}

.side-panel__item {
  display: block;
  width: 100%;
  padding: 0.65rem 1rem;
  background: none;
  border: none;
  color: var(--color-text-heading);
  font-family: var(--font-heading);
  font-variant: small-caps;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.side-panel__item:hover {
  background: rgba(232, 190, 142, 0.06);
  color: #e8be8e;
  text-decoration: none;
}

.side-panel__item--logout:hover { color: #c97070; }

.side-panel__divider {
  height: 1px;
  background: var(--color-border);
  margin: 0.5rem 0;
}

.dusktime-block {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(10, 10, 15, 0.5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.35rem 0.5rem;
  white-space: nowrap;
}

.dusktime-block--borderless {
  background: transparent;
  border: none;
  padding: 0;
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
}

@media (max-width: 899px) {
  .dusktime-block { padding: 0.25rem 0.4rem; }
  .dusktime-icon { font-size: 0.75rem; }
  .dusktime__time { font-size: 0.7rem; }
  .dusktime__period { font-size: 0.6rem; }
  .duskcoins__amount { font-size: 0.8rem; }
  .duskcoins__coin { width: 22px; height: 22px; }
  .user-avatar-btn { width: 36px; height: 36px; font-size: 1.1rem; }
  .side-panel-btn { width: 36px; height: 36px; font-size: 1.4rem; }
}

.dusktime-icon { font-size: 0.9rem; }

.dusktime-brand {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.dusktime-emblem {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
  opacity: 0.9;
}

.dusktime__wordmark-img {
  height: 28px;
  width: auto;
  object-fit: contain;
  opacity: 0.95;
}

.dusktime-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}

.dusktime__time {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  color: #e8be8e;
  white-space: nowrap;
}

.dusktime__period {
  font-family: var(--font-heading);
  font-variant: small-caps;
  font-size: 0.75rem;
  color: #e8be8e;
  white-space: nowrap;
}

.coins-block {
  display: flex;
  align-items: center;
}

.duskcoins {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(20, 18, 26, 0.7);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.2rem 0.6rem 0.2rem 0.25rem;
  cursor: default;
  white-space: nowrap;
}

.duskcoins__coin {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.duskcoins__amount {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: #e8be8e;
  letter-spacing: 0.02em;
}

/* User avatar — smaller than familiar */
.user-avatar-block {
  position: relative;
}

.user-avatar-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #e8be8e;
  background: rgba(232, 190, 142, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.user-avatar-btn:hover {
  background: rgba(232, 190, 142, 0.15);
}

.user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

/* Avatar action menu */
.avatar-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 170px;
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  z-index: 400;
}

.avatar-menu--open { display: block; }

.avatar-menu__item {
  display: block;
  width: 100%;
  padding: 0.7rem 1rem;
  background: none;
  border: none;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-family: var(--font-heading);
  font-variant: small-caps;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.avatar-menu__item:last-child { border-bottom: none; }
.avatar-menu__item:hover { background: rgba(255,255,255,0.05); color: #e8be8e; }
.avatar-menu__item--logout:hover { color: #c97070; }

/* ── MIDDLE ZONE (fills remaining space) ── */
.game-middle {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem 0.75rem;
}

/* Map page — lock scrolling and centre content */
.game-middle--map {
  overflow: hidden;
  justify-content: center;
  align-items: center;
}

.game-content {
  width: 100%;
  max-width: 900px;
  padding-top: 0.75rem;
  padding-bottom: 2rem;
}

/* Map page — no extra padding, every pixel counts */
.game-middle--map .game-content {
  padding-top: 0;
  padding-bottom: 0;
}

/* Map page centres the content — the map wrapper handles its own sizing */
.game-middle--map .game-content {
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  flex: 1 1 0;
  min-height: 0;
  padding: 0;
}

/* ── SLIDE-IN SIDEBAR ───────────────────── */
.sidebar-panel {
  position: fixed;
  top: 0;
  right: -320px;
  width: 300px;
  height: 100vh;
  background: var(--color-bg-panel);
  border-left: 1px solid var(--color-border);
  z-index: 300;
  transition: right 0.3s ease;
  overflow-y: auto;
  padding: 3.5rem 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sidebar-panel--open { right: 0; }

.sidebar-close-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}

.sidebar-close-btn:hover { color: var(--color-text); }

.sidebar-widgets {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── OVERLAY ────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 299;
}

.sidebar-overlay--visible { display: block; }
body.sidebar-is-open { overflow: hidden; }

/* ── PUBLIC (logged-out) layout ─────────── */
.body--public {
  min-height: 100dvh;
  background: var(--color-bg);
}

.main-content--centered {
  max-width: 680px;
  margin: 3rem auto;
  padding: 0 1rem;
}

/* ── Ad slots ───────────────────────────── */
.ad-slot-sidebar { width: 100%; }

/* ── Scrollbars: handled in base.css — invisible ── */

/* ── Portrait lock overlay ──────────────── */
.rotate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #0a0a0f;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  text-align: center;
  padding: 2rem;
}

.rotate-overlay__icon {
  font-size: 3.5rem;
  animation: rotate-hint 2s ease-in-out infinite;
}

@keyframes rotate-hint {
  0%, 100% { transform: rotate(0deg); }
  40%       { transform: rotate(-90deg); }
  60%       { transform: rotate(-90deg); }
}

.rotate-overlay__text {
  font-family: var(--font-heading);
  font-variant: small-caps;
  color: #e8be8e;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
}

.rotate-overlay__sub {
  font-style: italic;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

@media (orientation: landscape) and (max-height: 600px) {
  .rotate-overlay { display: flex; }
}

/* ── Onboarding layout ──────────────────── */
.onboarding-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 3rem 1rem;
  background: var(--color-bg);
}

.onboarding-panel { width: 100%; max-width: 860px; }

.onboarding-panel h1 {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.onboarding-panel .subtitle {
  text-align: center;
  color: var(--color-text-muted);
  font-style: italic;
  margin-bottom: 2.5rem;
}

.onboarding-section { margin-bottom: 2rem; }

.onboarding-section legend,
.onboarding-section label.section-label,
.onboarding-section span.section-label {
  font-family: var(--font-heading);
  font-variant: small-caps;
  letter-spacing: 0.08em;
  color: var(--color-text-heading);
  font-size: 1.1rem;
  margin-bottom: 1rem;
  display: block;
}

/* ── Desktop ────────────────────────────── */
@media (min-width: 600px) {
  /* Dusktime — side by side on tablet+ */
  .dusktime-block--borderless {
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
  }
  .dusktime-emblem { width: 40px; height: 40px; }
  .dusktime__wordmark-img { height: 36px; }
  .dusktime-text { align-items: flex-start; }
  .dusktime__time { font-size: 0.9rem; }
  .dusktime__period { font-size: 0.75rem; }
}

@media (min-width: 900px) {
  .familiar-circle { width: 72px; height: 72px; font-size: 2.2rem; }
  .game-top { padding: 1.25rem 1.5rem 0.5rem; }
  .game-middle { padding: 0.5rem 1.5rem; }

  /* Dusktime — bigger on desktop */
  .dusktime-block--borderless { gap: 0.75rem; }
  .dusktime-emblem { width: 48px; height: 48px; }
  .dusktime__wordmark-img { height: 44px; }
  .dusktime__time { font-size: 1rem; }
  .dusktime__period { font-size: 0.8rem; }
}
