* {
  box-sizing: border-box;
}

:root {
  --surface: #14161f;
  --panel: #1c1f2c;
  --panel-edge: #2a2e40;
  --accent: #c8ff00;
  --accent2: #5ee1ff;
  --text: #e8eaf0;
  --muted: #9aa0b5;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: 'SN Pro', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background-color: var(--surface);
  background-image: radial-gradient(rgba(50, 52, 62, 0.45) 1px, var(--surface) 1px);
  background-size: 20px 20px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.app {
  min-height: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 1rem 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

/* --- Шапка --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.logo {
  margin: 0;
  font-family: 'JetBrains Mono', Menlo, monospace;
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: 0.12em;
  color: var(--text);
}

.logo__dot {
  color: var(--accent);
}

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

.chip {
  font-family: 'JetBrains Mono', Menlo, monospace;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

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

/* --- Сцена --- */
.stage {
  display: flex;
  gap: 0.9rem;
  justify-content: center;
  align-items: flex-start;
}

.boardWrap {
  position: relative;
  flex: 0 0 auto;
  border-radius: 14px;
  padding: 6px;
  background: linear-gradient(160deg, #23273a, #171a26);
  border: 1px solid var(--panel-edge);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

#board {
  display: block;
  width: min(300px, 68vw);
  height: auto;
  border-radius: 8px;
  background: #0e1017;
}

/* --- HUD --- */
.hud {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 190px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
  padding: 0.6rem 0.75rem 0.7rem;
}

.panel__label {
  font-family: 'JetBrains Mono', Menlo, monospace;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.panel__value {
  font-family: 'JetBrains Mono', Menlo, monospace;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent2);
  line-height: 1.1;
}

.panel__value--score {
  color: var(--accent);
}

.panel--next {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.panel--next .panel__label {
  align-self: flex-start;
}

#next {
  width: 120px;
  height: 90px;
}

.panelGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.keys {
  list-style: none;
  margin: 0.3rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--muted);
}

kbd {
  font-family: 'JetBrains Mono', Menlo, monospace;
  font-size: 0.7rem;
  font-weight: 600;
  background: #12141d;
  border: 1px solid var(--panel-edge);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0.1rem 0.35rem;
  color: var(--text);
  margin-right: 0.15rem;
}

/* --- Оверлеи --- */
.overlay {
  position: absolute;
  inset: 6px;
  border-radius: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 11, 16, 0.86);
  backdrop-filter: blur(3px);
  z-index: 5;
}

.overlay--show {
  display: flex;
  animation: fadeIn 0.22s ease;
}

.overlay__card {
  text-align: center;
  padding: 1.2rem 1rem;
  max-width: 250px;
}

.overlay__emoji {
  font-size: 2.6rem;
  line-height: 1;
  animation: bounce 1.4s ease-in-out infinite;
}

.overlay__title {
  margin: 0.55rem 0 0.4rem;
  font-family: 'JetBrains Mono', Menlo, monospace;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.overlay__text {
  margin: 0 0 0.9rem;
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--muted);
}

.overlay__text b {
  color: var(--accent2);
}

.btn {
  font-family: 'JetBrains Mono', Menlo, monospace;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  border: none;
  border-radius: 10px;
  padding: 0.7rem 1.5rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn--play {
  color: #10121a;
  background: linear-gradient(160deg, var(--accent), #9fe000);
  box-shadow: 0 6px 18px rgba(200, 255, 0, 0.3);
}

.btn--play:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(200, 255, 0, 0.4);
}

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

/* --- Мобильный пульт --- */
.pad {
  display: none;
  justify-content: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.pad__btn {
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 14px;
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: transform 0.08s ease, background 0.12s ease;
}

.pad__btn:active {
  transform: scale(0.92);
  background: #262a3c;
}

.pad__btn--rot {
  color: var(--accent2);
}

.pad__btn--drop {
  color: var(--accent);
}

/* --- Анимации --- */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-7px);
  }
}

/* --- Адаптив --- */
@media (max-width: 640px) {
  .stage {
    flex-direction: column;
    align-items: center;
  }

  .hud {
    width: min(360px, 92vw);
    flex-direction: row;
    flex-wrap: wrap;
  }

  .panel {
    flex: 1 1 45%;
  }

  .panel--keys {
    display: none;
  }

  .panelGrid {
    flex: 1 1 100%;
  }

  .panel--next {
    flex: 1 1 45%;
  }

  .pad {
    display: flex;
  }

  #board {
    width: min(300px, 84vw);
  }
}
