/* БАЗАР design tokens (finbazar.ru light product UI) */
: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-sm: 11px;
  --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;
  position: relative;
  background: var(--bazar-surface);
  box-shadow: 0 0 0 1px var(--bazar-border);
}

/* ——— Top app bar (like feed header) ——— */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px 10px;
  background: var(--bazar-surface);
  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);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

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

.brand-text {
  min-width: 0;
}

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

.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 12px;
  min-width: 62px;
  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.06em;
  color: var(--bazar-muted);
  line-height: 1.1;
}

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

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

/* ——— Game stage as feed card ——— */
.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: pointer;
  background: #fafafa;
}

/* ——— Overlays (modal card on top of stage) ——— */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  text-align: center;
  background: rgba(246, 246, 246, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 3;
}

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

.overlay-card {
  width: 100%;
  max-width: 300px;
  background: var(--bazar-surface);
  border: 0.5px solid var(--bazar-border);
  border-radius: var(--bazar-radius-lg);
  padding: 28px 22px 22px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
}

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

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

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

.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 .tagline {
  margin: 0 0 20px;
  color: var(--bazar-text-secondary);
  font-size: 14px;
  line-height: 1.45;
}

.overlay .final-score {
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 800;
  color: var(--bazar-black);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin: 4px 0 2px;
  letter-spacing: -0.03em;
}

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

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

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

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

/* Primary CTA — BAZAR lime pill */
.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;
  line-height: 22px;
  padding: 0 32px;
  min-height: var(--control-min);
  min-width: 180px;
  border-radius: var(--bazar-radius-pill);
  cursor: pointer;
  box-shadow: none;
  transition: background 0.12s ease, transform 0.12s ease;
  width: 100%;
}

.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: 14px;
  font-size: 12px;
  color: var(--bazar-muted);
  line-height: 1.45;
}

.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);
  color: var(--bazar-text);
}

/* Chip row under title (topics like feed) */
.topic-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin: 0 0 16px;
}

.topic-chip {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--bazar-radius-pill);
  background: var(--bazar-lime-soft);
  color: #3d5c00;
  border: none;
}

/* Footer like mobile tab bar caption */
.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);
  background: var(--bazar-surface);
}

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

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

@media (min-width: 720px) {
  body {
    background: var(--bazar-bg);
  }

  .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 {
    padding: 5px 8px;
    min-width: 52px;
  }

  .brand-sub {
    display: none;
  }

  .btn-primary {
    min-width: 0;
  }
}
