* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172c39;
  background: #91aebd;
}

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}

#game {
  position: fixed;
  inset: 0;
}

#hud {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: none;
  z-index: 3;
}

.hud-item {
  min-width: 104px;
  padding: 9px 12px;
  border: 1px solid rgba(26, 61, 80, 0.34);
  border-radius: 8px;
  background: rgba(214, 226, 232, 0.92);
  box-shadow: 0 8px 22px rgba(13, 38, 52, 0.28);
  backdrop-filter: blur(10px);
}

.hud-item span {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #294759;
}

.hud-item strong {
  display: block;
  margin-top: 2px;
  font-size: 22px;
  line-height: 1;
  color: #172c39;
  text-shadow: 0 1px 0 rgba(214, 226, 232, 0.65);
}

.hud-item.hold {
  min-width: 132px;
}

#hint {
  position: fixed;
  left: 50%;
  bottom: 14px;
  width: min(720px, calc(100vw - 24px));
  transform: translateX(-50%);
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(20, 37, 47, 0.78);
  color: #dce7ec;
  box-shadow: 0 8px 20px rgba(6, 20, 28, 0.28);
  text-align: center;
  font-size: 13px;
  z-index: 3;
  backdrop-filter: blur(7px);
}

#toast {
  position: fixed;
  top: 86px;
  left: 50%;
  max-width: min(460px, calc(100vw - 28px));
  min-height: 40px;
  transform: translate(-50%, -8px);
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(23, 50, 66, 0.18);
  background: rgba(216, 226, 231, 0.94);
  color: #1c3443;
  box-shadow: 0 14px 34px rgba(13, 36, 50, 0.32);
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 4;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(rgba(177, 203, 214, 0.22), rgba(42, 62, 73, 0.34)),
    radial-gradient(circle at 50% 15%, rgba(204, 216, 222, 0.68), rgba(204, 216, 222, 0) 34%);
  z-index: 5;
}

.overlay.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.panel {
  width: min(460px, 100%);
  padding: 24px;
  border: 1px solid rgba(24, 56, 75, 0.24);
  border-radius: 8px;
  background: rgba(216, 226, 231, 0.94);
  box-shadow: 0 24px 70px rgba(15, 39, 55, 0.35);
  backdrop-filter: blur(14px);
}

.panel.celebration-panel {
  width: min(720px, 100%);
}

.eyebrow {
  margin: 0 0 6px;
  color: #9c6570;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: #203849;
  font-size: clamp(34px, 9vw, 54px);
  line-height: 0.96;
}

.intro,
#end-copy {
  margin: 14px 0 20px;
  color: #4a6473;
  line-height: 1.5;
}

.victory-celebration {
  margin: 14px 0 18px;
}

.victory-image {
  position: relative;
  width: 100%;
  aspect-ratio: 1672 / 941;
  overflow: hidden;
  border: 1px solid rgba(26, 61, 80, 0.22);
  border-radius: 8px;
  background-image: url("./assets/congratulations-level3.png");
  background-position: center;
  background-size: cover;
  box-shadow: 0 18px 44px rgba(15, 39, 55, 0.28);
}

.victory-times {
  position: absolute;
  top: 3.4%;
  left: 1.35%;
  width: 15.5%;
  padding: 1.25% 1.15%;
  border: 1px solid rgba(215, 235, 252, 0.72);
  border-radius: 8px;
  background: #143f72;
  box-shadow:
    0 10px 22px rgba(7, 26, 54, 0.3),
    inset 0 0 18px rgba(39, 117, 177, 0.34);
}

.victory-time {
  color: #f3f8ff;
  font-size: clamp(10px, 1.55vw, 18px);
  font-weight: 900;
  line-height: 1.55;
  text-shadow: 0 2px 0 rgba(7, 31, 72, 0.82);
}

.victory-heart-link {
  position: absolute;
  left: 52.8%;
  top: 50.4%;
  width: 11.8%;
  height: 7.8%;
  display: grid;
  place-items: center;
  color: #bdefff;
  font: 900 clamp(12px, 2.25vw, 31px) Georgia, serif;
  text-decoration: none;
  text-shadow:
    0 2px 0 #0b4387,
    0 0 14px rgba(116, 226, 255, 0.95);
  transform: rotate(3deg);
  border-radius: 999px;
  animation: pinguLinkBlink 1.05s steps(1, end) infinite;
}

.victory-heart-link:hover {
  animation-duration: 0.62s;
}

@keyframes pinguLinkBlink {
  0%,
  49% {
    color: #bdefff;
    text-shadow:
      0 2px 0 #0b4387,
      0 0 14px rgba(116, 226, 255, 0.95);
  }

  50%,
  100% {
    color: #ffe56d;
    text-shadow:
      0 2px 0 #765b00,
      0 0 16px rgba(255, 230, 109, 0.96);
  }
}

.swatches {
  display: grid;
  grid-template-columns: repeat(7, minmax(40px, 1fr));
  gap: 9px;
  margin-bottom: 20px;
}

.swatch {
  position: relative;
  aspect-ratio: 1;
  border: 2px solid rgba(15, 35, 48, 0.48);
  box-shadow: inset 0 0 0 2px rgba(214, 226, 232, 0.34), 0 5px 12px rgba(15, 38, 52, 0.26);
}

.swatch.selected::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 3px solid #d6e2e8;
  border-radius: 999px;
  box-shadow: 0 0 0 2px rgba(18, 45, 62, 0.62);
}

#start-button,
#restart-button,
#save-high-score {
  width: 100%;
  padding: 13px 16px;
  background: #2d4a5c;
  color: #dbe4e8;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(24, 58, 80, 0.22);
}

#start-button:hover,
#restart-button:hover,
#save-high-score:hover {
  background: #3b5a6e;
}

.high-score-form {
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid rgba(26, 61, 80, 0.26);
  border-radius: 8px;
  background: rgba(198, 213, 220, 0.7);
}

.high-score-form label {
  display: block;
  margin-bottom: 8px;
  color: #294759;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.high-score-row {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 8px;
}

#high-score-name {
  min-width: 0;
  border: 1px solid rgba(26, 61, 80, 0.34);
  border-radius: 8px;
  padding: 10px 11px;
  background: rgba(230, 238, 242, 0.94);
  color: #172c39;
  font: inherit;
  font-weight: 800;
}

#save-high-score {
  padding: 10px;
}

.pingu-link-button {
  display: block;
  width: 100%;
  margin: 0 0 10px;
  padding: 13px 16px;
  border: 0;
  border-radius: 8px;
  background: #9a6f22;
  color: #fff2c9;
  font-weight: 900;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 8px 18px rgba(92, 61, 13, 0.24);
}

.pingu-link-button:hover {
  background: #b07f28;
  color: #fff8de;
}

.pingu-link-button.hidden {
  display: none;
}

canvas {
  display: block;
}

@media (max-width: 620px) {
  #hud {
    top: 10px;
    left: 10px;
    right: 10px;
  }

  .hud-item {
    min-width: calc(50% - 4px);
    padding: 8px 10px;
  }

  .hud-item strong {
    font-size: 19px;
  }

  #hint {
    font-size: 12px;
  }

  .panel.celebration-panel {
    padding: 12px;
  }

  .victory-times {
    width: 17.5%;
    padding: 1.2%;
  }

  .victory-time {
    font-size: clamp(7px, 2.1vw, 11px);
    line-height: 1.45;
  }

  .victory-heart-link {
    font-size: clamp(9px, 3.1vw, 16px);
  }
}
