/* Treehouse front door — Phase A (2026-08-18).
   Plain CSS chrome only: gradients, colors, emoji. NO background images,
   NO svg art, NO base64 art (live-art gate: nothing approved for this surface
   beyond the three picker portrait frames referenced from treehouse.js). */

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

:root {
  --th-sky-top: #1b2a5e;
  --th-sky-bottom: #3b1f63;
  --th-wood: #7c4a24;
  --th-wood-dark: #5b3418;
  --th-leaf: #2f9e5f;
  --th-leaf-bright: #4ade80;
  --th-sun: #facc15;
  --th-cream: #fff7e8;
  --th-berry: #f472b6;
  --th-ink: #241505;
  --th-panel: rgba(20, 14, 40, 0.72);
  --th-touch: 4rem;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Outfit", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--th-cream);
  background:
    radial-gradient(circle at 18% 12%, rgba(250, 204, 21, 0.28), transparent 26%),
    radial-gradient(circle at 82% 6%, rgba(244, 114, 182, 0.22), transparent 30%),
    radial-gradient(circle at 50% 118%, rgba(47, 158, 95, 0.5), transparent 55%),
    linear-gradient(180deg, var(--th-sky-top), var(--th-sky-bottom));
  background-attachment: fixed;
}

.treehouse-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- top nav ---------- */

.treehouse-navbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.7rem 1rem;
  background: rgba(12, 9, 30, 0.72);
  border-bottom: 3px solid rgba(250, 204, 21, 0.35);
}

.treehouse-brand {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--th-sun);
  text-decoration: none;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  background: rgba(250, 204, 21, 0.14);
  min-height: 2.9rem;
  display: inline-flex;
  align-items: center;
}

.treehouse-nav-links {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  align-items: center;
}

.treehouse-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.9rem;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: var(--th-cream);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.treehouse-nav-btn:hover,
.treehouse-nav-btn:focus-visible {
  background: rgba(255, 255, 255, 0.2);
  border-color: var(--th-sun);
}

.treehouse-nav-btn.primary {
  background: linear-gradient(135deg, #22c55e, #0ea5e9);
  border-color: #86efac;
  color: #06251a;
}

.treehouse-nav-btn.danger {
  border-color: #f87171;
  color: #fecaca;
}

.treehouse-nav-btn.danger.strong {
  background: #dc2626;
  color: #fff;
}

.treehouse-main {
  flex: 1;
  width: 100%;
  max-width: 68rem;
  margin: 0 auto;
  padding: 1.2rem 1rem 3rem;
}

/* ---------- picker view ---------- */

.player-picker-heading {
  text-align: center;
  font-size: clamp(2rem, 6vw, 3.4rem);
  font-weight: 900;
  margin: 1.4rem 0 1.6rem;
  color: var(--th-sun);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}

.player-picker-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 1rem;
  justify-items: stretch;
  max-width: 44rem;
  margin: 0 auto;
}

.player-picker-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  min-height: 11rem;
  padding: 1.1rem 0.8rem;
  border-radius: 1.6rem;
  border: 3px solid rgba(255, 255, 255, 0.25);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05));
  color: var(--th-cream);
  font-family: inherit;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
}

.player-picker-btn:hover,
.player-picker-btn:focus-visible {
  transform: translateY(-4px) scale(1.03);
  border-color: var(--th-leaf-bright);
}

.player-picker-btn.is-last-active {
  border-color: var(--th-sun);
  box-shadow: 0 0 0 4px rgba(250, 204, 21, 0.25);
}

.player-picker-portrait {
  width: 6.2rem;
  height: 6.2rem;
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.4));
  pointer-events: none;
}

.player-picker-avatar {
  font-size: 4.4rem;
  line-height: 6.2rem;
  height: 6.2rem;
}

.player-picker-name {
  font-size: 1.35rem;
  font-weight: 800;
  word-break: break-word;
  max-width: 100%;
}

.player-picker-add-row {
  margin: 1.6rem auto 0;
  max-width: 44rem;
  text-align: center;
}

.player-picker-add-btn {
  min-height: var(--th-touch);
  padding: 0.7rem 1.6rem;
  border-radius: 999px;
  border: 3px dashed rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.07);
  color: var(--th-cream);
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 800;
  cursor: pointer;
}

.player-picker-add-btn:hover,
.player-picker-add-btn:focus-visible {
  border-color: var(--th-berry);
  background: rgba(244, 114, 182, 0.16);
}

.player-picker-add-form {
  margin-top: 1rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.player-picker-name-input {
  min-height: var(--th-touch);
  font-family: inherit;
  font-size: 1.25rem;
  font-weight: 700;
  padding: 0.4rem 1rem;
  border-radius: 1rem;
  border: 3px solid rgba(255, 255, 255, 0.35);
  background: var(--th-cream);
  color: var(--th-ink);
  width: min(18rem, 100%);
}

.player-picker-add-confirm {
  min-height: var(--th-touch);
  padding: 0.6rem 1.5rem;
  border-radius: 1rem;
  border: none;
  background: linear-gradient(135deg, var(--th-berry), #a855f7);
  color: #fff;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 900;
  cursor: pointer;
}

.player-picker-add-error {
  width: 100%;
  margin: 0.4rem 0 0;
  color: #fda4af;
  font-weight: 700;
}

/* ---------- treehouse view ---------- */

.treehouse-room {
  border: 4px solid var(--th-wood-dark);
  border-radius: 2rem;
  background:
    linear-gradient(180deg, rgba(124, 74, 36, 0.32), rgba(91, 52, 24, 0.5)),
    linear-gradient(180deg, rgba(20, 14, 40, 0.5), rgba(20, 14, 40, 0.72));
  padding: 1.1rem clamp(0.8rem, 3vw, 2rem) 1.6rem;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
}

.treehouse-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.treehouse-active-player {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 1rem 0.35rem 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(250, 204, 21, 0.5);
  min-height: 3.4rem;
}

.treehouse-chip-portrait {
  width: 2.6rem;
  height: 2.6rem;
  object-fit: contain;
}

.treehouse-chip-avatar {
  font-size: 1.9rem;
}

.treehouse-chip-name {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--th-sun);
}

.treehouse-switch-btn {
  min-height: 3.4rem;
  padding: 0.5rem 1.2rem;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: var(--th-cream);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

.treehouse-switch-btn:hover,
.treehouse-switch-btn:focus-visible {
  border-color: var(--th-leaf-bright);
  background: rgba(74, 222, 128, 0.16);
}

.treehouse-heading {
  text-align: center;
  font-size: clamp(1.5rem, 4.5vw, 2.4rem);
  font-weight: 900;
  margin: 1rem 0 1.2rem;
  color: var(--th-cream);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
}

.treehouse-stations {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 1rem;
  max-width: 38rem;
  margin: 0 auto;
}

.treehouse-station {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 8.5rem;
  border-radius: 1.4rem;
  border: 3px solid rgba(255, 255, 255, 0.25);
  background: linear-gradient(180deg, rgba(14, 165, 233, 0.3), rgba(59, 31, 99, 0.4));
  color: var(--th-cream);
  text-decoration: none;
  transition: transform 120ms ease, border-color 120ms ease;
}

.treehouse-station:nth-child(2) {
  background: linear-gradient(180deg, rgba(244, 114, 182, 0.32), rgba(59, 31, 99, 0.4));
}

.treehouse-station:nth-child(3) {
  background: linear-gradient(180deg, rgba(74, 222, 128, 0.3), rgba(59, 31, 99, 0.4));
}

.treehouse-station:hover,
.treehouse-station:focus-visible {
  transform: translateY(-4px) scale(1.04);
  border-color: var(--th-sun);
}

.treehouse-station-icon {
  font-size: 3.2rem;
  line-height: 1;
}

.treehouse-station-label {
  font-size: 1.25rem;
  font-weight: 900;
}

.treehouse-world-door {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  margin: 1.4rem auto 0;
  max-width: 22rem;
  min-height: var(--th-touch);
  padding: 1rem 1.4rem;
  border-radius: 1.6rem;
  border: 4px solid var(--th-leaf);
  background: linear-gradient(135deg, rgba(47, 158, 95, 0.55), rgba(21, 94, 60, 0.6));
  color: var(--th-cream);
  text-decoration: none;
  text-align: center;
  transition: transform 120ms ease;
}

.treehouse-world-door:hover,
.treehouse-world-door:focus-visible {
  transform: scale(1.04);
  border-color: var(--th-leaf-bright);
}

.treehouse-world-door-icon {
  font-size: 2.6rem;
  line-height: 1.1;
}

.treehouse-world-door-label {
  font-size: 1.5rem;
  font-weight: 900;
  color: #d9f99d;
}

.treehouse-world-door-sub {
  font-size: 0.95rem;
  opacity: 0.85;
  font-weight: 700;
}

/* ---------- reward shelf ---------- */

.treehouse-shelf-wrap {
  margin: 1.8rem auto 0;
  max-width: 38rem;
}

.treehouse-shelf-heading {
  font-size: 1.15rem;
  font-weight: 900;
  margin: 0 0 0.5rem;
  color: var(--th-sun);
}

.treehouse-reward-shelf {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  min-height: 4.6rem;
  align-items: center;
  padding: 0.7rem 0.9rem;
  border-radius: 1.2rem;
  background: linear-gradient(180deg, rgba(124, 74, 36, 0.6), rgba(91, 52, 24, 0.72));
  border: 3px solid var(--th-wood-dark);
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.22);
}

.treehouse-shelf-empty {
  font-weight: 700;
  opacity: 0.85;
}

.treehouse-reward-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.4rem 0.7rem;
  border-radius: 0.9rem;
  background: rgba(255, 247, 232, 0.14);
  border: 2px solid rgba(250, 204, 21, 0.55);
}

.treehouse-reward-icon {
  font-size: 1.9rem;
  line-height: 1;
}

.treehouse-reward-label {
  font-size: 0.8rem;
  font-weight: 800;
}

/* ---------- parent gate + studio ---------- */

.parent-gate-corner {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 2px dashed rgba(255, 255, 255, 0.18);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.8rem;
}

.parent-gate-trigger {
  min-height: 3.2rem;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 247, 232, 0.8);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.parent-gate-challenge {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.8rem 1rem;
  border-radius: 1rem;
  background: var(--th-panel);
  border: 2px solid rgba(250, 204, 21, 0.4);
}

.parent-gate-question {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--th-sun);
}

.parent-gate-answer {
  min-height: 3.2rem;
  width: 6.5rem;
  font-family: inherit;
  font-size: 1.3rem;
  font-weight: 800;
  text-align: center;
  border-radius: 0.8rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: var(--th-cream);
  color: var(--th-ink);
}

.parent-gate-submit {
  min-height: 3.2rem;
  padding: 0.5rem 1.2rem;
  border-radius: 0.8rem;
  border: none;
  background: var(--th-sun);
  color: var(--th-ink);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 900;
  cursor: pointer;
}

.parent-gate-error {
  width: 100%;
  margin: 0;
  color: #fda4af;
  font-weight: 700;
}

.v2-studio-panel {
  width: 100%;
  padding: 1rem;
  border-radius: 1.2rem;
  background: var(--th-panel);
  border: 2px solid rgba(250, 204, 21, 0.4);
}

.studio-heading {
  margin: 0 0 0.7rem;
  font-size: 1.1rem;
  color: var(--th-sun);
}

.studio-links,
.studio-reset {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  align-items: center;
}

.studio-reset {
  margin-top: 0.8rem;
}

.studio-reset-status {
  margin: 0;
  font-weight: 700;
  color: #86efac;
}

/* ---------- arcade drawer ---------- */

.v2-arcade-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(24rem, 92vw);
  overflow-y: auto;
  z-index: 40;
  padding: 1rem;
  background: rgba(12, 9, 30, 0.97);
  border-left: 3px solid rgba(250, 204, 21, 0.4);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.v2-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.v2-drawer-title {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--th-sun);
}

.v2-drawer-close {
  min-width: 3rem;
  min-height: 3rem;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
  color: var(--th-cream);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
}

.v2-drawer-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: var(--th-touch);
  padding: 0.6rem 0.8rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.07);
  border: 2px solid rgba(255, 255, 255, 0.14);
  color: var(--th-cream);
  text-decoration: none;
}

.v2-drawer-item:hover,
.v2-drawer-item:focus-visible {
  border-color: var(--th-leaf-bright);
  background: rgba(74, 222, 128, 0.12);
}

.v2-drawer-icon {
  font-size: 1.8rem;
}

.v2-drawer-text strong {
  display: block;
  font-size: 1rem;
}

.v2-drawer-text small {
  display: block;
  color: #94a3b8;
  font-size: 0.8rem;
}

.v2-drawer-hide {
  min-height: var(--th-touch);
  margin-top: 0.4rem;
  border-radius: 1rem;
  border: 2px solid rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

.v2-arcade-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.55);
}

/* ---------- responsive ---------- */

@media (max-width: 480px) {
  .treehouse-navbar {
    padding: 0.55rem 0.65rem;
  }

  .treehouse-nav-btn {
    font-size: 0.85rem;
    padding: 0.4rem 0.75rem;
  }

  .player-picker-list {
    grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
    gap: 0.7rem;
  }

  .player-picker-btn {
    min-height: 9.5rem;
  }

  .treehouse-stations {
    grid-template-columns: repeat(auto-fit, minmax(7.6rem, 1fr));
    gap: 0.7rem;
  }

  .treehouse-topline {
    justify-content: center;
  }
}

@media (min-width: 900px) {
  .treehouse-main {
    padding-top: 2rem;
  }
}
