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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #12181f;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Fredoka', sans-serif;
  touch-action: manipulation;
}

#game-wrapper {
  position: relative;
  width: 100vw;
  height: 100vh;
  max-width: 440px;
  max-height: 860px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), 0 0 0 4px #0c1015;
  background-color: #4ec0ca;
  overflow: hidden;
}

/* Canvas is pixel crisp */
#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

/* In-game HUD */
.hud-layer {
  position: absolute;
  top: 14%;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 15;
}

.arcade-text {
  font-family: 'Press Start 2P', monospace;
  font-size: 40px;
  color: #ffffff;
  text-shadow: 
    3px 3px 0 #000000,
    -3px -3px 0 #000000,
    3px -3px 0 #000000,
    -3px 3px 0 #000000,
    0 4px 0 #000000,
    4px 0 0 #000000,
    0 -4px 0 #000000,
    -4px 0 0 #000000;
  letter-spacing: 2px;
}

/* UI Layer */
.ui-layer {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  z-index: 20;
}

.screen-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 90%;
  pointer-events: auto;
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.hidden {
  display: none !important;
}

/* Start Screen */
.logo-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
}

.logo-flappy {
  font-family: 'Press Start 2P', monospace;
  font-size: 32px;
  color: #f7b32b;
  text-shadow: 
    3px 3px 0 #000, -3px -3px 0 #000, 3px -3px 0 #000, -3px 3px 0 #000,
    0 5px 0 #c27a00;
  transform: rotate(-3deg);
}

.logo-wings {
  font-family: 'Press Start 2P', monospace;
  font-size: 38px;
  color: #ffffff;
  text-shadow: 
    3px 3px 0 #000, -3px -3px 0 #000, 3px -3px 0 #000, -3px 3px 0 #000,
    0 6px 0 #333333;
  margin-top: 4px;
  letter-spacing: 2px;
}

.tap-guide-box {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  border: 3px solid #ffffff;
  border-radius: 16px;
  padding: 16px 20px;
  text-align: center;
  box-shadow: 0 6px 0 rgba(0,0,0,0.5);
  margin-bottom: 18px;
}

.tap-icon-bounce {
  font-size: 38px;
  animation: bounceTap 1.2s infinite ease-in-out;
}

.tap-text {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  line-height: 1.6;
  color: #ffe600;
  margin-top: 6px;
  text-shadow: 2px 2px 0 #000;
}

.high-score-pill {
  font-family: 'Press Start 2P', monospace;
  font-size: 13px;
  color: #ffffff;
  background: #2b7029;
  border: 3px solid #144013;
  border-radius: 20px;
  padding: 8px 18px;
  text-shadow: 2px 2px 0 #000;
  box-shadow: 0 4px 0 #102e0f;
  margin-bottom: 10px;
}

.hint-tag {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #ffffff;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
  opacity: 0.9;
}

/* Game Over Card */
.gameover-banner {
  font-family: 'Press Start 2P', monospace;
  font-size: 26px;
  color: #e05338;
  text-shadow: 
    3px 3px 0 #000, -3px -3px 0 #000, 3px -3px 0 #000, -3px 3px 0 #000,
    0 5px 0 #851c08;
  margin-bottom: 18px;
  letter-spacing: 1px;
}

.score-card {
  width: 100%;
  background: #ded895;
  border: 4px solid #543847;
  border-radius: 12px;
  box-shadow: 0 8px 0 #331f2a;
  padding: 18px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}

.medal-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 45%;
  border-right: 3px dashed #b5ad65;
  padding-right: 12px;
}

.medal-badge {
  font-size: 40px;
  line-height: 1;
  margin-top: 6px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 3px 2px rgba(0,0,0,0.3));
}

.score-slot {
  width: 55%;
  padding-left: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.score-row {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.card-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: #e05338;
  text-shadow: 1px 1px 0 #ffffff;
}

.score-val {
  font-family: 'Press Start 2P', monospace;
  font-size: 20px;
  color: #333333;
  margin-top: 2px;
}

.score-val.gold {
  color: #d17c00;
}

/* Retro Play Button */
.retro-btn {
  background: linear-gradient(180deg, #5ee134 0%, #3ba819 100%);
  border: 4px solid #1c5c09;
  border-radius: 12px;
  padding: 14px 28px;
  box-shadow: 0 6px 0 #123e05, 0 10px 14px rgba(0,0,0,0.35);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  width: 80%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.retro-btn span {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  color: #ffffff;
  text-shadow: 2px 2px 0 #0f3d03;
}

.retro-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #123e05;
}

/* Sound Button */
.sound-toggle {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid #ffffff;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 30;
  backdrop-filter: blur(4px);
  box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

.sound-toggle:active {
  transform: scale(0.92);
}

/* Animations */
@keyframes bounceTap {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes popIn {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@media (max-width: 400px) {
  .logo-flappy { font-size: 26px; }
  .logo-wings { font-size: 32px; }
  .arcade-text { font-size: 34px; }
  .retro-btn span { font-size: 12px; }
}