:root {
  --bg-0: #09070d;
  --bg-1: #130d1b;
  --bg-2: #1e1428;
  --panel: rgba(21, 15, 29, 0.96);
  --panel-soft: rgba(33, 24, 43, 0.82);
  --gold: #e4bd6b;
  --gold-bright: #f9e2a4;
  --gold-dim: #9b7d49;
  --sand: #efe3c6;
  --ink: #f8f0df;
  --muted: #b9ab93;
  --muted-2: #8e806c;
  --teal: #79c9b8;
  --red: #cf626c;
  --red-dark: #7e303a;
  --green: #74c49a;
  --font-display: "Palatino Linotype", "Book Antiqua", Georgia, "Times New Roman", serif;
  --font-body: "Segoe UI", "Trebuchet MS", Roboto, system-ui, sans-serif;
  --shadow-deep: 0 30px 90px rgba(0, 0, 0, 0.68);
  --shadow-gold: 0 0 34px rgba(228, 189, 107, 0.16);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --topbar-height: 72px;
  --touch-height: 154px;
  --stage-max: calc((100dvh - 132px) * 1.7778);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  background: var(--bg-0);
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 50% 0%, rgba(105, 62, 109, 0.2), transparent 46%),
    linear-gradient(160deg, #09070d 0%, #130d1b 52%, #0b0810 100%);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

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

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

button:disabled {
  cursor: default;
}

svg {
  display: block;
}

h1,
h2,
h3,
p {
  margin: 0;
}

::selection {
  background: rgba(228, 189, 107, 0.28);
}

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

[hidden] {
  display: none !important;
}

.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  opacity: 1;
  transition: opacity 0.6s ease;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.app.is-loading {
  opacity: 0;
  pointer-events: none;
}

.app-atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.atmosphere-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.3;
}

.atmosphere-glow-1 {
  top: -25vh;
  left: 15vw;
  width: 55vw;
  height: 55vw;
  background: #55345d;
  animation: atmosphereDrift 24s ease-in-out infinite alternate;
}

.atmosphere-glow-2 {
  right: -18vw;
  bottom: -30vh;
  width: 48vw;
  height: 48vw;
  background: #3f2d1f;
  animation: atmosphereDrift 31s ease-in-out infinite alternate-reverse;
}

.atmosphere-grain {
  position: absolute;
  inset: 0;
  opacity: 0.28;
  background-image:
    radial-gradient(rgba(255, 236, 194, 0.15) 0.7px, transparent 0.8px),
    radial-gradient(rgba(255, 255, 255, 0.08) 0.6px, transparent 0.7px);
  background-position: 0 0, 11px 17px;
  background-size: 23px 23px, 31px 31px;
  mix-blend-mode: soft-light;
}

@keyframes atmosphereDrift {
  from { transform: translate3d(-2%, -2%, 0) scale(1); }
  to { transform: translate3d(4%, 3%, 0) scale(1.12); }
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background:
    radial-gradient(circle at 50% 48%, #32223c 0%, #160f20 42%, #09070d 80%);
  transition: opacity 0.7s ease, visibility 0.7s ease;
}

.loading-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-emblem {
  position: relative;
  width: 92px;
  height: 92px;
  margin-bottom: 1.6rem;
  border: 1px solid rgba(228, 189, 107, 0.5);
  transform: rotate(45deg);
  box-shadow: 0 0 60px rgba(228, 189, 107, 0.14), inset 0 0 30px rgba(228, 189, 107, 0.08);
  animation: emblemPulse 3s ease-in-out infinite;
}

.loading-eye {
  position: absolute;
  inset: 25px;
  border: 1px solid var(--gold);
  border-radius: 50% 50% 45% 45%;
}

.loading-eye::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold-bright);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 18px var(--gold);
}

.loading-ray {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 160px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(228, 189, 107, 0.6), transparent);
  transform: translate(-50%, -50%);
}

.loading-ray-2 { transform: translate(-50%, -50%) rotate(60deg); }
.loading-ray-3 { transform: translate(-50%, -50%) rotate(-60deg); }

@keyframes emblemPulse {
  0%, 100% { box-shadow: 0 0 42px rgba(228, 189, 107, 0.12), inset 0 0 24px rgba(228, 189, 107, 0.06); }
  50% { box-shadow: 0 0 78px rgba(228, 189, 107, 0.3), inset 0 0 34px rgba(228, 189, 107, 0.13); }
}

.loading-title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  letter-spacing: 0.08em;
  color: var(--gold-bright);
}

.loading-subtitle {
  color: var(--muted);
  letter-spacing: 0.34em;
  text-transform: uppercase;
  font-size: 0.65rem;
}

.loading-track {
  width: min(260px, 58vw);
  height: 2px;
  margin-top: 2rem;
  overflow: hidden;
  background: rgba(228, 189, 107, 0.16);
}

.loading-track span {
  display: block;
  width: 42%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--gold-bright), transparent);
  animation: loadingSlide 1.7s ease-in-out infinite;
}

@keyframes loadingSlide {
  from { transform: translateX(-120%); }
  to { transform: translateX(360%); }
}

.loading-label {
  margin-top: 0.8rem;
  font-size: 0.7rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted-2);
}

/* Верхняя панель */

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: clamp(0.8rem, 2vw, 2rem);
  min-height: var(--topbar-height);
  padding: 0.55rem clamp(0.8rem, 2.2vw, 2rem);
  border-bottom: 1px solid rgba(228, 189, 107, 0.18);
  background:
    linear-gradient(180deg, rgba(15, 10, 21, 0.96), rgba(15, 10, 21, 0.7)),
    radial-gradient(circle at 50% -60%, rgba(228, 189, 107, 0.22), transparent 68%);
  backdrop-filter: blur(16px);
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(228, 189, 107, 0.6), transparent);
}

.brand-mini {
  display: flex;
  align-items: center;
  gap: 0.68rem;
  min-width: 210px;
}

.brand-mini-mark {
  width: 38px;
  height: 38px;
  color: var(--gold);
  filter: drop-shadow(0 0 10px rgba(228, 189, 107, 0.24));
}

.brand-mini-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-mini-copy strong {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: 0.035em;
  color: var(--gold-bright);
}

.brand-mini-copy small {
  margin-top: 0.16rem;
  font-size: 0.58rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.hud {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: clamp(0.6rem, 1.8vw, 1.6rem);
  min-width: 0;
}

.hud-label {
  display: block;
  color: var(--muted-2);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  white-space: nowrap;
}

.hud-room {
  min-width: 130px;
  max-width: 210px;
  padding-right: clamp(0.6rem, 1.4vw, 1.2rem);
  border-right: 1px solid rgba(228, 189, 107, 0.16);
}

.hud-room-line {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  min-width: 0;
}

.hud-room-line strong {
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 1.3rem;
  line-height: 1.1;
}

.hud-room-line span {
  overflow: hidden;
  color: var(--sand);
  font-family: var(--font-display);
  font-size: 0.92rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-stat {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 104px;
}

.hud-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: var(--gold);
}

.hud-icon svg {
  width: 24px;
  height: 24px;
}

.hud-stat-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.hud-stat-copy strong {
  color: var(--ink);
  font-size: 0.87rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

.hud-stat-keys .hud-icon {
  color: var(--gold-bright);
}

.hud-health {
  min-width: 104px;
}

.hearts {
  display: flex;
  align-items: center;
  gap: 0.22rem;
  height: 25px;
}

.heart {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  color: rgba(228, 189, 107, 0.42);
  transition: color 0.24s ease, filter 0.24s ease, opacity 0.24s ease;
}

.heart svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linejoin: round;
}

.heart.is-full {
  color: var(--red);
  filter: drop-shadow(0 0 8px rgba(207, 98, 108, 0.42));
}

.heart.is-full svg {
  fill: var(--red);
  stroke: var(--red);
}

.hud-difficulty {
  min-width: 86px;
  padding-left: clamp(0.6rem, 1.3vw, 1.1rem);
  border-left: 1px solid rgba(228, 189, 107, 0.16);
}

.hud-difficulty strong {
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-size: 0.86rem;
  font-weight: 500;
}

.utility-bar {
  display: flex;
  align-items: stretch;
  gap: 0.32rem;
}

.utility-button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  min-width: 56px;
  min-height: 50px;
  padding: 0.3rem 0.55rem;
  border: 1px solid transparent;
  color: var(--muted);
  transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.utility-button svg {
  width: 21px;
  height: 21px;
}

.utility-button span {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.utility-button kbd {
  position: absolute;
  top: 2px;
  right: 2px;
  padding: 0 0.18rem;
  border: 1px solid rgba(228, 189, 107, 0.18);
  color: var(--muted-2);
  font-family: var(--font-body);
  font-size: 0.5rem;
  line-height: 1.1;
}

.utility-button:hover,
.utility-button:active {
  border-color: rgba(228, 189, 107, 0.24);
  color: var(--gold-bright);
  background: rgba(228, 189, 107, 0.08);
}

.utility-button:active {
  transform: translateY(1px);
}

.key-glyph {
  display: inline-grid;
  place-items: center;
}

.key-glyph svg {
  width: 64%;
  height: 64%;
  color: currentColor;
}

.map-node-badge.key-glyph svg {
  width: 11px;
  height: 11px;
}

.item-glyph.key-glyph svg {
  width: 22px;
  height: 22px;
}

.legend-key svg {
  width: 11px;
  height: 11px;
}

/* Сцена */

.game-main {
  position: relative;
  z-index: 5;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.stage-wrap {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: clamp(0.35rem, 1.2vh, 0.9rem) clamp(0.4rem, 1.4vw, 1.2rem) 0.25rem;
}

.stage-frame {
  position: relative;
  width: min(100%, var(--stage-max), 1560px);
  aspect-ratio: 16 / 9;
  max-height: 100%;
  overflow: hidden;
  border: 1px solid rgba(228, 189, 107, 0.32);
  background: #100b16;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.6),
    0 24px 70px rgba(0, 0, 0, 0.65),
    0 0 80px rgba(110, 73, 47, 0.12);
}

.stage-frame::before,
.stage-frame::after {
  content: "";
  position: absolute;
  z-index: 8;
  width: 44px;
  height: 44px;
  pointer-events: none;
  border-color: rgba(228, 189, 107, 0.7);
}

.stage-frame::before {
  top: 7px;
  left: 7px;
  border-top: 1px solid;
  border-left: 1px solid;
}

.stage-frame::after {
  right: 7px;
  bottom: 7px;
  border-right: 1px solid;
  border-bottom: 1px solid;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #0f0a14;
  touch-action: none;
}

.stage-vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 52%, rgba(5, 3, 8, 0.44) 100%),
    linear-gradient(180deg, rgba(7, 4, 11, 0.18), transparent 15%, transparent 78%, rgba(7, 4, 11, 0.52));
}

.stage-scanlines {
  position: absolute;
  inset: 0;
  z-index: 3;
  opacity: 0.16;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.035) 0,
    rgba(255, 255, 255, 0.035) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
}

.room-banner {
  position: absolute;
  z-index: 10;
  top: clamp(0.8rem, 3.2%, 1.8rem);
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(520px, 80%);
  padding: 0.55rem 1.6rem 0.7rem;
  color: var(--ink);
  text-align: center;
  background: linear-gradient(90deg, transparent, rgba(10, 7, 15, 0.68) 20%, rgba(10, 7, 15, 0.68) 80%, transparent);
  opacity: 0;
  transform: translate(-50%, -10px);
  pointer-events: none;
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.room-banner.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.room-banner span {
  color: var(--gold);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.room-banner strong {
  margin-top: 0.08rem;
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2.1vw, 1.85rem);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.9);
}

.room-banner small {
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: clamp(0.6rem, 1.1vw, 0.78rem);
  letter-spacing: 0.03em;
}

.interaction-prompt {
  position: absolute;
  z-index: 11;
  bottom: 7.5%;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.9rem 0.4rem 0.45rem;
  border: 1px solid rgba(228, 189, 107, 0.38);
  background: rgba(10, 7, 15, 0.86);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), 0 0 22px rgba(228, 189, 107, 0.08);
  color: var(--sand);
  font-size: clamp(0.65rem, 1.1vw, 0.82rem);
  transform: translateX(-50%);
  backdrop-filter: blur(8px);
  animation: promptFloat 2.4s ease-in-out infinite;
}

.interaction-key {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid rgba(228, 189, 107, 0.45);
  color: var(--gold-bright);
  font-size: 0.72rem;
  font-weight: 700;
}

@keyframes promptFloat {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -4px); }
}

.autosave-indicator {
  position: absolute;
  z-index: 10;
  right: 3.5%;
  bottom: 3.6%;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: rgba(239, 227, 198, 0.64);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.autosave-indicator.is-visible {
  opacity: 1;
}

.autosave-indicator span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.orientation-tip {
  display: none;
}

.keyboard-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(0.8rem, 2.6vw, 2.2rem);
  height: 32px;
  padding: 0 1rem;
  color: var(--muted-2);
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.keyboard-strip span {
  display: flex;
  align-items: center;
  gap: 0.28rem;
}

.keyboard-strip b {
  min-width: 18px;
  padding: 0.06rem 0.24rem;
  border: 1px solid rgba(228, 189, 107, 0.18);
  color: var(--muted);
  font-weight: 500;
  text-align: center;
}

/* Сенсорное управление */

.touch-controls {
  display: none;
  position: relative;
  z-index: 22;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--touch-height);
  padding: 0.4rem clamp(0.7rem, 3vw, 2.5rem) calc(0.7rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(228, 189, 107, 0.14);
  background:
    linear-gradient(180deg, rgba(12, 8, 17, 0.55), rgba(10, 7, 14, 0.97) 48%),
    radial-gradient(circle at 50% 130%, rgba(228, 189, 107, 0.1), transparent 64%);
  backdrop-filter: blur(14px);
  touch-action: none;
}

.touch-cluster {
  display: flex;
  align-items: flex-end;
  gap: clamp(0.5rem, 2.2vw, 1.1rem);
}

.touch-button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  width: clamp(66px, 11vw, 100px);
  height: clamp(66px, 11vw, 100px);
  border: 1px solid rgba(228, 189, 107, 0.32);
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 26%, rgba(228, 189, 107, 0.17), transparent 54%),
    rgba(31, 23, 41, 0.88);
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.42),
    inset 0 0 0 5px rgba(228, 189, 107, 0.04),
    inset 0 -10px 22px rgba(0, 0, 0, 0.24);
  color: var(--sand);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  transition: transform 0.08s ease, background 0.08s ease, border-color 0.08s ease, box-shadow 0.08s ease;
}

.touch-button svg {
  width: 36%;
  height: 36%;
  color: var(--gold-bright);
  filter: drop-shadow(0 0 6px rgba(249, 226, 164, 0.22));
}

.touch-button span {
  max-width: 92%;
  color: var(--muted);
  font-size: clamp(0.5rem, 1.6vw, 0.65rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
  line-height: 1.1;
}

.touch-button.is-pressed {
  border-color: var(--gold-bright);
  background:
    radial-gradient(circle at 38% 26%, rgba(228, 189, 107, 0.34), transparent 58%),
    rgba(56, 42, 29, 0.94);
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.35),
    inset 0 0 0 5px rgba(228, 189, 107, 0.09),
    0 0 22px rgba(228, 189, 107, 0.16);
  transform: translateY(2px) scale(0.97);
}

.touch-button.is-pressed span {
  color: var(--gold-bright);
}

.touch-move {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-areas:
    "up down"
    "left right";
  align-items: end;
  gap: 6px;
}

.touch-climb-up { grid-area: up; }
.touch-climb-down { grid-area: down; }
.touch-left { grid-area: left; }
.touch-right { grid-area: right; }

.touch-climb {
  width: clamp(46px, 8vw, 58px);
  height: clamp(46px, 8vw, 58px);
  border-color: rgba(121, 201, 184, 0.34);
  background:
    radial-gradient(circle at 38% 26%, rgba(121, 201, 184, 0.16), transparent 56%),
    rgba(24, 31, 38, 0.88);
}

.touch-climb svg {
  width: 34%;
  height: 34%;
  color: var(--teal);
}

.touch-climb span {
  font-size: clamp(0.43rem, 1.3vw, 0.56rem);
}

.touch-climb.is-pressed {
  border-color: rgba(181, 255, 240, 0.72);
  background:
    radial-gradient(circle at 38% 26%, rgba(121, 201, 184, 0.3), transparent 58%),
    rgba(31, 57, 51, 0.94);
}

.touch-jump {
  width: clamp(82px, 13.5vw, 122px);
  height: clamp(82px, 13.5vw, 122px);
  border-color: rgba(249, 226, 164, 0.46);
  background:
    radial-gradient(circle at 38% 26%, rgba(249, 226, 164, 0.22), transparent 56%),
    rgba(48, 34, 30, 0.9);
}

.touch-jump svg {
  width: 38%;
  height: 38%;
}

.touch-interact {
  width: clamp(60px, 10vw, 88px);
  height: clamp(60px, 10vw, 88px);
}

.touch-actions {
  align-items: flex-end;
}

.touch-center-hint {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  align-self: center;
  min-width: 0;
  padding-bottom: 0.2rem;
  color: var(--muted-2);
  text-align: center;
  pointer-events: none;
}

.touch-center-hint span {
  color: var(--muted);
  font-size: clamp(0.54rem, 1.4vw, 0.7rem);
  letter-spacing: 0.06em;
}

.touch-center-hint small {
  margin-top: 0.1rem;
  font-size: clamp(0.45rem, 1.1vw, 0.58rem);
  opacity: 0.72;
}

/* Общие экраны и панели */

.screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  overflow: hidden;
  padding: calc(var(--safe-top) + 0.8rem) 0.8rem calc(var(--safe-bottom) + 0.8rem);
  background:
    radial-gradient(circle at 50% 36%, rgba(81, 52, 73, 0.34), transparent 55%),
    rgba(7, 5, 10, 0.84);
  backdrop-filter: blur(14px);
}

.screen.is-open {
  display: flex;
  animation: screenFade 0.28s ease both;
}

@keyframes screenFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-screen {
  align-items: center;
  justify-content: center;
  touch-action: pan-y;
}

.modal-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(680px, 94vw);
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 1.6rem);
  overflow: hidden;
  border: 1px solid rgba(228, 189, 107, 0.32);
  background:
    linear-gradient(180deg, rgba(39, 28, 49, 0.98), rgba(18, 13, 25, 0.99)),
    radial-gradient(circle at 50% 0%, rgba(228, 189, 107, 0.1), transparent 50%);
  box-shadow: var(--shadow-deep), inset 0 0 80px rgba(228, 189, 107, 0.025);
  animation: panelRise 0.32s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

.modal-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.7;
}

@keyframes panelRise {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-wide { width: min(1020px, 95vw); }
.modal-tutorial { width: min(780px, 95vw); }
.modal-map { width: min(1240px, 97vw); height: min(90dvh, 900px); }
.modal-inventory { width: min(980px, 95vw); height: min(88dvh, 880px); }
.modal-achievements { width: min(900px, 95vw); height: min(86dvh, 820px); }
.modal-settings { width: min(700px, 95vw); }
.modal-confirm { width: min(560px, 94vw); }
.modal-pause {
  width: min(540px, 94vw);
  align-items: center;
  padding-bottom: 1.4rem;
  text-align: center;
  overflow-y: auto;
}
.modal-hint { width: min(650px, 95vw); }

.modal-header {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.4rem;
  padding: clamp(1.1rem, 2.4vw, 1.8rem) clamp(1.2rem, 2.6vw, 2rem) 1rem;
  border-bottom: 1px solid rgba(228, 189, 107, 0.13);
}

.modal-header > div:first-child {
  min-width: 0;
}

.eyebrow {
  margin-bottom: 0.35rem;
  color: var(--gold);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.27em;
  text-transform: uppercase;
}

.modal-header h2 {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3.2vw, 2.35rem);
  font-weight: 500;
  line-height: 1.13;
  letter-spacing: 0.02em;
}

.modal-header p:not(.eyebrow) {
  max-width: 640px;
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.icon-button {
  display: grid;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(228, 189, 107, 0.22);
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.icon-button:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
  background: rgba(228, 189, 107, 0.08);
}

.modal-footer {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 0.7rem;
  padding: 1rem clamp(1.2rem, 2.6vw, 2rem) 1.25rem;
  border-top: 1px solid rgba(228, 189, 107, 0.13);
  background: rgba(8, 6, 12, 0.24);
}

.modal-footer .settings-note {
  margin-right: auto;
  color: var(--muted-2);
  font-size: 0.68rem;
}

/* Кнопки */

.button {
  position: relative;
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.35rem;
  border: 1px solid transparent;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.045em;
  text-align: center;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.button:active {
  transform: translateY(1px);
}

.button-primary {
  border-color: rgba(249, 226, 164, 0.62);
  background:
    linear-gradient(135deg, #f2d58d, #d2a44f 52%, #ad7b33);
  color: #21150c;
  box-shadow: 0 8px 28px rgba(213, 165, 79, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.44);
}

.button-primary:hover {
  background:
    linear-gradient(135deg, #ffe9b4, #e5ba66 52%, #c18d3d);
  box-shadow: 0 10px 34px rgba(235, 192, 107, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.52);
}

.button-secondary {
  border-color: rgba(228, 189, 107, 0.4);
  background: rgba(228, 189, 107, 0.08);
  color: var(--gold-bright);
}

.button-secondary:hover {
  background: rgba(228, 189, 107, 0.15);
  border-color: rgba(228, 189, 107, 0.62);
}

.button-ghost {
  border-color: rgba(239, 227, 198, 0.16);
  color: var(--muted);
}

.button-ghost:hover {
  border-color: rgba(228, 189, 107, 0.4);
  color: var(--sand);
  background: rgba(228, 189, 107, 0.05);
}

.button-danger {
  border-color: rgba(207, 98, 108, 0.55);
  background: rgba(126, 48, 58, 0.54);
  color: #ffdbe0;
}

.button-danger:hover {
  background: rgba(165, 61, 75, 0.7);
}

.warning-note {
  margin: 0 clamp(1.2rem, 2.6vw, 2rem) 0.9rem;
  padding: 0.65rem 0.9rem;
  border-left: 2px solid var(--gold-dim);
  background: rgba(228, 189, 107, 0.06);
  color: var(--muted);
  font-size: 0.74rem;
}

/* Главное меню */

.menu-screen {
  z-index: 45;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden auto;
  padding: clamp(1rem, 4vh, 2.5rem) 1rem;
  background:
    radial-gradient(circle at 50% 42%, rgba(93, 62, 92, 0.24), transparent 46%),
    linear-gradient(180deg, rgba(9, 6, 13, 0.54), rgba(9, 6, 13, 0.92)),
    rgba(8, 5, 11, 0.42);
  backdrop-filter: blur(3px);
}

.menu-screen.is-open {
  animation: menuFade 0.6s ease both;
}

@keyframes menuFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.menu-decoration {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.menu-sun {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(58vw, 720px);
  aspect-ratio: 1;
  border: 1px solid rgba(228, 189, 107, 0.12);
  border-radius: 50%;
  transform: translate(-50%, -54%);
  box-shadow:
    0 0 0 44px rgba(228, 189, 107, 0.018),
    0 0 0 88px rgba(228, 189, 107, 0.012),
    inset 0 0 120px rgba(228, 189, 107, 0.04);
}

.menu-sun::before,
.menu-sun::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 130%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(228, 189, 107, 0.1), transparent);
}

.menu-sun::before { transform: translate(-50%, -50%); }
.menu-sun::after { transform: translate(-50%, -50%) rotate(90deg); }

.menu-column {
  position: absolute;
  top: 0;
  bottom: 0;
  width: clamp(45px, 6vw, 92px);
  opacity: 0.26;
  background:
    linear-gradient(90deg, transparent, rgba(228, 189, 107, 0.12), transparent),
    repeating-linear-gradient(180deg, transparent 0 24px, rgba(228, 189, 107, 0.08) 24px 25px);
}

.menu-column::after {
  content: "";
  position: absolute;
  top: 12%;
  bottom: 12%;
  left: 50%;
  width: 1px;
  background: rgba(228, 189, 107, 0.4);
  box-shadow: 0 0 18px rgba(228, 189, 107, 0.3);
}

.menu-column-left { left: 0; }
.menu-column-right { right: 0; transform: scaleX(-1); }

.menu-hieroglyphs {
  position: absolute;
  top: 0;
  left: 50%;
  width: min(900px, 90vw);
  height: 100%;
  border-left: 1px solid rgba(228, 189, 107, 0.045);
  border-right: 1px solid rgba(228, 189, 107, 0.045);
  transform: translateX(-50%);
  background-image:
    radial-gradient(circle, rgba(228, 189, 107, 0.15) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(228, 189, 107, 0.1) 0 1px, transparent 1.5px);
  background-position: 12% 20%, 78% 68%;
  background-size: 160px 190px, 220px 250px;
  opacity: 0.5;
}

.menu-content {
  position: relative;
  z-index: 2;
  display: flex;
  width: min(760px, 94vw);
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: menuContentIn 0.8s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

@keyframes menuContentIn {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}

.game-title {
  display: flex;
  flex-direction: column;
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-size: clamp(3rem, 9vw, 6.4rem);
  font-weight: 400;
  line-height: 0.82;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-shadow:
    0 2px 0 #4a2f1d,
    0 6px 28px rgba(0, 0, 0, 0.55),
    0 0 58px rgba(228, 189, 107, 0.14);
}

.game-title span:last-child {
  color: var(--sand);
  font-size: 0.76em;
  letter-spacing: 0.12em;
  opacity: 0.94;
}

.game-subtitle {
  margin-top: 0.45rem;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: clamp(0.92rem, 2.1vw, 1.35rem);
  letter-spacing: 0.52em;
  text-transform: uppercase;
  opacity: 0.9;
}

.menu-lead {
  max-width: 560px;
  margin-top: clamp(1rem, 2.4vh, 1.55rem);
  color: var(--muted);
  font-size: clamp(0.78rem, 1.45vw, 0.94rem);
  line-height: 1.65;
}

.menu-actions {
  display: flex;
  width: min(390px, 90vw);
  flex-direction: column;
  gap: 0.55rem;
  margin-top: clamp(1.1rem, 2.6vh, 1.8rem);
}

.menu-actions .button {
  min-height: 52px;
  flex-direction: column;
  gap: 0.05rem;
  padding: 0.5rem 1.2rem;
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 10px);
}

.menu-actions .button-label {
  font-family: var(--font-display);
  font-size: 0.98rem;
  letter-spacing: 0.07em;
}

.menu-actions .button small {
  color: inherit;
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  opacity: 0.6;
}

.menu-actions .button:disabled {
  border-color: rgba(228, 189, 107, 0.13);
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted-2);
  box-shadow: none;
}

.menu-actions-row {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.15rem;
}

.menu-actions-row .button {
  flex: 1;
  min-height: 38px;
  padding: 0.4rem 0.5rem;
  font-size: 0.66rem;
  clip-path: none;
}

.menu-features {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.2rem;
  color: var(--muted-2);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.menu-features b {
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.menu-features i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--gold-dim);
}

.menu-note {
  margin-top: 0.8rem;
  color: rgba(185, 171, 147, 0.62);
  font-size: 0.62rem;
  letter-spacing: 0.03em;
}

.menu-footer {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: clamp(0.7rem, 2vh, 1.4rem);
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: rgba(142, 128, 108, 0.55);
  font-size: 0.55rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.menu-footer-mark {
  color: var(--gold-dim);
  font-size: 0.7rem;
}

/* Сложность */

.difficulty-grid {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
  padding: clamp(0.9rem, 2vw, 1.3rem) clamp(1.2rem, 2.6vw, 2rem);
  overflow-y: auto;
  min-height: 0;
}

.difficulty-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 220px;
  padding: 1rem 0.9rem 0.9rem;
  border: 1px solid rgba(228, 189, 107, 0.18);
  background:
    linear-gradient(180deg, rgba(45, 31, 55, 0.7), rgba(18, 13, 25, 0.78));
  text-align: left;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.difficulty-card:hover {
  border-color: rgba(228, 189, 107, 0.44);
  transform: translateY(-2px);
}

.difficulty-card.is-selected {
  border-color: var(--gold-bright);
  background:
    linear-gradient(180deg, rgba(89, 64, 39, 0.62), rgba(29, 20, 31, 0.86));
  box-shadow: inset 0 0 0 1px rgba(249, 226, 164, 0.2), 0 10px 30px rgba(0, 0, 0, 0.28);
}

.difficulty-card.is-selected::after {
  content: "◈";
  position: absolute;
  top: 0.55rem;
  right: 0.65rem;
  color: var(--gold-bright);
  font-size: 0.8rem;
}

.difficulty-level {
  display: flex;
  gap: 0.18rem;
  margin-bottom: 0.7rem;
}

.difficulty-level i {
  width: 14px;
  height: 3px;
  background: rgba(228, 189, 107, 0.16);
}

.difficulty-card.is-selected .difficulty-level i,
.difficulty-card:hover .difficulty-level i {
  background: var(--gold);
}

.difficulty-name {
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-size: 1.18rem;
  font-weight: 500;
  line-height: 1.2;
}

.difficulty-epithet {
  margin-top: 0.1rem;
  color: var(--muted-2);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.difficulty-description {
  flex: 1;
  margin-top: 0.65rem;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.48;
}

.difficulty-health {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.7rem;
  color: var(--muted-2);
  font-size: 0.58rem;
}

.difficulty-health span {
  display: flex;
  gap: 0.16rem;
}

.difficulty-health i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
}

/* Обучение */

.tutorial-content {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: 104px 1fr;
  gap: 1.2rem;
  align-items: start;
  min-height: 0;
  padding: 1.5rem clamp(1.2rem, 2.6vw, 2rem);
  overflow-y: auto;
}

.tutorial-visual {
  position: relative;
  display: grid;
  width: 104px;
  height: 104px;
  place-items: center;
  border: 1px solid rgba(228, 189, 107, 0.24);
  border-radius: 50%;
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-size: 2.1rem;
  background: radial-gradient(circle, rgba(228, 189, 107, 0.12), transparent 68%);
}

.tutorial-visual::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px dashed rgba(228, 189, 107, 0.2);
  border-radius: 50%;
}

.tutorial-copy h3 {
  color: var(--sand);
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 500;
}

.tutorial-copy p {
  max-width: 500px;
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.62;
}

.tutorial-dots {
  display: flex;
  gap: 0.35rem;
  margin-top: 1rem;
}

.tutorial-dots span {
  width: 18px;
  height: 2px;
  background: rgba(228, 189, 107, 0.18);
}

.tutorial-dots span.is-active {
  background: var(--gold);
  box-shadow: 0 0 8px rgba(228, 189, 107, 0.4);
}

/* Карта */

.map-header {
  align-items: center;
  flex: 0 0 auto;
}

.map-progress {
  display: flex;
  flex-direction: column;
  margin-left: auto;
  text-align: right;
}

.map-progress span {
  color: var(--muted-2);
  font-size: 0.56rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.map-progress strong {
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.map-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 300px);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.map-canvas-shell {
  position: relative;
  min-height: 380px;
  margin: 0.8rem;
  overflow: hidden;
  border: 1px solid rgba(228, 189, 107, 0.12);
  background:
    radial-gradient(circle at 50% 45%, rgba(228, 189, 107, 0.07), transparent 58%),
    repeating-linear-gradient(0deg, transparent 0 39px, rgba(228, 189, 107, 0.05) 39px 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(228, 189, 107, 0.05) 39px 40px),
    #0f0b15;
}

.map-canvas-shell::before,
.map-canvas-shell::after {
  content: "";
  position: absolute;
  z-index: 1;
  width: 62px;
  height: 62px;
  border-color: rgba(228, 189, 107, 0.28);
  pointer-events: none;
}

.map-canvas-shell::before {
  top: 8px;
  left: 8px;
  border-top: 1px solid;
  border-left: 1px solid;
}

.map-canvas-shell::after {
  right: 8px;
  bottom: 8px;
  border-right: 1px solid;
  border-bottom: 1px solid;
}

.map-lines {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.map-line {
  fill: none;
  stroke: rgba(228, 189, 107, 0.2);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.map-line.is-open {
  stroke: rgba(121, 201, 184, 0.4);
}

.map-line.is-locked {
  stroke: rgba(207, 98, 108, 0.55);
  stroke-dasharray: 6 5;
}

.map-node {
  position: absolute;
  z-index: 3;
  display: flex;
  width: 52px;
  height: 52px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(228, 189, 107, 0.24);
  border-radius: 50%;
  background: #241c2c;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.95rem;
  transform: translate(-50%, -50%);
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.map-node:hover {
  z-index: 5;
  transform: translate(-50%, -50%) scale(1.1);
}

.map-node.status-complete {
  border-color: rgba(116, 196, 154, 0.72);
  background: radial-gradient(circle at 40% 32%, rgba(116, 196, 154, 0.28), rgba(22, 38, 31, 0.96) 68%);
  color: #d8ffe8;
  box-shadow: 0 0 16px rgba(116, 196, 154, 0.15);
}

.map-node.status-partial {
  border-color: rgba(228, 189, 107, 0.76);
  background: radial-gradient(circle at 40% 32%, rgba(228, 189, 107, 0.25), rgba(43, 32, 23, 0.96) 68%);
  color: var(--gold-bright);
  box-shadow: 0 0 16px rgba(228, 189, 107, 0.12);
}

.map-node.status-unvisited {
  border-color: rgba(142, 128, 108, 0.26);
  background: #1a1720;
  color: rgba(185, 171, 147, 0.42);
}

.map-node.is-current {
  box-shadow:
    0 0 0 3px rgba(121, 201, 184, 0.2),
    0 0 0 5px rgba(121, 201, 184, 0.08),
    0 0 28px rgba(121, 201, 184, 0.3);
  animation: currentNodePulse 2.6s ease-in-out infinite;
}

@keyframes currentNodePulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(121, 201, 184, 0.16), 0 0 0 5px rgba(121, 201, 184, 0.05), 0 0 22px rgba(121, 201, 184, 0.18); }
  50% { box-shadow: 0 0 0 4px rgba(121, 201, 184, 0.3), 0 0 0 8px rgba(121, 201, 184, 0.08), 0 0 34px rgba(121, 201, 184, 0.4); }
}

.map-node-number {
  line-height: 1;
}

.map-node-icons {
  position: absolute;
  top: -7px;
  right: -7px;
  display: flex;
  gap: 2px;
}

.map-node-badge {
  display: grid;
  width: 17px;
  height: 17px;
  place-items: center;
  border: 1px solid rgba(228, 189, 107, 0.32);
  border-radius: 50%;
  background: #17111e;
  color: var(--gold-bright);
  font-family: var(--font-body);
  font-size: 0.55rem;
  font-weight: 700;
  line-height: 1;
}

.map-node-badge.badge-question {
  border-color: rgba(121, 201, 184, 0.5);
  color: var(--teal);
}

.map-node-badge.badge-key {
  color: var(--gold-bright);
}

.map-node.is-final {
  border-radius: 4px;
  transform: translate(-50%, -50%) rotate(45deg);
}

.map-node.is-final .map-node-number {
  transform: rotate(-45deg);
  font-size: 0.72rem;
}

.map-node.is-final:hover {
  transform: translate(-50%, -50%) rotate(45deg) scale(1.08);
}

.map-gate {
  position: absolute;
  z-index: 3;
  display: flex;
  width: 96px;
  height: 46px;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  border: 1px solid rgba(207, 98, 108, 0.5);
  background: rgba(40, 18, 26, 0.94);
  color: #f0b7bd;
  font-size: 0.5rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 22px rgba(207, 98, 108, 0.12);
}

.map-gate.is-open {
  border-color: rgba(116, 196, 154, 0.5);
  background: rgba(18, 40, 30, 0.94);
  color: #c9ffe1;
}

.map-gate small {
  display: block;
  font-size: 0.45rem;
  opacity: 0.66;
}

.map-compass {
  position: absolute;
  z-index: 2;
  top: 16px;
  right: 18px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(228, 189, 107, 0.18);
  border-radius: 50%;
  color: var(--gold-dim);
  font-family: var(--font-display);
  font-size: 0.72rem;
}

.map-compass::before {
  content: "✦";
  position: absolute;
  top: -9px;
  color: var(--gold);
  font-size: 0.55rem;
}

.map-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid rgba(228, 189, 107, 0.12);
  background: rgba(9, 7, 13, 0.3);
  overflow-y: auto;
}

.map-details {
  min-height: 184px;
  padding: 1.1rem 1rem;
  border-bottom: 1px solid rgba(228, 189, 107, 0.1);
}

.map-details,
.map-legend,
.map-total {
  flex: 0 0 auto;
}

.map-details-empty {
  color: var(--muted-2);
  font-size: 0.72rem;
  line-height: 1.55;
}

.map-room-kicker {
  color: var(--gold);
  font-size: 0.54rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.map-room-name {
  margin-top: 0.18rem;
  color: var(--sand);
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 500;
  line-height: 1.2;
}

.map-room-subtitle {
  margin-top: 0.2rem;
  color: var(--muted-2);
  font-size: 0.64rem;
  line-height: 1.4;
}

.map-room-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.7rem;
  padding: 0.22rem 0.5rem;
  border: 1px solid rgba(228, 189, 107, 0.2);
  color: var(--muted);
  font-size: 0.58rem;
}

.map-room-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}

.map-room-status.status-complete {
  border-color: rgba(116, 196, 154, 0.36);
  color: var(--green);
}

.map-room-status.status-complete::before { background: var(--green); }
.map-room-status.status-partial { border-color: rgba(228, 189, 107, 0.36); color: var(--gold); }
.map-room-status.status-partial::before { background: var(--gold); }
.map-room-status.status-unvisited { color: var(--muted-2); }

.map-room-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-top: 0.7rem;
}

.map-room-meta div {
  padding: 0.42rem 0.5rem;
  border: 1px solid rgba(228, 189, 107, 0.09);
  background: rgba(255, 255, 255, 0.018);
}

.map-room-meta span {
  display: block;
  color: var(--muted-2);
  font-size: 0.5rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.map-room-meta strong {
  color: var(--sand);
  font-size: 0.7rem;
  font-weight: 500;
}

.map-room-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.55rem;
}

.map-room-flag {
  padding: 0.14rem 0.38rem;
  border: 1px solid rgba(121, 201, 184, 0.22);
  color: var(--teal);
  font-size: 0.52rem;
}

.map-room-flag.is-key {
  border-color: rgba(228, 189, 107, 0.3);
  color: var(--gold-bright);
}

.map-room-flag.is-locked {
  border-color: rgba(207, 98, 108, 0.36);
  color: var(--red);
}

.map-travel {
  width: 100%;
  margin-top: 0.75rem;
}

.map-legend {
  padding: 1rem;
  border-bottom: 1px solid rgba(228, 189, 107, 0.1);
}

.map-legend h3 {
  color: var(--gold);
  font-size: 0.56rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.map-legend ul {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  margin: 0.65rem 0 0;
  padding: 0;
  list-style: none;
}

.map-legend li {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.58rem;
  line-height: 1.4;
}

.legend-swatch {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  margin-top: 0.12rem;
  border-radius: 50%;
  border: 1px solid;
}

.legend-complete { border-color: var(--green); background: rgba(116, 196, 154, 0.28); }
.legend-partial { border-color: var(--gold); background: rgba(228, 189, 107, 0.25); }
.legend-unvisited { border-color: var(--muted-2); background: rgba(142, 128, 108, 0.12); }

.legend-lock,
.legend-key,
.legend-question {
  display: grid;
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  place-items: center;
  border: 1px solid rgba(228, 189, 107, 0.24);
  border-radius: 50%;
  font-size: 0.53rem;
  line-height: 1;
}

.legend-lock { border-color: rgba(207, 98, 108, 0.44); color: var(--red); }
.legend-key { color: var(--gold); }
.legend-question { border-color: rgba(121, 201, 184, 0.4); color: var(--teal); }

.map-total {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: auto;
  padding: 1rem;
}

.map-total div {
  padding: 0.55rem 0.6rem;
  border: 1px solid rgba(228, 189, 107, 0.12);
  background: rgba(255, 255, 255, 0.018);
}

.map-total span {
  display: block;
  color: var(--muted-2);
  font-size: 0.5rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.map-total strong {
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 500;
}

/* Инвентарь */

.inventory-summary {
  display: flex;
  gap: 0.8rem;
  margin-left: auto;
  color: var(--muted);
  font-size: 0.66rem;
  white-space: nowrap;
}

.inventory-summary b {
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 500;
}

.inventory-content {
  flex: 1 1 auto;
  min-height: 0;
  padding: clamp(0.9rem, 2vw, 1.3rem) clamp(1.1rem, 2.5vw, 1.8rem) 1.5rem;
  overflow-y: auto;
}

.inventory-section + .inventory-section {
  margin-top: 1.5rem;
}

.inventory-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid rgba(228, 189, 107, 0.16);
}

.inventory-section-head h3 {
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 500;
}

.inventory-section-head span {
  color: var(--muted-2);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.5rem;
  margin-top: 0.7rem;
}

.inventory-card {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  min-height: 82px;
  padding: 0.62rem;
  border: 1px solid rgba(228, 189, 107, 0.13);
  background: linear-gradient(145deg, rgba(42, 30, 51, 0.52), rgba(20, 14, 26, 0.62));
}

.item-glyph {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(228, 189, 107, 0.28);
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-size: 1.05rem;
  background: radial-gradient(circle, rgba(228, 189, 107, 0.13), transparent 70%);
}

.item-glyph.glyph-key {
  border-color: rgba(249, 226, 164, 0.45);
  color: var(--gold-bright);
}

.item-glyph.glyph-secret {
  border-color: rgba(121, 201, 184, 0.32);
  color: var(--teal);
}

.item-card-copy {
  min-width: 0;
}

.item-card-copy strong {
  display: block;
  color: var(--sand);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.22;
}

.item-card-copy small {
  display: block;
  margin-top: 0.16rem;
  color: var(--muted-2);
  font-size: 0.54rem;
  letter-spacing: 0.04em;
}

.item-card-copy p {
  margin-top: 0.24rem;
  color: var(--muted);
  font-size: 0.59rem;
  line-height: 1.35;
}

.inventory-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  padding: 2rem;
  text-align: center;
}

.inventory-empty .empty-glyph {
  display: grid;
  width: 74px;
  height: 74px;
  place-items: center;
  margin-bottom: 1rem;
  border: 1px solid rgba(228, 189, 107, 0.22);
  border-radius: 50%;
  color: var(--gold-dim);
  font-family: var(--font-display);
  font-size: 1.6rem;
  opacity: 0.64;
}

.inventory-empty h3 {
  color: var(--sand);
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 500;
}

.inventory-empty p {
  max-width: 390px;
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.55;
}

.inventory-note {
  margin-top: 1.2rem;
  padding: 0.65rem 0.8rem;
  border-left: 2px solid rgba(121, 201, 184, 0.4);
  background: rgba(121, 201, 184, 0.04);
  color: var(--muted-2);
  font-size: 0.64rem;
  line-height: 1.5;
}

/* Достижения */

.achievements-content {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  min-height: 0;
  padding: clamp(0.9rem, 2vw, 1.3rem) clamp(1.2rem, 2.6vw, 2rem) 1.5rem;
  overflow-y: auto;
}

.achievement-card {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid rgba(228, 189, 107, 0.12);
  background: rgba(255, 255, 255, 0.018);
  opacity: 0.6;
}

.achievement-card.is-unlocked {
  border-color: rgba(228, 189, 107, 0.32);
  background: linear-gradient(145deg, rgba(66, 48, 31, 0.34), rgba(24, 17, 31, 0.5));
  opacity: 1;
}

.achievement-medal {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(228, 189, 107, 0.26);
  border-radius: 50%;
  color: var(--muted-2);
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.achievement-card.is-unlocked .achievement-medal {
  border-color: var(--gold);
  color: var(--gold-bright);
  box-shadow: 0 0 18px rgba(228, 189, 107, 0.12);
}

.achievement-copy strong {
  display: block;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 500;
}

.achievement-card.is-unlocked .achievement-copy strong {
  color: var(--sand);
}

.achievement-copy p {
  margin-top: 0.18rem;
  color: var(--muted-2);
  font-size: 0.61rem;
  line-height: 1.4;
}

.achievement-reward {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.1rem 0.35rem;
  border: 1px solid rgba(228, 189, 107, 0.16);
  color: var(--gold-dim);
  font-size: 0.5rem;
}

/* Настройки */

.settings-list {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0.4rem clamp(1.2rem, 2.6vw, 2rem);
  overflow-y: auto;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid rgba(228, 189, 107, 0.1);
}

.setting-row:last-child {
  border-bottom: 0;
}

.setting-row strong {
  display: block;
  color: var(--sand);
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 500;
}

.setting-row span {
  display: block;
  margin-top: 0.12rem;
  color: var(--muted-2);
  font-size: 0.65rem;
}

.setting-row-danger strong {
  color: #e8a3a9;
}

.toggle {
  position: relative;
  flex: 0 0 auto;
  width: 48px;
  height: 26px;
  border: 1px solid rgba(228, 189, 107, 0.24);
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.28);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.toggle span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  margin: 0;
  border-radius: 50%;
  background: var(--muted-2);
  transition: transform 0.2s ease, background 0.2s ease;
}

.toggle[aria-checked="true"] {
  border-color: rgba(228, 189, 107, 0.6);
  background: rgba(228, 189, 107, 0.18);
}

.toggle[aria-checked="true"] span {
  background: var(--gold-bright);
  transform: translateX(22px);
  box-shadow: 0 0 10px rgba(228, 189, 107, 0.4);
}

.settings-note {
  margin-right: auto;
  color: var(--muted-2);
  font-size: 0.62rem;
}

/* Подсказка */

.hint-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  padding: 1.4rem clamp(1.2rem, 2.6vw, 2rem);
  text-align: center;
  overflow-y: auto;
}

.hint-eye {
  position: relative;
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  margin-bottom: 0.8rem;
  border: 1px solid rgba(228, 189, 107, 0.34);
  border-radius: 50%;
}

.hint-eye::before,
.hint-eye::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}

.hint-eye::before {
  inset: 14px;
  border: 1px solid rgba(228, 189, 107, 0.5);
}

.hint-eye::after {
  width: 12px;
  height: 12px;
  background: var(--gold-bright);
  box-shadow: 0 0 18px rgba(228, 189, 107, 0.7);
}

.hint-eye span {
  position: absolute;
  inset: -9px;
  border-top: 1px solid rgba(228, 189, 107, 0.18);
  border-radius: 50%;
}

.hint-room {
  color: var(--gold);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hint-text {
  max-width: 520px;
  margin-top: 0.55rem;
  color: var(--sand);
  font-family: var(--font-display);
  font-size: clamp(0.98rem, 2vw, 1.2rem);
  line-height: 1.55;
}

.hint-progress {
  display: grid;
  width: 100%;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 1.1rem;
}

.hint-progress div {
  padding: 0.6rem;
  border: 1px solid rgba(228, 189, 107, 0.12);
  background: rgba(255, 255, 255, 0.018);
}

.hint-progress span {
  display: block;
  color: var(--muted-2);
  font-size: 0.52rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hint-progress strong {
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 500;
}

.hint-extra {
  margin-top: 0.9rem;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.5;
}

/* Пауза */

.pause-emblem {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  margin-top: 1.4rem;
  border: 1px solid rgba(228, 189, 107, 0.3);
  border-radius: 50%;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 1.3rem;
}

.modal-pause .eyebrow {
  margin-top: 0.8rem;
}

.modal-pause h2 {
  color: var(--sand);
  font-family: var(--font-display);
  font-size: 2.3rem;
  font-weight: 500;
}

.pause-subtitle {
  margin-top: 0.2rem;
  color: var(--muted-2);
  font-size: 0.72rem;
}

.pause-stats {
  display: grid;
  width: calc(100% - 3rem);
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin-top: 1.2rem;
}

.pause-stats div {
  padding: 0.55rem;
  border: 1px solid rgba(228, 189, 107, 0.11);
}

.pause-stats span {
  display: block;
  color: var(--muted-2);
  font-size: 0.5rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pause-stats strong {
  color: var(--sand);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 500;
}

.pause-actions {
  display: flex;
  width: calc(100% - 3rem);
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 1rem;
}

.pause-note {
  margin-top: 0.8rem;
  color: var(--muted-2);
  font-size: 0.58rem;
}

/* Победа */

.victory-screen {
  z-index: 60;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  background:
    radial-gradient(circle at 50% 42%, rgba(252, 221, 150, 0.28), transparent 36%),
    radial-gradient(circle at 50% 50%, rgba(83, 58, 25, 0.75), transparent 60%),
    #0c0809;
  backdrop-filter: none;
}

.victory-screen.is-open {
  animation: victoryIn 1s ease both;
}

@keyframes victoryIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.victory-rays {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 150vmax;
  height: 150vmax;
  background: repeating-conic-gradient(from 0deg, rgba(249, 226, 164, 0.09) 0deg 2deg, transparent 2deg 10deg);
  mask-image: radial-gradient(circle, #000 0%, transparent 62%);
  -webkit-mask-image: radial-gradient(circle, #000 0%, transparent 62%);
  transform: translate(-50%, -50%);
  animation: raysTurn 80s linear infinite;
  pointer-events: none;
}

@keyframes raysTurn {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.victory-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.victory-particle {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold-bright);
  box-shadow: 0 0 10px var(--gold);
  animation: particleRise linear infinite;
}

@keyframes particleRise {
  from { transform: translateY(100vh) scale(0.4); opacity: 0; }
  15% { opacity: 1; }
  to { transform: translateY(-12vh) scale(1.2); opacity: 0; }
}

.victory-content {
  position: relative;
  z-index: 2;
  display: flex;
  width: min(720px, 92vw);
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
  text-align: center;
}

.victory-content h2 {
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-size: clamp(3.2rem, 9vw, 6.4rem);
  font-weight: 400;
  line-height: 0.95;
  letter-spacing: 0.05em;
  text-shadow: 0 0 50px rgba(249, 226, 164, 0.32);
}

.victory-subtitle {
  margin-top: 0.35rem;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.victory-divider {
  display: flex;
  width: min(420px, 80%);
  align-items: center;
  gap: 0.7rem;
  margin: 1.2rem 0;
  color: var(--gold);
}

.victory-divider span {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(228, 189, 107, 0.6));
}

.victory-divider span:last-child {
  background: linear-gradient(90deg, rgba(228, 189, 107, 0.6), transparent);
}

.victory-divider i {
  font-style: normal;
  font-size: 0.7rem;
}

.victory-ending {
  max-width: 620px;
  color: #e8ddc5;
  font-family: var(--font-display);
  font-size: clamp(0.9rem, 1.7vw, 1.06rem);
  line-height: 1.72;
}

.victory-stats {
  display: grid;
  width: min(560px, 100%);
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  margin-top: 1.4rem;
}

.victory-stats div {
  padding: 0.62rem 0.4rem;
  border: 1px solid rgba(228, 189, 107, 0.18);
  background: rgba(14, 10, 9, 0.34);
}

.victory-stats span {
  display: block;
  color: var(--muted-2);
  font-size: 0.5rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.victory-stats strong {
  display: block;
  margin-top: 0.08rem;
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-size: 0.94rem;
  font-weight: 500;
}

.victory-perfect {
  margin-top: 0.8rem;
  color: var(--gold);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
}

.victory-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.3rem;
}

.victory-actions .button {
  min-width: 180px;
}

/* Поражение */

.defeat-screen {
  z-index: 60;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  background:
    radial-gradient(circle at 50% 50%, rgba(104, 31, 42, 0.34), transparent 50%),
    rgba(6, 4, 8, 0.92);
  backdrop-filter: blur(10px);
}

.defeat-shadow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(3, 2, 5, 0.72));
  pointer-events: none;
}

.defeat-content {
  position: relative;
  z-index: 2;
  display: flex;
  width: min(620px, 92vw);
  flex-direction: column;
  align-items: center;
  padding: 1.2rem;
  text-align: center;
}

.defeat-content h2 {
  color: #e7a8ae;
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 7vw, 5.1rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.03em;
  text-shadow: 0 0 40px rgba(207, 98, 108, 0.24);
}

.defeat-subtitle {
  margin-top: 0.4rem;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.9rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.defeat-message {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  margin-top: 1.4rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid rgba(207, 98, 108, 0.18);
  background: rgba(126, 48, 58, 0.08);
  color: var(--muted);
  font-size: 0.7rem;
  text-align: left;
}

.defeat-message span {
  color: var(--red);
  font-size: 0.8rem;
}

.defeat-message p {
  line-height: 1.55;
}

.defeat-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.2rem;
}

/* Уведомления */

.toast-layer {
  position: fixed;
  z-index: 90;
  top: calc(var(--safe-top) + 4.9rem);
  left: 50%;
  display: flex;
  width: min(440px, calc(100vw - 2rem));
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  max-width: 100%;
  padding: 0.55rem 0.85rem;
  border: 1px solid rgba(228, 189, 107, 0.3);
  background: rgba(15, 11, 21, 0.95);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.46), 0 0 20px rgba(228, 189, 107, 0.06);
  color: var(--sand);
  font-size: 0.72rem;
  line-height: 1.35;
  opacity: 0;
  transform: translateY(-5px);
  animation: toastIn 0.28s ease forwards, toastOut 0.35s ease 2.7s forwards;
  backdrop-filter: blur(10px);
}

.toast::before {
  content: "◈";
  color: var(--gold);
  font-size: 0.6rem;
}

.toast.toast-key {
  border-color: rgba(249, 226, 164, 0.5);
}

.toast.toast-secret {
  border-color: rgba(121, 201, 184, 0.42);
}

.toast.toast-secret::before {
  color: var(--teal);
}

.toast.toast-warning {
  border-color: rgba(207, 98, 108, 0.46);
}

.toast.toast-warning::before {
  color: var(--red);
}

@keyframes toastIn {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(-4px); }
}

.achievement-popup {
  position: fixed;
  z-index: 95;
  right: clamp(0.7rem, 2vw, 1.5rem);
  bottom: calc(var(--safe-bottom) + 1rem);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: min(340px, calc(100vw - 1.4rem));
  padding: 0.7rem 1rem;
  border: 1px solid rgba(228, 189, 107, 0.45);
  background:
    linear-gradient(145deg, rgba(64, 46, 30, 0.97), rgba(20, 14, 27, 0.98));
  box-shadow: var(--shadow-deep), 0 0 30px rgba(228, 189, 107, 0.12);
  animation: achievementIn 0.45s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

.achievement-popup.is-leaving {
  animation: achievementOut 0.35s ease both;
}

.achievement-popup-icon {
  display: grid;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid rgba(228, 189, 107, 0.4);
  border-radius: 50%;
  color: var(--gold-bright);
}

.achievement-popup small {
  display: block;
  color: var(--gold);
  font-size: 0.5rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.achievement-popup strong {
  display: block;
  margin-top: 0.05rem;
  color: var(--sand);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 500;
}

@keyframes achievementIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes achievementOut {
  to { opacity: 0; transform: translateX(40px); }
}

.noscript-note {
  position: fixed;
  z-index: 300;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 1rem;
  background: #1b121f;
  color: var(--sand);
  text-align: center;
}

/* Адаптивность */

@media (max-width: 1180px) {
  .brand-mini {
    min-width: 0;
  }

  .brand-mini-copy {
    display: none;
  }

  .hud-difficulty {
    display: none;
  }

  .utility-button span {
    display: none;
  }

  .utility-button {
    min-width: 48px;
  }

  .utility-button kbd {
    display: none;
  }
}

@media (max-width: 940px) {
  :root {
    --topbar-height: 62px;
  }

  .hud-room {
    min-width: 100px;
    max-width: 150px;
  }

  .hud-stat {
    min-width: 80px;
  }

  .hud-health {
    min-width: 84px;
  }

  .hud-room-line span {
    font-size: 0.8rem;
  }

  .difficulty-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .difficulty-card {
    min-height: 190px;
  }

  .map-body {
    display: block;
    grid-template-columns: 1fr;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .map-canvas-shell {
    height: min(48dvh, 410px);
    min-height: 310px;
    flex: 0 0 auto;
  }

  .map-sidebar {
    display: block;
    border-top: 1px solid rgba(228, 189, 107, 0.1);
    border-left: 0;
    overflow: visible;
  }

  .map-details {
    flex: 0 0 auto;
    min-height: 0;
  }

  .map-legend {
    flex: 0 0 auto;
  }

  .map-total {
    margin-top: 0;
  }

  .achievements-content {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  :root {
    --topbar-height: 58px;
    --touch-height: 144px;
  }

  .topbar {
    gap: 0.35rem;
    padding: 0.4rem 0.55rem;
  }

  .brand-mini {
    display: none;
  }

  .hud {
    justify-content: flex-start;
    gap: 0.45rem;
  }

  .hud-room {
    min-width: 72px;
    max-width: 98px;
    padding-right: 0.4rem;
  }

  .hud-room-line {
    gap: 0.25rem;
  }

  .hud-room-line strong {
    font-size: 1.05rem;
  }

  .hud-room-line span {
    font-size: 0.67rem;
  }

  .hud-label {
    font-size: 0.48rem;
    letter-spacing: 0.1em;
  }

  .hud-stat {
    min-width: 0;
    gap: 0.2rem;
  }

  .hud-icon {
    width: 20px;
    height: 20px;
  }

  .hud-icon svg {
    width: 19px;
    height: 19px;
  }

  .hud-stat-copy strong {
    font-size: 0.7rem;
  }

  .hud-stat-copy .hud-label {
    display: none;
  }

  .hud-health {
    min-width: 0;
  }

  .hud-health .hud-label {
    display: none;
  }

  .heart {
    width: 13px;
    height: 13px;
    transform: rotate(-45deg) scale(0.8);
  }

  .heart::before,
  .heart::after {
    width: 13px;
    height: 13px;
  }

  .heart::before { top: -7px; }
  .heart::after { left: 6px; }

  .utility-bar {
    gap: 0.1rem;
  }

  .utility-button {
    min-width: 40px;
    min-height: 42px;
    padding: 0.25rem;
  }

  .utility-button svg {
    width: 19px;
    height: 19px;
  }

  .modal-header {
    gap: 0.6rem;
    padding: 1rem 1rem 0.8rem;
  }

  .modal-header p:not(.eyebrow) {
    font-size: 0.72rem;
  }

  .modal-footer {
    padding: 0.8rem 1rem 1rem;
  }

  .modal-footer .settings-note {
    display: none;
  }

  .difficulty-grid {
    gap: 0.45rem;
    padding: 0.8rem 1rem;
  }

  .difficulty-card {
    min-height: 168px;
    padding: 0.75rem;
  }

  .difficulty-name {
    font-size: 1rem;
  }

  .difficulty-description {
    font-size: 0.62rem;
  }

  .tutorial-content {
    grid-template-columns: 68px 1fr;
    gap: 0.8rem;
    padding: 1rem;
  }

  .tutorial-visual {
    width: 68px;
    height: 68px;
    font-size: 1.4rem;
  }

  .tutorial-copy h3 {
    font-size: 1.15rem;
  }

  .tutorial-copy p {
    font-size: 0.73rem;
  }

  .inventory-grid {
    grid-template-columns: 1fr;
  }

  .inventory-summary {
    display: none;
  }

  .map-progress {
    display: none;
  }

  .map-canvas-shell {
    min-height: 380px;
    margin: 0.5rem;
  }

  .map-node {
    width: 42px;
    height: 42px;
    font-size: 0.8rem;
  }

  .map-gate {
    width: 80px;
    height: 38px;
    font-size: 0.42rem;
  }

  .map-node-badge {
    width: 14px;
    height: 14px;
    font-size: 0.45rem;
  }

  .modal-map {
    height: calc(100dvh - 1.2rem);
  }

  .victory-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .victory-actions,
  .defeat-actions {
    flex-direction: column;
    width: min(320px, 100%);
  }

  .victory-actions .button {
    width: 100%;
  }

  .toast-layer {
    top: calc(var(--safe-top) + 4.2rem);
  }

  .keyboard-strip {
    display: none;
  }

  .menu-actions-row {
    flex-wrap: wrap;
  }

  .menu-actions-row .button {
    flex: 1 1 40%;
  }

  .menu-footer {
    display: none;
  }

  .menu-screen {
    justify-content: flex-start;
    padding-top: clamp(2rem, 8vh, 4rem);
  }

  .menu-sun {
    width: 84vw;
    top: 46%;
  }
}

@media (pointer: coarse), (max-width: 900px) {
  #app {
    --stage-max: calc((100dvh - var(--topbar-height) - var(--touch-height) - 12px) * 1.7778);
  }

  .touch-controls {
    display: flex;
  }

  .keyboard-strip {
    display: none;
  }

  .utility-button kbd {
    display: none;
  }

  .utility-button {
    min-width: 48px;
    min-height: 48px;
  }

  .utility-button span {
    display: none;
  }

  .screen {
    touch-action: pan-y;
  }
}

@media (orientation: portrait) and (pointer: coarse) {
  .orientation-tip {
    position: absolute;
    z-index: 12;
    top: 0.45rem;
    right: 0.55rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.45rem;
    border: 1px solid rgba(228, 189, 107, 0.18);
    background: rgba(10, 7, 15, 0.7);
    color: rgba(239, 227, 198, 0.6);
    font-size: 0.48rem;
    pointer-events: none;
  }

  .touch-center-hint {
    display: none;
  }

  .touch-controls {
    gap: 0.35rem;
    padding-right: 0.65rem;
    padding-left: 0.65rem;
  }

  .stage-wrap {
    padding-top: 0.3rem;
  }

  .hud-hearts .heart:nth-child(n + 5) {
    display: none;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  :root {
    --topbar-height: 48px;
    --touch-height: 116px;
  }

  .topbar {
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
  }

  .hud-label {
    display: none;
  }

  .hud-room {
    min-width: 64px;
  }

  .hud-room-line strong {
    font-size: 1rem;
  }

  .hud-room-line span {
    font-size: 0.66rem;
  }

  .hud-icon {
    display: none;
  }

  .utility-button {
    min-width: 44px;
    min-height: 40px;
  }

  .stage-wrap {
    padding-top: 0.15rem;
  }

  .touch-button {
    width: 62px;
    height: 62px;
  }

  .touch-jump {
    width: 78px;
    height: 78px;
  }

  .touch-interact {
    width: 56px;
    height: 56px;
  }

  .touch-button span {
    display: none;
  }

  .touch-center-hint {
    padding-bottom: 0;
  }

  .room-banner {
    top: 0.5rem;
    padding-top: 0.25rem;
    padding-bottom: 0.3rem;
  }

  .room-banner small {
    display: none;
  }

  .interaction-prompt {
    bottom: 4%;
  }

  .toast-layer {
    top: calc(var(--safe-top) + 3.2rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 760px) {
  .topbar {
    min-height: 56px;
    gap: 0.25rem;
    padding: 0.35rem 0.45rem;
  }

  .hud {
    gap: 0.28rem;
    min-width: 0;
  }

  .hud-room {
    min-width: 52px;
    max-width: 68px;
    flex: 0 1 68px;
    padding-right: 0.28rem;
  }

  .hud-room .hud-label {
    display: none;
  }

  .hud-room-line {
    gap: 0.18rem;
  }

  .hud-room-line strong {
    font-size: 1rem;
  }

  .hud-room-line span {
    font-size: 0.62rem;
  }

  .hud-stat {
    min-width: 0;
    flex: 0 0 auto;
    gap: 0.12rem;
  }

  .hud-stat .hud-icon {
    display: grid;
    width: 13px;
    height: 13px;
  }

  .hud-stat .hud-icon svg {
    width: 13px;
    height: 13px;
  }

  .hud-stat-copy strong {
    font-size: 0.64rem;
    letter-spacing: 0;
    white-space: nowrap;
  }

  .hud-health {
    min-width: 0;
  }

  .hud-health .hud-label {
    display: none;
  }

  .hearts {
    gap: 3px;
    height: 19px;
  }

  .heart {
    width: 12px;
    height: 12px;
    border: 0;
    background: none;
    transform: none;
  }

  .heart svg {
    width: 12px;
    height: 12px;
  }

  .heart::before,
  .heart::after {
    display: none;
  }

  .heart.is-full {
    border: 0;
    background: none;
    box-shadow: none;
  }

  .touch-interact span {
    font-size: 0.47rem;
    line-height: 1.05;
  }

  .utility-bar {
    gap: 0;
    flex: 0 0 auto;
  }

  .utility-button {
    min-width: 33px;
    min-height: 35px;
    padding: 0.12rem;
  }

  .utility-button svg {
    width: 16px;
    height: 16px;
  }

  .touch-interact {
    width: clamp(66px, 10vw, 88px);
    height: clamp(66px, 10vw, 88px);
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  #app {
    --topbar-height: 48px;
    --touch-height: 0px;
    --stage-max: calc((100dvh - 58px) * 1.7778);
  }

  .game-main {
    position: relative;
  }

  .stage-wrap {
    height: 100%;
    padding: 4px 92px 4px 84px;
  }

  .stage-frame {
    max-height: calc(100dvh - 56px);
  }

  .touch-controls {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    min-height: 0;
    height: auto;
    padding: 0 8px 9px;
    border: 0;
    background: none;
    backdrop-filter: none;
    pointer-events: none;
  }

  .touch-cluster {
    flex-direction: column;
    align-items: center;
    gap: 7px;
    pointer-events: none;
  }

  .touch-move {
    display: grid;
    grid-template-columns: 64px;
    grid-template-areas:
      "up"
      "down"
      "left"
      "right";
    gap: 6px;
    align-items: center;
    justify-items: center;
  }

  .touch-move .touch-climb {
    width: 52px;
    height: 52px;
  }

  .touch-move .touch-direction {
    width: 64px;
    height: 64px;
  }

  .touch-actions {
    align-items: flex-end;
  }

  .touch-button {
    width: 64px;
    height: 64px;
    pointer-events: auto;
    background:
      radial-gradient(circle at 38% 26%, rgba(228, 189, 107, 0.19), transparent 54%),
      rgba(24, 17, 32, 0.82);
  }

  .touch-jump {
    width: 82px;
    height: 82px;
  }

  .touch-interact {
    width: 66px;
    height: 66px;
  }

  .touch-button span {
    display: none;
  }

  .touch-center-hint {
    display: none;
  }

  .hud-stat .hud-icon {
    display: grid;
    width: 18px;
    height: 18px;
  }

  .hud-stat .hud-icon svg {
    width: 18px;
    height: 18px;
  }

  .toast-layer {
    top: calc(var(--safe-top) + 3.3rem);
    width: min(380px, calc(100vw - 220px));
  }
}
