* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: #fdf3e3;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN", sans-serif;
  color: #5b4a36;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

#wrap {
  max-width: 520px;
  margin: 0 auto;
  padding: 8px 10px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

#topbar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

h1 {
  font-size: 20px;
  text-align: center;
  color: #e8833a;
  line-height: 1.2;
  text-shadow: 1px 1px 0 #fff;
}

.scorebox {
  background: #fff;
  border: 3px solid #ffcf8e;
  border-radius: 14px;
  padding: 4px 12px;
  min-width: 84px;
  text-align: center;
  box-shadow: 0 3px 0 #f0d9b8;
}
.scorebox .label { font-size: 11px; color: #b08a5e; }
.scorebox div:last-child { font-size: 22px; font-weight: bold; color: #e8833a; }

#subbar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#next-box {
  background: #fff;
  border: 2px solid #ffcf8e;
  border-radius: 12px;
  padding: 3px 12px;
  font-size: 15px;
}
#next-emoji { font-size: 22px; vertical-align: middle; }
#mute-btn, #help-btn {
  background: #fff;
  border: 2px solid #ffcf8e;
  border-radius: 12px;
  font-size: 18px;
  padding: 3px 10px;
  cursor: pointer;
  margin-left: 6px;
}

#scene-wrap {
  position: relative;
  width: 100%;
}
#scene-wrap.shake { animation: shake 0.5s; }
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-8px, 4px); }
  40% { transform: translate(7px, -5px); }
  60% { transform: translate(-5px, 3px); }
  80% { transform: translate(4px, -2px); }
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 18px;
  background: linear-gradient(#fffdf7, #fff6e3);
  border: 4px solid #d9a05b;
  box-shadow: 0 5px 0 #c08a49, inset 0 -12px 0 rgba(217, 160, 91, 0.25);
}

#flash {
  position: absolute;
  inset: 0;
  background: #fff;
  border-radius: 18px;
  opacity: 0;
  pointer-events: none;
}
#flash.on { animation: flashAnim 0.55s ease-out; }
@keyframes flashAnim {
  0% { opacity: 0.95; }
  100% { opacity: 0; }
}

#boom-word {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 52px;
  font-weight: bold;
  color: #ff5722;
  text-shadow: 3px 3px 0 #fff, -2px -2px 0 #fff, 0 0 18px #ffd54f;
  pointer-events: none;
  white-space: nowrap;
}
#boom-word.on { animation: boomWord 1.4s ease-out; }
@keyframes boomWord {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
  25% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  45% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.1); opacity: 0; }
}

#evolution {
  font-size: 15px;
  letter-spacing: 1px;
  background: #fff;
  border-radius: 12px;
  padding: 4px 10px;
  border: 2px solid #ffe3b8;
  color: #c8a06a;
}
#evolution span { font-size: 18px; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(91, 74, 54, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 20px;
}
.overlay.hidden { display: none; }

.panel {
  background: #fffdf7;
  border-radius: 22px;
  border: 4px solid #ffcf8e;
  padding: 24px 22px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.panel h2 { color: #e8833a; margin-bottom: 14px; font-size: 24px; }
.panel .big { font-size: 16px; margin: 10px 0; line-height: 1.5; }
.panel .small { font-size: 13px; color: #b08a5e; margin: 10px 0 4px; }

.final-score {
  font-size: 46px;
  font-weight: bold;
  color: #e8833a;
  margin: 6px 0;
}
.final-best { font-size: 14px; color: #b08a5e; margin-bottom: 12px; min-height: 20px; }

.main-btn {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 13px;
  font-size: 19px;
  font-weight: bold;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(#ffb054, #f2913a);
  border: none;
  border-radius: 16px;
  box-shadow: 0 4px 0 #d0752a;
  cursor: pointer;
}
.main-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #d0752a; }

.sub-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 11px;
  font-size: 16px;
  font-weight: bold;
  font-family: inherit;
  color: #5b4a36;
  background: #fff;
  border: 3px solid #ffcf8e;
  border-radius: 16px;
  box-shadow: 0 3px 0 #f0d9b8;
  cursor: pointer;
}
.sub-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #f0d9b8; }
