* {
  box-sizing: border-box;
}

:root {
  --kvibe-surface: #12141c;
  --kvibe-grid-dot: rgba(50, 52, 62, 0.45);
  --accent: #c8ff00;
  --accent-2: #ff5f6d;
  --panel: #191b24;
  --board-size: min(96vw, 78vh, 768px);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'SN Pro', system-ui, -apple-system, sans-serif;
  color: #e8eaf0;
  background-color: var(--kvibe-surface);
  background-image: radial-gradient(
    var(--kvibe-grid-dot) 1px,
    var(--kvibe-surface) 1px
  );
  background-size: 20px 20px;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 1rem 1.5rem;
  gap: 1rem;
}

/* ---------- шапка ---------- */
.topbar {
  width: 100%;
  max-width: 860px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.logo {
  margin: 0;
  font-family: 'JetBrains Mono', Menlo, monospace;
  font-size: 1.55rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.hud {
  display: flex;
  gap: 0.65rem;
}

.hud__item {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  padding: 0.45rem 0.95rem;
  min-width: 98px;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.hud__label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #8a8fa3;
}

.hud__value {
  font-family: 'JetBrains Mono', Menlo, monospace;
  font-size: 1.55rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
}

.hud__value--best {
  color: var(--accent);
}

.topbar__actions {
  display: flex;
  gap: 0.4rem;
}

.icon-btn {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: var(--panel);
  font-size: 1.4rem;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}

.icon-btn:hover {
  background: #232633;
  transform: translateY(-2px);
}

.icon-btn.is-off {
  filter: grayscale(1);
  opacity: 0.6;
}

/* ---------- поле ---------- */
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.board-wrap {
  position: relative;
  width: var(--board-size);
  height: var(--board-size);
  border-radius: 24px;
  overflow: hidden;
  box-shadow:
    0 0 0 2px rgba(200, 255, 0, 0.18),
    0 18px 50px rgba(0, 0, 0, 0.55);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  background: #16211a;
  touch-action: none;
}

/* ---------- оверлей ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 18, 0.82);
  backdrop-filter: blur(4px);
  padding: 1rem;
  /* фон не перехватывает клики — их всегда получает кнопка карточки */
  pointer-events: none;
}

.overlay[hidden] {
  display: none;
}

.overlay__card {
  pointer-events: auto;
  width: min(100%, 420px);
  text-align: center;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 22px;
  padding: 1.8rem 1.5rem 1.5rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  animation: pop 0.28s ease;
}

@keyframes pop {
  from {
    transform: scale(0.88);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.overlay__emoji {
  font-size: 3.4rem;
  line-height: 1;
  animation: wiggle 1.6s ease-in-out infinite;
}

@keyframes wiggle {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}

.overlay__title {
  margin: 0.6rem 0 0;
  font-family: 'JetBrains Mono', Menlo, monospace;
  font-size: 2rem;
  color: var(--accent);
}

.overlay__text {
  margin: 0.6rem 0 0;
  font-size: 1.02rem;
  line-height: 1.5;
  color: #b8b8c8;
}

.overlay__stats {
  margin-top: 0.8rem;
  display: flex;
  justify-content: center;
  gap: 1rem;
  font-family: 'JetBrains Mono', Menlo, monospace;
  font-size: 1.15rem;
}

.overlay__stats b {
  color: var(--accent);
}

.btn {
  margin-top: 1.1rem;
  width: 100%;
  padding: 1rem 1.1rem;
  border: none;
  border-radius: 16px;
  background: var(--accent);
  color: #10130a;
  font-family: 'JetBrains Mono', Menlo, monospace;
  font-size: 1.35rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  box-shadow: 0 8px 22px rgba(200, 255, 0, 0.25);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(200, 255, 0, 0.35);
}

.btn:active {
  transform: translateY(1px);
}

.overlay__hint {
  margin: 0.85rem 0 0;
  font-size: 0.85rem;
  color: #8a8fa3;
  line-height: 1.7;
}

kbd {
  display: inline-block;
  padding: 0.05rem 0.35rem;
  margin: 0 0.1rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-bottom-width: 2px;
  background: #232633;
  font-family: 'JetBrains Mono', Menlo, monospace;
  font-size: 0.8rem;
  color: #e8eaf0;
}

/* ---------- крестовина (мобайл) ---------- */
.pad {
  display: none;
  grid-template-columns: repeat(3, 72px);
  grid-template-rows: repeat(3, 72px);
  gap: 8px;
  justify-content: center;
}

.pad__btn {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--panel);
  color: var(--accent);
  border-radius: 16px;
  font-size: 1.5rem;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.pad__btn:active {
  background: var(--accent);
  color: #10130a;
}

.pad__btn--up { grid-area: 1 / 2; }
.pad__btn--left { grid-area: 2 / 1; }
.pad__btn--down { grid-area: 2 / 2; }
.pad__btn--right { grid-area: 2 / 3; }

/* ---------- подвал ---------- */
.tips {
  font-size: 0.92rem;
  color: #8a8fa3;
  text-align: center;
}

.tip--apple { color: #ff8a80; }
.tip--golden { color: #ffd54f; }

@media (max-width: 720px), (hover: none) {
  .pad {
    display: grid;
  }
  .tips {
    display: none;
  }
}
