/* A Game For The Nature — game HUD, overlays and screens.
   Everything is scoped under .agftn3d so it never leaks into the theme. */

.agftn3d {
  --agftn-accent: #f7a41d;
  --agftn-bg: rgba(8, 15, 24, 0.78);
  --agftn-bg-strong: rgba(8, 15, 24, 0.9);
  --agftn-line: rgba(255, 255, 255, 0.14);
  --agftn-text: #f3f6fa;
  --agftn-muted: #a9b6c6;
  --agftn-ok: #3ecf8e;
  --agftn-danger: #ff5d5d;
  --agftn-radius: 18px;
  position: relative;
  width: 100%;
  min-height: 320px;
  overflow: hidden;
  background: #05080d;
  color: var(--agftn-text);
  font-family: "Montserrat", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  outline: none;
  isolation: isolate;
  box-sizing: border-box;
}
.agftn3d *, .agftn3d *::before, .agftn3d *::after { box-sizing: border-box; }
.agftn3d:fullscreen { width: 100vw; height: 100vh !important; }
.agftn3d:focus-visible { box-shadow: inset 0 0 0 3px var(--agftn-accent); }
.agftn3d [hidden] { display: none !important; }
.agftn3d h2, .agftn3d h3, .agftn3d p, .agftn3d ul, .agftn3d li, .agftn3d a, .agftn3d button, .agftn3d select { font-family: inherit; letter-spacing: normal; text-transform: none; text-shadow: none; }
.agftn3d button { box-shadow: none; }
.agftn3d button { font-family: inherit; font-size: inherit; line-height: 1.2; }

.agftn3d .agftn3d__canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
.agftn3d.is-dragging .agftn3d__canvas { cursor: grabbing; }

/* Logo */
.agftn3d__logo {
  position: absolute; top: 14px; left: 14px; z-index: 6;
  max-width: min(230px, 38%); max-height: 64px; width: auto; height: auto;
  background: #fff; padding: 6px 10px; border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.agftn3d--logo-top-right .agftn3d__logo { left: auto; right: 14px; }

/* HUD */
.agftn3d__hud { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.agftn3d .agftn3d__level {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 18px 9px; border-radius: 14px;
  background: var(--agftn-bg); border: 1px solid var(--agftn-line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  text-align: center; max-width: min(560px, 60%);
}
.agftn3d .agftn3d__level-label { font-size: 11px; letter-spacing: 0.18em; font-weight: 800; color: var(--agftn-accent); }
.agftn3d .agftn3d__level-title { font-size: 15px; font-weight: 700; line-height: 1.2; }
.agftn3d .agftn3d__level-day { font-size: 12px; color: var(--agftn-muted); }
.agftn3d .agftn3d__progress {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; gap: 5px; width: min(520px, 70%);
}
.agftn3d .agftn3d__seg { flex: 1; height: 7px; border-radius: 6px; background: rgba(255, 255, 255, 0.16); overflow: hidden; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35); }
.agftn3d .agftn3d__seg i { display: block; height: 100%; width: 0; background: var(--agftn-accent); border-radius: inherit; transition: width 0.25s linear; }
.agftn3d .agftn3d__seg.is-done i { background: var(--agftn-ok); }
.agftn3d .agftn3d__buttons { position: absolute; top: 14px; right: 14px; display: flex; gap: 8px; pointer-events: auto; }
.agftn3d--logo-top-right .agftn3d__buttons { top: 88px; }
.agftn3d .agftn3d__btn {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: var(--agftn-bg); border: 1px solid var(--agftn-line); color: var(--agftn-text);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  cursor: pointer; transition: transform 0.15s ease, background 0.15s ease;
}
.agftn3d .agftn3d__btn svg { width: 22px; height: 22px; fill: currentColor; }
.agftn3d .agftn3d__btn:hover { background: rgba(255, 255, 255, 0.14); transform: translateY(-1px); }
.agftn3d .agftn3d__btn:focus-visible { outline: 3px solid var(--agftn-accent); outline-offset: 2px; }
.agftn3d .agftn3d__btn[aria-pressed="false"] { opacity: 0.55; }
.agftn3d .agftn3d__prompt {
  position: absolute; left: 50%; bottom: 58px; transform: translateX(-50%);
  padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: 15px;
  background: var(--agftn-bg-strong); border: 1px solid var(--agftn-accent);
  box-shadow: 0 0 24px color-mix(in srgb, var(--agftn-accent) 45%, transparent);
  opacity: 0; transition: opacity 0.2s ease, transform 0.2s ease; white-space: nowrap;
}
.agftn3d .agftn3d__prompt.is-visible { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.agftn3d .agftn3d__prompt kbd, .agftn3d kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px; margin: 0 2px; border-radius: 6px;
  background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.25);
  font: 700 12px/1.5 inherit; text-align: center; color: var(--agftn-text);
}
.agftn3d .agftn3d__toast {
  position: absolute; left: 50%; top: 96px; transform: translateX(-50%) scale(0.96);
  padding: 12px 22px; border-radius: 14px; font-weight: 700; text-align: center;
  background: var(--agftn-bg-strong); border: 1px solid var(--agftn-line);
  opacity: 0; transition: opacity 0.3s ease, transform 0.3s ease; max-width: 80%;
}
.agftn3d .agftn3d__toast.is-visible { opacity: 1; transform: translateX(-50%) scale(1); }
.agftn3d .agftn3d__toast--big { font-size: 22px; letter-spacing: 0.02em; }
.agftn3d .agftn3d__toast--big small { display: block; font-size: 12px; letter-spacing: 0.2em; color: var(--agftn-accent); }
.agftn3d .agftn3d__toast--bad { border-color: var(--agftn-danger); }
.agftn3d .agftn3d__toast--good { border-color: var(--agftn-ok); }
.agftn3d .agftn3d__hint { position: absolute; left: 14px; bottom: 14px; font-size: 12px; color: rgba(255, 255, 255, 0.7); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); }
.agftn3d.is-touch .agftn3d__hint { display: none; }

/* Edge vignette when the player is close to stepping off */
.agftn3d::after {
  content: ""; position: absolute; inset: 0; z-index: 4; pointer-events: none;
  box-shadow: inset 0 0 120px 30px rgba(255, 40, 30, 0.55);
  opacity: var(--agftn-warn, 0); transition: opacity 0.15s linear;
}

/* Fade to black / white */
.agftn3d__fade { position: absolute; inset: 0; z-index: 20; background: #000; opacity: 0; pointer-events: none; transition: opacity 0.7s ease; }
.agftn3d .agftn3d__fade.is-on { opacity: 1; }
.agftn3d .agftn3d__fade.is-white { background: #fff; }

/* Panel overlay: right-side card, the 3D view stays visible */
.agftn3d__panel {
  position: absolute; inset: 0; z-index: 12; display: flex; align-items: center; justify-content: flex-end;
  padding: 80px 24px 60px; pointer-events: none;
}
.agftn3d .agftn3d__panel-card {
  pointer-events: auto; width: min(460px, 100%); max-height: 100%; overflow: auto;
  padding: 26px 26px 22px; border-radius: var(--agftn-radius);
  background: var(--agftn-bg-strong); border: 1px solid var(--agftn-line);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: agftn3d-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  user-select: text; -webkit-user-select: text;
}
.agftn3d .agftn3d__eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; color: var(--agftn-accent); }
.agftn3d .agftn3d__panel-day { color: var(--agftn-muted); letter-spacing: 0.06em; }
.agftn3d .agftn3d__panel-title { margin: 0 0 14px; font-size: 22px; line-height: 1.25; font-weight: 800; color: #fff; }
.agftn3d .agftn3d__panel-list { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 9px; }
.agftn3d .agftn3d__panel-list li {
  position: relative; padding: 10px 12px 10px 38px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.07); font-size: 15px;
  animation: agftn3d-in 0.4s both cubic-bezier(0.2, 0.8, 0.2, 1);
}
.agftn3d .agftn3d__panel-list li::before {
  content: ""; position: absolute; left: 14px; top: 16px; width: 10px; height: 10px; border-radius: 3px;
  background: var(--agftn-accent); transform: rotate(45deg); box-shadow: 0 0 10px var(--agftn-accent);
}
.agftn3d .agftn3d__panel-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

/* Buttons */
.agftn3d__cta {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 20px; border-radius: 999px; cursor: pointer;
  background: rgba(255, 255, 255, 0.08); color: var(--agftn-text); border: 1px solid rgba(255, 255, 255, 0.2);
  font-weight: 700; text-decoration: none; transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.agftn3d .agftn3d__cta:hover { background: rgba(255, 255, 255, 0.16); transform: translateY(-1px); color: var(--agftn-text); }
.agftn3d .agftn3d__cta:focus-visible { outline: 3px solid var(--agftn-accent); outline-offset: 3px; }
.agftn3d .agftn3d__cta--primary { background: var(--agftn-accent); border-color: transparent; color: #1a1206; box-shadow: 0 8px 24px color-mix(in srgb, var(--agftn-accent) 40%, transparent); }
.agftn3d .agftn3d__cta--primary:hover { background: var(--agftn-accent); color: #1a1206; filter: brightness(1.08); }
.agftn3d .agftn3d__cta--big { font-size: 18px; padding: 14px 30px; min-height: 54px; }

/* Screens (loading / start / pause / final / error) */
.agftn3d__screen {
  position: absolute; inset: 0; z-index: 15; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(ellipse at center, rgba(5, 10, 18, 0.35), rgba(5, 10, 18, 0.8));
}
.agftn3d .agftn3d__screen--loading { background: radial-gradient(ellipse at 50% 30%, #12304a 0%, #05080d 70%); z-index: 18; transition: opacity 0.6s ease; }
.agftn3d .agftn3d__screen--loading.is-leaving { opacity: 0; pointer-events: none; }
.agftn3d .agftn3d__screen--start { background: linear-gradient(180deg, rgba(5, 10, 18, 0.05) 30%, rgba(5, 10, 18, 0.75)); align-items: flex-end; padding-bottom: 7%; }
.agftn3d .agftn3d__screen-card {
  width: min(560px, 100%); max-height: 100%; overflow: auto; text-align: center;
  padding: 30px 28px; border-radius: 22px;
  background: var(--agftn-bg); border: 1px solid var(--agftn-line);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  animation: agftn3d-in 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.agftn3d .agftn3d__screen-card--wide { width: min(760px, 100%); }
.agftn3d .agftn3d__big { margin: 0 0 10px; font-size: clamp(26px, 5vw, 44px); line-height: 1.05; font-weight: 900; letter-spacing: 0.01em; text-transform: uppercase; color: #fff; }
.agftn3d .agftn3d__big--sm { font-size: clamp(22px, 3.5vw, 30px); }
.agftn3d .agftn3d__sub { margin: 0 auto 20px; max-width: 520px; color: #d4dde8; font-size: 16px; }
.agftn3d .agftn3d__bar { height: 8px; margin: 22px auto 10px; max-width: 360px; border-radius: 8px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.agftn3d .agftn3d__bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--agftn-accent), #ffe08a); transition: width 0.3s ease; }
.agftn3d .agftn3d__loading-text { margin: 0; color: var(--agftn-muted); font-size: 14px; }
.agftn3d .agftn3d__controls-help { margin-top: 20px; font-size: 13px; color: var(--agftn-muted); }
.agftn3d .agftn3d__keys-desktop { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 16px; }
.agftn3d .agftn3d__keys-touch { display: none; }
.agftn3d.is-touch .agftn3d__keys-desktop { display: none; }
.agftn3d.is-touch .agftn3d__keys-touch { display: block; }
.agftn3d .agftn3d__warn { margin: 12px 0 0; color: #ffd08a; font-weight: 600; }
.agftn3d .agftn3d__menu { display: grid; gap: 10px; max-width: 320px; margin: 16px auto 0; }
.agftn3d .agftn3d__field { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 600; color: var(--agftn-muted); text-align: left; }
.agftn3d .agftn3d__field select {
  min-height: 40px; padding: 6px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.08);
  color: var(--agftn-text); border: 1px solid rgba(255, 255, 255, 0.2); font: inherit;
}
.agftn3d .agftn3d__field select option { color: #111; }
.agftn3d .agftn3d__form-wrap { margin: 10px 0 16px; border-radius: 14px; overflow: hidden; background: #fff; height: min(60vh, 560px); }
.agftn3d .agftn3d__form { width: 100%; height: 100%; border: 0; display: block; }
.agftn3d .agftn3d__error-text { color: #ffb4b4; }

/* Touch controls */
.agftn3d__touch { position: absolute; inset: 0; z-index: 7; pointer-events: none; }
.agftn3d .agftn3d__joy {
  position: absolute; left: 22px; bottom: 44px; width: 132px; height: 132px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.08); border: 2px solid rgba(255, 255, 255, 0.25);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); pointer-events: auto; touch-action: none;
}
.agftn3d .agftn3d__joy-knob {
  position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.45); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  transition: transform 0.08s linear;
}
.agftn3d .agftn3d__act, .agftn3d .agftn3d__run {
  position: absolute; right: 26px; bottom: 60px; width: 76px; height: 76px; border-radius: 50%;
  background: color-mix(in srgb, var(--agftn-accent) 75%, transparent); color: #1a1206; border: 2px solid rgba(255, 255, 255, 0.5);
  font-size: 26px; font-weight: 900; pointer-events: auto; touch-action: none;
}
.agftn3d .agftn3d__run { right: 116px; bottom: 36px; width: 56px; height: 56px; background: rgba(255, 255, 255, 0.14); color: #fff; display: grid; place-items: center; }
.agftn3d .agftn3d__run svg { width: 26px; height: 26px; fill: currentColor; }
.agftn3d .agftn3d__run[aria-pressed="true"] { background: color-mix(in srgb, var(--agftn-accent) 60%, transparent); }
.agftn3d .agftn3d__gyro {
  position: absolute; right: 16px; top: 70px; padding: 8px 14px; border-radius: 999px; pointer-events: auto;
  background: var(--agftn-bg); color: var(--agftn-text); border: 1px solid var(--agftn-line); font-size: 13px; font-weight: 700;
}
.agftn3d .agftn3d__gyro[aria-pressed="true"] { border-color: var(--agftn-accent); color: var(--agftn-accent); }

/* Minigame host */
.agftn3d__mg-host { position: absolute; inset: 0; z-index: 14; }

/* Screen-reader / SEO programme: visually hidden, still in the DOM */
.agftn3d__sr {
  position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important;
  overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important;
}
.agftn3d .agftn3d__noscript { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 20px; text-align: center; }

@keyframes agftn3d-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }

@media (max-width: 720px) {
  .agftn3d .agftn3d__level { top: 66px; max-width: 76%; padding: 6px 12px; }
  .agftn3d .agftn3d__level-title { font-size: 13px; }
  .agftn3d .agftn3d__level-day { display: none; }
  .agftn3d .agftn3d__logo { max-height: 42px; max-width: 30%; padding: 4px 6px; top: 10px; }
  .agftn3d .agftn3d__buttons { top: auto; bottom: 208px; right: 10px; flex-direction: column; }
  .agftn3d--logo-top-right .agftn3d__buttons { top: auto; }
  .agftn3d .agftn3d__btn { width: 38px; height: 38px; }
  .agftn3d .agftn3d__progress { bottom: 10px; width: 60%; }
  .agftn3d .agftn3d__panel { align-items: flex-end; justify-content: center; padding: 70px 12px 14px; }
  .agftn3d .agftn3d__panel-card { max-height: 70%; padding: 20px 18px 16px; }
  .agftn3d .agftn3d__panel-title { font-size: 19px; }
  .agftn3d .agftn3d__prompt { bottom: 190px; font-size: 13px; }
  .agftn3d .agftn3d__toast { top: 80px; }
}
@media (prefers-reduced-motion: reduce) {
  .agftn3d *, .agftn3d *::before, .agftn3d *::after { animation: none !important; transition: none !important; }
}

/* Thin, discreet scrollbars inside cards */
.agftn3d__panel-card, .agftn3d .agftn3d__screen-card { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.25) transparent; }
.agftn3d .agftn3d__panel-card::-webkit-scrollbar, .agftn3d .agftn3d__screen-card::-webkit-scrollbar { width: 6px; }
.agftn3d .agftn3d__panel-card::-webkit-scrollbar-thumb, .agftn3d .agftn3d__screen-card::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.25); border-radius: 6px; }
