html, body {
  margin: 0;
  padding: 0;
  background: #000;
  color: #fff;
  font-family: Arial, Helvetica, sans-serif;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

.page-shell {
  width: 100vw;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 10px calc(18px + env(safe-area-inset-bottom));
  gap: 6px;
}

.top-bar {
  width: min(100%, 390px);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 7px;
  position: relative;
  z-index: 60;
  pointer-events: auto;
  flex-shrink: 0;
}

.action-row {
  width: min(100%, 390px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 7px;
  position: relative;
  z-index: 60;
  pointer-events: auto;
  flex-shrink: 0;
}

#scoreText,
#livesText {
  text-align: center;
  padding: 7px 5px;
  border: 2px solid #ffeb00;
  border-radius: 12px;
  color: #ffeb00;
  text-shadow: 0 0 8px rgba(255, 235, 0, 0.65);
  background: rgba(17, 17, 17, 0.95);
  font-weight: 700;
  font-size: 14px;
}

.pong-header {
  display: flex;
  justify-content: center;
  align-items: center;
}

.pong-header img {
  height: 30px;
  max-width: 118px;
  object-fit: contain;
  filter: drop-shadow(0 0 6px #ff2bd6)
          drop-shadow(0 0 10px #ff2bd6);
}

#game-shell {
  position: relative;
  width: min(100%, 390px);
  aspect-ratio: 10 / 14.6;
  border: 4px solid #ffeb00;
  border-radius: 18px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 18px rgba(255, 235, 0, 0.28);
  touch-action: none;
  flex-shrink: 1;
  min-height: 0;
}

#game-container,
#game-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  touch-action: none;
}

#control-pad {
  width: min(100%, 390px);
  height: 58px;
  border: 3px solid #ffeb00;
  border-radius: 16px;
  background: linear-gradient(90deg, #111, #222, #111);
  box-shadow: 0 0 14px rgba(255, 235, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
  position: relative;
  z-index: 80;
  flex-shrink: 0;
}

.control-label {
  color: #ffeb00;
  font-weight: 900;
  letter-spacing: 3px;
  font-size: 13px;
  opacity: 0.8;
}

button {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  border-radius: 12px;
  padding: 9px 7px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  min-height: 42px;
  position: relative;
  z-index: 100;
  pointer-events: auto;
  touch-action: manipulation;
  user-select: none;
}

#startBtn,
#restartBtn {
  background: #ffeb00;
  color: #000;
}

#leaderBtn,
#leaderBtnInline,
#closeLeaderboardBtn {
  background: #00eaff;
  color: #00151a;
}

#shareBtn {
  background: #ff007f;
  color: #fff;
}

.action-row button {
  flex: 1;
}

#shareBtn[disabled] {
  opacity: 0.55;
}

.overlay,
.modal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.72);
  z-index: 40;
  pointer-events: auto;
}

.modal {
  position: fixed;
  z-index: 120;
}

.overlay-card,
.modal-card {
  width: 100%;
  max-width: 340px;
  border: 2px solid #ffeb00;
  border-radius: 18px;
  background: rgba(10, 10, 10, 0.96);
  padding: 18px 16px;
  text-align: center;
  box-shadow: 0 0 18px rgba(255, 235, 0, 0.18);
  pointer-events: auto;
}

.overlay-card h1,
.modal-card h2 {
  margin: 0 0 12px;
  color: #ffeb00;
}

.overlay-card p,
.modal-card p {
  margin: 0 0 10px;
  line-height: 1.45;
}

.button-stack {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  position: relative;
  z-index: 100;
  pointer-events: auto;
}

.hidden {
  display: none !important;
}

#leaderboardList {
  margin: 10px 0 0;
  padding-left: 22px;
  text-align: left;
}

#leaderboardList li {
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

@media (max-height: 700px) {
  .page-shell {
    padding: 5px 8px calc(12px + env(safe-area-inset-bottom));
    gap: 5px;
  }

  #game-shell {
    width: min(100%, 365px);
    aspect-ratio: 10 / 13.8;
  }

  #control-pad {
    width: min(100%, 365px);
    height: 50px;
  }

  button {
    min-height: 38px;
    font-size: 12px;
    padding: 8px 6px;
  }

  #scoreText,
  #livesText {
    padding: 6px 5px;
    font-size: 13px;
  }

  .pong-header img {
    height: 26px;
    max-width: 100px;
  }
}