/* БАЗАР — Собери портфель */
:root {
  --bazar-lime: #adff00;
  --bazar-lime-hover: #9eeb00;
  --bazar-lime-active: #8fd600;
  --bazar-lime-soft: rgba(173, 255, 0, 0.18);
  --bazar-black: #000000;
  --bazar-text: #111111;
  --bazar-text-secondary: #6b6b6b;
  --bazar-muted: #8a8a8a;
  --bazar-bg: #f6f6f6;
  --bazar-surface: #ffffff;
  --bazar-border: rgba(0, 0, 0, 0.08);
  --bazar-border-strong: rgba(0, 0, 0, 0.12);
  --bazar-green: #60b900;
  --bazar-red: #ff4545;
  --bazar-radius-md: 16px;
  --bazar-radius-lg: 24px;
  --bazar-radius-pill: 99px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --control-min: 56px;
  --font-display: "Montserrat", "Golos Text", system-ui, sans-serif;
  --font-body: "Roboto", "Golos Text", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bazar-bg);
  color: var(--bazar-text);
  font-family: var(--font-body);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  min-height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.app {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  min-height: 0;
  background: var(--bazar-surface);
  box-shadow: 0 0 0 1px var(--bazar-border);
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px 10px;
  border-bottom: 0.5px solid var(--bazar-border);
  z-index: 2;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--bazar-lime);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand-sub {
  font-size: 12px;
  color: var(--bazar-text-secondary);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.hud-scores {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-mute {
  appearance: none;
  border: 0.5px solid var(--bazar-border);
  background: var(--bazar-bg);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.12s ease, transform 0.12s ease;
}

.btn-mute:active {
  transform: scale(0.96);
}

.btn-mute.is-muted {
  opacity: 0.65;
  background: #eee;
}

.score-pill {
  background: var(--bazar-bg);
  border: 0.5px solid var(--bazar-border);
  border-radius: var(--bazar-radius-pill);
  padding: 6px 10px;
  min-width: 72px;
  text-align: center;
}

.score-pill .label {
  display: block;
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bazar-muted);
}

.score-pill .value {
  display: block;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--bazar-black);
  line-height: 1.25;
  white-space: nowrap;
}

.score-pill.best .value {
  color: var(--bazar-green);
}

.promo-strip {
  flex: 0 0 auto;
  padding: 8px 14px;
  background: var(--bazar-lime-soft);
  border-bottom: 0.5px solid var(--bazar-border);
  font-size: 12px;
  line-height: 1.4;
  color: #3d5c00;
  text-align: center;
}

.promo-strip strong {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--bazar-black);
}

.stage-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  margin: 10px 12px 8px;
  border-radius: var(--bazar-radius-lg);
  overflow: hidden;
  border: 0.5px solid var(--bazar-border-strong);
  background: var(--bazar-surface);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.06);
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  background: #fafafa;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 14px;
  text-align: center;
  background: rgba(246, 246, 246, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 3;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.overlay[hidden] {
  display: none !important;
}

.overlay-card {
  width: 100%;
  max-width: 320px;
  max-height: 100%;
  box-sizing: border-box;
  background: var(--bazar-surface);
  border: 0.5px solid var(--bazar-border);
  border-radius: var(--bazar-radius-lg);
  padding: 20px 18px 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
  overflow: auto;
}

.overlay-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  margin: 0 auto 12px;
  overflow: hidden;
  background: var(--bazar-lime);
}

.overlay-logo img {
  width: 100%;
  height: 100%;
  display: block;
}

.overlay .eyebrow {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bazar-text-secondary);
  margin: 0 0 6px;
}

.overlay h1 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: clamp(22px, 6vw, 26px);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.overlay .tagline {
  margin: 0 0 12px;
  color: var(--bazar-text-secondary);
  font-size: 14px;
  line-height: 1.45;
}

.rules {
  list-style: none;
  text-align: left;
  font-size: 13px;
  line-height: 1.4;
  color: var(--bazar-text);
  margin: 0 0 14px;
  padding: 12px 14px;
  background: var(--bazar-bg);
  border-radius: 12px;
  border: 0.5px solid var(--bazar-border);
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.rules li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 8px;
  padding: 0;
  min-width: 0;
}

.rules li:last-child {
  margin-bottom: 0;
}

.rules li::before {
  content: "";
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  margin-top: 0.45em;
  border-radius: 50%;
  background: var(--bazar-lime);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.rules li span,
.rules li strong {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.final-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  color: var(--bazar-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.final-score {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 4px 0 8px;
  font-variant-numeric: tabular-nums;
}

.best-line {
  font-size: 14px;
  color: var(--bazar-text-secondary);
  margin: 0 0 4px;
}

.best-line strong {
  color: var(--bazar-black);
  font-family: var(--font-display);
}

.new-best {
  color: var(--bazar-green);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  min-height: 1.2em;
  margin: 0 0 14px;
}

.btn-primary {
  appearance: none;
  border: none;
  background: var(--bazar-lime);
  color: var(--bazar-black);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  padding: 0 28px;
  min-height: var(--control-min);
  min-width: 180px;
  width: 100%;
  border-radius: var(--bazar-radius-pill);
  cursor: pointer;
  transition: background 0.12s ease, transform 0.12s ease;
}

.btn-primary:hover {
  background: var(--bazar-lime-hover);
}

.btn-primary:active {
  background: var(--bazar-lime-active);
  transform: scale(0.98);
}

.btn-primary:focus-visible {
  outline: 2px solid var(--bazar-black);
  outline-offset: 3px;
}

.hint {
  margin-top: 12px;
  font-size: 12px;
  color: var(--bazar-muted);
  line-height: 1.4;
}

.hint kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  border: 0.5px solid var(--bazar-border-strong);
  background: var(--bazar-bg);
  font-size: 11px;
  font-family: var(--font-body);
}

.lives-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 10px;
}

.life {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bazar-border-strong);
}

.life.on {
  background: var(--bazar-lime);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.footer-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px 14px;
  font-size: 12px;
  color: var(--bazar-muted);
  border-top: 0.5px solid var(--bazar-border);
}

.footer-wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--bazar-black);
  letter-spacing: -0.02em;
}

.footer-bar .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--bazar-border-strong);
}

@media (min-width: 720px) {
  .app {
    max-width: 420px;
    margin: 16px auto;
    border-radius: var(--bazar-radius-lg);
    overflow: hidden;
    min-height: calc(100dvh - 32px);
    max-height: 900px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.08);
  }

  .stage-wrap {
    min-height: 480px;
  }
}

@media (max-width: 360px) {
  .score-pill {
    min-width: 60px;
    padding: 5px 8px;
  }

  .brand-sub {
    display: none;
  }

  .promo-strip {
    font-size: 11px;
  }
}
