:root {
  --sai-top: env(safe-area-inset-top, 0px);
  --sai-right: env(safe-area-inset-right, 0px);
  --sai-bottom: env(safe-area-inset-bottom, 0px);
  --sai-left: env(safe-area-inset-left, 0px);
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Fredoka One', 'Baloo 2', 'Poppins', system-ui, sans-serif;
  color: #fff;
  background: linear-gradient(160deg, #4ec0ca, #78d9e0 55%, #4ec0ca);
  -webkit-font-smoothing: antialiased;
}
#gameContainer {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#gameCanvas {
  display: block;
  background: transparent;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.hud {
  display: none;
}

#overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  background: rgba(0, 0, 0, 0.4);
}

.menu, .gameover, .stats-view, .volume-menu, .reset-confirmation {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  animation: pop-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.7); }
  to   { opacity: 1; transform: scale(1); }
}

.game-title {
  font-size: 52px;
  font-weight: 900;
  color: #fff;
  text-shadow:
    0 3px 0 #e67e22,
    0 6px 0 #d35400,
    0 8px 15px rgba(0,0,0,0.3);
  letter-spacing: 2px;
  animation: title-bob 2s ease-in-out infinite;
}
@keyframes title-bob {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50%      { transform: translateY(-6px) rotate(1deg); }
}

.game-bird {
  font-size: 64px;
  animation: bird-flap 0.6s ease-in-out infinite alternate;
  line-height: 1;
}
@keyframes bird-flap {
  from { transform: translateY(0) rotate(-5deg); }
  to   { transform: translateY(-10px) rotate(5deg); }
}

.game-subtitle {
  font-size: 15px;
  color: rgba(255,255,255,0.8);
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
  margin-bottom: 8px;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 220px;
  margin-top: 4px;
}

.mbtn {
  display: block;
  width: 100%;
  padding: 14px 0;
  border: none;
  border-radius: 50px;
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  text-shadow: 0 1px 2px rgba(0,0,0,0.25);
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
}
.mbtn:active {
  transform: scale(0.94);
}
.mbtn-play {
  background: linear-gradient(180deg, #4cd964, #34c759);
  box-shadow: 0 4px 0 #28a745, 0 6px 15px rgba(40,167,69,0.4);
  font-size: 20px;
}
.mbtn-play:active {
  box-shadow: 0 2px 0 #28a745;
  transform: translateY(2px) scale(0.98);
}
.mbtn-stats {
  background: linear-gradient(180deg, #5ac8fa, #34aadc);
  box-shadow: 0 4px 0 #1e90d0, 0 6px 15px rgba(30,144,208,0.4);
}
.mbtn-stats:active {
  box-shadow: 0 2px 0 #1e90d0;
  transform: translateY(2px) scale(0.98);
}
.mbtn-menu {
  background: linear-gradient(180deg, #ff9f0a, #ff8c00);
  box-shadow: 0 4px 0 #e07600, 0 6px 15px rgba(224,118,0,0.4);
}
.mbtn-menu:active {
  box-shadow: 0 2px 0 #e07600;
  transform: translateY(2px) scale(0.98);
}
.mbtn-back {
  background: linear-gradient(180deg, #8e8e93, #636366);
  box-shadow: 0 4px 0 #48484a, 0 6px 15px rgba(72,72,74,0.4);
}
.mbtn-back:active {
  box-shadow: 0 2px 0 #48484a;
  transform: translateY(2px) scale(0.98);
}
.mbtn-danger {
  background: linear-gradient(180deg, #ff453a, #d62d20);
  box-shadow: 0 4px 0 #a01a10, 0 6px 15px rgba(160,26,16,0.4);
}
.mbtn-danger:active {
  box-shadow: 0 2px 0 #a01a10;
  transform: translateY(2px) scale(0.98);
}
.mbtn-mute {
  background: linear-gradient(180deg, #af52de, #8944ab);
  box-shadow: 0 4px 0 #6d3690, 0 6px 15px rgba(109,54,144,0.4);
}
.mbtn-mute:active {
  box-shadow: 0 2px 0 #6d3690;
  transform: translateY(2px) scale(0.98);
}

.hs-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  border-radius: 50px;
  background: rgba(0,0,0,0.25);
  font-size: 16px;
  font-weight: 700;
  color: #ffd700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
}

.go-score-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin: 4px 0;
}
.go-label {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  text-transform: uppercase;
  letter-spacing: 2px;
}
.go-score {
  font-size: 72px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0,0,0,0.2), 0 6px 20px rgba(0,0,0,0.3);
  line-height: 1;
}
.go-message {
  font-size: 15px;
  color: rgba(255,255,255,0.85);
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.go-best {
  font-size: 15px;
  font-weight: 700;
  color: #ffd700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.go-medal {
  font-size: 56px;
  line-height: 1;
}
.go-new-record {
  font-size: 16px;
  font-weight: 700;
  color: #ffd700;
  text-shadow: 0 0 10px rgba(255,215,0,0.6);
  animation: pulse-record 1s ease-in-out infinite;
}
@keyframes pulse-record {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}

.stats-card {
  background: rgba(0,0,0,0.25);
  border-radius: 16px;
  padding: 16px 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 240px;
  backdrop-filter: blur(4px);
}
.sc-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.sc-val {
  font-size: 28px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.sc-label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.stats-rank {
  font-size: 18px;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.vol-slider-wrap {
  width: 200px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.25);
  border-radius: 50px;
  padding: 10px 16px;
  backdrop-filter: blur(4px);
}
.vol-slider-wrap label {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  white-space: nowrap;
}
.vol-slider {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.2);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.vol-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.reset-text {
  font-size: 14px;
  color: rgba(255,255,255,0.8);
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  max-width: 260px;
  line-height: 1.5;
}

.homeBtn {
  position: fixed;
  top: max(10px, var(--sai-top));
  left: max(10px, var(--sai-left));
  padding: 8px 14px;
  min-height: 40px;
  background: rgba(0,0,0,0.25);
  border: none;
  border-radius: 50px;
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  transition: transform 0.15s;
  user-select: none;
  -webkit-user-select: none;
}
.homeBtn:active {
  transform: scale(0.92);
}
.volumeBtn {
  position: fixed;
  top: max(10px, var(--sai-top));
  right: max(10px, var(--sai-right));
  padding: 8px 14px;
  min-height: 40px;
  min-width: 40px;
  background: rgba(0,0,0,0.25);
  border: none;
  border-radius: 50px;
  color: #fff;
  font-size: 20px;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  cursor: pointer;
  transition: transform 0.15s;
  user-select: none;
  -webkit-user-select: none;
}
.volumeBtn:active {
  transform: scale(0.92);
}

@media (max-width: 480px) {
  .game-title { font-size: 40px; }
  .game-bird { font-size: 52px; }
  .menu-buttons { width: 200px; }
  .mbtn { padding: 12px 0; font-size: 16px; }
  .go-score { font-size: 56px; }
  .stats-card { width: 210px; padding: 12px 16px; }
  .sc-val { font-size: 24px; }
}
@media (max-width: 375px) {
  .game-title { font-size: 34px; }
  .game-bird { font-size: 44px; }
  .menu-buttons { width: 180px; }
  .mbtn { padding: 11px 0; font-size: 15px; }
  .go-score { font-size: 48px; }
  .go-medal { font-size: 44px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .game-bird { font-size: 40px; }
  .game-title { font-size: 32px; }
  .mbtn { padding: 10px 0; font-size: 15px; }
  .go-score { font-size: 48px; }
  .go-medal { font-size: 40px; }
  .menu, .gameover, .stats-view, .volume-menu, .reset-confirmation {
    gap: 4px;
  }
}
