* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #04121f;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#wrap {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0;
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}

#score {
  font-size: 46px;
  font-weight: 800;
  color: #eaf6ff;
  line-height: 1;
  letter-spacing: 1px;
  text-shadow: 0 0 18px rgba(120, 200, 255, .65);
}

#best {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  color: rgba(180, 220, 255, .55);
}

#lives {
  display: flex;
  gap: 8px;
}

.life {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: linear-gradient(150deg, #bfefff, #4aa8e0);
  box-shadow: 0 0 12px rgba(120, 200, 255, .6), inset 0 0 8px rgba(255, 255, 255, .6);
  transform: rotate(12deg);
  transition: transform .35s, opacity .35s, filter .35s;
}

.life.lost {
  opacity: .18;
  filter: grayscale(1);
  transform: rotate(12deg) scale(.65);
}

/* ---------- Combo ---------- */
#combo {
  position: absolute;
  left: 50%;
  top: 26%;
  transform: translate(-50%, -50%) scale(.6);
  font-size: 52px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #dff3ff;
  text-shadow: 0 0 26px rgba(90, 190, 255, .9);
  opacity: 0;
  pointer-events: none;
}

#combo.pop {
  animation: comboPop .85s ease-out forwards;
}

@keyframes comboPop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(.5) rotate(-6deg); }
  25%  { opacity: 1; transform: translate(-50%, -50%) scale(1.15) rotate(2deg); }
  70%  { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); }
  100% { opacity: 0; transform: translate(-50%, -75%) scale(.95); }
}

/* ---------- Overlay ---------- */
#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 14, 26, .72);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s;
}

#overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.panel {
  text-align: center;
  padding: 40px 46px;
  border-radius: 20px;
  background: rgba(10, 32, 54, .78);
  border: 1px solid rgba(130, 210, 255, .25);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .12);
  max-width: 90vw;
}

.panel h1 {
  font-size: 56px;
  font-weight: 800;
  letter-spacing: 4px;
  color: #eaf8ff;
  text-shadow: 0 0 34px rgba(90, 190, 255, .8);
}

.panel h1 span {
  color: #6ec8ff;
  display: block;
  font-size: 34px;
  letter-spacing: 12px;
  margin-top: -2px;
}

.sub {
  margin-top: 14px;
  font-size: 16px;
  color: rgba(200, 230, 255, .72);
}

.legend {
  margin: 24px auto 6px;
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 10px 26px;
  justify-content: center;
  font-size: 13.5px;
  color: rgba(200, 230, 255, .8);
}

.legend div {
  display: flex;
  align-items: center;
  gap: 9px;
}

.chip {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  transform: rotate(12deg);
  flex: none;
}

.chip.ice    { background: linear-gradient(150deg, #dff4ff, #7ec8ee); }
.chip.deep   { background: linear-gradient(150deg, #9fd4ff, #2a72c8); }
.chip.frozen { background: linear-gradient(150deg, #ffffff, #b7f0ff); box-shadow: 0 0 10px #9fe8ff; }
.chip.bomb   { background: radial-gradient(circle at 35% 30%, #6b6b73, #17171c); }

button#start,
button.again {
  margin-top: 26px;
  padding: 15px 44px;
  font: 700 17px/1 inherit;
  letter-spacing: 2px;
  color: #06263c;
  background: linear-gradient(160deg, #d6f2ff, #63bdf0);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(60, 160, 230, .45);
  transition: transform .12s, box-shadow .2s;
}

button#start:hover,
button.again:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(60, 160, 230, .6);
}

button#start:active,
button.again:active { transform: translateY(1px); }

.hint {
  margin-top: 16px;
  font-size: 12px;
  letter-spacing: 1.5px;
  color: rgba(170, 210, 240, .45);
}

.final {
  margin-top: 18px;
  font-size: 15px;
  color: rgba(200, 230, 255, .8);
}

.final b {
  display: block;
  font-size: 60px;
  font-weight: 800;
  color: #eaf8ff;
  text-shadow: 0 0 30px rgba(90, 190, 255, .75);
  line-height: 1.1;
}

.newbest {
  margin-top: 8px;
  font-size: 14px;
  letter-spacing: 3px;
  font-weight: 700;
  color: #7fe0ff;
}

@media (max-width: 560px) {
  .panel { padding: 30px 24px; }
  .panel h1 { font-size: 40px; }
  .panel h1 span { font-size: 24px; letter-spacing: 8px; }
  .legend { grid-template-columns: auto; }
  #score { font-size: 34px; }
}
