/* ===== палитра ===== */
:root {
  --ink: #0a0a0a;          /* почти чёрный */
  --rust: #4a4a4a;
  --rust-2: #9a9a9a;       /* даты */
  --blood: #000;           /* выбранная игра */
  --red: #f0f0f0;          /* пометки */
  --sepia: #d4d4d4;        /* основной текст */
  --muted: #858585;
  --gray: #b3b3b3;         /* окна */
  --gray-hi: #ececec;
  --gray-lo: #5c5c5c;
  --gray-dk: #2d2d2d;
  --ui: "PT Sans", Helvetica, Arial, sans-serif;
  --mono: "PT Mono", monospace;
  --hand: "Caveat", cursive;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 12px; }
body {
  margin: 0; min-height: 100vh; color: var(--sepia); font: 13px/1.4 var(--mono);
  /* ровный тёмный фон: светлее в центре, темнее к краям */
  background: radial-gradient(ellipse at 50% 30%, #222 0%, #111 55%, #050505 100%) fixed var(--ink);
  padding-bottom: 40px;
}
a { color: var(--sepia); }
a:hover { color: #fff; }
p { margin: 0 0 6px; }

/* ===== рабочий стол ===== */
.desktop {
  position: relative; max-width: 1120px; margin: 0 auto; padding: 18px 16px 30px;
  display: grid; gap: 18px;
  grid-template-columns: minmax(0, 1fr) 260px;
  align-items: start;
}
#w-head, #w-events, #w-about, #w-contact { grid-column: 1 / -1; }
#w-games { grid-column: 1; grid-row: span 2; }
#w-tools, #w-arts { grid-column: 2; }
@media (max-width: 900px) {
  .desktop { grid-template-columns: minmax(0, 1fr); }
  #w-games, #w-tools, #w-arts { grid-column: 1; grid-row: auto; }
}
/* вкладки: показываем только окна текущей страницы */
.win[data-page]:not(.shown) { display: none; }
.menubar a.current { background: #333; color: #f2f2f2; padding: 0 6px; margin: 0 -6px; }
.sigil {
  position: fixed; right: 18px; bottom: 50px; width: 46px; height: 46px; object-fit: cover;
  filter: invert(1); opacity: .35;
  pointer-events: none;
}

/* ===== окно в духе старой Unix-ОС ===== */
.win {
  position: relative; background: var(--gray); padding: 3px;
  border: 2px solid; border-color: var(--gray-hi) var(--gray-lo) var(--gray-lo) var(--gray-hi);
  box-shadow: 1px 1px 0 #000, 6px 8px 18px rgba(0,0,0,.6);
  color: #111; font-family: var(--ui);
  transform: translate(var(--x, 0px), var(--y, 0px));
}
.win.dragging { box-shadow: 1px 1px 0 #000, 14px 18px 30px rgba(0,0,0,.7); }
.titlebar {
  display: flex; align-items: center; gap: 6px; height: 24px; padding: 0 3px;
  background: linear-gradient(#c9c9c9, #a3a3a3);
  border: 1px solid; border-color: var(--gray-hi) var(--gray-lo) var(--gray-lo) var(--gray-hi);
  cursor: grab; user-select: none; touch-action: none;
}
.win.active .titlebar { background: linear-gradient(#6a6a6a, #3a3a3a); color: #f2f2f2; }
.t-title { flex: 1; font-style: italic; font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-sys, .t-btns button {
  width: 16px; height: 16px; padding: 0; background: var(--gray); cursor: pointer;
  border: 1px solid; border-color: var(--gray-hi) var(--gray-lo) var(--gray-lo) var(--gray-hi); position: relative;
}
.t-sys::after { content: ""; position: absolute; left: 3px; right: 3px; top: 6px; height: 2px; background: #333; box-shadow: 0 1px 0 #fff; }
.t-btns { display: flex; gap: 3px; }
.b-min::after { content: ""; position: absolute; left: 5px; top: 5px; width: 4px; height: 4px; border: 1px solid #222; }
.b-max::after { content: ""; position: absolute; left: 2px; top: 2px; right: 2px; bottom: 2px; border: 1px solid #222; }
.t-btns button:active { border-color: var(--gray-lo) var(--gray-hi) var(--gray-hi) var(--gray-lo); }

.menubar {
  display: flex; gap: 18px; padding: 3px 8px; font-size: 13px; align-items: center;
  border-bottom: 1px solid var(--gray-lo);
}
.menubar a, .menubar span { color: #111; text-decoration: none; }
.menubar a:hover { text-decoration: underline; color: #000; }
.menubar-right { margin-left: auto; }

/* тёмная «вдавленная» область внутри окна */
.win-body {
  margin-top: 3px; padding: 12px 14px; color: var(--sepia); font-family: var(--mono);
  background: linear-gradient(180deg, #1a1a1a, #0d0d0d);
  border: 2px solid; border-color: var(--gray-lo) var(--gray-hi) var(--gray-hi) var(--gray-lo);
}
.win.minimized .win-body, .win.minimized .menubar { display: none; }
.win.maximized { position: fixed; inset: 8px 8px 44px; z-index: 500; overflow: auto; transform: none !important; }

/* заголовки-«наклейки», как вырезанная бумага */
.label {
  display: inline-block; margin: 0 0 10px; padding: 2px 12px 3px;
  font: italic 700 26px/1.1 var(--ui); color: #111; letter-spacing: .02em;
  background: #e6e6e6; transform: rotate(-1.2deg);
  box-shadow: 2px 2px 0 rgba(0,0,0,.6);
  clip-path: polygon(0 6%, 4% 0, 30% 4%, 62% 0, 100% 5%, 98% 50%, 100% 96%, 70% 100%, 35% 95%, 2% 100%, 0 60%);
}
.label.small { font-size: 16px; margin-top: 14px; }

/* ===== шапка ===== */
.head-body { background: #000; overflow: hidden; }
.hero { display: flex; justify-content: center; }
.hero img { display: block; width: min(560px, 100%); height: auto; margin-top: -55px; }
.head-title { display: flex; align-items: center; gap: 16px; }
.head-logo { width: 110px; height: 110px; margin: -16px -10px; object-fit: cover; flex: none; filter: invert(1); }
.head-title h1 { font-size: 40px; }

/* бесконечная лента кнопок, едет влево */
.badges {
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.badges-track { display: flex; width: max-content; animation: badges-run 30s linear infinite; }
.badges:hover .badges-track { animation-play-state: paused; }
.badges-set { display: flex; gap: 8px; padding-right: 8px; }
@keyframes badges-run { to { transform: translateX(-50%); } }
.badge {
  width: 88px; height: 31px; display: flex; align-items: center; justify-content: center; gap: 4px;
  font: 700 11px/1 var(--mono); text-align: center; text-decoration: none; border: 1px solid #888; overflow: hidden;
  transition: transform .12s;
}
.badge:hover { transform: translateY(-2px); }
.b-logo { background: #000; color: #fff; }
.b-logo img { width: 26px; height: 26px; object-fit: cover; filter: invert(1); }
.b-tg { background: linear-gradient(#5a5a5a, #2e2e2e); color: #fff; }
.b-itch { background: #e8e8e8; color: #000; }
.b-ds { background: linear-gradient(#8a8a8a, #5e5e5e); color: #fff; }

/* ===== каталог: окно просмотра ===== */
.viewport-body { padding: 0; }
.viewport {
  position: relative; aspect-ratio: 4/3; max-height: 460px; width: 100%; overflow: hidden;
  background: radial-gradient(circle at 50% 45%, #333, #0b0b0b 75%);
}
.vp-img { position: absolute; inset: 10%; width: 80%; height: 80%; object-fit: contain; }
.vp-placeholder {
  position: absolute; inset: 0; display: none;
  background: radial-gradient(circle at 50% 45%, #2e2e2e, transparent 60%);
}
.viewport.no-img .vp-img { display: none; }
.viewport.no-img .vp-placeholder { display: block; }
.viewport.switching { animation: tear .35s steps(3); }
@keyframes tear {
  0% { filter: none; transform: none; }
  33% { filter: contrast(1.6); transform: translateX(-6px) skewX(4deg); clip-path: inset(10% 0 40% 0); }
  66% { transform: translateX(5px); clip-path: inset(50% 0 5% 0); }
  100% { filter: none; transform: none; clip-path: inset(0); }
}

/* красные пометки поверх картинок */
.annot { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.annot-box, .annot-arrow {
  fill: none; stroke: var(--red); stroke-width: 2.5; vector-effect: non-scaling-stroke;
  stroke-dasharray: 1200; stroke-dashoffset: 1200; transition: stroke-dashoffset .9s ease-out;
}
.annot-label {
  position: absolute; top: 8%; right: 5%; font: 700 30px/1 var(--hand); color: var(--red);
  transform: rotate(-4deg); opacity: 0; transition: opacity .4s .5s;
  text-shadow: 1px 1px 0 rgba(0,0,0,.6);
}
.viewport.marked .annot-box, .viewport.marked .annot-arrow,
.photo:hover .annot-box { stroke-dashoffset: 0; }
.viewport.marked .annot-label, .photo:hover .annot-label { opacity: 1; }

.statusbar {
  display: flex; gap: 4px; align-items: stretch; padding: 4px; background: var(--gray);
  font: 12px var(--ui); color: #111;
}
.field {
  padding: 3px 8px; background: #c9c9c9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border: 1px solid; border-color: var(--gray-lo) var(--gray-hi) var(--gray-hi) var(--gray-lo);
}
.field.grow { flex: 1; min-width: 0; }
.btn {
  padding: 3px 14px; background: var(--gray); color: #111; text-decoration: none; font-weight: 700;
  border: 2px solid; border-color: var(--gray-hi) var(--gray-lo) var(--gray-lo) var(--gray-hi);
}
.btn:hover { color: #000; background: #c4c4c4; }
.btn:active { border-color: var(--gray-lo) var(--gray-hi) var(--gray-hi) var(--gray-lo); }

/* ===== палитра инструментов: иконки игр ===== */
.tools-body { padding: 6px; background: var(--gray); border-color: var(--gray-lo) var(--gray-hi) var(--gray-hi) var(--gray-lo); }
.tools { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
@media (max-width: 900px) { .tools { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); } }
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px 5px;
  background: var(--gray); cursor: pointer; font: 12px var(--ui); color: #111;
  border: 2px solid; border-color: var(--gray-hi) var(--gray-lo) var(--gray-lo) var(--gray-hi);
}
.tool i {
  width: 46px; height: 46px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #8a8a8a, #1a1a1a 75%);
  box-shadow: 1px 2px 3px rgba(0,0,0,.5); transition: transform .15s;
}
.tool:hover i { transform: scale(1.12); }
.tool.selected { background: #9d9d9d; border-color: var(--gray-lo) var(--gray-hi) var(--gray-hi) var(--gray-lo); }
.tool.selected span { color: var(--blood); font-weight: 700; }
/* новая игра: само окно каталога медленно светится (рамка и экран внутри) */
#w-games.glow-new { animation: new-frame 3.5s ease-in-out infinite; }
#w-games.glow-new .titlebar { background-image: none; color: #000; }
#w-games.glow-new .titlebar,
#w-games.glow-new .statusbar { animation: new-frame 3.5s ease-in-out infinite; }
#w-games.glow-new .viewport::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  animation: new-screen 3.5s ease-in-out infinite;
}
@keyframes new-frame {
  0%, 100% { background-color: var(--gray); }
  50% { background-color: #f2f2f2; }
}
@keyframes new-screen {
  0%, 100% { box-shadow: inset 0 0 0 rgba(255,255,255,0); background: transparent; }
  50% { box-shadow: inset 0 0 60px 6px rgba(255,255,255,.3); background: rgba(255,255,255,.05); }
}

/* ===== строки-таблицы (ивенты, контакты) ===== */
.rows { border: 1px solid #2a2a2a; }
.row { display: flex; gap: 10px; padding: 5px 8px; font-size: 12px; align-items: baseline; border-bottom: 1px solid #2a2a2a; }
.row:last-child { border-bottom: 0; }
.row:nth-child(odd) { background: rgba(255,255,255,.04); }
.row:hover { background: rgba(255,255,255,.1); }
.cell.date { color: var(--rust-2); white-space: nowrap; }
.cell.grow { flex: 1; min-width: 0; }
.cell.ago { color: var(--muted); white-space: nowrap; }
.cell.key { color: var(--muted); min-width: 80px; }

/* ===== обо мне ===== */
.about-body { display: flex; gap: 20px; align-items: flex-start; }
@media (max-width: 640px) { .about-body { flex-direction: column; } }
.photo { position: relative; margin: 0; aspect-ratio: 1; width: min(260px, 100%); flex: none; background: #d6d6d6; overflow: hidden; border: 1px solid #000; }
.photo-blur {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 22% 26% at 50% 40%, #5e5e5e, transparent 70%),
    radial-gradient(ellipse 45% 40% at 50% 92%, #181818, transparent 70%),
    radial-gradient(ellipse 34% 42% at 50% 34%, #121212, transparent 72%),
    linear-gradient(#cccccc, #888);
  filter: blur(6px);
}
.photo .annot-label { top: auto; bottom: 8%; right: 10%; }
.about-text .label { font-size: 20px; }

/* ===== панель задач ===== */
.taskbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: 34px; z-index: 400;
  display: flex; align-items: center; gap: 6px; padding: 3px 6px;
  background: var(--gray); border-top: 2px solid var(--gray-hi); font: 12px var(--ui); color: #111;
}
.task-start, .task, .task-clock {
  display: flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; background: var(--gray);
  border: 2px solid; border-color: var(--gray-hi) var(--gray-lo) var(--gray-lo) var(--gray-hi); white-space: nowrap;
}
.task-start { font-weight: 700; font-style: italic; }
.task-start img { width: 18px; height: 18px; object-fit: cover; }
.tasks { flex: 1; display: flex; gap: 4px; overflow: hidden; }
.task { cursor: pointer; font: inherit; color: inherit; }
.task[hidden] { display: none; }
.task.off { border-color: var(--gray-lo) var(--gray-hi) var(--gray-hi) var(--gray-lo); background: #a2a2a2; font-style: italic; }
.task-clock { border-color: var(--gray-lo) var(--gray-hi) var(--gray-hi) var(--gray-lo); font-family: var(--mono); }
@media (max-width: 640px) { .tasks { display: none; } .taskbar { justify-content: space-between; } }

/* редкий «сбой» окна */
.win.glitch { animation: glitch .3s steps(2); }
@keyframes glitch {
  0% { transform: translate(var(--x, 0), var(--y, 0)); }
  30% { transform: translate(calc(var(--x, 0px) - 5px), var(--y, 0)) skewX(-2deg); filter: contrast(1.4); }
  60% { transform: translate(calc(var(--x, 0px) + 4px), calc(var(--y, 0px) + 1px)); clip-path: inset(0 0 30% 0); }
  100% { transform: translate(var(--x, 0), var(--y, 0)); }
}

/* если в системе выключены анимации — гасим резкие эффекты, но лента кнопок продолжает плавно ехать */
@media (prefers-reduced-motion: reduce) {
  .win.glitch, .viewport.switching { animation: none; }
}

/* ===== прокрутка в окнах (полоса в стиле старой ОС) ===== */
.tools-body, .arts-body { max-height: 262px; overflow-y: auto; }
.tools-body::-webkit-scrollbar, .arts-body::-webkit-scrollbar { width: 16px; }
.tools-body::-webkit-scrollbar-track, .arts-body::-webkit-scrollbar-track { background: #8f8f8f; border-left: 1px solid var(--gray-lo); }
.tools-body::-webkit-scrollbar-thumb, .arts-body::-webkit-scrollbar-thumb {
  background: var(--gray); border: 2px solid; border-color: var(--gray-hi) var(--gray-lo) var(--gray-lo) var(--gray-hi);
}
.tools-body, .arts-body { scrollbar-color: var(--gray) #8f8f8f; }

/* ===== арты ===== */
.arts-body { padding: 6px; }
.arts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
@media (max-width: 900px) { .arts { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); } }
.art {
  aspect-ratio: 1; padding: 0; cursor: pointer; overflow: hidden; background: #0d0d0d;
  border: 2px solid; border-color: var(--gray-lo) var(--gray-hi) var(--gray-hi) var(--gray-lo);
}
.art { position: relative; }
.art img { position: absolute; inset: 6px; width: calc(100% - 12px); height: calc(100% - 12px); object-fit: contain; transition: transform .2s; }
.art img.inv { filter: invert(1); }
.art:hover img { transform: scale(1.08); }
.art:hover { border-color: #f2f2f2; }
.art.empty { cursor: default; background: radial-gradient(circle at 50% 45%, #2a2a2a, #0d0d0d 70%); }

/* окно просмотра арта */
.lightbox { position: fixed; inset: 0; z-index: 900; display: flex; align-items: center; justify-content: center; padding: 20px 16px 50px; background: rgba(0,0,0,.7); }
.lightbox[hidden] { display: none; }
.lightbox .win { transform: none; max-width: min(900px, 100%); }
.lb-body { padding: 0; background: #0d0d0d; }
.lb-body img { display: block; max-width: 100%; max-height: calc(100vh - 140px); margin: 0 auto; }
.b-close::before, .b-close::after { content: ""; position: absolute; left: 3px; right: 3px; top: 6px; height: 2px; background: #222; }
.b-close::before { transform: rotate(45deg); } .b-close::after { transform: rotate(-45deg); }
