* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: #0f1012;
  color: #fff;
  font-family: Arial, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.app {
  width: 100%;
  max-width: 560px;
  background: #1c1d22;
  border-radius: 24px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  padding: 18px 18px 20px;
}

.topbar {
  display: grid;
  grid-template-columns: 110px 1fr 110px;
  align-items: center;
  gap: 12px;
  text-align: center;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  text-align: center;
  font-size: 26px;
  line-height: 1.1;
  font-weight: 700;
}

.nav-btn,
.mode-btn {
  appearance: none;
  border: none;
  text-decoration: none;
  background: #3a3b40;
  color: #fff;
  border-radius: 10px;
  min-height: 40px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

.nav-btn:hover,
.mode-btn:hover {
  background: #4a4b51;
}

.nav-btn:active,
.mode-btn:active {
  transform: translateY(1px);
}

.game-area {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.modes {
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.mode-btn {
  min-width: 90px;
}

.mode-btn.active {
  background: #349623;
}

.scoreboard {
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.score-box {
  min-width: 116px;
  background: #2a2b31;
  border-radius: 14px;
  padding: 10px 16px;
  text-align: center;
}

.score-label {
  display: block;
  color: #bfc3cf;
  font-size: 13px;
  margin-bottom: 4px;
}

.score-value {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
}

.best-box .score-value {
  color: #ffd166;
}

.message {
  min-height: 24px;
  margin-bottom: 12px;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  color: #d9dce5;
}

.message.fail {
  color: #ff6b6b;
}

.message.perfect {
  color: #ffd166;
}

.game-wrap {
  width: 100%;
  height: 400px;
  background: #0b0c0f;
  border-radius: 20px;
  position: relative;
  overflow: hidden;
  margin-bottom: 12px;
}

.tower {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(0);
  width: 260px;
  height: 100%;
  transition: transform 0.18s ease-out;
}

.block {
  position: absolute;
  height: 32px;
  border-radius: 6px;
  background: #8a8a8a;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.22);
}

.block.base {
  background: #5f636d;
}

.dark-overlay {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 2;
}

.dark-overlay.show {
  opacity: 0.55;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 3;
}

.overlay.show {
  display: flex;
}

.panel {
  width: 100%;
  max-width: 320px;
  background: #23242a;
  padding: 24px 20px;
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 24px;
}

.panel p {
  margin: 0 0 18px;
  font-size: 17px;
}

.panel-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.share-btn {
  background: #45a72f;
}

.share-btn:hover {
  background: #3b78f0;
}

.hint {
  text-align: center;
  color: #b9bcc6;
  font-size: 14px;
}

@media (max-width: 600px) {
  body {
    padding: 12px;
  }

  .app {
    padding: 14px 12px 16px;
    border-radius: 20px;
  }

  .topbar {
    grid-template-columns: 90px 1fr 90px;
    gap: 8px;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .nav-btn,
  .mode-btn {
    min-height: 36px;
    font-size: 12px;
    padding: 8px 10px;
  }

  .mode-btn {
    min-width: 76px;
  }

  .score-box {
    min-width: 100px;
    padding: 8px 12px;
  }

  .score-value {
    font-size: 18px;
  }

  .game-wrap {
    height: 360px;
  }

  .tower {
    width: 230px;
  }

  .block {
    height: 30px;
  }

  .panel h2 {
    font-size: 22px;
  }

  .panel p {
    font-size: 16px;
  }
}