/* The Last Trencher — celestial / heavenly fantasy theme.
   Palette drawn from the logo: sky blue, white clouds, silver filigree. */
:root {
  --sky-light: #d7ecff;
  --sky: #4aa6ff;
  --sky-deep: #1773e6;
  --abyss: #06223f;          /* deep blue for contrast */
  --silver: #f3f9ff;
  --silver-dim: #cfe2f7;
  --glow: #9fd2ff;
  --text: #eef6ff;
  --muted: #a9c4e0;
  --danger: #ff8aa0;
  --ok: #8ff0d2;
  --serif: "Cinzel", "Times New Roman", serif;
  --body: "Cormorant Garamond", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #04101f;
  color: var(--text);
  font-family: var(--body);
  overflow: hidden;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

#app { position: fixed; inset: 0; }

/* ---- Cinematic video background + filter stack ---- */
.bg-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  /* tasteful cinematic grade so the celestial scene reads behind the UI */
  filter: saturate(1.12) contrast(1.04) brightness(0.9) blur(1px);
  transform: scale(1.04); /* hide blur edge bleed */
  z-index: 0;
}
.bg-filter {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(8,34,63,0.30) 0%, rgba(6,24,48,0.20) 38%, rgba(4,16,32,0.74) 100%),
    radial-gradient(120% 90% at 50% 22%, rgba(74,166,255,0.18) 0%, rgba(6,24,48,0) 55%);
}
.bg-vignette {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  box-shadow: inset 0 0 240px 60px rgba(2,12,26,0.85);
}
.music-toggle {
  position: fixed; top: 14px; right: 14px; z-index: 60;
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  background: rgba(13,40,72,0.55); border: 1px solid rgba(207,226,247,0.4);
  color: var(--silver); font-size: 16px; backdrop-filter: blur(6px);
}
.music-toggle:hover { background: rgba(159,210,255,0.2); }
.music-toggle.off { opacity: 0.5; }

/* ---- Unity canvas host ---- */
#gameContainer {
  position: absolute; inset: 0; display: none; background: #000; z-index: 6;
}
#gameContainer canvas { width: 100% !important; height: 100% !important; display: block; }
body.playing #gameContainer { display: block; }
body.playing #landing { display: none; }

/* ---- Landing ---- */
#landing {
  position: absolute; inset: 0; z-index: 4;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(10px, 2vh, 20px);
  padding: clamp(14px, 3vh, 28px) 16px;
  /* respect notches / home indicators on phones */
  padding-bottom: calc(clamp(14px, 3vh, 28px) + env(safe-area-inset-bottom, 0px));
  text-align: center;
  /* Short screens scroll instead of letting blocks pile onto each other. */
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.brand { display: flex; flex-direction: column; align-items: center; gap: clamp(5px, 1vh, 8px); }
.logo-wrap { position: relative; }
.logo {
  /* capped by height too — vertical space is what actually runs out */
  width: min(clamp(150px, 26vw, 262px), 27vh);
  height: auto; display: block;
  /* The crest is a transparent PNG, so glow must follow its alpha — box-shadow
     would draw a rectangle around the element box instead of the artwork. */
  filter:
    drop-shadow(0 4px 16px rgba(2, 12, 26, 0.7))
    drop-shadow(0 0 30px rgba(120, 190, 255, 0.42));
  animation: floaty 6s ease-in-out infinite;
}
@keyframes floaty { 0%,100% { transform: translateY(-4px);} 50% { transform: translateY(6px);} }

.brand .tag {
  font-family: var(--body);
  font-size: clamp(14px, 1.9vw, 19px);
  font-style: italic;
  letter-spacing: 0.5px;
  color: var(--sky-light);
  text-shadow: 0 1px 14px rgba(74,166,255,0.6);
}
.brand .token {
  margin-top: 2px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--silver);
  border: 1px solid rgba(207,226,247,0.5);
  border-radius: 999px;
  padding: 4px 16px;
  background: rgba(23,115,230,0.18);
  box-shadow: 0 0 18px rgba(74,166,255,0.35), inset 0 0 12px rgba(255,255,255,0.08);
}
.brand .online {
  margin-top: clamp(2px, 0.8vh, 8px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--silver-dim);
}
.brand .online .odot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #8ff0d2; box-shadow: 0 0 10px #8ff0d2;
  animation: boe-pulse 2s ease-in-out infinite;
}
@keyframes boe-pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ---- Forge Your Hero (character customizer) ---- */
.forge-toggle { font-size: 13px; }
.forge {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px; margin: -2px 0 2px;
  background: rgba(2,12,26,0.4);
  border: 1px solid rgba(207,226,247,0.22); border-radius: 10px;
}
.hero-name {
  width: 100%; box-sizing: border-box;
  background: rgba(2,12,26,0.55); border: 1px solid rgba(207,226,247,0.3);
  border-radius: 8px; color: var(--silver); font-family: var(--serif);
  font-size: 14px; letter-spacing: 1px; text-align: center; padding: 9px 10px; outline: none;
}
.hero-name:focus { border-color: var(--sky); }
.forge-rows { display: flex; flex-direction: column; gap: 7px; }
.frow { display: flex; align-items: center; gap: 8px; }
.frow .flbl {
  flex: 0 0 78px; font-family: var(--serif); font-size: 11px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--muted);
}
.frow .fval {
  flex: 1; text-align: center; font-family: var(--serif); font-size: 13px;
  color: var(--silver); display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 22px;
}
.frow .fbtn {
  flex: 0 0 30px; height: 30px; cursor: pointer;
  background: rgba(159,210,255,0.08); border: 1px solid rgba(207,226,247,0.3);
  border-radius: 8px; color: var(--silver); font-size: 15px; line-height: 1;
}
.frow .fbtn:hover { background: rgba(159,210,255,0.2); border-color: rgba(255,255,255,0.7); }
.frow .swatch {
  width: 30px; height: 16px; border-radius: 4px; display: inline-block;
  border: 1px solid rgba(255,255,255,0.55); box-shadow: 0 0 8px rgba(74,166,255,0.4);
}

/* ---- Ornate framed panel ---- */
.panel {
  position: relative;
  width: min(420px, 92vw);
  padding: clamp(16px, 2.4vh, 26px) clamp(16px, 3vw, 24px);
  display: flex; flex-direction: column; gap: clamp(9px, 1.5vh, 14px);
  background: linear-gradient(180deg, rgba(13,40,72,0.62), rgba(6,22,44,0.72));
  border: 1px solid rgba(207,226,247,0.45);
  border-radius: 16px;
  backdrop-filter: blur(9px) saturate(1.1);
  box-shadow:
    0 0 0 1px rgba(74,166,255,0.18),
    0 24px 70px rgba(2,12,26,0.6),
    inset 0 0 22px rgba(159,210,255,0.10),
    inset 0 1px 0 rgba(255,255,255,0.18);
}
/* inner hairline frame, like the logo's filigree border */
.panel::before {
  content: ""; position: absolute; inset: 7px; border-radius: 11px;
  border: 1px solid rgba(207,226,247,0.22); pointer-events: none;
}
.panel .corner {
  position: absolute; color: var(--silver); font-size: 13px; opacity: 0.85;
  text-shadow: 0 0 10px rgba(159,210,255,0.9); pointer-events: none;
}
.panel .corner.tl { top: 6px; left: 9px; }
.panel .corner.tr { top: 6px; right: 9px; }
.panel .corner.bl { bottom: 6px; left: 9px; }
.panel .corner.br { bottom: 6px; right: 9px; }

button.cta, button.ghost {
  appearance: none; cursor: pointer;
  font-family: var(--serif);
  font-weight: 600; letter-spacing: 2px; text-transform: uppercase;
  border-radius: 11px;
  padding: clamp(11px, 1.6vh, 14px) 18px;
  font-size: clamp(13px, 1.6vh, 15px);
  min-height: 44px; /* iOS/Android minimum comfortable touch target */
  transition: transform 0.08s ease, filter 0.18s ease, box-shadow 0.18s ease;
}
button.cta {
  border: 1px solid rgba(255,255,255,0.7);
  color: #07223f;
  background: linear-gradient(180deg, #ffffff 0%, #dcecff 48%, #a9d2ff 100%);
  box-shadow: 0 0 22px rgba(120,190,255,0.55), inset 0 1px 0 rgba(255,255,255,0.9);
  text-shadow: 0 1px 0 rgba(255,255,255,0.6);
}
button.cta:hover { filter: brightness(1.06); box-shadow: 0 0 32px rgba(150,205,255,0.8), inset 0 1px 0 rgba(255,255,255,0.9); }
button.cta:active { transform: translateY(1px); }
button.cta[disabled] { opacity: 0.6; cursor: progress; }

button.ghost {
  color: var(--silver);
  background: rgba(159,210,255,0.06);
  border: 1px solid rgba(207,226,247,0.4);
  box-shadow: inset 0 0 16px rgba(159,210,255,0.08);
}
button.ghost:hover { background: rgba(159,210,255,0.14); border-color: rgba(207,226,247,0.7); }

.wallet-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-family: var(--serif); font-size: 12px; letter-spacing: 1px; color: var(--muted);
  background: rgba(2,12,26,0.4); border: 1px solid rgba(207,226,247,0.18);
  border-radius: 10px; padding: 10px 12px;
}
.wallet-row .addr { color: var(--ok); font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0; }

.status { min-height: 18px; font-size: 16px; color: var(--muted); font-style: italic; }
.status.err { color: var(--danger); }
.status.ok { color: var(--ok); }

/* ---- Links ---- */
.links { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.link-pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--serif); font-size: 13px; font-weight: 600; letter-spacing: 1.5px;
  text-decoration: none; color: var(--silver);
  padding: 10px 18px; border-radius: 999px;
  border: 1px solid rgba(207,226,247,0.4);
  background: rgba(13,40,72,0.45);
  backdrop-filter: blur(6px);
  box-shadow: 0 0 16px rgba(74,166,255,0.2);
  transition: transform 0.1s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.link-pill:hover { transform: translateY(-2px); border-color: rgba(255,255,255,0.8); box-shadow: 0 0 26px rgba(120,190,255,0.5); }
.link-pill .ico { font-size: 14px; opacity: 0.95; }
.link-pill.buy {
  color: #07223f;
  background: linear-gradient(180deg, #ffffff, #bfe0ff);
  border-color: rgba(255,255,255,0.8);
}
.link-pill.buy .buy-token { letter-spacing: 1px; }
/* Telegram — Robinhood green so the two socials read as a pair, not a clone */
.link-pill.tg {
  color: #d9ffe4;
  border-color: rgba(0, 200, 5, 0.55);
  background: rgba(6, 40, 16, 0.5);
  box-shadow: 0 0 16px rgba(0, 200, 5, 0.22);
}
.link-pill.tg:hover { border-color: rgba(0, 200, 5, 0.95); box-shadow: 0 0 26px rgba(0, 200, 5, 0.45); }

/* ---- Contract address (hidden until config.contract is set) ---- */
.ca {
  margin-top: 14px; text-align: center;
  font-family: var(--serif); font-size: 11px; letter-spacing: 1px;
  color: rgba(207, 226, 247, 0.72);
}
.ca .ca-lbl { opacity: 0.7; margin-right: 6px; }
.ca .ca-val {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px; letter-spacing: 0;
  color: #d9ffe4; cursor: pointer; border-bottom: 1px dashed rgba(0, 200, 5, 0.5);
}
.ca .ca-val:hover { color: #fff; border-bottom-color: rgba(0, 200, 5, 0.9); }

/* ---- Footer ---- */
/* In normal flow, NOT pinned to the viewport. Pinning it made it collide with
   the social pills whenever the centred content grew taller than the screen. */
.site-footer {
  margin-top: clamp(4px, 1vh, 10px);
  text-align: center; pointer-events: none;
  font-family: var(--serif);
  font-size: clamp(9px, 1.1vw, 11px);
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(207, 226, 247, 0.42);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

/* ---- Responsive: short viewports (landscape phones, small windows) ---- */
/* Vertical space is the binding constraint here — shrink the tall things. */
@media (max-height: 640px) {
  /* claw back vertical space so the default state needs no scrolling */
  #landing {
    gap: 6px;
    padding: 8px 16px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .brand { gap: 3px; }
  .logo { width: min(clamp(118px, 19vw, 168px), 24vh); animation: none; }
  .brand .tag { font-size: 13px; }
  .brand .token { font-size: 10px; letter-spacing: 2px; padding: 3px 12px; }
  .brand .online { font-size: 10px; letter-spacing: 1.5px; }
  .panel { padding: 10px 15px; gap: 7px; }
  .site-footer { margin-top: 2px; }
  button.cta, button.ghost { padding: 10px 14px; font-size: 13px; min-height: 40px; }
  .forge { padding: 9px; gap: 7px; }
  .forge-rows { gap: 5px; }
  .link-pill { padding: 8px 13px; font-size: 11px; }
}

/* ---- Responsive: narrow phones (portrait) ---- */
@media (max-width: 480px) {
  #landing { padding-left: 12px; padding-right: 12px; }
  .panel { width: 100%; }
  .brand .tag { font-size: 15px; }
  /* Pills share the row evenly instead of wrapping awkwardly. max-width keeps a
     single remaining pill from stretching into a full-width bar. */
  .links { gap: 8px; width: 100%; }
  .link-pill {
    flex: 1 1 auto; min-width: 0; max-width: 240px;
    justify-content: center; padding: 11px 10px;
  }
  /* Roomier steppers — 30px was under the comfortable tap size */
  .frow .flbl { flex: 0 0 60px; font-size: 10px; letter-spacing: 1px; }
  .frow .fbtn { flex: 0 0 36px; height: 36px; }
  .frow .fval { font-size: 12px; }
  .hero-name { font-size: 16px; } /* >=16px stops iOS auto-zooming on focus */
  .site-footer { font-size: 9px; letter-spacing: 1.5px; }
}

/* Users who prefer less motion shouldn't get the floating logo */
@media (prefers-reduced-motion: reduce) {
  .logo { animation: none; }
}

/* ---- Loading overlay ---- */
#loading {
  position: absolute; inset: 0; z-index: 7; display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: radial-gradient(80% 60% at 50% 45%, rgba(10,40,75,0.6), rgba(3,12,26,0.96));
}
body.loading #loading { display: flex; }
#loading .label { font-family: var(--serif); font-size: 20px; letter-spacing: 4px; color: var(--silver); text-shadow: 0 0 18px rgba(159,210,255,0.8); }
#loading .bar { width: min(360px, 80vw); height: 5px; border-radius: 999px; background: rgba(207,226,247,0.16); overflow: hidden; border: 1px solid rgba(207,226,247,0.2); }
#loading .bar > div { height: 100%; width: 0%; background: linear-gradient(90deg, #ffffff, var(--sky)); box-shadow: 0 0 12px var(--glow); transition: width 0.2s ease; }

/* ---- Mobile touch controls (shown only while playing on a touch device) ---- */
#touchControls { position: absolute; inset: 0; z-index: 8; display: none; pointer-events: none; }
body.playing.touch #touchControls { display: block; }

/* left half is the floating-joystick zone */
.joy-zone {
  position: absolute; left: 0; bottom: 0; width: 55%; height: 70%;
  pointer-events: auto; touch-action: none;
}
.joy-base {
  position: absolute; width: 112px; height: 112px; margin: -56px 0 0 -56px;
  border-radius: 50%; left: -999px; top: -999px;
  border: 1.5px solid rgba(207,226,247,0.5);
  background: radial-gradient(circle at 50% 40%, rgba(159,210,255,0.16), rgba(13,40,72,0.30));
  box-shadow: 0 0 22px rgba(74,166,255,0.35), inset 0 0 18px rgba(159,210,255,0.12);
  opacity: 0; transition: opacity 0.12s ease; pointer-events: none;
}
.joy-base.on { opacity: 1; }
.joy-knob {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #ffffff, #bfe0ff 60%, #79b4ff);
  border: 1px solid rgba(255,255,255,0.8);
  box-shadow: 0 0 18px rgba(120,190,255,0.7);
}
.act-cluster {
  position: absolute; right: 24px; bottom: 30px;
  display: flex; align-items: flex-end; gap: 16px; pointer-events: none;
}
.act-btn {
  pointer-events: auto; touch-action: none; cursor: pointer;
  width: 74px; height: 74px; border-radius: 50%;
  font-size: 30px; line-height: 1; color: #07223f;
  border: 1.5px solid rgba(255,255,255,0.8);
  background: radial-gradient(circle at 50% 38%, #ffffff, #cfe6ff 62%, #a9d2ff);
  box-shadow: 0 6px 18px rgba(2,12,26,0.5), 0 0 22px rgba(120,190,255,0.5), inset 0 1px 0 rgba(255,255,255,0.9);
  display: flex; align-items: center; justify-content: center;
  -webkit-user-select: none; user-select: none;
}
.act-btn.jump { width: 62px; height: 62px; font-size: 26px; }
.act-btn.pressed { transform: scale(0.92); filter: brightness(1.1); }

/* Fullscreen toggle (mobile) */
.fs-btn {
  position: absolute; top: 14px; right: 14px; z-index: 9; display: none;
  pointer-events: auto; cursor: pointer;
  width: 42px; height: 42px; border-radius: 11px; font-size: 18px; color: var(--silver);
  background: rgba(13,40,72,0.5); border: 1px solid rgba(207,226,247,0.4);
  backdrop-filter: blur(6px);
}
body.touch.playing .fs-btn { display: block; }

/* ---- Rotate-to-landscape guard ---- */
#rotate {
  position: fixed; inset: 0; z-index: 50; display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: radial-gradient(70% 60% at 50% 45%, rgba(10,40,75,0.7), rgba(3,12,26,0.98));
  text-align: center; padding: 24px; color: var(--silver); font-family: var(--serif); letter-spacing: 2px;
}
#rotate .icon { font-size: 46px; animation: tilt 1.6s ease-in-out infinite; }
@keyframes tilt { 0%,100% { transform: rotate(-12deg);} 50% { transform: rotate(78deg);} }
@media (max-width: 920px) and (orientation: portrait) {
  body.playing #rotate { display: flex; }
}
