/* Nightfall Sigils — portrait, adaptive */

:root {
  --ns-bg-tint: rgba(8, 6, 18, 0.55);
  --ns-panel: rgba(12, 10, 24, 0.88);
  --ns-text: #e8e4f2;
  --ns-muted: #9a92b0;
  --ns-accent: #c9a86c;
  --ns-danger: #c44b5c;
  --ns-safe-top: max(0.75rem, env(safe-area-inset-top));
  --ns-safe-bottom: max(0.75rem, env(safe-area-inset-bottom));
  --ns-safe-x: max(1rem, env(safe-area-inset-left), env(safe-area-inset-right));
  --ns-game-hud-pad: calc(env(safe-area-inset-top, 0px) + 14px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ns-text);
  background: #0a0812;
}

.ns-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-color: #120e1c;
  background-image: url("../images/nightfallBack.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.ns-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(6, 4, 14, 0.45) 0%, rgba(6, 4, 14, 0.75) 100%);
  pointer-events: none;
}

#ns-app {
  position: relative;
  z-index: 1;
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.ns-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: var(--ns-safe-top) var(--ns-safe-x) var(--ns-safe-bottom);
  overflow: hidden;
  transition: opacity 0.32s ease, transform 0.32s ease;
  opacity: 1;
  transform: translateY(0);
}

.ns-screen.ns-hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: translateY(10px) !important;
}

@media (prefers-reduced-motion: reduce) {
  .ns-screen {
    transition: opacity 0.18s ease;
    transform: none !important;
  }
}

.ns-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.ns-btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 0.85rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(180deg, #3d3358 0%, #2a223c 100%);
  color: var(--ns-text);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.ns-btn:active {
  transform: scale(0.97);
}

.ns-btn-primary {
  background: linear-gradient(180deg, #6b5480 0%, #4a3a62 100%);
  border: 1px solid rgba(201, 168, 108, 0.35);
}

.ns-btn-ghost {
  background: rgba(255, 255, 255, 0.08);
}

.ns-back {
  align-self: flex-start;
  margin-bottom: 0.5rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.95rem;
}

.ns-title {
  text-align: center;
  font-size: clamp(1.25rem, 4.5vw, 1.6rem);
  font-weight: 700;
  margin-bottom: 0.75rem;
  letter-spacing: 0.04em;
}

.ns-sub {
  text-align: center;
  color: var(--ns-muted);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

/* Loading */
#screen-loading {
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.ns-launch-logo {
  width: min(48vw, 220px);
  height: auto;
  animation: ns-pulse 1.6s ease-in-out infinite;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.5));
}

@keyframes ns-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.06);
    opacity: 0.92;
  }
}

.ns-loading-dots {
  font-size: 0.85rem;
  color: var(--ns-muted);
  letter-spacing: 0.2em;
}

/* Onboarding */
.ns-onboard-img {
  width: min(72vw, 320px);
  height: auto;
  margin: 0 auto 1rem;
  display: block;
}

.ns-onboard-text {
  max-width: 28rem;
  margin: 0 auto 1rem;
  line-height: 1.55;
  font-size: 0.95rem;
  color: var(--ns-text);
  text-align: center;
}

.ns-stack {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 100%;
  max-width: 20rem;
  margin: 0 auto;
}

.ns-menu-logo {
  width: min(64vw, 280px);
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  display: block;
  filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.45));
}

.ns-stat-row {
  text-align: center;
  font-size: 0.95rem;
  flex-shrink: 0;
  padding-top: 0.75rem;
  color: var(--ns-accent);
}

.ns-menu-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1.35rem;
  width: 100%;
  min-height: 0;
}

#screen-menu {
  justify-content: flex-start;
  padding-top: var(--ns-safe-top);
}

#screen-menu .ns-stack {
  margin-top: 0;
}

/* Onboarding — vertical center */
#screen-onboarding {
  padding: 0;
  justify-content: stretch;
}

.ns-onboard-outer {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 0;
  width: 100%;
  padding: var(--ns-safe-top) var(--ns-safe-x) var(--ns-safe-bottom);
}

.ns-onboard-scroll {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-height: 100%;
  text-align: center;
}

.ns-onboard-scroll .ns-stack {
  margin-top: 0.75rem;
}

/* Game HUD */
#screen-game {
  padding-top: var(--ns-game-hud-pad);
  padding-left: var(--ns-safe-x);
  padding-right: var(--ns-safe-x);
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
}

.ns-game-hud {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto auto;
  gap: 0.25rem 0.5rem;
  align-items: start;
  flex-shrink: 0;
}

.ns-hud-left {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.ns-hud-glory {
  font-size: 1.1rem;
  font-weight: 700;
}

.ns-hud-coins {
  font-size: 0.85rem;
  color: var(--ns-accent);
}

.ns-hud-lives {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  margin-top: 0.25rem;
}

.ns-life-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ns-accent);
  box-shadow: 0 0 8px rgba(201, 168, 108, 0.6);
}

.ns-life-dot.ns-life-off {
  background: #333;
  box-shadow: none;
}

.ns-hud-pause {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  align-self: start;
  margin-top: 2px;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
}

.ns-hud-combo {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.85rem;
  min-height: 1.4rem;
}

.ns-hud-combo.ns-flash-damage {
  animation: ns-flash-red 0.35s ease;
}

@keyframes ns-flash-red {
  from {
    color: var(--ns-danger);
    text-shadow: 0 0 12px rgba(196, 75, 92, 0.8);
  }
  to {
    color: inherit;
    text-shadow: none;
  }
}

.ns-mult {
  color: var(--ns-accent);
  font-weight: 700;
}

.ns-game-field {
  position: relative;
  flex: 1;
  min-height: 120px;
  margin-top: 0.5rem;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.25);
  touch-action: none;
}

.ns-entity {
  position: absolute;
  width: clamp(48px, 14vw, 64px);
  height: clamp(48px, 14vw, 64px);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  pointer-events: none;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

.ns-tap-fx {
  position: absolute;
  width: 48px;
  height: 48px;
  margin-left: -24px;
  margin-top: -24px;
  border-radius: 50%;
  border: 2px solid rgba(201, 168, 108, 0.85);
  pointer-events: none;
  animation: ns-tap-ring 0.35s ease-out forwards;
  z-index: 50;
}

@keyframes ns-tap-ring {
  to {
    transform: scale(2);
    opacity: 0;
  }
}

/* Overlays */
.ns-overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  background: rgba(4, 2, 12, 0.82);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--ns-safe-top) var(--ns-safe-x) var(--ns-safe-bottom);
  text-align: center;
}

.ns-overlay-inner {
  max-width: 22rem;
  width: 100%;
}

#screen-gameover {
  justify-content: center;
  align-items: center;
}

.ns-go-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 22rem;
  text-align: center;
  gap: 0.35rem;
}

.ns-go-inner .ns-title {
  margin-bottom: 0.35rem;
}

.ns-go-actions {
  margin-top: 1rem;
}

.ns-overlay h2 {
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
}

.ns-overlay p {
  margin-bottom: 0.5rem;
  color: var(--ns-muted);
  font-size: 0.95rem;
}

/* Archive */
.ns-rune-card {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--ns-panel);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.ns-rune-card img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.ns-rune-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.ns-rune-name {
  font-weight: 600;
  font-size: 1rem;
}

.ns-rune-status {
  font-size: 0.8rem;
  color: var(--ns-muted);
}

.ns-rune-price {
  font-size: 0.8rem;
  color: var(--ns-accent);
}

.ns-rune-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.ns-rune-actions .ns-btn {
  padding: 0.45rem 0.65rem;
  font-size: 0.8rem;
}

/* How to play */
.ns-how-block {
  background: var(--ns-panel);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  text-align: left;
}

.ns-how-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.ns-how-icons img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.ns-how-block p {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--ns-text);
}

/* Meaning */
.ns-meaning-icon {
  width: min(40vw, 160px);
  height: auto;
  margin: 0 auto 0.5rem;
  display: block;
}

.ns-meaning-short {
  text-align: center;
  color: var(--ns-accent);
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

.ns-meaning-full {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ns-muted);
  margin-bottom: 1rem;
}

.ns-meaning-tags {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--ns-text);
  background: rgba(0, 0, 0, 0.25);
  padding: 0.75rem;
  border-radius: 10px;
  margin-bottom: 1rem;
}

.ns-meaning-tags strong {
  color: var(--ns-accent);
  display: block;
  margin-bottom: 0.25rem;
}

/* Settings */
.ns-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  max-width: 22rem;
  margin: 0 auto;
  width: 100%;
}

.ns-toggle-row input[type="checkbox"] {
  width: 48px;
  height: 28px;
}
