@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@700;800;900&family=Playfair+Display:ital,wght@0,700;1,700;1,800&family=Plus+Jakarta+Sans:wght@500;600;700;800&display=swap');

:root {
  --fg-green: #0b5b2e;
  --fg-green-deep: #06391c;
  --fg-gold: #e8c547;
  --fg-gold-deep: #c9a227;
  --fg-ink: #1c2a22;
  --fg-safe-top: env(safe-area-inset-top, 0px);
  --fg-safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body.fg-auth.has-fg-bnav {
  min-height: 0;
  overflow: hidden;
}

body.fg-auth.has-fg-bnav .fg-shell {
  min-height: 0;
}

body.fg-auth {
  min-height: 100dvh;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  color: #f4f7f5;
  background-color: #16382c;
  background-image:
    linear-gradient(180deg, rgba(10, 36, 28, 0.22) 0%, rgba(8, 28, 24, 0.08) 38%, rgba(6, 22, 18, 0.48) 100%),
    var(--fg-page-bg);
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  -webkit-text-size-adjust: 100%;
}

/* Login/register only — keep village HUD visible on dashboard & play */
body.fg-auth--login .fg-hud,
body.fg-auth--register .fg-hud {
  display: none !important;
}

.fg-shell {
  width: 100%;
  max-width: 430px;
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    0
    18px
    calc(16px + var(--fg-safe-bottom));
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ---- Top-right social (icons only) ---- */
.fg-social {
  position: absolute;
  top: calc(10px + var(--fg-safe-top));
  right: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 5;
  width: 46px;
}

.fg-social__ico {
  width: 46px;
  height: 46px;
  display: block;
  text-decoration: none;
  background: transparent;
  box-shadow: none;
  flex-shrink: 0;
  transition: transform 0.12s ease;
}

.fg-social__ico img {
  width: 46px;
  height: 46px;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.28));
}

.fg-social__ico:active { transform: scale(0.94); }

/* ---- Form — no panel background, blends with page ---- */
.fg-panel {
  flex-shrink: 0;
  width: 100%;
  margin-top: -36px;
  padding: 20px 4px 18px;
  background: none;
  border: 0;
  box-shadow: none;
  position: relative;
  z-index: 3;
}

.fg-panel__title {
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: 'Cinzel', 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #f3d56a;
  text-shadow:
    0 1px 0 #8a6a12,
    0 2px 4px rgba(0, 0, 0, 0.75),
    0 0 12px rgba(0, 0, 0, 0.45);
}

.fg-diamond {
  width: 9px;
  height: 9px;
  background: linear-gradient(180deg, #ffe9a0, #d4a017);
  transform: rotate(45deg);
  box-shadow: 0 0 8px rgba(243, 213, 106, 0.55);
  flex-shrink: 0;
}

.fg-alerts {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
}

.fg-alert {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 241, 241, 0.95);
  color: #9b1c1c;
  font-size: 12px;
  font-weight: 700;
}

.fg-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fg-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  height: 48px;
  padding: 0 2px 10px;
  background: transparent !important;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.fg-field::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1.5px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(243, 213, 106, 0.28) 12%,
    rgba(243, 213, 106, 0.72) 50%,
    rgba(243, 213, 106, 0.28) 88%,
    transparent 100%
  );
  pointer-events: none;
  transition: height 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.fg-field:focus-within::after {
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 233, 160, 0.55) 10%,
    #f3d56a 50%,
    rgba(255, 233, 160, 0.55) 90%,
    transparent 100%
  );
  box-shadow: 0 0 10px rgba(243, 213, 106, 0.45);
}

.fg-ico {
  width: 26px;
  height: 26px;
  border-radius: 0;
  display: grid;
  place-items: center;
  background: transparent !important;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
}

.fg-ico img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}

.fg-prefix {
  font-size: 14px;
  font-weight: 800;
  color: #f3d56a;
  flex-shrink: 0;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.65),
    0 0 8px rgba(0, 0, 0, 0.35);
}

.fg-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent !important;
  background-color: transparent !important;
  box-shadow: none !important;
  -webkit-appearance: none;
  appearance: none;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  color: #fffef5;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.7),
    0 0 6px rgba(0, 0, 0, 0.4);
  caret-color: #f3d56a;
}

.fg-field input::placeholder {
  color: rgba(255, 254, 245, 0.9);
  font-weight: 600;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.55),
    0 0 6px rgba(0, 0, 0, 0.35);
  opacity: 1;
}

.fg-field input:-webkit-autofill,
.fg-field input:-webkit-autofill:hover,
.fg-field input:-webkit-autofill:focus,
.fg-field input:-webkit-autofill:active {
  -webkit-text-fill-color: #fffef5 !important;
  caret-color: #f3d56a;
  transition: background-color 99999s ease-out 0s;
  box-shadow: 0 0 0 1000px transparent inset !important;
}

.fg-eye {
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: rgba(255, 254, 245, 0.78);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.fg-eye svg { width: 17px; height: 17px; }
.fg-eye.is-on { color: #f3d56a; }

.fg-submit {
  margin-top: 14px;
  width: 100%;
  min-height: 40px;
  padding: 9px 16px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  color: #5a3b08;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: linear-gradient(180deg, #ffe08a 0%, #f0c84a 42%, #d4a017 100%);
  box-shadow:
    0 3px 0 #8a6a12,
    0 8px 14px rgba(6, 40, 18, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.fg-submit__arrow {
  font-size: 18px;
  line-height: 1;
  font-weight: 400;
}

.fg-submit:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #8a6a12, 0 6px 12px rgba(6, 40, 18, 0.18);
}

.fg-switch {
  margin: 12px 0 2px;
  text-align: center;
  font-size: 12px;
  font-weight: 650;
  color: rgba(255, 254, 245, 0.88);
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.65),
    0 0 8px rgba(0, 0, 0, 0.35);
}

.fg-switch a {
  color: #f3d56a;
  font-weight: 800;
  text-decoration: none;
  text-shadow:
    0 1px 0 #8a6a12,
    0 2px 4px rgba(0, 0, 0, 0.65);
}

/* ---- Cozy village with walking people ---- */
.fg-village {
  --door-a: 18%;
  --door-b: 50%;
  --door-c: 82%;
  position: relative;
  width: calc(100% + 36px);
  margin: 0 -18px 0;
  height: auto;
  padding-top: var(--fg-safe-top);
  flex-shrink: 0;
  overflow: hidden;
  pointer-events: none;
  background: transparent;
}

.fg-village__art {
  position: relative;
  z-index: 0;
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 10px 18px rgba(8, 28, 18, 0.28));
}

.fg-hud {
  position: absolute;
  z-index: 4;
  top: calc(14px + var(--fg-safe-top));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 20px);
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
}

.fg-hud__stats {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 4px;
  width: 100%;
  max-width: 100%;
}

.fg-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 0 1 auto;
  min-width: 0;
  min-height: 28px;
  padding: 3px 8px 3px 6px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, #6a4324 0%, #3d2412 100%);
  box-shadow:
    0 2px 0 #241408,
    0 6px 10px rgba(20, 10, 4, 0.28),
    inset 0 1px 0 rgba(255, 220, 170, 0.22);
  border: 1px solid rgba(255, 214, 160, 0.18);
}

.fg-chip svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}

.fg-chip__val {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.55);
  white-space: nowrap;
}

.fg-chip__val--ore { color: #ff9a3c; }
.fg-chip__val--heart { color: #ff6ea8; }
.fg-chip__val--gnome { color: #7dff7a; }
.fg-chip__val--gold { color: #ffe14a; }

.fg-hud__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 6px 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff5a4a 0%, #e12626 58%, #c31b1b 100%);
  color: #fffef8;
  font-family: 'Cinzel', 'Playfair Display', serif;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-shadow: 0 1px 0 #8a1414, 0 2px 4px rgba(80, 0, 0, 0.45);
  box-shadow:
    0 3px 0 #8d1414,
    0 8px 14px rgba(90, 10, 10, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.fg-hud__cta--link {
  pointer-events: auto;
  text-decoration: none;
}

.fg-village__lane {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 20%;
  height: 48px;
  z-index: 2;
}

.fg-villager {
  position: absolute;
  bottom: 0;
  width: 28px;
  height: 42px;
  margin-left: -14px;
  transform-origin: 50% 100%;
  will-change: left, opacity, transform;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.4));
}

.fg-villager img,
.fg-villager__body {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center bottom;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: transparent;
  transform-origin: 50% 100%;
  animation: fg-bob 0.28s ease-in-out infinite alternate;
}

.fg-villager--a { animation: fg-walk-a 12s linear infinite; }
.fg-villager--b { animation: fg-walk-b 14s linear infinite; }
.fg-villager--c { animation: fg-walk-c 16s linear infinite; }

@keyframes fg-bob {
  from { transform: translateY(0); }
  to { transform: translateY(-2px); }
}

@keyframes fg-walk-a {
  0%   { left: var(--door-a); opacity: 1; transform: scaleX(1); }
  18%  { left: calc(var(--door-b) - 8%); opacity: 1; transform: scaleX(1); }
  24%  { left: var(--door-b); opacity: 0; transform: scaleX(1) scale(0.25) translateY(-10px); }
  32%  { left: var(--door-c); opacity: 0; transform: scaleX(-1) scale(0.25) translateY(-10px); }
  34%  { left: var(--door-c); opacity: 1; transform: scaleX(-1); }
  52%  { left: calc(var(--door-b) + 8%); opacity: 1; transform: scaleX(-1); }
  58%  { left: var(--door-b); opacity: 0; transform: scaleX(-1) scale(0.25) translateY(-10px); }
  66%  { left: var(--door-a); opacity: 0; transform: scaleX(1) scale(0.25) translateY(-10px); }
  68%  { left: var(--door-a); opacity: 1; transform: scaleX(1); }
  100% { left: var(--door-a); opacity: 1; transform: scaleX(1); }
}

@keyframes fg-walk-b {
  0%   { left: var(--door-b); opacity: 1; transform: scaleX(-1); }
  16%  { left: calc(var(--door-a) + 8%); opacity: 1; transform: scaleX(-1); }
  22%  { left: var(--door-a); opacity: 0; transform: scaleX(-1) scale(0.25) translateY(-10px); }
  32%  { left: var(--door-c); opacity: 0; transform: scaleX(-1) scale(0.25) translateY(-10px); }
  34%  { left: var(--door-c); opacity: 1; transform: scaleX(-1); }
  52%  { left: calc(var(--door-b) + 8%); opacity: 1; transform: scaleX(-1); }
  58%  { left: var(--door-b); opacity: 0; transform: scaleX(-1) scale(0.25) translateY(-10px); }
  66%  { left: var(--door-a); opacity: 0; transform: scaleX(1) scale(0.25) translateY(-10px); }
  68%  { left: var(--door-a); opacity: 1; transform: scaleX(1); }
  86%  { left: calc(var(--door-b) - 8%); opacity: 1; transform: scaleX(1); }
  92%  { left: var(--door-b); opacity: 0; transform: scaleX(1) scale(0.25) translateY(-10px); }
  100% { left: var(--door-b); opacity: 0; transform: scaleX(-1) scale(0.25) translateY(-10px); }
}

@keyframes fg-walk-c {
  0%   { left: var(--door-c); opacity: 1; transform: scaleX(-1); }
  18%  { left: calc(var(--door-b) + 8%); opacity: 1; transform: scaleX(-1); }
  24%  { left: var(--door-b); opacity: 0; transform: scaleX(-1) scale(0.25) translateY(-10px); }
  34%  { left: var(--door-a); opacity: 0; transform: scaleX(1) scale(0.25) translateY(-10px); }
  36%  { left: var(--door-a); opacity: 1; transform: scaleX(1); }
  54%  { left: calc(var(--door-b) - 8%); opacity: 1; transform: scaleX(1); }
  60%  { left: var(--door-b); opacity: 0; transform: scaleX(1) scale(0.25) translateY(-10px); }
  70%  { left: var(--door-c); opacity: 0; transform: scaleX(-1) scale(0.25) translateY(-10px); }
  72%  { left: var(--door-c); opacity: 1; transform: scaleX(-1); }
  100% { left: var(--door-c); opacity: 1; transform: scaleX(-1); }
}

@media (prefers-reduced-motion: reduce) {
  .fg-villager,
  .fg-villager__body {
    animation: none;
  }
  .fg-villager--a { left: var(--door-a); }
  .fg-villager--b { left: var(--door-b); }
  .fg-villager--c { left: var(--door-c); }
}

@media (max-width: 360px) {
  .fg-panel__title { font-size: 20px; }
  .fg-village__lane { height: 42px; }
  .fg-villager { width: 24px; height: 36px; margin-left: -12px; }
  .fg-hud__stats { gap: 3px; }
  .fg-chip { padding: 3px 6px 3px 5px; gap: 3px; }
  .fg-chip svg { width: 12px; height: 12px; }
  .fg-chip__val { font-size: 9px; }
  .fg-hud__cta { font-size: 11px; padding: 5px 12px; min-height: 28px; }
}
