* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #05060f;
  font-family: 'Trebuchet MS', 'Segoe UI', sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
#game { display: block; position: fixed; inset: 0; }

#topbar {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: env(safe-area-inset-top, 8px) 14px 0;
  padding-top: max(env(safe-area-inset-top), 10px);
  pointer-events: none; z-index: 5;
}
#title {
  flex: 1; text-align: center;
  font-weight: 800; letter-spacing: 3px;
  font-size: clamp(13px, 4.2vw, 22px);
  color: #bcd2ff;
  text-shadow: 0 0 12px rgba(90,140,255,0.8), 0 0 4px rgba(160,75,255,0.9);
}
.hudbtn {
  pointer-events: auto;
  width: 42px; height: 42px; border-radius: 12px;
  background: rgba(30,40,80,0.5);
  border: 1px solid rgba(120,160,255,0.35);
  color: #cfe0ff; font-size: 20px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
  box-shadow: 0 0 14px rgba(80,120,255,0.25);
}
.hudbtn:active { transform: scale(0.92); }
.hudbtn.off { opacity: 0.45; }
.hudbtn.corner {
  position: fixed; z-index: 5;
  right: 14px; bottom: max(env(safe-area-inset-bottom), 14px);
  width: 48px; height: 48px; font-size: 24px;
}
.bargroup { display: flex; gap: 8px; pointer-events: none; }

#gameOver {
  position: fixed; inset: 0; z-index: 10;
  display: none; align-items: center; justify-content: center;
  background: rgba(4,6,18,0.78); backdrop-filter: blur(6px);
}
#gameOver.show { display: flex; animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.panel {
  text-align: center; padding: 34px 30px;
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(40,30,80,0.85), rgba(15,18,45,0.9));
  border: 1px solid rgba(160,120,255,0.4);
  box-shadow: 0 0 50px rgba(120,80,255,0.4);
  max-width: 86vw;
}
.panel h1 {
  color: #ff7df4; font-size: clamp(22px, 7vw, 34px);
  letter-spacing: 2px; text-shadow: 0 0 18px rgba(255,47,230,0.7);
}
.panel .sub { color: #9fb2e0; margin: 8px 0 20px; font-size: 15px; }
.scores { display: flex; gap: 26px; justify-content: center; margin-bottom: 24px; }
.scores .lbl { display: block; font-size: 12px; color: #8fa6d8; letter-spacing: 2px; }
.scores .val { display: block; font-size: clamp(28px, 9vw, 44px); font-weight: 800; color: #fff;
  text-shadow: 0 0 14px rgba(90,140,255,0.8); }
.play {
  border: none; cursor: pointer;
  padding: 14px 34px; border-radius: 14px;
  font-size: 18px; font-weight: 800; letter-spacing: 1px;
  color: #06121a;
  background: linear-gradient(135deg, #9bff3d, #21e6ff);
  box-shadow: 0 0 26px rgba(33,230,255,0.6);
}
.play:active { transform: scale(0.95); }

/* secondary / outline button */
.play.ghost {
  margin-top: 12px;
  background: transparent;
  color: #bcd2ff;
  border: 1px solid rgba(140,180,255,0.5);
  box-shadow: 0 0 16px rgba(80,120,255,0.2);
}

/* ---- Start screen + How to play overlays ---- */
#startScreen, #howto {
  position: fixed; inset: 0; z-index: 12;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4,6,18,0.82); backdrop-filter: blur(7px);
}
#howto { display: none; z-index: 14; }
#startScreen.hidden { display: none; }
#howto.show { display: flex; animation: fade .3s ease; }

.panel.start { padding: 40px 34px; }
.logo {
  font-weight: 800; letter-spacing: 4px; line-height: 0.95;
  font-size: clamp(40px, 15vw, 76px);
  background: linear-gradient(135deg, #9bff3d, #21e6ff 55%, #ff7df4);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 22px rgba(120,80,255,0.55));
}
.tagline { color: #9fb2e0; margin: 14px 0 22px; font-size: clamp(12px, 3.6vw, 15px); letter-spacing: 1px; }
.panel .best { margin-bottom: 26px; }
.panel .best .lbl { display: block; font-size: 12px; color: #8fa6d8; letter-spacing: 2px; }
.panel .best .val { display: block; font-size: clamp(26px, 8vw, 40px); font-weight: 800; color: #fff;
  text-shadow: 0 0 14px rgba(90,140,255,0.8); }

.steps {
  list-style: none; text-align: left; margin: 18px 0 24px;
  max-width: 320px;
}
.steps li {
  color: #d4e1ff; font-size: clamp(13px, 3.8vw, 15px);
  padding: 7px 0 7px 26px; position: relative; line-height: 1.35;
}
.steps li::before {
  content: "◆"; position: absolute; left: 0; top: 7px;
  color: #21e6ff; font-size: 12px; text-shadow: 0 0 8px rgba(33,230,255,0.8);
}

/* ---- Toast (share fallback feedback) ---- */
#toast {
  position: fixed; left: 50%; bottom: 14%; z-index: 30;
  transform: translateX(-50%) translateY(16px);
  background: rgba(20,28,60,0.95); color: #d4e1ff;
  padding: 12px 22px; border-radius: 12px;
  border: 1px solid rgba(120,160,255,0.4);
  font-size: 15px; max-width: 80vw; text-align: center;
  box-shadow: 0 0 24px rgba(80,120,255,0.3);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
