@font-face {
  font-family: "Syne TG";
  src: url("../fonts/Syne-Variable.ttf") format("truetype");
  font-weight: 400 800;
  font-display: swap;
}

@font-face {
  font-family: "Nunito TG";
  src: url("../fonts/Nunito-Variable.ttf") format("truetype");
  font-weight: 400 800;
  font-display: swap;
}

:root {
  --tg-ink: #07161c;
  --tg-deep: #0c2430;
  --tg-panel: rgba(10, 36, 46, 0.72);
  --tg-line: rgba(200, 245, 66, 0.18);
  --tg-lime: #c8f542;
  --tg-amber: #ffb14a;
  --tg-coral: #ff6b4a;
  --tg-teal: #2dd4bf;
  --tg-mist: #d7efe6;
  --tg-muted: #8fb4a8;
  --tg-radius: 1.25rem;
  --tg-font-display: "Syne TG", "Avenir Next", "Segoe UI", sans-serif;
  --tg-font-body: "Nunito TG", "Avenir Next", "Segoe UI", sans-serif;
  --tg-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

.tg-body {
  min-height: 100vh;
  color: var(--tg-mist);
  font-family: var(--tg-font-body);
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(45, 212, 191, 0.18), transparent 55%),
    radial-gradient(900px 600px at 90% 10%, rgba(255, 177, 74, 0.14), transparent 50%),
    linear-gradient(165deg, #061219 0%, #0a2230 45%, #0d2a28 100%);
  overflow-x: hidden;
}

.tg-atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(200, 245, 66, 0.08) 0 1px, transparent 1.5px),
    radial-gradient(circle at 70% 60%, rgba(45, 212, 191, 0.08) 0 1px, transparent 1.5px);
  background-size: 120px 120px, 180px 180px;
  animation: tg-drift 28s linear infinite;
  opacity: 0.7;
  z-index: 0;
}

@keyframes tg-drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-40px, 20px, 0); }
}

.tg-main {
  position: relative;
  z-index: 1;
}

.tg-top {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.7rem clamp(0.85rem, 3vw, 1.75rem);
  backdrop-filter: blur(14px);
  background: rgba(7, 22, 28, 0.78);
  border-bottom: 1px solid color-mix(in srgb, var(--tg-teal) 18%, transparent);
}

.tg-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
  text-decoration: none;
}

.tg-brand__text {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
}

.tg-nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  max-width: min(100%, 28rem);
}

.tg-nav::-webkit-scrollbar {
  display: none;
}

.tg-nav a {
  color: var(--tg-mist);
  text-decoration: none;
  padding: 0.55rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 999px;
  transition: border-color 0.2s, background 0.2s, color 0.2s, box-shadow 0.3s;
  white-space: nowrap;
  flex: 0 0 auto;
}

.tg-nav a:hover,
.tg-nav a.is-active {
  border-color: var(--tg-line);
  background: rgba(200, 245, 66, 0.08);
  color: var(--tg-lime);
}

.tg-nav a.is-pulse {
  animation: tg-nav-pulse 1.4s ease 2;
}

@keyframes tg-nav-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(200, 245, 66, 0); }
  50% { box-shadow: 0 0 0 4px rgba(200, 245, 66, 0.28); }
}

:focus-visible {
  outline: 2px solid var(--tg-lime);
  outline-offset: 2px;
}

.tg-btn:focus:not(:focus-visible),
.tg-chip:focus:not(:focus-visible),
.tg-egg:focus:not(:focus-visible),
.tg-nav a:focus:not(:focus-visible) {
  outline: none;
}

.tg-main {
  padding: 0 clamp(1rem, 3vw, 2rem) 2.5rem;
}

.tg-display {
  font-family: var(--tg-font-display);
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 750;
  letter-spacing: -0.04em;
  margin: 0 0 0.4rem;
  line-height: 1.05;
}

.tg-display--sm {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
}

.tg-lead {
  margin: 0 0 1.25rem;
  color: var(--tg-muted);
  max-width: 38rem;
}

.tg-habitat {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.9fr);
  gap: 1.25rem;
  align-items: stretch;
  min-height: calc(100vh - 7rem);
}

.tg-split {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.2fr);
  gap: 1.25rem;
}

.tg-habitat__stage {
  position: relative;
  border-radius: calc(var(--tg-radius) + 0.4rem);
  overflow: hidden;
  box-shadow: var(--tg-shadow);
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(180deg, rgba(12, 42, 48, 0.5), rgba(7, 22, 28, 0.85));
  min-height: 520px;
}

.tg-habitat__stage--compact {
  min-height: 460px;
}

.tg-stage-frame {
  position: absolute;
  inset: 0;
}

.tg-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.tg-layer img,
.tg-layer svg,
.tg-layer object {
  width: min(92%, 520px);
  height: auto;
  max-height: 92%;
}

.tg-layer--bg { z-index: 1; }
.tg-layer--aura { z-index: 2; }
.tg-pet { z-index: 3; position: absolute; inset: 0; }
.tg-layer--body { z-index: 3; }
/* The .tg-layer--{bottom,shoes,top,face,hat,accessory,held} ladder that used to
   live here was dead: the rig emits .tg-slot--* inside .tg-part, so these seven
   selectors matched nothing. Gear layering is owned by the parent part's
   --tg-pz in rig.css. */

.tg-panel {
  background: var(--tg-panel);
  border: 1px solid var(--tg-line);
  border-radius: var(--tg-radius);
  padding: 1.25rem;
  backdrop-filter: blur(14px);
  box-shadow: var(--tg-shadow);
}

.tg-panel--wide {
  min-height: 460px;
}

.tg-identity {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.tg-name {
  font-family: var(--tg-font-display);
  font-size: 1.8rem;
  margin: 0;
  letter-spacing: -0.03em;
}

.tg-meta {
  margin: 0.25rem 0 0;
  color: var(--tg-muted);
}

.tg-coins {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  min-width: 4.75rem;
  padding: 0.4rem 0.75rem;
  border-radius: 1rem;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 177, 74, 0.28);
}

.tg-coins--lg {
  padding: 0.55rem 0.95rem;
}

.tg-stats {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 1.1rem;
}

.tg-stat {
  display: grid;
  gap: 0.25rem;
}

.tg-stat__row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--tg-muted);
}

.tg-stat__bar {
  height: 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.tg-stat__fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--tg-teal), var(--tg-lime));
  transition: width 0.45s ease;
}

.tg-stat[data-stat="happiness"] .tg-stat__fill {
  background: linear-gradient(90deg, var(--tg-amber), var(--tg-coral));
}

.tg-stat[data-stat="energy"] .tg-stat__fill {
  background: linear-gradient(90deg, #38bdf8, var(--tg-teal));
}

.tg-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.tg-btn {
  appearance: none;
  border: 1px solid var(--tg-line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--tg-mist);
  border-radius: 0.9rem;
  padding: 0.75rem 0.9rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s, border-color 0.2s;
}

.tg-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(200, 245, 66, 0.45);
  background: rgba(200, 245, 66, 0.1);
}

.tg-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.tg-btn--primary {
  background: linear-gradient(135deg, var(--tg-lime), #9be15d);
  color: var(--tg-ink);
  border-color: transparent;
}

.tg-btn.is-suggested {
  box-shadow: 0 0 0 1px rgba(200, 245, 66, 0.35);
}

.tg-stat.is-low .tg-stat__row span:last-child {
  color: var(--tg-coral);
}

.tg-coins__label {
  font-size: 0.68rem;
  color: var(--tg-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tg-coins__value {
  font-family: var(--tg-font-display);
  font-weight: 750;
  font-size: 1.35rem;
  color: var(--tg-amber);
  line-height: 1;
}

.tg-coins--lg .tg-coins__value {
  font-size: 1.75rem;
}

.tg-next {
  margin: 0 0 1rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid rgba(200, 245, 66, 0.28);
  border-radius: 1rem;
  background: rgba(200, 245, 66, 0.06);
}

.tg-next__title {
  margin: 0 0 0.55rem;
  font-family: var(--tg-font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--tg-lime);
}

.tg-next__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tg-chip--link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.tg-builder-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 0.95rem;
  border: 1px solid rgba(45, 212, 191, 0.28);
  background: rgba(45, 212, 191, 0.08);
}

.tg-builder-hint[data-mode="place"] {
  border-color: rgba(200, 245, 66, 0.35);
  background: rgba(200, 245, 66, 0.08);
}

.tg-builder-hint[data-mode="clear"] {
  border-color: rgba(255, 107, 74, 0.35);
  background: rgba(255, 107, 74, 0.08);
}

.tg-builder-hint__text {
  margin: 0;
  flex: 1 1 12rem;
  font-size: 0.9rem;
  color: var(--tg-mist);
}

.tg-builder-hint__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tg-empty-state {
  display: grid;
  gap: 0.75rem;
  justify-items: start;
  padding: 0.5rem 0 1rem;
  grid-column: 1 / -1;
}

.tg-hatch {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: clamp(1rem, 4vw, 2.5rem);
  text-align: center;
  background:
    radial-gradient(500px 320px at 50% 35%, rgba(200, 245, 66, 0.12), transparent 70%),
    rgba(5, 16, 22, 0.78);
  backdrop-filter: blur(8px);
}

/*
 * Author `display: grid` beats the UA `[hidden] { display: none }` rule.
 * Without this, hatch stays painted after hatch.hidden = true / PHP hidden attr.
 */
.tg-hatch[hidden],
.tg-hatch.is-complete {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

#tg-panel[hidden],
.tg-play__hud[hidden] {
  display: none !important;
}

.tg-eggs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.6rem;
  width: min(100%, 640px);
  margin: 0.5rem 0 1rem;
}

.tg-egg {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 1rem;
  padding: 0.6rem;
  cursor: pointer;
  color: inherit;
  transition: border-color 0.2s, transform 0.2s, background 0.2s;
}

.tg-egg img {
  width: 100%;
  height: auto;
  display: block;
}

.tg-egg span {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
}

.tg-egg.is-selected,
.tg-egg:hover {
  border-color: var(--tg-lime);
  background: rgba(200, 245, 66, 0.08);
  transform: translateY(-3px);
}

.tg-field {
  display: grid;
  gap: 0.35rem;
  text-align: left;
  width: min(100%, 320px);
  margin-bottom: 1rem;
}

.tg-field input {
  border: 1px solid var(--tg-line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--tg-mist);
  border-radius: 0.8rem;
  padding: 0.7rem 0.85rem;
  font: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.tg-field input::placeholder {
  color: color-mix(in srgb, var(--tg-muted) 80%, transparent);
}

.tg-field input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--tg-lime) 55%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tg-lime) 18%, transparent);
  background: rgba(0, 0, 0, 0.35);
}

.tg-shop__head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.tg-filters,
.tg-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.tg-chip {
  border: 1px solid var(--tg-line);
  background: transparent;
  color: var(--tg-mist);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font: inherit;
}

.tg-chip.is-active {
  background: rgba(200, 245, 66, 0.14);
  color: var(--tg-lime);
  border-color: rgba(200, 245, 66, 0.4);
}

.tg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 0.75rem;
}

.tg-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 1rem;
  padding: 0.7rem;
  display: grid;
  gap: 0.45rem;
  text-align: center;
}

.tg-card__preview {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 0.75rem;
}

.tg-card__preview img {
  width: 78%;
  height: auto;
}

.tg-card__title {
  font-size: 0.82rem;
  word-break: break-word;
}

.tg-card__meta {
  font-size: 0.75rem;
  color: var(--tg-muted);
}

.tg-rarity-common { color: #b7c9c2; }
.tg-rarity-uncommon { color: #86efac; }
.tg-rarity-rare { color: #7dd3fc; }
.tg-rarity-epic { color: var(--tg-teal); }
.tg-rarity-legendary { color: var(--tg-amber); }

.tg-toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(120%);
  background: rgba(7, 22, 28, 0.94);
  border: 1px solid var(--tg-line);
  color: var(--tg-mist);
  padding: 0.75rem 1.1rem;
  border-radius: 999px;
  z-index: 60;
  max-width: min(92vw, 28rem);
  text-align: center;
  transition: transform 0.25s ease;
  pointer-events: none;
}

.tg-toast.is-on {
  transform: translateX(-50%) translateY(0);
}

.tg-toast--ok {
  border-color: rgba(200, 245, 66, 0.45);
  box-shadow: 0 8px 28px rgba(200, 245, 66, 0.12);
}

.tg-toast--err {
  border-color: rgba(255, 107, 74, 0.55);
  box-shadow: 0 8px 28px rgba(255, 107, 74, 0.14);
}

@media (max-width: 920px) {
  .tg-habitat,
  .tg-split {
    grid-template-columns: 1fr;
  }

  .tg-habitat__stage {
    min-height: min(52vh, 360px);
  }

  .tg-habitat__stage--compact {
    min-height: min(42vh, 300px);
  }

  .tg-eggs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tg-brand__text small {
    display: none;
  }

  .tg-top__tools {
    max-width: min(100%, 22rem);
  }

  .tg-actions--dock {
    position: sticky;
    bottom: 0;
    z-index: 35;
    margin: 0 -1.25rem -1.25rem;
    padding: 0.75rem 1.25rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, rgba(7, 22, 28, 0), rgba(7, 22, 28, 0.92) 28%, rgba(7, 22, 28, 0.96));
    border-top: 1px solid rgba(200, 245, 66, 0.12);
    backdrop-filter: blur(10px);
  }
}

@media (max-width: 560px) {
  .tg-eggs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tg-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tg-actions .tg-btn {
    padding: 0.65rem 0.55rem;
    font-size: 0.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tg-atmosphere,
  .tg-pet,
  .tg-btn,
  .tg-nav a.is-pulse {
    animation: none !important;
    transition: none !important;
  }
}
