* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background:
    radial-gradient(
      circle at 20% 15%,
      rgba(255, 196, 87, 0.38),
      transparent 28%
    ),
    radial-gradient(
      circle at 80% 12%,
      rgba(255, 111, 145, 0.32),
      transparent 26%
    ),
    linear-gradient(180deg, #fff3c9 0%, #ffe0a3 45%, #ffc879 100%);
  color: #3f2812;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.game-shell {
  width: min(100%, 460px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.top-ui {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.score-box {
  min-height: 58px;
  padding: 10px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.68);
  border: 2px solid rgba(150, 88, 36, 0.18);
  box-shadow: 0 10px 22px rgba(134, 74, 16, 0.15);
  backdrop-filter: blur(10px);
}

.score-box.right {
  text-align: right;
}

.score-label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  opacity: 0.72;
}

.score-value {
  display: block;
  font-size: 23px;
  line-height: 1.1;
  font-weight: 950;
  letter-spacing: -0.04em;
}

.next-box {
  width: 74px;
  height: 74px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.8);
  border: 2px solid rgba(150, 88, 36, 0.18);
  box-shadow: 0 10px 22px rgba(134, 74, 16, 0.15);
  position: relative;
  overflow: hidden;
}

.next-box::before {
  content: "NEXT";
  position: absolute;
  top: 5px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  font-weight: 950;
  opacity: 0.58;
}

#gameCanvas {
  width: min(100%, 430px);
  aspect-ratio: 420 / 640;
  max-height: calc(100vh - 112px);
  border-radius: 26px;
  background: #fff9e9;
  box-shadow:
    0 18px 50px rgba(121, 65, 10, 0.25),
    inset 0 0 0 4px rgba(255, 255, 255, 0.7),
    inset 0 -16px 30px rgba(196, 110, 35, 0.13);
  border: 4px solid rgba(131, 75, 30, 0.28);
  touch-action: none;
  cursor: pointer;
}

.help-text {
  width: 100%;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  color: rgba(63, 40, 18, 0.76);
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(71, 36, 5, 0.28);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.overlay.hidden {
  display: none;
}

.panel {
  width: min(100%, 390px);
  padding: 26px 22px 22px;
  border-radius: 28px;
  background:
    radial-gradient(
      circle at 20% 0%,
      rgba(255, 229, 142, 0.95),
      transparent 38%
    ),
    linear-gradient(180deg, #fffef7, #ffe2a9);
  border: 3px solid rgba(121, 65, 10, 0.18);
  box-shadow: 0 28px 70px rgba(77, 39, 5, 0.35);
  text-align: center;
}

.panel h1 {
  margin: 0 0 8px;
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: -0.06em;
}

.panel p {
  margin: 8px 0 18px;
  font-size: 15px;
  line-height: 1.55;
  font-weight: 700;
  color: rgba(63, 40, 18, 0.76);
}

.button-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 950;
  color: white;
  background: linear-gradient(180deg, #ff7a59, #e84f30);
  box-shadow: 0 10px 18px rgba(213, 78, 42, 0.32);
  cursor: pointer;
}

button.secondary {
  color: #5a3515;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 0 0 2px rgba(139, 82, 32, 0.15);
}

@media (max-width: 380px) {
  body {
    padding: 8px;
  }

  .score-box {
    min-height: 50px;
    padding: 8px 10px;
    border-radius: 15px;
  }

  .score-value {
    font-size: 19px;
  }

  .next-box {
    width: 62px;
    height: 62px;
    border-radius: 18px;
  }

  .help-text {
    font-size: 12px;
  }
}
