*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--night-0);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.55;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3,
h4,
h5,
p,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
}

a {
  color: var(--gold);
  text-decoration: none;
}

a:hover {
  color: var(--gold-soft);
}

::selection {
  background: rgba(216, 75, 87, 0.45);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: var(--radius-xs);
}

/* Scrollbars -------------------------------------------------------------*/
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(217, 179, 108, 0.28) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  background: rgba(217, 179, 108, 0.25);
  border-radius: 999px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

/* Shell ------------------------------------------------------------------*/
.app {
  position: relative;
  isolation: isolate;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

#screen {
  position: relative;
  z-index: var(--z-content);
  flex: 1;
  min-height: 0;
}

.screen {
  min-height: calc(100dvh - var(--topbar-h));
  padding: calc(var(--topbar-h) + var(--space-5)) var(--page-pad)
    calc(var(--space-10) + var(--safe-bottom));
  padding-left: max(var(--page-pad), var(--safe-left));
  padding-right: max(var(--page-pad), var(--safe-right));
  animation: screen-in 0.5s var(--ease-out) both;
}

.screen--flush {
  padding: 0;
  min-height: 100dvh;
}

.page {
  width: min(100%, var(--content-max));
  margin: 0 auto;
}

.page--narrow {
  width: min(100%, 760px);
  margin: 0 auto;
}

.page-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}

.eyebrow {
  font-size: var(--fs-xs);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}

.page-title {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  line-height: 1.08;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.page-sub {
  color: var(--muted);
  max-width: 62ch;
  font-size: var(--fs-sm);
}

.section {
  margin-top: var(--space-8);
}

.section-title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  font-size: var(--fs-xs);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line-strong), transparent);
}

/* Atmosphere -------------------------------------------------------------*/
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: var(--z-scene);
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(36, 46, 78, 0.55), transparent 60%),
    radial-gradient(90% 60% at 12% 100%, rgba(60, 20, 30, 0.22), transparent 60%),
    radial-gradient(80% 50% at 90% 90%, rgba(20, 30, 60, 0.3), transparent 60%),
    linear-gradient(180deg, #070910 0%, #05060a 55%, #080a11 100%);
  transition: background 1.4s var(--ease-in-out);
}

.atmosphere__moon {
  position: absolute;
  top: calc(5vh + var(--safe-top));
  right: 8vw;
  width: clamp(90px, 18vw, 200px);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 36%, rgba(255, 248, 230, 0.16) 0 6%, transparent 7%),
    radial-gradient(circle at 62% 58%, rgba(120, 90, 70, 0.22) 0 8%, transparent 9%),
    radial-gradient(circle at 50% 50%, #f3e7c8 0%, #e7d3a7 48%, #c8a976 78%, #8a6d3f 100%);
  box-shadow:
    0 0 40px 6px rgba(240, 217, 166, 0.18),
    0 0 120px 30px rgba(216, 75, 87, 0.08);
  opacity: 0.72;
  filter: saturate(0.85);
}

.atmosphere__moon::after {
  content: "";
  position: absolute;
  inset: -35%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(240, 217, 166, 0.14), transparent 62%);
  opacity: 0.7;
}

/* The scene is static by default: animated full-screen layers were the main
   reason the game dropped below 40 fps on laptops and phones. Motion is an
   opt-in (`Эффекты: полные`) and is transform/opacity only. */
.fx-full .atmosphere__moon::after {
  animation: moon-breathe 12s var(--ease-in-out) infinite;
}

.atmosphere__fog {
  position: absolute;
  width: 70vw;
  height: 40vh;
  border-radius: 50%;
  opacity: 0.22;
  background: radial-gradient(
    ellipse at center,
    rgba(120, 140, 190, 0.28) 0%,
    rgba(120, 140, 190, 0.17) 34%,
    rgba(120, 140, 190, 0.07) 56%,
    transparent 74%
  );
}

.fx-full .atmosphere__fog {
  animation: fog-drift 34s linear infinite;
  will-change: transform;
}

.atmosphere__fog--a {
  left: -20vw;
  bottom: 4vh;
}

.atmosphere__fog--b {
  right: -25vw;
  bottom: -6vh;
  width: 90vw;
  opacity: 0.14;
  animation-duration: 46s;
  animation-direction: reverse;
}

.atmosphere__rain {
  position: absolute;
  inset: -220px -10% 0 -10%;
  background-image: repeating-linear-gradient(
    104deg,
    transparent 0 12px,
    rgba(190, 210, 255, 0.045) 12px 13px,
    transparent 13px 27px
  );
  background-size: 220px 220px;
  opacity: 0.55;
}

.fx-full .atmosphere__rain {
  animation: rain-fall 1.15s linear infinite;
  will-change: transform;
}

.atmosphere__grain {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  opacity: 0.04;
  mix-blend-mode: soft-light;
}

.atmosphere__vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 50% 40%, transparent 40%, rgba(0, 0, 0, 0.5) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.25), transparent 22%, transparent 78%, rgba(0, 0, 0, 0.4));
}

.atmosphere--day {
  background:
    radial-gradient(110% 80% at 50% -10%, rgba(120, 80, 50, 0.32), transparent 60%),
    radial-gradient(80% 60% at 15% 100%, rgba(90, 50, 30, 0.18), transparent 60%),
    linear-gradient(180deg, #10101a 0%, #0b0c13 55%, #090a0f 100%);
}

.atmosphere--day .atmosphere__moon {
  opacity: 0.24;
  background: radial-gradient(circle at 50% 50%, #ffe9c4, #d9a15e 70%, #a7652f);
}

.atmosphere--day .atmosphere__rain {
  opacity: 0.12;
}

.atmosphere--verdict .atmosphere__moon {
  background: radial-gradient(circle at 50% 50%, #ffd3cd, #d84b57 62%, #6f1620);
  box-shadow: 0 0 50px 10px rgba(216, 75, 87, 0.28), 0 0 140px 40px rgba(216, 75, 87, 0.12);
  opacity: 0.85;
}

/* Skyline ----------------------------------------------------------------*/
.skyline {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: min(42vh, 380px);
  pointer-events: none;
}

.skyline__back {
  fill: #0a0d16;
  opacity: 0.9;
}

.skyline__mid {
  fill: #070910;
  opacity: 0.95;
}

.skyline__front {
  fill: #04050a;
}

.skyline__window {
  fill: rgba(240, 217, 166, 0.5);
  opacity: 0.5;
  animation: window-flicker 7s steps(1) infinite;
}

/* Utilities --------------------------------------------------------------*/
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.row--between {
  justify-content: space-between;
}

.wrap {
  flex-wrap: wrap;
}

.grow {
  flex: 1;
  min-width: 0;
}

.muted {
  color: var(--muted);
}

.dim {
  color: var(--muted-2);
}

.gold {
  color: var(--gold);
}

.danger {
  color: var(--danger);
}

.town {
  color: var(--town);
}

.center {
  text-align: center;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.nowrap {
  white-space: nowrap;
}

.truncate {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

.divider {
  height: 1px;
  border: 0;
  margin: var(--space-5) 0;
  background: linear-gradient(90deg, transparent, var(--line-strong), transparent);
}

/* Animations -------------------------------------------------------------*/
@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pop {
  0% {
    opacity: 0;
    transform: scale(0.92);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes moon-breathe {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

@keyframes fog-drift {
  from {
    transform: translate3d(-4vw, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(6vw, -2vh, 0) scale(1.08);
  }
  to {
    transform: translate3d(-4vw, 0, 0) scale(1);
  }
}

@keyframes rain-fall {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(-60px, 220px, 0);
  }
}

@keyframes window-flicker {
  0%,
  38%,
  41%,
  100% {
    opacity: 0.5;
  }
  39% {
    opacity: 0.15;
  }
  40% {
    opacity: 0.75;
  }
}

@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(217, 179, 108, 0.35);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(217, 179, 108, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(217, 179, 108, 0);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-4px);
  }
  40% {
    transform: translateX(4px);
  }
  60% {
    transform: translateX(-2px);
  }
  80% {
    transform: translateX(2px);
  }
}

@keyframes shimmer {
  from {
    background-position: -220% 0;
  }
  to {
    background-position: 220% 0;
  }
}

@keyframes float-soft {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-7px);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

/* Low-effects mode: same palette, no compositing stunts. Added automatically
   when the device cannot hold ~50 fps. */
.fx-lite *,
.fx-lite *::before,
.fx-lite *::after {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.fx-lite .atmosphere__fog,
.fx-lite .atmosphere__rain,
.fx-lite .atmosphere__grain {
  display: none;
}

.fx-lite .panel,
.fx-lite .modal,
.fx-lite .hud,
.fx-lite .action-dock,
.fx-lite .toast {
  background-color: rgba(9, 11, 19, 0.92);
}

body.is-hidden .atmosphere {
  filter: brightness(0.6);
}
