:root {
  --sky: #4ec0ca;
  --gold: #f4d35e;
  --gold-dark: #c9a227;
  --navy: #1b2a4a;
  --red: #c41e3a;
  --cream: #f7efe0;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: #1a2433;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

body {
  display: grid;
  place-items: center;
}

#game-wrap {
  position: relative;
  width: min(100vw, calc(100vh * 400 / 640));
  height: min(100vh, calc(100vw * 640 / 400));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  border-radius: 8px;
  overflow: hidden;
  background: #4aa3e8;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
  padding: 24px;
}

.overlay.hidden {
  display: none;
}

#hud {
  position: absolute;
  top: 28px;
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
  z-index: 2;
}

#score {
  font-size: clamp(36px, 10vw, 52px);
  font-weight: 800;
  color: #fff;
  letter-spacing: 2px;
  text-shadow:
    3px 3px 0 #3d2a12,
    -2px 0 0 #3d2a12,
    2px 0 0 #3d2a12,
    0 -2px 0 #3d2a12,
    0 2px 0 #3d2a12;
  opacity: 0;
  transition: opacity 0.15s ease;
}

#score.visible {
  opacity: 1;
}

#mute {
  position: absolute;
  top: 1.6%;
  right: 1.8%;
  z-index: 6;
  width: 9.2%;
  max-width: 42px;
  aspect-ratio: 1;
  height: auto;
  border-radius: 50%;
  border: 3px solid #1a1a1a;
  background: #fff;
  color: #111;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: none;
  display: grid;
  place-items: center;
  padding: 0;
  line-height: 1;
}

#mute.muted {
  opacity: 0.45;
}

#game-wrap:has(#start-screen:not(.hidden)) #mute {
  opacity: 0;
}

#start-screen {
  background: url("assets/boot-screen.jpg") center / cover no-repeat;
  padding: 0;
}

#play {
  pointer-events: auto;
  position: absolute;
  left: 50%;
  top: 69%;
  transform: translate(-50%, -50%);
  width: 52%;
  height: 8.5%;
  opacity: 0;
  cursor: pointer;
  border: 0;
  background: transparent;
  font-size: 0;
}

.panel {
  pointer-events: auto;
  background: linear-gradient(#f3d9a4, #e2b86a);
  border: 4px solid #5a3b12;
  border-radius: 14px;
  padding: 22px 28px 20px;
  min-width: 240px;
  box-shadow: 0 8px 0 #8a5a18, 0 16px 28px rgba(0, 0, 0, 0.35);
}

.panel h2 {
  color: var(--red);
  font-size: 28px;
  letter-spacing: 2px;
  text-shadow: 2px 2px 0 #fff3d0;
  margin-bottom: 16px;
}

.stats {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 16px;
}

.stats .label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #8a4a18;
}

.stats span:last-child {
  display: block;
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  text-shadow: 2px 2px 0 #5a3b12;
}

.medal.hidden {
  display: none;
}

.medal {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  border: 4px solid #5a3b12;
}

.medal.bronze { background: radial-gradient(circle at 30% 30%, #f0c28a, #b87333); }
.medal.silver { background: radial-gradient(circle at 30% 30%, #f4f4f4, #8a8a8a); }
.medal.gold { background: radial-gradient(circle at 30% 30%, #ffe9a0, #d4a017); }
.medal.platinum { background: radial-gradient(circle at 30% 30%, #e8f6ff, #7ec8e3); }

#restart {
  width: 100%;
  cursor: pointer;
  background: linear-gradient(#5ad46a, #2ea043);
  color: #fff;
  border: 3px solid #145c22;
  border-bottom-width: 6px;
  border-radius: 10px;
  padding: 10px 14px 8px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1px;
}

#restart:active {
  transform: translateY(3px);
  border-bottom-width: 3px;
}
