:root{
  --bg1:#0b1020;
  --bg2:#121a35;
  --panel:#121a2aee;
  --text:#eaf2ff;
  --muted:#a9b6d6;
  --accent:#7cf2ff;
  --accent2:#ffd66e;
}

*{box-sizing:border-box}

html,body{
  height:100%;
  margin:0;
}

body{
  font-family: ui-rounded, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 20% 20%, #1b2a66 0%, var(--bg1) 55%),
              radial-gradient(900px 500px at 80% 10%, #3a1e6a 0%, transparent 60%),
              linear-gradient(180deg, var(--bg2), var(--bg1));
  color:var(--text);
  overscroll-behavior:none;
}

#wrap{
  max-width:1100px;
  margin:0 auto;
  padding:10px;
}

/* ===== HEADER ===== */

#topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:8px 10px;
  border-radius:16px;
  background:var(--panel);
  border:1px solid #223058;
  box-shadow:0 10px 24px #00000055;
}

.brand{display:flex; align-items:center; gap:10px}

.logo{
  width:40px;
  height:40px;
  border-radius:12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display:grid;
  place-items:center;
  color:#0b1020;
  font-size:20px;
  font-weight:900;
}

.title{font-weight:900; font-size:16px}
.subtitle{color:var(--muted); font-size:11px}

.controls{display:flex; gap:8px; flex-wrap:wrap}

.btn{
  border:1px solid #2a3a66;
  background:#0f1730;
  color:var(--text);
  padding:9px 10px;
  border-radius:12px;
  cursor:pointer;
  font-weight:800;
  user-select:none;
}

.btn.primary{
  background: linear-gradient(135deg, #3fe8ff, #ffd66e);
  color:#071023;
  border-color: transparent;
}

/* ===== MAIN LAYOUT ===== */

#main{
  margin-top:10px;
}

/* ===== CANVAS ===== */

canvas#game{
  width:100%;
  aspect-ratio: 16 / 9;
  max-height:70vh;
  border-radius:18px;
  background: linear-gradient(180deg, #0f1640, #0b1020);
  border:1px solid #223058;
  box-shadow:0 18px 40px #00000066;
  touch-action:none;
  display:block;
}

/* ===== HUD ===== */

#hud{
  margin-top:10px;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
}

.hudBox{
  background:var(--panel);
  border:1px solid #223058;
  border-radius:14px;
  padding:10px;
}

.hudLabel{
  color:var(--muted);
  font-size:11px;
  font-weight:800;
}

.hudValue{
  font-size:18px;
  font-weight:1000;
  margin-top:4px;
}

/* ===== JUMP BUTTON ===== */

.jumpBtn{
  position:absolute;
  right:18px;
  bottom:18px;
  width:90px;
  height:90px;
  border-radius:999px;
  border:1px solid #2a3a66;
  background: linear-gradient(135deg, #3fe8ff, #ffd66e);
  color:#071023;
  font-weight:1000;
  cursor:pointer;
  box-shadow:0 16px 35px #00000088;
}

/* ===== OVERLAY ===== */

.overlay{
  position:absolute;
  inset:0;
  display:grid;
  place-items:center;
  background: rgba(0,0,0,.6);
  border-radius:18px;
}

.hidden{display:none}

.panel{
  width:min(420px, 92vw);
  background:#121a2a;
  border:1px solid #2a3a66;
  border-radius:18px;
  padding:18px;
  text-align:center;
}

/* ===== FOOTER ===== */

#footer{
  margin-top:10px;
  color:var(--muted);
  font-size:12px;
  text-align:center;
}

/* ============================= */
/* ===== MOBILE OPTIMIZED ===== */
/* ============================= */

@media (max-width: 900px){

  /* Make canvas BIG on mobile */
  canvas#game{
    aspect-ratio: auto;
    height: 78dvh;   /* uses dynamic viewport height (fixes iPhone issue) */
    max-height:none;
  }

  /* Hide footer to free space */
  #footer{
    display:none;
  }

  /* Slightly smaller header text */
  .subtitle{
    display:none;
  }

}

/* Extra small phones */
@media (max-width: 420px){

  canvas#game{
    height: 82dvh;
  }

  .jumpBtn{
    width:75px;
    height:75px;
  }
}
