/* =========================================================
   A.D. — светлый минимализм
   Один файл на весь сайт: главная + страница игры.
   ========================================================= */

:root {
  /* палитра */
  --bg:          #F7F6F2;   /* тёплая бумага */
  --bg-elev:     #FFFFFF;
  --bg-sunken:   #F1EFE9;
  --ink:         #16161A;
  --ink-soft:    #45444E;
  --ink-mute:    #8B8894;
  --line:        #E4E1D8;
  --line-strong: #D5D1C6;
  --accent:      #D9452A;   /* вермильон */
  --accent-ink:  #B3341D;
  --accent-soft: #FCEDE9;

  /* типографика */
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua",
                  Georgia, "Times New Roman", serif;
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif;

  /* размеры */
  --wrap: 1120px;
  --gutter: 24px;
  --radius: 16px;
  --radius-sm: 10px;

  --shadow-sm: 0 1px 2px rgba(22, 22, 26, .05), 0 2px 8px rgba(22, 22, 26, .04);
  --shadow-md: 0 2px 4px rgba(22, 22, 26, .05), 0 12px 32px rgba(22, 22, 26, .08);
  --shadow-lg: 0 4px 8px rgba(22, 22, 26, .06), 0 24px 56px rgba(22, 22, 26, .12);

  --ease: cubic-bezier(.22, .68, .32, 1);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* display из классов (flex/grid) перебивает hidden из браузерных стилей,
   поэтому объявляем правило явно — иначе скрытые из JS элементы видны */
[hidden] { display: none !important; }

h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -0.02em; }
p { margin: 0; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

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

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 100;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
}
.skip-link:focus { left: 16px; }

/* ---------------- header ---------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s var(--ease), background .3s var(--ease);
}
.site-header.is-stuck { border-bottom-color: var(--line); }

.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 68px;
}

.brand-mark {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.brand-mark .dot,
.footer-mark .dot { color: var(--accent); }

.site-nav {
  margin-left: auto;
  display: flex;
  gap: 28px;
  font-size: 15px;
  color: var(--ink-soft);
}
.site-nav a {
  position: relative;
  padding-block: 4px;
  transition: color .2s var(--ease);
}
.site-nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .28s var(--ease);
}
.site-nav a:hover { color: var(--ink); }
.site-nav a:hover::after { transform: scaleX(1); }

.lang-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elev);
}
.lang-btn {
  background: none;
  border: 0;
  padding: 1px 2px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--ink-mute);
  transition: color .2s var(--ease);
}
.lang-btn:hover { color: var(--ink); }
.lang-btn[aria-pressed="true"] { color: var(--accent); }
.lang-sep {
  width: 1px;
  height: 12px;
  background: var(--line-strong);
}

/* ---------------- hero ---------------- */
.hero {
  position: relative;
  min-height: min(88vh, 780px);
  display: flex;
  align-items: center;
  padding-block: 72px 96px;
  overflow: hidden;
}

.hero-glow {
  position: absolute;
  inset: -20% -10% auto -10%;
  height: 120%;
  pointer-events: none;
  background:
    radial-gradient(42% 46% at 22% 28%, rgba(217, 69, 42, .10), transparent 70%),
    radial-gradient(38% 44% at 78% 22%, rgba(64, 92, 214, .09), transparent 70%),
    radial-gradient(50% 40% at 50% 88%, rgba(214, 178, 64, .10), transparent 72%);
  filter: blur(6px);
}

.hero-inner {
  position: relative;
  text-align: center;
}

.monogram {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(88px, 21vw, 216px);
  line-height: .92;
  letter-spacing: -0.045em;
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
}
.mono-ch {
  display: inline-block;
  background: linear-gradient(175deg, var(--ink) 20%, #4b4a55 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: mono-rise .9s var(--ease) backwards;
  animation-delay: calc(var(--i) * 90ms + 80ms);
}
/* точки монограммы рисуем в CSS: форма «.» слишком зависит от системного шрифта */
.mono-dot {
  align-self: flex-end;
  flex: none;
  width: .125em;
  height: .125em;
  margin: 0 .05em .11em .03em;
  border-radius: 50%;
  background: var(--accent);
  animation: mono-rise .9s var(--ease) backwards;
  animation-delay: calc(var(--i) * 90ms + 80ms);
}

@keyframes mono-rise {
  from { opacity: 0; transform: translateY(28px) rotate(-2deg); }
  to   { opacity: 1; transform: none; }
}

.hero-greeting {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(22px, 4.2vw, 34px);
  color: var(--ink-soft);
  letter-spacing: .005em;
  animation: fade-up .9s var(--ease) .48s backwards;
}

.hero-tagline {
  max-width: 46ch;
  margin: 22px auto 0;
  color: var(--ink-mute);
  font-size: clamp(15px, 1.9vw, 17px);
  line-height: 1.7;
  text-wrap: balance;
  animation: fade-up .9s var(--ease) .58s backwards;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 34px;
  animation: fade-up .9s var(--ease) .68s backwards;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
}
.scroll-line {
  display: block;
  width: 1px;
  height: 46px;
  background: linear-gradient(var(--line-strong), transparent);
  animation: cue 2.4s var(--ease) infinite;
  transform-origin: top;
}
@keyframes cue {
  0%, 100% { transform: scaleY(.4); opacity: .4; }
  50%      { transform: scaleY(1);  opacity: 1; }
}

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding-inline: 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: transform .2s var(--ease), background .2s var(--ease),
              border-color .2s var(--ease), box-shadow .25s var(--ease), color .2s var(--ease);
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background: var(--accent);
  box-shadow: 0 6px 20px rgba(217, 69, 42, .28);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--ink-soft);
}
.btn-ghost:hover {
  border-color: var(--ink);
  color: var(--ink);
  background: var(--bg-elev);
}

/* ---------------- sections ---------------- */
.section { padding-block: clamp(64px, 9vw, 112px); }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 22px;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--line);
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(30px, 4.6vw, 44px);
  font-weight: 700;
}
.section-sub {
  margin-top: 8px;
  color: var(--ink-mute);
  font-size: 15px;
}

.counter {
  font-size: 13px;
  letter-spacing: .1em;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-bottom: 6px;
}

/* ---------------- games grid ---------------- */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 26px;
}

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .32s var(--ease), box-shadow .32s var(--ease),
              border-color .32s var(--ease);
}
.game-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
}

.game-cover {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--bg-sunken);
  overflow: hidden;
}
.game-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .5s var(--ease);
}
.game-card:hover .game-cover img { transform: scale(1.04); }

/* заглушка обложки: градиент + инициалы, если картинки ещё нет */
.cover-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(120% 120% at 20% 15%, hsl(var(--h) 62% 88%), transparent 60%),
    linear-gradient(150deg, hsl(var(--h) 55% 92%), hsl(calc(var(--h) + 42) 48% 86%));
}
.cover-fallback span {
  font-family: var(--font-display);
  font-size: 54px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: hsl(var(--h) 45% 32%);
  opacity: .55;
}

.game-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  border-radius: 999px;
  background: rgba(255, 255, 255, .92);
  color: var(--ink-soft);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(4px);
}
.game-badge.is-soon { color: var(--accent-ink); background: var(--accent-soft); }

.game-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 10px;
  padding: 20px 22px 22px;
}

.game-title {
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 700;
}

.game-desc {
  color: var(--ink-mute);
  font-size: 14.5px;
  line-height: 1.6;
  flex: 1;
}

.game-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.game-tags li {
  font-size: 12px;
  letter-spacing: .02em;
  color: var(--ink-mute);
  background: var(--bg-sunken);
  border-radius: 999px;
  padding: 3px 10px;
}

.game-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.game-year {
  font-size: 13px;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
}
.game-play {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--accent);
}
.game-play .arrow {
  transition: transform .28s var(--ease);
}
.game-card:hover .game-play .arrow { transform: translateX(4px); }

/* вся карточка кликабельна */
.game-card .stretched::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.game-card.is-soon { opacity: .78; }
.game-card.is-soon:hover { transform: none; box-shadow: var(--shadow-sm); }

.grid-empty {
  padding: 56px 0;
  text-align: center;
  color: var(--ink-mute);
}

/* появление карточек при скролле */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .6s var(--ease), transform .6s var(--ease);
}
.reveal.is-in { opacity: 1; transform: none; }

/* ---------------- about ---------------- */
.section-about {
  background: var(--bg-elev);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.about-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 80px);
  align-items: start;
}
.about-text {
  margin-top: 20px;
  max-width: 56ch;
  color: var(--ink-soft);
}
.about-text-muted { color: var(--ink-mute); font-size: 15.5px; }

.contacts {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.contacts li { border-bottom: 1px solid var(--line); }
.contacts a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 2px;
  transition: padding-inline-start .25s var(--ease), color .2s var(--ease);
}
.contacts a:hover { padding-inline-start: 8px; color: var(--accent); }
.contact-key {
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.contact-val { font-size: 15px; }

/* ---------------- footer ---------------- */
.site-footer {
  padding-block: 34px;
  background: var(--bg);
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--ink-mute);
}
.footer-mark {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
}
.footer-top { transition: color .2s var(--ease); }
.footer-top:hover { color: var(--accent); }

/* ---------------- адаптив ---------------- */
@media (max-width: 720px) {
  body { font-size: 16px; }
  .header-inner { gap: 14px; height: 62px; }
  .site-nav { display: none; }
  .lang-switch { margin-left: auto; }
  .about-inner { grid-template-columns: 1fr; }
  .section-head { flex-direction: column; align-items: flex-start; }
  .games-grid { grid-template-columns: 1fr; gap: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* =========================================================
   СТРАНИЦА ИГРЫ  (/play/<slug>/)
   ========================================================= */

.body-play { background: var(--bg); }

.play-main { padding-bottom: 8px; }

/* ---------------- шапка ---------------- */
.play-header .header-inner { gap: 18px; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: var(--ink-soft);
  white-space: nowrap;
  transition: color .2s var(--ease);
}
.back-link:hover { color: var(--accent); }
.back-arrow {
  display: inline-block;
  transition: transform .25s var(--ease);
}
.back-link:hover .back-arrow { transform: translateX(-3px); }

.play-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.play-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding-inline: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .2s var(--ease), color .2s var(--ease), background .2s var(--ease);
}
.tool-btn:hover { border-color: var(--ink); color: var(--ink); }
.tool-icon { font-size: 13px; line-height: 1; }

/* ---------------- сцена с игрой ---------------- */
.stage-section { padding: 28px 0 8px; }

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: var(--ar, 16 / 9);
  max-width: calc(76vh * var(--arn, 1.778));
  margin-inline: auto;
  background: #101014;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.game-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* полноэкранный режим: сцена занимает весь экран */
.stage:fullscreen {
  max-width: none;
  aspect-ratio: auto;
  width: 100%;
  height: 100%;
  border-radius: 0;
  box-shadow: none;
}

.stage-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  color: #EFEDE8;
  background: #101014;
}
.stage-msg-text {
  font-family: var(--font-display);
  font-size: clamp(19px, 3vw, 24px);
  font-weight: 700;
}
.stage-msg-hint {
  max-width: 42ch;
  font-size: 14.5px;
  line-height: 1.6;
  color: rgba(239, 237, 232, .62);
  overflow-wrap: anywhere;
}
.stage-msg-btn {
  margin-top: 6px;
  border-color: rgba(255, 255, 255, .28);
  color: rgba(239, 237, 232, .9);
}
.stage-msg-btn:hover {
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .5);
  color: #fff;
}

.stage-spinner {
  width: 30px;
  height: 30px;
  border: 2px solid rgba(255, 255, 255, .18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stage-hint {
  margin: 14px auto 0;
  text-align: center;
  font-size: 13.5px;
  color: var(--ink-mute);
}

/* ---------------- комментарии ---------------- */
.comments-section { padding-block: clamp(48px, 7vw, 88px); }

.comments-inner {
  max-width: 780px;
  margin-inline: auto;
}

.comments-head { margin-bottom: 28px; }

.comments-count {
  display: inline-block;
  margin-left: 10px;
  padding: 2px 11px;
  vertical-align: middle;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}
.comments-count:empty { display: none; }

/* форма */
.comment-form {
  display: grid;
  gap: 16px;
  padding: 22px;
  margin-bottom: 36px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.field { display: grid; gap: 7px; position: relative; }
.field label {
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.field-name input,
.field-text textarea {
  width: 100%;
  padding: 11px 13px;
  font: inherit;
  font-size: 15.5px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease);
}
.field-name input { max-width: 320px; }
.field-text textarea {
  resize: vertical;
  min-height: 104px;
  line-height: 1.6;
}
.field-name input:focus,
.field-text textarea:focus {
  outline: none;
  background: var(--bg-elev);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.char-count {
  position: absolute;
  right: 2px;
  bottom: -19px;
  font-size: 12px;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
}

/* ловушка для ботов: убрана из потока, но не display:none —
   иначе часть ботов её игнорирует */
.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.form-foot {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.form-msg {
  font-size: 14px;
  color: var(--ink-mute);
}
.form-msg.is-error { color: var(--accent-ink); }
.form-msg.is-ok    { color: #2E7D4F; }

.btn:disabled { opacity: .55; cursor: default; }
.btn-primary:disabled:hover { background: var(--ink); box-shadow: var(--shadow-sm); }

/* список */
.comment-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.comment {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 14px;
  padding: 18px 2px;
  border-bottom: 1px solid var(--line);
}
.comment:last-child { border-bottom: 0; }

.comment-avatar {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: hsl(var(--h, 20) 52% 92%);
  color: hsl(var(--h, 20) 42% 34%);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  user-select: none;
}

.comment-body { min-width: 0; }

.comment-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.comment-name {
  font-weight: 600;
  font-size: 15.5px;
  overflow-wrap: anywhere;
}
.comment-time {
  font-size: 13px;
  color: var(--ink-mute);
}

.comment-text {
  color: var(--ink-soft);
  font-size: 15.5px;
  line-height: 1.65;
  white-space: pre-wrap;      /* переносы строк сохраняются без вставки HTML */
  overflow-wrap: anywhere;
}

.comments-empty {
  padding: 28px 0;
  color: var(--ink-mute);
  text-align: center;
}

@media (max-width: 720px) {
  .play-title { display: none; }
  .tool-btn span:not(.tool-icon) { display: none; }
  .tool-btn { padding-inline: 11px; }
  .stage-section { padding-top: 16px; }
  .stage { border-radius: var(--radius-sm); }
  .comment-form { padding: 16px; }
  .comment { grid-template-columns: 32px minmax(0, 1fr); gap: 11px; }
  .comment-avatar { width: 32px; height: 32px; font-size: 15px; }
}
