@font-face {
  font-family: 'Ristretto Slab Pro';
  src: url('../RistrettoSlabPro.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #090909;
  --panel: #151413;
  --paper: #f4efe7;
  --gold: #c8a97e;
  --gold-bright: #f0d6a8;
  --muted: #aaa39a;
  --danger: #ef5b46;
  --success: #80c99a;
  --line: rgba(200, 169, 126, 0.32);
  --shadow: rgba(0, 0, 0, 0.48);
}

* { box-sizing: border-box; }

html,
body { min-height: 100%; }

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--paper);
  background: var(--ink);
  font-family: Inter, Arial, sans-serif;
}

body.playing {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='42' height='42' viewBox='0 0 42 42'%3E%3Cg transform='rotate(35 21 21)'%3E%3Crect x='18' y='10' width='6' height='27' rx='3' fill='%23c8a97e'/%3E%3Cpath d='M9 7h24v10H9z' fill='%23f0d6a8'/%3E%3C/g%3E%3C/svg%3E") 15 30, pointer;
}

.metrika-pixel {
  position: absolute;
  left: -9999px;
}

.game-page {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.game-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 390px);
  align-items: end;
  gap: 28px;
  margin-bottom: 18px;
}

.game-heading { min-width: 0; }

.eyebrow,
.stat-label {
  margin: 0;
  color: var(--gold);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2 {
  font-family: 'Ristretto Slab Pro', serif;
  font-weight: 400;
  letter-spacing: 0;
}

h1 {
  max-width: 100%;
  margin: 5px 0 0;
  font-size: clamp(2.6rem, 6vw, 4.5rem);
  line-height: 0.96;
  overflow-wrap: anywhere;
}

.intro {
  max-width: 390px;
  margin: 0 0 4px auto;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
  text-align: right;
}

.hud {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) minmax(100px, 1fr) auto minmax(100px, 1fr);
  align-items: center;
  gap: 14px;
  margin-bottom: 13px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.stat strong {
  font-family: 'Ristretto Slab Pro', serif;
  font-size: clamp(1.65rem, 4vw, 2.65rem);
  font-weight: 400;
  line-height: 1;
}

.stat-time { justify-content: flex-end; }

button,
.command {
  border: 0;
  border-radius: 2px;
  font: inherit;
}

button { cursor: pointer; }

button:focus-visible,
.command:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

.command {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 11px 17px;
  color: var(--ink);
  background: var(--gold);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  transition: background 150ms ease, color 150ms ease, transform 150ms ease;
}

.command:hover { background: var(--gold-bright); }
.command:active { transform: translateY(1px); }
.command:disabled { cursor: not-allowed; opacity: 0.45; }

.start-button { min-width: 154px; }

.stage-wrap {
  position: relative;
  overflow-x: hidden;
  overflow-y: hidden;
  border: 1px solid var(--line);
  background: #050505;
  box-shadow: 0 24px 70px var(--shadow);
  touch-action: manipulation;
}

.stage {
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: 2 / 1;
  overflow: hidden;
  isolation: isolate;
}

.band-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.88) contrast(1.08) saturate(0.85);
}

.stage-shade {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.12), transparent 45%, rgba(0, 0, 0, 0.34));
  mix-blend-mode: multiply;
}

.target {
  position: absolute;
  z-index: 5;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  height: var(--h);
  padding: 0;
  border: 0;
  background: transparent;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transform-origin: 50% 100%;
  transition: transform 130ms ease, filter 130ms ease, opacity 130ms ease;
}

.target.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.target::after {
  content: "";
  position: absolute;
  inset: -5%;
  border: 2px solid rgba(240, 214, 168, 0.48);
  border-radius: 50%;
  opacity: 0.42;
  transition: border-color 130ms ease, opacity 130ms ease;
}

.target img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  filter: brightness(0.88) contrast(1.08) saturate(0.85);
}

.target:hover::after,
.target:focus-visible::after { border-color: var(--gold-bright); opacity: 1; }

.target.hit {
  transform: translate(calc(-50% + 2px), calc(-50% + 4px)) scale(0.97);
  filter: brightness(1.18) saturate(1.1);
}

.target.hit::after { border-color: var(--danger); }

.target.dodge-left { transform: translate(-105%, -68%) rotate(-8deg) scale(0.93); }
.target.dodge-right { transform: translate(5%, -68%) rotate(8deg) scale(0.93); }

.target.cooling { pointer-events: none; }

.flash {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  background: rgba(240, 214, 168, 0.18);
  opacity: 0;
}

.flash.on { animation: flash 220ms ease-out; }

@keyframes flash {
  0% { opacity: 0.8; }
  100% { opacity: 0; }
}

.spark {
  position: absolute;
  z-index: 8;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold-bright);
  pointer-events: none;
  animation: spark 550ms ease-out forwards;
}

@keyframes spark {
  to { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}

.announcement {
  position: absolute;
  left: 50%;
  top: 30%;
  z-index: 10;
  width: min(620px, 84%);
  color: var(--gold-bright);
  font-family: 'Ristretto Slab Pro', serif;
  font-size: clamp(2rem, 7vw, 5.2rem);
  line-height: 0.95;
  text-align: center;
  text-shadow: 0 4px 0 #000, 0 0 30px rgba(239, 91, 70, 0.8);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.72);
}

.announcement.show { animation: announce 850ms ease-out; }
.announcement.miss { color: var(--danger); }
.announcement.honor { color: #fff2ba; }

@keyframes announce {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.72); }
  18%, 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -62%) scale(1.05); }
}

.message {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 11;
  width: min(390px, 84%);
  padding: 24px;
  border: 1px solid rgba(200, 169, 126, 0.5);
  background: rgba(10, 10, 10, 0.88);
  text-align: center;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(5px);
}

.message[hidden] { display: none; }

.message h2 {
  margin: 0 0 8px;
  font-size: clamp(1.8rem, 5vw, 3.1rem);
}

.message p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.result {
  margin-top: 22px;
  padding: 24px 0 4px;
  border-top: 1px solid var(--line);
}

.result[hidden] { display: none; }

.result h2 {
  margin: 8px 0;
  font-size: clamp(2rem, 5vw, 3.6rem);
}

.result-score,
.result-record { margin: 0; }

.result-score {
  font-family: 'Ristretto Slab Pro', serif;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
}

.result-score strong,
.result-record strong { color: var(--gold-bright); font-weight: 400; }

.result-record {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.result-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.command-secondary {
  border: 1px solid var(--line);
  color: var(--paper);
  background: transparent;
}

.command-secondary:hover { color: var(--ink); }
.command-primary { background: #f26a21; }
.command-primary:hover { background: #ff873f; }

.share-status {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: var(--success);
  font-size: 0.8rem;
}

.share-dialog {
  width: min(760px, calc(100% - 28px));
  max-height: min(760px, calc(100dvh - 28px));
  padding: 22px;
  overflow-y: auto;
  border: 1px solid rgba(200, 169, 126, 0.58);
  border-radius: 4px;
  color: var(--paper);
  background: rgba(12, 12, 11, 0.98);
  box-shadow: 0 22px 70px var(--shadow);
}

.share-dialog::backdrop {
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(4px);
}

.share-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.share-dialog h2 {
  margin: 6px 0 0;
  font-size: clamp(2rem, 5vw, 3.2rem);
}

.share-close {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--paper);
  background: transparent;
  font-size: 2rem;
  line-height: 1;
}

.share-close:hover,
.share-close:focus-visible { color: var(--gold-bright); }

.share-dialog-note {
  max-width: 630px;
  margin: 12px 0 18px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.share-targets {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.share-target {
  display: flex;
  min-width: 0;
  min-height: 74px;
  padding: 10px 6px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--paper);
  background: rgba(255, 255, 255, 0.025);
  font-size: 0.73rem;
  line-height: 1.15;
  text-align: center;
}

.share-target:hover,
.share-target:focus-visible {
  border-color: var(--gold);
  background: rgba(200, 169, 126, 0.12);
}

.share-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: 0.67rem;
  font-weight: 800;
}

.share-mark::before { content: attr(data-mark); }
.share-telegram .share-mark { background: #229ed9; }
.share-telegram .share-mark::before { content: 'TG'; }
.share-vk .share-mark { background: #2787f5; }
.share-vk .share-mark::before { content: 'VK'; }
.share-max .share-mark { color: #111; background: #c7ff36; }
.share-max .share-mark::before { content: 'M'; }
.share-whatsapp .share-mark { background: #25d366; }
.share-whatsapp .share-mark::before { content: 'WA'; }
.share-ok .share-mark { background: #ee8208; }
.share-ok .share-mark::before { content: 'OK'; }
.share-viber .share-mark { background: #7360f2; }
.share-viber .share-mark::before { content: 'VI'; }
.share-instagram .share-mark { background: #c13584; }
.share-instagram .share-mark::before { content: 'IG'; }
.share-tiktok .share-mark { color: #fff; background: #111; box-shadow: inset 2px 0 #25f4ee, inset -2px 0 #fe2c55; }
.share-tiktok .share-mark::before { content: 'TT'; }
.share-x .share-mark { background: #111; border: 1px solid #555; }
.share-x .share-mark::before { content: 'X'; }
.share-facebook .share-mark { background: #1877f2; }
.share-facebook .share-mark::before { content: 'f'; font-size: 1rem; }

.share-tools {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.share-tools .command { min-height: 42px; padding: 9px 12px; }
.share-tools [hidden] { display: none; }

.orientation-note {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  color: var(--paper);
  background: var(--panel);
  font-size: 0.75rem;
  line-height: 1.45;
}

.orientation-note.show { display: flex; }

.orientation-note button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 7px 10px;
  color: var(--ink);
  background: var(--gold);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

@media (max-width: 719px) {
  .game-page { width: min(100% - 18px, 1180px); padding-top: 16px; }
  .game-header { display: block; }
  .intro { margin: 12px 0 0; text-align: left; }
  .hud { grid-template-columns: 1fr 1fr; }
  .start-button { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .stat-time { justify-content: flex-start; }
  .stage-wrap { overflow-x: auto; scrollbar-width: thin; }
  .stage { min-width: 720px; }
  .message { width: min(390px, calc(100vw - 48px)); }
  .orientation-note.show { display: flex; }
  .result-actions { grid-template-columns: 1fr; }
  .share-dialog { padding: 18px 14px; }
  .share-targets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .share-target { min-height: 64px; flex-direction: row; justify-content: flex-start; padding: 9px 10px; }
  .share-tools { grid-template-columns: 1fr; }
}

@media (max-width: 360px) {
  h1 { font-size: 2.3rem; }
  .eyebrow { font-size: 0.62rem; }
  .hud { gap: 9px; padding: 11px; }
  .stat { display: block; }
  .stat-label { display: block; margin-bottom: 4px; }
  .orientation-note { align-items: stretch; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}
