:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --ink: #f8fbff;
  --muted: rgba(235, 246, 255, .7);
  --green: #66e368;
  --green-dark: #218c45;
  --gold: #ffd45d;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  position: fixed;
  overscroll-behavior: none;
  background: #07172e;
  color: var(--ink);
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

button { font: inherit; }

#gameShell {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #07172e;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }

#hud {
  position: absolute;
  z-index: 5;
  left: calc(10px + var(--safe-left));
  right: calc(10px + var(--safe-right));
  top: calc(10px + var(--safe-top));
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 7px;
  pointer-events: none;
}

.hudBlock {
  min-width: 0;
  padding: 7px 8px;
  text-align: center;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 12px;
  background: rgba(5,16,32,.66);
  box-shadow: 0 5px 16px rgba(0,0,0,.18);
  backdrop-filter: blur(7px);
}

.hudBlock small, .finalScore small, .resultGrid small {
  display: block;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .13em;
  color: rgba(255,255,255,.62);
}

.hudBlock strong { display: block; margin-top: 1px; font-size: 16px; }
.hudScore strong { color: var(--gold); }

#comboPill {
  position: absolute;
  top: 55px;
  left: 50%;
  translate: -50% 0;
  min-width: 48px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--gold);
  color: #26320d;
  text-align: center;
  font-size: 13px;
  font-weight: 1000;
  box-shadow: 0 4px 13px rgba(0,0,0,.2);
  transition: transform .12s ease;
}

#comboPill.bump { transform: scale(1.2); }

#hearts {
  position: absolute;
  top: 55px;
  right: 4px;
  display: flex;
  gap: 3px;
}

#hearts i {
  font-style: normal;
  font-size: 17px;
  line-height: 1;
  color: #ff6d7e;
  text-shadow: 0 0 8px rgba(255,109,126,.55);
}

#hearts i::before { content: "♥"; }

#hearts i.used { opacity: .2; filter: grayscale(1); text-shadow: none; }

.iconBtn {
  position: absolute;
  z-index: 7;
  right: calc(12px + var(--safe-right));
  bottom: calc(12px + var(--safe-bottom));
  width: 42px;
  height: 42px;
  padding: 0 0 3px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 50%;
  background: rgba(5,16,32,.58);
  color: #fff;
  font-size: 26px;
  cursor: pointer;
}

#toast {
  position: absolute;
  z-index: 8;
  top: calc(105px + var(--safe-top));
  left: 50%;
  translate: -50% 0;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(5,16,32,.82);
  box-shadow: 0 7px 20px rgba(0,0,0,.25);
  font-size: 14px;
  font-weight: 950;
  white-space: nowrap;
  pointer-events: none;
  animation: toastIn .18s ease-out;
}

@keyframes toastIn { from { opacity: 0; transform: translateY(8px) scale(.92); } }

.overlay {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(18px + var(--safe-top)) calc(18px + var(--safe-right)) calc(18px + var(--safe-bottom)) calc(18px + var(--safe-left));
  background: radial-gradient(circle at 50% 10%, rgba(92,190,255,.28), transparent 45%), rgba(3,12,24,.55);
  backdrop-filter: blur(8px);
}

.panel {
  width: min(420px, 100%);
  max-height: 94vh;
  overflow: auto;
  padding: 24px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 26px;
  background: linear-gradient(160deg, rgba(19,49,71,.94), rgba(7,24,42,.96));
  box-shadow: 0 24px 70px rgba(0,0,0,.42), inset 0 1px rgba(255,255,255,.08);
  text-align: center;
}

.menuPanel h1 {
  margin: -8px 0 8px;
  font-size: clamp(45px, 13vw, 68px);
  line-height: .78;
  letter-spacing: -.06em;
  text-shadow: 0 5px 0 rgba(0,0,0,.16);
}

.menuPanel h1 span { color: var(--green); }
.logoPea { color: var(--green); font-size: 58px; text-shadow: -14px 9px 0 #2eb14f, 14px 9px 0 #2eb14f; }
.tagline { margin: 18px 0; color: var(--muted); font-size: 14px; }

.bestCard {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 12px;
  margin: 15px 0;
  padding: 12px 15px;
  border-radius: 15px;
  background: rgba(0,0,0,.2);
  text-align: left;
}

.bestCard span { grid-row: 1 / 3; color: var(--muted); font-size: 11px; font-weight: 900; letter-spacing: .12em; }
.bestCard strong { color: var(--gold); font-size: 23px; line-height: 1; text-align: right; }
.bestCard small { color: var(--muted); text-align: right; }

.primaryBtn, .secondaryBtn {
  width: 100%;
  min-height: 50px;
  margin-top: 9px;
  border-radius: 15px;
  font-weight: 1000;
  letter-spacing: .05em;
  cursor: pointer;
}

.primaryBtn {
  border: 0;
  background: linear-gradient(#78ee79, #42bd59);
  color: #092517;
  box-shadow: 0 6px 0 #1f783a, 0 10px 22px rgba(0,0,0,.26);
}

.primaryBtn:active { translate: 0 4px; box-shadow: 0 2px 0 #1f783a; }
.secondaryBtn { border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.07); color: #fff; }
.campaignLabel { margin: 16px 0 0; color: rgba(255,255,255,.42); font-size: 10px; }

.mobileHelp { display: none; grid-template-columns: auto 1fr; gap: 10px; align-items: center; margin: 10px 0 2px; padding: 9px 11px; border-radius: 12px; background: rgba(102,227,104,.09); text-align: left; }
.mobileHelp b { color: var(--green); font-size: 9px; letter-spacing: .12em; }
.mobileHelp span { color: var(--muted); font-size: 11px; line-height: 1.35; }
.controlToggle { display: none; width: 100%; min-height: 42px; margin: 7px 0 0; padding: 0 13px; align-items: center; justify-content: space-between; border: 1px solid rgba(255,255,255,.16); border-radius: 12px; background: rgba(255,255,255,.06); color: #fff; font-weight: 900; font-size: 11px; letter-spacing: .05em; }
.controlToggle b { min-width: 42px; padding: 4px 7px; border-radius: 999px; background: rgba(255,255,255,.12); color: var(--muted); }
.controlToggle[aria-pressed="true"] b { background: var(--green); color: #092517; }

#touchControls { position: absolute; z-index: 6; inset: 0; display: none; pointer-events: none; }
#touchControls.visible { display: block; }
.movePad { position: absolute; left: calc(22px + var(--safe-left)); bottom: calc(28px + var(--safe-bottom)); width: 104px; height: 104px; border: 3px solid rgba(255,255,255,.55); border-radius: 50%; background: radial-gradient(circle,rgba(255,255,255,.08) 0 31%,rgba(5,16,32,.52) 32%); box-shadow: 0 5px 22px rgba(0,0,0,.28),inset 0 0 0 8px rgba(255,255,255,.035); pointer-events: auto; touch-action: none; }
.movePad::before,.movePad::after { content:""; position:absolute; top:50%; width:0; height:0; translate:0 -50%; border-top:7px solid transparent; border-bottom:7px solid transparent; opacity:.65; }
.movePad::before { left:10px; border-right:9px solid #fff; }.movePad::after { right:10px; border-left:9px solid #fff; }
.movePad i { position:absolute; left:50%; top:50%; width:42px; height:42px; translate:-50% -50%; border:2px solid rgba(255,255,255,.7); border-radius:50%; background:linear-gradient(#72e976,#36a951); box-shadow:0 4px 10px rgba(0,0,0,.35); }
#jumpButton { position:absolute; right:calc(25px + var(--safe-right)); bottom:calc(72px + var(--safe-bottom)); width:88px; height:88px; padding:0; border:3px solid rgba(255,255,255,.62); border-radius:50%; background:linear-gradient(#ffe070,#e7a934); color:#30220a; box-shadow:0 7px 0 #96681d,0 10px 24px rgba(0,0,0,.32); font-size:14px; font-weight:1000; pointer-events:auto; touch-action:none; }
#jumpButton span { display:block; font-size:25px; line-height:.8; }#jumpButton.pressed { translate:0 5px; box-shadow:0 2px 0 #96681d; }

@media (hover:none) and (pointer:coarse) { .mobileHelp { display:grid; }.controlToggle { display:flex; } }

.compactPanel h2 { margin: 4px 0 14px; font-size: 25px; }
.compactPanel p { color: var(--muted); line-height: 1.45; }
.controlDemo { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin: 20px 0; }
.controlDemo span { padding: 12px 5px; border-radius: 12px; background: rgba(255,255,255,.08); font-size: 11px; font-weight: 900; line-height: 1.5; }
.controlDemo b { font-size: 35px; }

.resultIcon { font-size: 53px; }
.finalScore { margin: 15px 0; }
.finalScore strong { display: block; color: var(--gold); font-size: 52px; line-height: 1; }
.resultGrid { display: grid; grid-template-columns: repeat(2,1fr); gap: 7px; }
.resultGrid > div { padding: 10px 4px; border-radius: 12px; background: rgba(0,0,0,.2); }
.resultGrid .wideMetric { grid-column: 1 / -1; }
.resultGrid strong { display: block; margin-top: 4px; font-size: 19px; }
.keyboardHint { margin: 9px 0 5px; color: rgba(255,255,255,.62); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
@media (hover: none) and (pointer: coarse) { .keyboardHint { display: none; } }
.newBest { color: var(--gold) !important; font-weight: 1000; letter-spacing: .12em; animation: pulse .7s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.06); } }

.leaderboardPanel { position: relative; }
.closePanel { position: absolute; top: 10px; right: 10px; width: 35px; height: 35px; border: 0; border-radius: 50%; background: rgba(255,255,255,.08); color: white; font-size: 22px; }
#leaderboardRows { margin-top: 12px; }
.leaderRow { display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; padding: 10px 2px; border-top: 1px solid rgba(255,255,255,.1); text-align: left; }
.leaderRow b:last-child { color: var(--gold); }

@media (max-height: 620px) {
  .panel { padding: 16px 20px; }
  .menuPanel h1 { font-size: 46px; }
  .logoPea { font-size: 40px; }
  .tagline { margin: 10px 0; }
  .bestCard { margin: 9px 0; }
  .mobileHelp { margin-top:6px; padding:7px 9px; }.controlToggle{min-height:36px;margin-top:4px}
  .primaryBtn, .secondaryBtn { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
