.stage {
  background: #9fdcff;
  width: 100vw;   /* exact px size is set from game.js */
  height: 100vh;
  max-width: none;
  max-height: none;
  box-shadow: none;
}

/* HUD + menus live in a logical-size layer scaled to the screen (set from game.js). */
.ui {
  --k: 1;
  position: absolute;
  top: 0;
  left: 0;
  width: 1180px;
  height: 820px;
  transform-origin: 0 0;
  pointer-events: none;
  z-index: 3;
}
.ui > .overlay { pointer-events: auto; }

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.hud {
  position: absolute;
  top: calc(16px + var(--safe-top) / var(--k));
  left: calc(20px + var(--safe-left) / var(--k));
  right: calc(20px + var(--safe-right) / var(--k));
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 3;
  pointer-events: none;
}

.hud > *, .hud-right > * { pointer-events: auto; }

.hud-right { margin-left: auto; display: flex; gap: 12px; }

.hud-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 6px 16px rgba(30, 60, 90, 0.18);
  font: 900 30px/1 "Nunito", system-ui, sans-serif;
  color: #3b5a75;
  cursor: pointer;
  transition: transform 0.1s ease;
}
.hud-btn { display: grid; place-items: center; padding: 0; }
.win-actions .round { display: grid; place-items: center; color: #3b5a75; }
.win-actions .round svg { width: 40px; height: 40px; }
.hud-btn:active { transform: scale(0.92); }
.hud-btn:disabled { opacity: 0.4; }

.level-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 22px 6px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  border: 4px solid #fff;
  box-shadow: 0 6px 16px rgba(30, 60, 90, 0.18);
  font-weight: 900;
  font-size: 22px;
  color: #3b5a75;
}
.level-pill b {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ffd43b, #ff922b);
  color: #5a3300;
  font-size: 26px;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: rgba(110, 180, 225, 0.5);
}

.card {
  position: relative;
  background: rgba(255, 255, 255, 0.95);
  border: 6px solid #fff;
  border-radius: 40px;
  box-shadow: 0 24px 60px rgba(30, 60, 90, 0.25);
  text-align: center;
  padding: 36px 48px 40px;
}

.title-card { width: 760px; }
.title-card h1 {
  font-size: 84px;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: #e08a1e;
  text-shadow: 0 4px 0 #ffe3a3;
  line-height: 1;
}
.title-card .sub { margin-top: 10px; font-size: 26px; font-weight: 800; color: #6b7f90; }

.back-link {
  position: absolute;
  top: 22px;
  left: 22px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #f1f6fa;
  color: #3b5a75;
  font-size: 30px;
  font-weight: 900;
  text-decoration: none;
}

.big-play {
  margin-top: 26px;
  font-size: 36px;
  padding: 18px 56px;
  border-radius: 999px;
}

.level-grid {
  margin-top: 28px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  max-width: 620px;
  margin-left: auto;
  margin-right: auto;
}

.level-btn {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 20px;
  border: 4px solid #e3eef6;
  background: #f6fafd;
  font: 900 26px/1 "Nunito", system-ui, sans-serif;
  color: #6b7f90;
  cursor: pointer;
}
.level-btn:active { transform: scale(0.94); }
.level-btn.done { background: #fff4d1; border-color: #ffd66b; color: #b46a00; }
.level-btn i {
  position: absolute;
  top: -10px;
  right: -8px;
  font-style: normal;
  font-size: 26px;
  color: #ffb703;
  text-shadow: 0 2px 0 #fff;
}

.win-card { width: 560px; animation: pop-in 0.35s cubic-bezier(.2, 1.6, .4, 1); }
.win-stars { font-size: 56px; color: #ffc53d; letter-spacing: 0.1em; text-shadow: 0 4px 0 #ffe8a3; }
.win-card h2 { font-size: 76px; font-weight: 900; color: #2f9e44; line-height: 1.1; }
#all-done { font-size: 24px; font-weight: 800; color: #6b7f90; }
.win-actions { margin-top: 26px; display: flex; justify-content: center; gap: 16px; }
.win-actions .round { width: 84px; height: 84px; border-radius: 50%; font-size: 36px; padding: 0; }
.win-actions .next { white-space: nowrap; font-size: 34px; border-radius: 999px; padding: 0 40px; height: 84px; }

@keyframes pop-in {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* This game also works in portrait, so never show the "rotate" screen. */
.rotate-hint { display: none !important; }
