/* ═══ CATCH THE CLUTCH — Pocket Dragons fan tribute ═══
   Та же визуальная система, что в FIRST FLIGHT (одна студия, один зал):
   почти чёрная ночь, латунь #d9a441, пергамент #f4ead7, янтарный ключевой
   свет, белый фосфор цифр. Плюс микро-взаимодействия: блик по латуни,
   каскадное появление титула, дыханием светящаяся главная кнопка. */
:root {
  --ink: #05070a;
  --amber: #ffb54d;
  --amber-bright: #ffc66e;
  --cream: #f4ead7;
  --cream-dim: #c8b79a;
  --brass: #d9a441;
  --brass-deep: #8a621c;
  --phos: #f2f7ff;
  --danger: #ff4d3d;
  --serif: "Cinzel", "Palatino Linotype", Georgia, serif;
  --mono: "JetBrains Mono", "Consolas", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; background: var(--ink); }

body {
  font-family: var(--mono);
  color: var(--cream);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

#app { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }

#game {
  width: 100vw; height: 100vh;
  object-fit: cover;
  display: block;
}
@supports (height: 100dvh) {
  #game { height: 100dvh; }
}

/* ── atmosphere ── */
#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 40;
  background: radial-gradient(ellipse at 50% 42%, transparent 44%, rgba(2,3,5,.7) 100%);
}
#grain {
  position: fixed; inset: -50%; pointer-events: none; z-index: 41; opacity: .12;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.32'/%3E%3C/svg%3E");
  background-size: 160px 160px;
  animation: grainShift 1.8s steps(3) infinite;
}
@keyframes grainShift {
  0% { transform: translate(0,0); } 33% { transform: translate(-6px,4px); }
  66% { transform: translate(5px,-5px); } 100% { transform: translate(0,0); }
}
#flash {
  position: fixed; inset: 0; background: #fff3e0; opacity: 0;
  pointer-events: none; z-index: 60;
}

/* рамка витрины — двойной волосок, как кабинет прибора */
#app::after {
  content: ""; position: fixed; inset: 12px; z-index: 45; pointer-events: none;
  border: 1px solid rgba(217,164,65,.28);
  box-shadow: inset 0 0 0 5px rgba(5,6,10,.0), 0 0 0 5px transparent;
  outline: 1px solid rgba(217,164,65,.08); outline-offset: 5px;
}

/* ── overlays ── */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  overflow-y: auto;
  transition: opacity .45s ease, visibility 0s;
  visibility: visible;
}
.overlay.hidden { opacity: 0; pointer-events: none; visibility: hidden; transition: opacity .45s ease, visibility 0s .45s; }

/* ══ title ═ */
/* титул: тёмная живая сцена машины за текстом, без постерного коллажа */
#screen-title {
  align-items: flex-start;
  background:
    radial-gradient(ellipse at 50% 62%, rgba(5,7,10,.3) 0%, rgba(5,7,10,.82) 82%),
    linear-gradient(180deg, rgba(5,7,10,.72) 0%, rgba(5,7,10,.3) 34%, rgba(5,7,10,.12) 60%, rgba(5,7,10,.55) 100%);
}
.title-block {
  position: relative; text-align: center; padding: 20px;
  width: 100%;
  padding-top: clamp(20px, 6vh, 64px);
  max-height: 100vh; max-height: 100dvh;
}

/* каскадное появление: титул собирается по строке, как приборная панель */
.title-block > * { animation: rise .8s ease both; }
.title-block > *:nth-child(1) { animation-delay: .05s; }
.title-block > *:nth-child(2) { animation-delay: .18s; }
.title-block > *:nth-child(3) { animation-delay: .32s; }
.title-block > *:nth-child(4) { animation-delay: .46s; }
.title-block > *:nth-child(5) { animation-delay: .6s; }
.title-block > *:nth-child(6) { animation-delay: .74s; }
.title-block > *:nth-child(7) { animation-delay: .86s; }
.title-block > *:nth-child(8) { animation-delay: .98s; }
@keyframes rise { from { opacity: 0; transform: translateY(22px); } }

.over {
  font-family: var(--mono); font-size: 10px; letter-spacing: .38em;
  color: var(--brass); margin-bottom: 16px; text-transform: uppercase;
}
h1 {
  font-family: var(--serif); font-weight: 700;
  font-size: clamp(26px, 7.4vw, 88px); letter-spacing: .12em;
  color: var(--cream);
  text-shadow: 0 0 38px rgba(255,181,77,.4), 0 3px 0 rgba(0,0,0,.65), 0 8px 34px rgba(0,0,0,.8);
}
.sub {
  margin-top: 12px; font-size: 12.5px; letter-spacing: .2em; color: var(--cream-dim);
}
@media (max-height: 620px) {
  h1 { font-size: clamp(24px, 6vw, 56px); }
  .over { margin-bottom: 8px; }
  .sub { margin-top: 8px; }
  .plate { margin-top: 12px; padding: 12px 30px; }
  .hint { margin-top: 10px; }
}
.hint { margin-top: 16px; font-size: 10px; letter-spacing: .22em; color: #a89d84; text-shadow: 0 1px 3px rgba(0,0,0,.95), 0 0 12px rgba(0,0,0,.8); }
/* плашка-ссылка на соседнюю игру — у нижнего края сцены, не поверх машины */
#screen-title .title-block { position: static; }
#screen-title .link-plate {
  position: absolute; right: max(16px, env(safe-area-inset-bottom)); bottom: max(16px, env(safe-area-inset-bottom));
  margin: 0; width: fit-content;
}
/* клавиши-чипы вместо голой строки текста */
.key {
  display: inline-block; margin: 0 3px; padding: 3px 8px 2px;
  font-family: var(--mono); font-size: 9px; letter-spacing: .18em;
  color: var(--cream-dim);
  border: 1px solid rgba(217,164,65,.35); border-radius: 2px;
  background: rgba(8,8,10,.55);
  box-shadow: inset 0 1px 0 rgba(244,234,215,.07);
}
.best-line { margin-top: 8px; font-size: 11px; letter-spacing: .22em; color: var(--amber); min-height: 15px; font-variant-numeric: tabular-nums; }

/* ── brass plate buttons ── */
.plate {
  position: relative;
  display: inline-block; margin-top: 18px;
  font-family: var(--serif); font-weight: 700; font-size: 15px; letter-spacing: .22em;
  color: #1c1408;
  background: linear-gradient(180deg, #f2c46d 0%, #d9a441 48%, #b47e29 82%, #8a621c 100%);
  border: 1px solid #5d4520; border-radius: 1px;
  padding: 15px 40px; cursor: pointer;
  overflow: hidden;
  box-shadow:
    0 1px 0 #4a3517,
    0 14px 36px rgba(0,0,0,.55),
    inset 0 1px 0 rgba(255,255,255,.5);
  transition: transform .08s, filter .15s, box-shadow .15s;
  text-decoration: none;
}
/* блик скользит по латуни при наведении — микро-взаимодействие «живого металла» */
.plate::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 46%;
  left: -60%;
  background: linear-gradient(100deg, transparent 0%, rgba(255,255,255,.42) 50%, transparent 100%);
  transform: skewX(-18deg);
  transition: left .5s ease;
  pointer-events: none;
}
.plate:hover::after { left: 115%; }
.plate:hover {
  filter: brightness(1.08);
  box-shadow:
    0 1px 0 #4a3517,
    0 16px 40px rgba(255,181,77,.28),
    inset 0 1px 0 rgba(255,255,255,.5);
}
.plate:active { transform: translateY(1px); box-shadow: 0 4px 12px rgba(0,0,0,.5); }
.plate:focus-visible { outline: 1px solid var(--amber-bright); outline-offset: 3px; }
.plate.ghost {
  background: rgba(8,8,10,.55); color: var(--brass);
  border: 1px solid rgba(217,164,65,.32);
  box-shadow: inset 0 1px 0 rgba(244,234,215,.08);
}
.plate.ghost::after { background: linear-gradient(100deg, transparent 0%, rgba(217,164,65,.25) 50%, transparent 100%); }
.plate.ghost:hover { color: var(--amber-bright); border-color: var(--brass); }

/* главная кнопка дышит янтарём, пока ждёт Хранителя */
#btn-start { animation: rise .8s ease both, ctaBreath 3.2s ease-in-out 1.6s infinite; }
@keyframes ctaBreath {
  0%, 100% { box-shadow: 0 1px 0 #4a3517, 0 14px 36px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.5); }
  50% { box-shadow: 0 1px 0 #4a3517, 0 14px 48px rgba(255,181,77,.42), inset 0 1px 0 rgba(255,255,255,.5); }
}

/* плашка-ссылка на соседнюю игру: стрелка уезжает при наведении */
.link-plate {
  font-size: 11px; letter-spacing: .26em; padding: 10px 20px; margin-top: 20px;
  font-family: var(--mono); font-weight: 700;
}
.link-plate span { display: inline-block; transition: transform .25s ease; }
.link-plate:hover span { transform: translateX(-4px); }

/* ══ watch card (plaque) ══ */
#screen-dead { background: rgba(3,4,6,.52); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.plaque {
  position: relative;
  text-align: center; min-width: min(430px, 88vw);
  max-height: 92vh; max-height: 92dvh;
  overflow-y: auto;
  background: rgba(8,8,10,.94);
  border: 1px solid rgba(217,164,65,.42); border-radius: 2px;
  padding: 32px 36px 28px;
  box-shadow:
    0 40px 90px rgba(0,0,0,.8),
    inset 0 1px 0 rgba(244,234,215,.06),
    inset 0 0 0 5px rgba(217,164,65,.08);
  animation: rise .5s cubic-bezier(.2, 1.5, .4, 1) both;
}
.plaque::before, .plaque::after {
  content: ""; position: absolute; width: 4px; height: 4px; border-radius: 50%;
  background: var(--brass); box-shadow: 0 0 4px rgba(217,164,65,.5);
}
.plaque::before { left: 8px; top: 8px; }
.plaque::after { right: 8px; top: 8px; }
.plaque-head {
  font-family: var(--serif); font-size: 14px; letter-spacing: .32em; color: var(--brass);
  border-bottom: 1px solid rgba(217,164,65,.22); padding-bottom: 15px; margin-bottom: 20px;
}
.plaque-score {
  font-family: var(--mono); font-weight: 700; font-variant-numeric: tabular-nums;
  font-size: 68px; color: var(--phos);
  text-shadow: 0 0 18px rgba(210,232,255,.55), 0 0 64px rgba(160,200,255,.28);
}
.plaque-score .unit { font-size: 18px; color: #7d8fa5; margin-left: 8px; letter-spacing: .1em; }
.plaque-medal {
  font-family: var(--serif); font-size: 19px; letter-spacing: .28em;
  color: var(--amber-bright); margin-top: 8px;
  text-shadow: 0 0 16px rgba(255,181,77,.45);
}
.plaque-best { margin-top: 12px; font-size: 11px; letter-spacing: .2em; color: #8f8672; font-variant-numeric: tabular-nums; }
.rank { margin-top: 14px; }
.rank-bar {
  height: 5px; border-radius: 3px; overflow: hidden;
  background: rgba(217,164,65,.14);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.6);
}
.rank-bar i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, #8a621c 0%, #d9a441 55%, #f2c46d 100%);
  box-shadow: 0 0 10px rgba(217,164,65,.55);
  transition: width .7s cubic-bezier(.2,.9,.3,1);
}
.rank-note { margin-top: 8px; font-size: 9.5px; letter-spacing: .2em; color: #a2906d; }
.plaque-stats { margin-top: 7px; font-size: 10px; letter-spacing: .18em; color: #6f7d8e; font-variant-numeric: tabular-nums; }
.plaque-hint {
  margin-top: 15px; font-size: 9.5px; letter-spacing: .24em; color: rgba(217,164,65,.6);
  animation: hintPulse 2.4s ease-in-out infinite;
}
@keyframes hintPulse { 0%,100% { opacity: .45 } 50% { opacity: .95 } }
.plaque-actions { display: flex; gap: 10px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.plaque-actions .plate { font-size: 13px; padding: 12px 22px; }

/* ── латунный D-pad: четыре поста, как в оригинальной «Ну, погоди!» ── */
#dpad { display: none; }
body.touch #dpad { display: block; }
.dpad-btn {
  position: fixed; z-index: 55;
  width: 76px; height: 76px;
  font-size: 0;   /* никаких текстовых глифов: шеврон рисуется рамкой */
  background:
    linear-gradient(180deg, rgba(40,34,24,.92) 0%, rgba(10,9,8,.96) 100%);
  border: 1px solid rgba(217,164,65,.5); border-radius: 2px;
  box-shadow:
    0 8px 22px rgba(0,0,0,.5),
    inset 0 1px 0 rgba(244,234,215,.16);
  cursor: pointer;
  transition: transform .06s, filter .12s, border-color .12s;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
/* латунный шеврон к соответствующему посту */
.dpad-btn::before {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 20px; height: 20px;
  border-left: 2px solid var(--brass); border-top: 2px solid var(--brass);
  transform: translate(-50%, -50%) rotate(-45deg);
}
.dpad-btn[data-pos="2"]::before { transform: translate(-50%, -50%) rotate(45deg); }
.dpad-btn[data-pos="1"]::before { transform: translate(-50%, -50%) rotate(-135deg); }
.dpad-btn[data-pos="3"]::before { transform: translate(-50%, -50%) rotate(135deg); }
.dpad-btn:active {
  transform: translateY(1px);
  filter: brightness(1.12);
  border-color: var(--amber);
  box-shadow: 0 4px 10px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,181,77,.25);
}
.dpad-btn[data-pos="0"] { left: 16px; top: 14%; }
.dpad-btn[data-pos="2"] { right: 16px; top: 14%; }
.dpad-btn[data-pos="1"] { left: 16px; bottom: 10%; }
.dpad-btn[data-pos="3"] { right: 16px; bottom: 10%; }
/* на титуле и карточке кнопки не нужны — не перекрываем плашку */
body[data-mode="title"] #dpad, body[data-mode="dead"] #dpad { opacity: 0; pointer-events: none; }
#dpad { transition: opacity .3s ease; }

@media (max-width: 560px) {
  .plaque { padding: 24px 18px 20px; }
  .plaque-score { font-size: 54px; }
  #app::after { inset: 6px; }
  .plaque-hint { margin-top: 12px; }
  .dpad-btn { width: 68px; height: 68px; font-size: 20px; }
}

@media (orientation: landscape) and (max-height: 480px) {
  .plaque { padding: 14px 22px 12px; max-height: 94vh; max-height: 94dvh; }
  .plaque-head { padding-bottom: 8px; margin-bottom: 10px; font-size: 12px; }
  .plaque-score { font-size: 40px; }
  .plaque-medal { font-size: 15px; margin-top: 4px; }
  .plaque-best { margin-top: 7px; }
  .rank { margin-top: 8px; }
  .plaque-actions .plate { padding: 9px 16px; font-size: 12px; }
  .plaque-hint { margin-top: 8px; animation: none; opacity: .8; }
  .dpad-btn { width: 58px; height: 58px; font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  #grain { animation: none; }
  .title-block > *, .plaque, .title-dragon, .poster, .plaque-hint, #btn-start { animation: none; }
  .plaque-hint { opacity: .8; }
  .plate::after { display: none; }
}
