* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  touch-action: manipulation;
}

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;
}

.topbar {
  display: grid;
  grid-template-columns: 100px 1fr 140px;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.topbar h1 {
  margin: 0;
  text-align: center;
  font-size: 28px;
  line-height: 1.1;
}

.nav-btn {
  appearance: none;
  border: none;
  text-decoration: none;
  background: #3a3b40;
  color: #fff;
  border-radius: 10px;
  min-height: 40px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.stats-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-bottom: 12px;
  font-size: 18px;
  font-weight: 700;
}

.stats-bar div:first-child {
  justify-self: start;
}

.stats-bar div:last-child {
  justify-self: end;
}

#shareBtn{
    background: #538d4e;
}

.share-pill {
  appearance: none;
  border: 3px solid #d7d7d7;
  background: transparent;
  color: #fff;
  border-radius: 999px;
  padding: 8px 22px;
  min-height: 42px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.share-pill:hover {
  background: #2a2b30;
  transform: translateY(-1px);
}

.game-wrap {
  display: flex;
  justify-content: center;
}

canvas {
  display: block;
  width: 100%;
  max-width: 400px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  background: #0b0b0d;
  border: 4px solid #d7d7d7;
  border-radius: 8px;
  image-rendering: pixelated;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.message {
  min-height: 24px;
  text-align: center;
  margin-top: 14px;
  font-size: 16px;
  font-weight: 700;
}

.controls {
  margin: 18px auto 0;
  width: 240px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.ctrl {
  appearance: none;
  border: none;
  border-radius: 12px;
  min-height: 58px;
  background: #4a4b50;
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.ctrl.empty {
  visibility: hidden;
}

.copy-toast {
  position: fixed;
  top: 18px;
  right: 18px;
  background: #2f2f31;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  border: 1px solid #4a4a4d;
  z-index: 999;
}

.hidden {
  display: none !important;
}

@media (min-width: 801px) {
  .controls {
    display: none;
  }
}

@media (max-width: 600px) {
  body {
    padding: 12px;
    align-items: flex-start;
  }

  .app {
    padding: 14px;
    border-radius: 20px;
  }

  .topbar {
    grid-template-columns: 78px 1fr 110px;
    gap: 8px;
    margin-bottom: 8px;
  }

  .topbar h1 {
    font-size: 20px;
  }

  .nav-btn {
    min-height: 36px;
    font-size: 12px;
    padding: 8px 10px;
  }

  .stats-bar {
    font-size: 15px;
    gap: 8px;
    margin-bottom: 10px;
  }

  .share-pill {
    min-height: 36px;
    padding: 6px 16px;
    font-size: 12px;
    border-width: 2px;
  }

  .message {
    font-size: 14px;
  }

  .controls {
    width: 220px;
    gap: 8px;
  }

  .ctrl {
    min-height: 54px;
    font-size: 22px;
  }

  .copy-toast {
    top: 12px;
    right: 12px;
    font-size: 13px;
    padding: 8px 10px;
  }
}