/* ── Font (self-hosted) ── */
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 300;
  font-display: block;
  src: url('fonts/cormorant-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 300;
  font-display: block;
  src: url('fonts/cormorant-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url('fonts/cormorant-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url('fonts/cormorant-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

html, body {
  margin: 0; padding: 0;
  background: #191919;
  font-family: 'Cormorant Garamond', serif;
  color: #e0e0e0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  width: 100%; height: 100dvh;
}
body { display: flex; flex-direction: column; }
body.landscape { flex-direction: row; }

#main-area {
  flex: 1; position: relative; overflow: hidden;
}
#main-canvas {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
}

/* ── Strip ── */
#strip {
  height: 108px;
  background: #191919;
  border-top: none;
  padding: 0 10px;
  display: flex; flex-direction: row; align-items: center; justify-content: flex-start;
  gap: 10px; overflow-x: auto; flex-shrink: 0;
  opacity: 0; transition: opacity 0.3s;
}
#strip::-webkit-scrollbar { height: 4px; }
#strip::-webkit-scrollbar-track { background: rgba(255,255,255,0.03); }
#strip::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }
#strip::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.4); }
#strip.ready { opacity: 1; }
body.landscape #strip {
  position: absolute; top: 0; bottom: 0; right: 0;
  height: auto; width: 190px;
  flex-direction: column; overflow-y: auto; overflow-x: hidden;
  border-top: none; border-left: 1px solid rgba(255,255,255,0.06);
  padding: 10px 0; gap: 12px; align-items: center; justify-content: flex-start;
}
body.landscape #strip::-webkit-scrollbar { height: auto; width: 4px; }
body.landscape #strip::-webkit-scrollbar-track { background: rgba(255,255,255,0.03); }
body.landscape #strip::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }
body.landscape #strip::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.4); }

/* ── Contour cards ── */
.contour-card {
  width: 90px; height: 100px;
  border: 1.5px solid rgba(255,255,255,0.3);
  border-radius: 10px;
  background: rgba(35,35,35,0.8);
  transition: all 0.3s;
  cursor: pointer; flex-shrink: 0; touch-action: manipulation;
}
body.landscape .contour-card { width: 160px; height: 133px; }
.contour-card { display: flex; align-items: center; justify-content: center; overflow: hidden; }
.contour-card canvas { width: 100%; height: 100%; border-radius: 9px; }
.contour-card.selected {
  border-color: rgba(255,255,255,0.7);
  box-shadow: 0 0 24px rgba(255,255,255,0.2);
  transform: scale(1.05);
}
body.landscape .contour-card.selected {
  transform: scale(1.05);
}
.contour-card.found {
  border-color: rgba(255,255,255,0.35);
  box-shadow: 0 0 12px rgba(255,255,255,0.1);
  pointer-events: none;
}
/* §21.5.2.1: паузы перед угасанием нет, но само угасание — 0.6s.
   0.3s оказалось резко: карточка не таяла, а моргала.
   Запасной таймер в cards.js считается от этой длительности — менять вместе. */
.contour-card.fading {
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
.contour-card.gone {
  display: none;
}

/* ── Loading screen ── */
#loading-screen {
  position: absolute; inset: 0; z-index: 350;
  display: flex; align-items: center; justify-content: center;
  background: #191919;
  transition: opacity 0.8s;
}
#loading-screen span {
  font-size: 52px; font-weight: 300; letter-spacing: 10px;
  color: rgba(220,220,220,0.6);
  animation: pulse-loading 2.5s ease-in-out infinite;
}
@keyframes pulse-loading {
  0%,100% { opacity: 0.4; } 50% { opacity: 1; }
}

/* ── Title screen ── */
#title-screen {
  position: absolute; inset: 0; z-index: 300;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #191919;
  transition: opacity 2s;
}
#title-screen h1 { font-size: 86px; font-weight: 300; letter-spacing: 12px; margin: 0; }
#title-screen p { font-size: 22px; color: rgba(220,220,220,0.75); letter-spacing: 4px; margin: -9px 0 21px 0; }
#title-screen .sub { font-size: 16px; letter-spacing: 2px; animation: pulse-sub 3s ease-in-out infinite; }
#title-screen .sub a { color: inherit; text-decoration: none; }
#title-screen .sub a:hover { color: rgba(220,220,220,0.75); }
.title-sep { margin: 0 6px; opacity: 0.3; }
@keyframes pulse-sub { 0%,100% { color: rgba(180,180,180,0.35); } 50% { color: rgba(220,220,220,0.75); } }

/* ── Tutorial overlay (dimming) ── */
#tut-overlay {
  position: fixed; inset: 0; z-index: 190;
  background: rgba(0,0,0,0.3);
  opacity: 0; transition: opacity 0.5s; pointer-events: none;
}
#tut-overlay.visible { opacity: 1; }
#tut-overlay.strong { background: rgba(0,0,0,0.6); pointer-events: auto; }

/* ── Size hint (dots tutorial) ── */
#size-hint {
  position: fixed; z-index: 201;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: 18px; letter-spacing: 2px; color: rgba(220,220,220,0.9);
  opacity: 0; transition: opacity 0.6s; pointer-events: none;
}
#size-hint span {
  background: rgba(25,25,25,0.85); border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px; padding: 12px 22px; white-space: nowrap; line-height: 1;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
#size-hint.visible { opacity: 1; }

/* ── Hints tip (level 2 tutorial) ── */
#hints-tip {
  position: fixed; z-index: 201;
  display: none; flex-direction: column; align-items: flex-end; gap: 8px;
  font-size: 18px; letter-spacing: 2px; color: rgba(220,220,220,0.9);
  opacity: 0; transition: opacity 0.6s; pointer-events: none;
}
#hints-tip svg { margin-right: 6px; }
#hints-tip span {
  background: rgba(25,25,25,0.85); border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px; padding: 12px 22px; white-space: nowrap; line-height: 1;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
#hints-tip.visible { opacity: 1; }

/* ── Settings ── */
#settings-btn {
  position: absolute; top: 12px; right: 14px; z-index: 210;
  color: rgba(200,200,200,0.25);
  cursor: pointer; line-height: 1;
  transition: color 0.2s;
}
#settings-btn:hover { color: rgba(200,200,200,0.50); }
#settings-btn.active { color: rgba(200,200,200,0.55); }
#settings-panel {
  position: absolute; top: 42px; right: 14px; z-index: 210;
  background: rgba(30,30,30,0.92);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 10px 14px;
  display: none;
  font-size: 14px; letter-spacing: 1px;
  color: rgba(200,200,200,0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
#settings-panel.open { display: block; }
#settings-panel label {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  white-space: nowrap; margin-bottom: 6px;
}
#settings-panel label:last-child { margin-bottom: 0; }
#settings-panel input[type="checkbox"] {
  accent-color: rgba(220,220,220,0.85);
  width: 16px; height: 16px;
}
.settings-sep {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 8px 0;
}
.settings-action {
  display: block; width: 100%;
  font-family: 'Cormorant Garamond', serif;
  font-size: 14px; letter-spacing: 1px;
  color: rgba(200,200,200,0.7);
  background: none; border: none;
  padding: 6px 0;
  cursor: pointer; text-align: left;
  transition: color 0.2s;
}
.settings-action:hover {
  color: rgba(220,220,220,0.95);
}

/* ── Level complete ── */
#level-complete {
  position: absolute; inset: 0; z-index: 250;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(20,20,20,0.75);
  transition: opacity 3s;
  letter-spacing: 6px;
  font-size: 46px; font-weight: 300;
  color: rgba(220,220,220,0.7);
  opacity: 0; pointer-events: none;
}
#level-complete.visible { opacity: 1; pointer-events: auto; }
#level-buttons { display: flex; gap: 16px; margin-top: 24px; }

.level-btn {
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px; letter-spacing: 2px;
  color: rgba(220,220,220,0.7);
  background: rgba(35,35,35,0.6);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 12px 24px;
  cursor: pointer;
  transition: all 0.3s;
}
.level-btn:hover {
  background: rgba(50,50,50,0.8);
  border-color: rgba(255,255,255,0.3);
}

.all-levels-link {
  display: block;
  margin-top: 20px;
  font-size: 14px;
  letter-spacing: 2px;
  color: rgba(180,180,180,0.35);
  text-decoration: none;
  transition: color 0.3s;
}
.all-levels-link:hover { color: rgba(220,220,220,0.6); }

/* ── Level transition overlay ── */
/* Затемнение между уровнями (§15.1.1).
   Длительности и цвет приходят из levels.js через CSS-переменные —
   менять там, не здесь. Значения ниже — запасные, если JS не отработал. */
#transition-overlay {
  position: absolute; inset: 0; z-index: 400;
  background: var(--transition-bg, rgba(20,20,20,0.75));
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition-fade-in, 2s);
  display: flex; align-items: center; justify-content: center;
}
#transition-overlay.active {
  /* pointer-events НЕ ставим: оверлей перехвата кликов не делает никогда.
     Раньше стоял auto, и ~4 секунды клики уходили в него, а не в холст —
     картинка выглядела некликабельной (§15.1). */
  opacity: 1;
  transition: opacity var(--transition-fade-out, 2s);
}
#transition-overlay span {
  font-family: 'Cormorant Garamond', serif;
  font-size: 28px; letter-spacing: 1px;
  color: rgba(220,220,220,0.75);
}


/* ── §21: вступление и «Как играть» ──────────────────────────────────────────
   Перенесено из накладки кастдева. Своя копия там сохраняется намеренно:
   кастдев отрабатывает сейчас, трогать его ради общего кода нельзя (§16).
   Правка демки требует правки в двух местах — так записано в §21.5.        */
#ku-intro {
  position: fixed; inset: 0; z-index: 500;
  display: none;
  background: #191919;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  user-select: none; -webkit-user-select: none;
}
#ku-intro.visible { display: block; }
#ku-intro.transparent { background: transparent; pointer-events: none; }
body.ku-intro-open #main-area,
body.ku-intro-open #strip { pointer-events: none; }
#ku-intro.hero {
  background: #191919 center/cover no-repeat;
}
#ku-intro.hero::before {
  content: '';
  position: fixed; inset: 0;
  background: linear-gradient(rgba(15,15,15,0.72), rgba(15,15,15,0.88));
  pointer-events: none;
}
.ku-i-screen {
  position: relative;
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding: 40px 24px calc(40px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; justify-content: center;
  gap: 26px;
  color: #e0e0e0;
}
.ku-i-title {
  font-size: 27px; font-weight: 300; line-height: 1.35;
  letter-spacing: 1px;
  color: rgba(230,230,230,0.95);
}
.ku-i-text {
  font-size: 19px; font-weight: 300; line-height: 1.55;
  letter-spacing: 0.5px;
  color: rgba(210,210,210,0.75);
  user-select: text; -webkit-user-select: text;
  /* Переносы \n в текстах i18n иначе схлопываются в пробел, и абзацы,
     написанные раздельно, склеиваются в один. Замечено 30.08.2026. */
  white-space: pre-line;
}
.ku-i-note {
  font-size: 15px; letter-spacing: 1px;
  color: rgba(180,180,180,0.45);
}
.ku-i-list {
  margin: -4px 0 0; padding-left: 22px;
  font-size: 19px; font-weight: 300; line-height: 1.7;
  letter-spacing: 0.5px;
  color: rgba(210,210,210,0.75);
}
.ku-i-list li::marker { color: rgba(210,210,210,0.35); }
.ku-i-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.ku-i-btn {
  font-family: 'Cormorant Garamond', serif;
  font-size: 18px; letter-spacing: 2px;
  color: rgba(225,225,225,0.85);
  background: rgba(40,40,40,0.7);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 10px;
  padding: 15px 26px;
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s, color 0.25s, opacity 0.25s;
  touch-action: manipulation;
  width: 100%;
}
.ku-i-btn:hover:not(:disabled) {
  background: rgba(58,58,58,0.85);
  border-color: rgba(255,255,255,0.32);
}
.ku-i-btn:disabled {
  opacity: 0.32;
  cursor: default;
}
.ku-i-btn.primary {
  background: rgba(225,225,225,0.9);
  border-color: rgba(255,255,255,0.9);
  color: #191919;
}
.ku-i-btn.primary:hover:not(:disabled) { background: #fff; }
.ku-i-btn.ghost {
  background: none;
  border-color: rgba(255,255,255,0.12);
  color: rgba(200,200,200,0.6);
}
.ku-i-textarea { min-height: 92px; }
#ku-tut-guide {
  position: fixed; inset: 0; z-index: 480;
  pointer-events: none;
  display: none;
}
#ku-tut-guide.visible { display: block; }
#ku-tut-guide .ku-tut-dim {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  transition: opacity 0.5s;
}
#ku-tut-guide.no-dim .ku-tut-dim { opacity: 0; }
#ku-tut-bubble {
  position: absolute; left: 50%; transform: translateX(-50%);
  max-width: 340px;
  background: rgba(28,28,28,0.94);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 12px;
  padding: 16px 22px;
  font-size: 19px; font-weight: 300; line-height: 1.4; letter-spacing: 0.5px;
  color: rgba(235,235,235,0.95);
  text-align: center;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.4s;
}
#ku-tut-guide.visible ~ 
.ku-i-demo {
  position: relative;
  width: 100%; max-width: 460px; margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
  background: #141414;
  border: 1px solid rgba(255,255,255,0.08);
}
.ku-i-demo-canvas { display: block; width: 100%; }
.ku-i-demo.ku-i-demo-failed { display: none; }
.ku-i-steps { display: flex; flex-direction: column; gap: 8px; }
.ku-i-step {
  font-size: 17px; font-weight: 300; letter-spacing: 0.5px;
  color: rgba(190,190,190,0.35);
  transition: color 0.35s;
}
.ku-i-step.active { color: rgba(240,240,240,0.95); }
@media (max-height: 620px) {
  .ku-i-screen { justify-content: flex-start; gap: 18px; padding-top: 56px; }
  .ku-i-title { font-size: 23px; }
  .ku-i-text { font-size: 17px; }
}
.ku-i-demo-canvas { cursor: pointer; touch-action: manipulation; }
.ku-i-note.ku-i-ok { color: rgba(150,210,160,0.85); }
.ku-i-btn.pulse { animation: ku-i-btn-pulse 1.6s ease-in-out 2; }
@keyframes ku-i-btn-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
  50% { box-shadow: 0 0 0 8px rgba(255,255,255,0.14); }
}
