/* Игровой экран: HUD, таймер, хореограф, бустеры, оверлеи. */
#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#game-canvas:active { cursor: grabbing; }

.hud {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
  padding: 0 clamp(10px, 2.2vw, 26px) calc(14px + var(--safe-bottom));
}
.hud button { pointer-events: auto; }
.hud-top {
  display: flex;
  align-items: flex-start;
  gap: clamp(8px, 1.6vw, 18px);
  padding-top: calc(12px + var(--safe-top));
}
.hud-left { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.hud-levelbox { display: flex; flex-direction: column; gap: 2px; }
.hud-style {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: 0 0 16px rgba(255, 63, 176, 0.7);
}
.hud-level {
  font-size: 15px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.9);
  max-width: 34vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-timer {
  flex: 1 1 auto;
  max-width: 460px;
  margin: 2px auto 0;
  min-width: 120px;
}
.timer-bar {
  position: relative;
  height: 13px;
  border-radius: 8px;
  background: rgba(10, 4, 18, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45);
  overflow: visible;
}
.timer-fill {
  position: absolute;
  inset: 1px auto 1px 1px;
  width: 100%;
  border-radius: 7px;
  background: linear-gradient(90deg, #2ee6a0, #7ef0c4 40%, #ffd166 78%, #ffb14a);
  box-shadow: 0 0 18px rgba(62, 240, 164, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: width 0.18s linear, background 0.4s;
}
.timer-bar.warn .timer-fill {
  background: linear-gradient(90deg, #ffd166, #ff9b3d);
  box-shadow: 0 0 18px rgba(255, 175, 60, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.timer-bar.danger .timer-fill {
  background: linear-gradient(90deg, #ff3b62, #ff7a45);
  box-shadow: 0 0 22px rgba(255, 59, 98, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  animation: dangerPulse 0.9s ease-in-out infinite;
}
@keyframes dangerPulse { 50% { filter: brightness(1.35); } }
.notch {
  position: absolute;
  top: 50%;
  width: 17px; height: 17px;
  margin-left: -8.5px;
  transform: translateY(-50%);
  color: var(--gold);
  opacity: 0.55;
  filter: drop-shadow(0 0 6px rgba(255, 209, 102, 0.5));
  pointer-events: none;
}
.notch svg { width: 100%; height: 100%; }
.notch::after {
  content: '';
  position: absolute;
  left: 50%; top: 100%;
  width: 1px; height: 8px;
  background: rgba(255, 255, 255, 0.35);
}
.notch.n3 { left: 62%; }
.notch.n2 { left: 35%; }

.timer-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin-top: 5px;
}
.timer-text {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.7), 0 0 20px rgba(255, 63, 176, 0.4);
}
.timer-cap {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: 0 0 auto; }
.freed {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}
.freed b { font-family: var(--font-display); font-size: 36px; font-weight: 700; line-height: 1; color: var(--good); filter: drop-shadow(0 0 16px rgba(62, 240, 164, 0.7)); }
.freed span, .freed i { font-size: 16px; font-weight: 800; color: var(--ink-faint); font-style: normal; }
.freed em {
  font-style: normal;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-left: 6px;
}
.pressure { display: flex; gap: 6px; }
.pip {
  width: 22px; height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.18);
  transition: background 0.3s, box-shadow 0.3s;
}
.pip.on { background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.pip.on:nth-child(2) { background: #ff9b3d; box-shadow: 0 0 12px #ff9b3d; }
.pip.on:nth-child(3) { background: #ff5b6e; box-shadow: 0 0 12px #ff5b6e; }
.pip.on:nth-child(4) { background: #ff2d55; box-shadow: 0 0 16px #ff2d55; }

/* ------------------------------------------------------------- хореограф */
.hud-coach {
  position: absolute;
  right: clamp(10px, 2.2vw, 26px);
  bottom: calc(112px + var(--safe-bottom));
  display: flex;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}
.coach-card {
  position: relative;
  width: 372px;
  height: 496px;
  border-radius: 26px 26px 32px 32px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(180deg, rgba(40, 18, 60, 0.5), rgba(18, 7, 30, 0.82));
  backdrop-filter: blur(8px);
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}
.coach-card canvas { width: 100%; height: 100%; display: block; }
.coach-name {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 10px 0 9px;
  text-align: center;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.8);
  background: linear-gradient(180deg, transparent, rgba(10, 4, 18, 0.9) 40%);
}
.coach-bubble {
  position: relative;
  max-width: 300px;
  margin-bottom: 40px;
  padding: 16px 20px;
  border-radius: 20px 20px 6px 20px;
  background: rgba(255, 255, 255, 0.95);
  color: #2a0f30;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.32;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(6px) scale(0.96);
  transition: opacity 0.25s, transform 0.25s;
}
.coach-bubble:empty { display: none; }
.coach-bubble.pop { opacity: 1; transform: none; animation: bubblePop 0.3s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
@keyframes bubblePop { from { transform: scale(0.86); } to { transform: none; } }

/* --------------------------------------------------------------- бустеры */
.hud-boosters {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 10px;
  pointer-events: none;
}
.booster {
  pointer-events: auto;
  position: relative;
  width: 168px;
  padding: 16px 10px 12px;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(180deg, rgba(46, 22, 66, 0.82), rgba(20, 8, 32, 0.9));
  backdrop-filter: blur(10px);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: transform 0.14s, border-color 0.18s, box-shadow 0.18s;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.38);
}
.booster:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, 0.32); }
.booster:active { transform: translateY(1px) scale(0.97); }
.booster-ico { display: grid; place-items: center; }
.booster-ico svg { width: 48px; height: 48px; color: var(--accent-3); }
.booster:nth-child(2) .booster-ico svg { color: #8fdcff; }
.booster:nth-child(3) .booster-ico svg { color: #ffd166; }
.booster-count {
  position: absolute;
  top: -10px; right: -8px;
  min-width: 34px;
  padding: 3px 9px;
  border-radius: 12px;
  background: linear-gradient(180deg, #ff86cc, #ff3fa8);
  color: #2a0620;
  font-size: 17px;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 4px 12px rgba(255, 63, 176, 0.5);
}
.booster-name {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
}
.booster.empty { opacity: 0.55; }
.booster.empty .booster-count { background: rgba(255, 255, 255, 0.18); color: #fff; box-shadow: none; }

/* --------------------------------------------------------------- оверлеи */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(80% 80% at 50% 45%, rgba(20, 6, 34, 0.55), rgba(6, 1, 12, 0.9));
  backdrop-filter: blur(7px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.overlay-card {
  width: min(440px, 92vw);
  padding: 28px;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(165deg, rgba(52, 24, 76, 0.92), rgba(20, 8, 34, 0.96));
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  text-align: center;
  animation: cardIn 0.35s cubic-bezier(0.2, 1.2, 0.4, 1) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(16px) scale(0.96); } to { opacity: 1; transform: none; } }
.intro-style {
  display: inline-block;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent, #ff3fb0);
  padding: 8px 16px;
  border-radius: 12px;
  border: 1px solid currentColor;
  margin-bottom: 16px;
  text-shadow: 0 0 16px currentColor;
}
.intro-card h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 42px;
  letter-spacing: -0.01em;
  background: linear-gradient(100deg, #ff8ad1 0%, #ff3fa8 45%, #ff2dbb 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 20px rgba(255, 63, 176, 0.7));
}
.overlay-card h2 .dim { color: rgba(255, 255, 255, 0.32); font-size: 26px; }
.intro-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 16px;
  text-shadow: 0 0 20px currentColor;
}
.intro-row {
  display: flex;
  justify-content: center;
  gap: 16px;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 20px;
}
.intro-row i { width: 1px; background: rgba(255, 255, 255, 0.2); display: inline-block; }
.intro-line {
  margin: 0 0 24px;
  font-size: 18px;
  line-height: 1.5;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  font-style: italic;
  padding: 16px 20px;
  border-radius: 18px;
  background: linear-gradient(165deg, rgba(255, 63, 176, 0.18), rgba(139, 92, 246, 0.18));
  border: 1px solid rgba(255, 63, 176, 0.35);
  text-align: center;
  box-shadow: 0 0 30px rgba(255, 63, 176, 0.25);
}
.intro-card .btn { width: 100%; margin-top: 8px; font-size: 18px; padding: 18px 24px; }
.intro-hint {
  margin-top: 18px;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.7);
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.fail-title {
  font-family: var(--font-display);
  font-size: 25px;
  margin-bottom: 14px;
  color: #ff8fa3;
}
.fail-sub { font-size: 12px; font-weight: 800; color: var(--ink-faint); margin-bottom: 18px; }
.overlay-actions { display: flex; gap: 10px; }
.overlay-actions .btn { flex: 1; }
.overlay-actions.col { flex-direction: column; }
.pause-note {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-faint);
  margin-bottom: 20px;
}
.win-flash { background: radial-gradient(60% 60% at 50% 50%, rgba(255, 220, 120, 0.35), rgba(6, 1, 12, 0.92)); }
.win-word {
  font-family: var(--font-display);
  font-size: clamp(46px, 11vw, 110px);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 70px rgba(255, 210, 120, 0.9), 0 12px 40px rgba(0, 0, 0, 0.5);
  animation: winPop 0.8s cubic-bezier(0.2, 1.3, 0.3, 1) both;
}
@keyframes winPop {
  0% { transform: scale(0.4) rotate(-6deg); opacity: 0; }
  55% { transform: scale(1.06) rotate(1deg); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* «кризис» — красная рамка */
body.crisis .hud::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 120px 20px rgba(255, 45, 85, 0.35);
  animation: crisisPulse 1.1s ease-in-out infinite;
}
@keyframes crisisPulse { 50% { box-shadow: inset 0 0 160px 40px rgba(255, 45, 85, 0.5); } }

/* ---------------------------------------------------------------- адаптив */
@media (max-height: 760px) {
  .coach-card { width: 252px; height: 336px; }
  .coach-bubble { font-size: 15px; max-width: 250px; padding: 12px 15px; margin-bottom: 24px; }
  .booster { width: 132px; padding: 10px 8px 8px; }
  .booster-ico svg { width: 38px; height: 38px; }
  .booster-name { font-size: 11px; }
}
@media (max-width: 860px) {
  .hud-level { max-width: 34vw; }
  .hud-timer { max-width: 300px; }
  .timer-cap { display: none; }
  .coach-card { width: 220px; height: 294px; }
  .coach-bubble { max-width: 220px; font-size: 14px; margin-bottom: 20px; padding: 11px 13px; }
  .booster { width: 118px; padding: 10px 6px 8px; }
  .booster-ico svg { width: 34px; height: 34px; }
  .booster-name { font-size: 11px; }
  .booster-count { font-size: 13px; min-width: 26px; }
}
@media (max-width: 620px) {
  .hud { padding-left: 8px; padding-right: 8px; }
  .hud-left .hud-levelbox { display: none; }
  .hud-style { display: none; }
  .freed b { font-size: 28px; }
  .freed em { display: none; }
  .timer-text { font-size: 20px; }
  .notch { width: 14px; height: 14px; }
  .coach-card { display: none; }
  .coach-name { font-size: 8px; letter-spacing: 0.12em; }
  .hud-coach { flex-direction: column; align-items: flex-end; gap: 6px; right: 8px; bottom: calc(96px + var(--safe-bottom)); }
  .coach-bubble { margin-bottom: 0; }
  .coach-bubble { max-width: 132px; font-size: 10.5px; }
  .hud-boosters { gap: 6px; }
  .booster { width: 104px; padding: 8px 4px 6px; }
  .booster-ico svg { width: 30px; height: 30px; }
  .booster-name { font-size: 10px; }
  .overlay-card { padding: 22px 18px; border-radius: 24px; }
  .intro-title { font-size: 18px; }
  .intro-line { font-size: 15px; padding: 12px 14px; }
  .intro-card .btn { font-size: 16px; padding: 16px 20px; }
  .intro-row { font-size: 13px; gap: 12px; }
  .freed b { font-size: 28px; }
  .pip { width: 18px; height: 5px; }
}
@media (max-height: 560px) {
  .hud-coach { bottom: calc(90px + var(--safe-bottom)); }
  .coach-card { width: 96px; height: 128px; }
}
