:root {
  --bg: #090C12;
  --surface: #111622;
  --rim: rgba(255, 255, 255, 0.10);
  --text: #F4F7FC;
  --text-2: #9EACC2;
  --accent: #F0B429;
  --ad-h: 90px;
}
@media (max-width: 760px), (max-height: 520px) {
  :root { --ad-h: 60px; }
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
a { color: var(--text-2); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--text); }

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding-top: env(safe-area-inset-top, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  background: var(--bg);
}
#game { position: relative; flex: 1 1 auto; min-height: 0; }
#unity-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--bg);
  outline: none;
  touch-action: none;
}

/* ── Loader ── */
#loader {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  background: var(--bg);
  overflow: hidden;
  transition: opacity 0.5s ease, transform 0.5s ease;
}
#loader.is-done { opacity: 0; transform: scale(1.03); pointer-events: none; }

.loader__bg {
  position: absolute; inset: -2%;
  background: url("loader-bg.jpg") center center / cover no-repeat;
  opacity: 0.62;
  animation: nhDrift 26s ease-out forwards;
}
@keyframes nhDrift { from { transform: scale(1.00); } to { transform: scale(1.07); } }

.loader__vignette {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(9, 12, 18, 0.10) 0%, rgba(9, 12, 18, 0.70) 70%, rgba(9, 12, 18, 0.96) 100%),
    linear-gradient(180deg, rgba(9, 12, 18, 0.30) 0%, rgba(9, 12, 18, 0.00) 40%, rgba(9, 12, 18, 0.94) 100%);
}
.loader__grid {
  position: absolute; inset: 0; opacity: 0.18;
  background-image:
    linear-gradient(rgba(240, 180, 41, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(240, 180, 41, 0.18) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 60%, #000 0%, transparent 65%);
          mask-image: radial-gradient(ellipse at 50% 60%, #000 0%, transparent 65%);
  animation: nhGrid 18s linear infinite;
}
@keyframes nhGrid { from { background-position: 0 0, 0 0; } to { background-position: 0 56px, 56px 0; } }

.loader__hero {
  position: relative; z-index: 2; flex: 1 1 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 20px 0;
  animation: nhRise 0.8s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes nhRise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.loader__emblem { position: relative; width: 104px; height: 104px; margin-bottom: 20px; }
.loader__halo {
  position: absolute; inset: -18px; border-radius: 50%;
  background: radial-gradient(circle, rgba(240, 180, 41, 0.38) 0%, rgba(240, 180, 41, 0) 68%);
  animation: nhPulse 2.6s ease-in-out infinite;
}
@keyframes nhPulse { 0%, 100% { opacity: 0.55; transform: scale(0.94); } 50% { opacity: 1; transform: scale(1.06); } }
.loader__logo {
  position: relative; width: 104px; height: 104px; border-radius: 24px; display: block;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(240, 180, 41, 0.35);
}
.loader__title {
  margin: 0;
  font-size: clamp(34px, 10vw, 74px);
  font-weight: 800; letter-spacing: clamp(2px, 0.9vw, 6px); line-height: 1;
  white-space: nowrap; text-align: center;
  color: #FFFFFF;
  text-shadow: 0 6px 28px rgba(0, 0, 0, 0.8);
  font-family: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
}
.loader__tagline {
  margin: 12px 0 0; color: var(--accent);
  font-size: 15px; font-weight: 700; letter-spacing: 3px; text-transform: uppercase;
}

.loader__bottom {
  position: relative; z-index: 2;
  width: min(560px, 88vw);
  display: flex; flex-direction: column; align-items: stretch;
  padding-bottom: max(24px, env(safe-area-inset-bottom, 24px));
}
.loader__status {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 10px;
}
.loader__stage { color: var(--text); font-size: 15px; font-weight: 600; letter-spacing: 0.3px; }
.loader__pct {
  font-size: 15px; font-weight: 800; color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.loader__bar {
  position: relative; height: 10px; border-radius: 6px; overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.loader__fill {
  position: absolute; inset: 0; border-radius: 6px;
  transform-origin: left center; transform: scaleX(0.02);
  background: linear-gradient(90deg, #C98A12 0%, #F0B429 60%, #FFD86B 100%);
  box-shadow: 0 0 18px rgba(240, 180, 41, 0.55);
  overflow: hidden;
  will-change: transform;
}
.loader__shine {
  position: absolute; top: 0; bottom: 0; width: 40%; left: -40%;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.55) 50%, rgba(255, 255, 255, 0) 100%);
  animation: nhShine 1.6s ease-in-out infinite;
}
@keyframes nhShine { from { left: -40%; } to { left: 110%; } }

.loader__tip-box {
  min-height: 48px; margin-top: 16px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.loader__tip-label {
  flex: 0 0 auto; padding: 3px 8px; border-radius: 6px;
  background: rgba(240, 180, 41, 0.14); color: var(--accent);
  font-size: 12px; font-weight: 800; letter-spacing: 1.5px;
}
.loader__text {
  margin: 0; color: var(--text-2);
  font-size: 15px; line-height: 1.4; text-align: left;
  transition: opacity 0.22s ease;
}
.loader__text.is-fading { opacity: 0; }

.loader__links { margin-top: 14px; display: flex; align-items: center; justify-content: center; gap: 22px; }
.loader__link {
  background: none; border: 0; padding: 6px 2px;
  color: var(--text-2); font-size: 14px; font-family: inherit; cursor: pointer;
  transition: color 0.15s ease;
}
.loader__link:hover { color: var(--text); }
.loader__link[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .loader__bg, .loader__grid, .loader__halo, .loader__shine, .loader__hero { animation: none; }
}
@media (max-width: 520px) {
  .loader__emblem, .loader__logo { width: 84px; height: 84px; }
  .loader__tagline { font-size: 13px; letter-spacing: 2px; }
  .loader__text { font-size: 14px; }
}

.x-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--rim);
  color: var(--text); font-size: 18px; line-height: 1; cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.x-btn:hover { background: rgba(255, 255, 255, 0.16); transform: scale(1.06); }

/* ── About Modal ── */
#about-drawer {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 9, 14, 0.86); padding: 20px;
}
#about-drawer[hidden] { display: none; }
.about-card {
  max-width: 540px; width: 100%; padding: 26px 30px;
  background: var(--surface);
  border: 1px solid var(--rim);
  border-radius: 16px;
}
.about-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.about-head h2 { margin: 0; font-size: 22px; }
.about-card p, .about-card li { color: var(--text-2); line-height: 1.55; font-size: 15px; }
.about-card strong { color: var(--text); }
.about-card ul { padding-left: 18px; margin: 12px 0 0; }
.about-card li { margin-bottom: 8px; }

/* ── Privacy / Terms overlay (over the game, same tab) ── */
#legal-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 6, 10, 0.82); padding: max(16px, env(safe-area-inset-top, 16px)) 16px 16px;
  -webkit-user-select: text; user-select: text;
}
#legal-overlay[hidden] { display: none; }
.legal-card {
  position: relative; width: min(860px, 100%); height: min(88vh, 100%);
  background: #0A0D13; border: 1px solid var(--rim); border-radius: 16px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}
.legal-card iframe { width: 100%; height: 100%; border: 0; display: block; background: #0A0D13; }
.legal-close { position: absolute; top: 12px; right: 12px; z-index: 2; }

#error {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 24px; text-align: center;
}
#error[hidden] { display: none; }
#error button {
  border: 0; border-radius: 10px; padding: 12px 28px; font-size: 16px; font-weight: 700;
  background: var(--accent); color: #141006; cursor: pointer;
}

/* ── Banner strip ── */
#ad-strip {
  flex: 0 0 var(--ad-h); height: var(--ad-h);
  position: relative; display: flex; align-items: center; justify-content: center;
  background: #070A0F; border-top: 1px solid rgba(255, 255, 255, 0.06);
}
#ad-strip[hidden] { display: none; }
#ad-slot { display: flex; align-items: center; justify-content: center; height: 100%; }
.ad-strip__links { position: absolute; right: 12px; bottom: 6px; display: flex; gap: 12px; font-size: 11px; }
@media (max-width: 760px) { .ad-strip__links { display: none; } }

/* In-game side ad slot (placed by the game over a free gap; never over game UI) */
#ad-dock { position: fixed; z-index: 5; width: auto; pointer-events: auto; visibility: hidden; }
.ad-dock__label { font: 600 11px/16px system-ui, sans-serif; color: rgba(238, 242, 247, 0.45); text-align: center; letter-spacing: 0.06em; text-transform: uppercase; }
