/* ============================================================
   Slingshot Ball Game - stylesheet
   Cartoon style, responsive for desktop & mobile
   ============================================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", "Trebuchet MS", Verdana, sans-serif;
  background: radial-gradient(circle at 50% 30%, #1a2a4a 0%, #0b1226 70%);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* ---- The stage keeps a fixed 5:3 game ratio centered on screen ---- */
#stage {
  position: relative;
  width: min(100vw, calc(100vh * 1.6667));
  height: min(100vh, calc(100vw / 1.6667));
  margin: 0 auto;
  overflow: hidden;
  border-radius: 0;
  box-shadow: 0 10px 60px rgba(0, 0, 0, 0.6);
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: linear-gradient(#8ed0ff 0%, #cfeaff 65%, #eaf8ff 100%);
}

.hidden {
  display: none !important;
}

/* ============================================================
   Screens (menus) - full overlay on top of the canvas
   ============================================================ */
.screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 20, 40, 0.55);
  backdrop-filter: blur(3px);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.panel {
  background: linear-gradient(180deg, #ffffff 0%, #f0f4fa 100%);
  border-radius: 24px;
  padding: 28px 36px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), inset 0 0 0 4px rgba(255, 255, 255, 0.9);
  border: 6px solid #ffc94d;
  max-width: 92%;
  max-height: 94%;
  overflow-y: auto;
}

.panel-wide {
  width: min(720px, 94%);
}

.panel-title {
  font-size: 30px;
  color: #2b4a6f;
  margin-bottom: 18px;
  text-shadow: 0 2px 0 #fff;
}

.win-title { color: #2e7d32; }
.lose-title { color: #c62828; }

.title {
  font-size: 52px;
  line-height: 1.05;
  color: #ff8f00;
  text-shadow: 0 3px 0 #b26a00, 0 6px 12px rgba(0,0,0,0.35);
  letter-spacing: 1px;
}

.subtitle {
  color: #5a7189;
  margin: 10px 0 22px;
  font-size: 16px;
}

/* ---- Buttons ---- */
.btn {
  display: block;
  width: 100%;
  margin: 10px 0;
  padding: 13px 20px;
  font-size: 17px;
  font-weight: 700;
  color: #2b4a6f;
  background: linear-gradient(180deg, #ffffff, #e8eef7);
  border: 3px solid #b9cbe0;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.btn:hover {
  transform: translateY(-2px) scale(1.02);
  background: linear-gradient(180deg, #fff, #dce8f7);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}

.btn:active {
  transform: translateY(1px) scale(0.98);
}

.btn-play {
  background: linear-gradient(180deg, #66bb6a, #2e7d32);
  color: #fff;
  border-color: #1b5e20;
  font-size: 20px;
}

.btn-play:hover {
  background: linear-gradient(180deg, #81c784, #388e3c);
}

/* ---- Icon buttons in the HUD ---- */
.icon-btn {
  width: 42px;
  height: 42px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  background: rgba(20, 40, 70, 0.65);
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}

.icon-btn:hover { background: rgba(20, 40, 70, 0.9); transform: scale(1.08); }

/* ============================================================
   HUD
   ============================================================ */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  pointer-events: none;
}

#hud .hud-left,
#hud .hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

#hud .icon-btn { pointer-events: auto; }

.hud-item {
  background: rgba(20, 40, 70, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 12px;
  padding: 4px 14px;
  text-align: center;
  color: #fff;
}

.hud-item span {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.8;
}

.hud-item b { font-size: 18px; }

#hud-balls {
  display: flex;
  gap: 5px;
  align-items: center;
  background: rgba(20, 40, 70, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 12px;
  padding: 6px 10px;
  height: 42px;
}

#hud-balls .mini-ball {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: inset 0 -4px 6px rgba(0, 0, 0, 0.3), inset 0 3px 4px rgba(255, 255, 255, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.7);
}

#hud-balls .mini-ball.dim { opacity: 0.25; }

#hud-balltype {
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  background: rgba(20, 40, 70, 0.6);
  padding: 8px 12px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.5);
}

/* ============================================================
   Level select grid
   ============================================================ */
#level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 12px;
  margin: 0 0 16px;
}

.level-btn {
  position: relative;
  padding: 14px 6px 30px;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #42a5f5, #1565c0);
  border: 3px solid #0d47a1;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.level-btn:hover:not(.locked) { transform: translateY(-3px) scale(1.05); box-shadow: 0 8px 18px rgba(0,0,0,0.3); }
.level-btn.locked {
  background: linear-gradient(180deg, #90a4ae, #546e7a);
  border-color: #37474f;
  cursor: not-allowed;
  color: #cfd8dc;
}

.level-btn .stars-row {
  position: absolute;
  bottom: 6px;
  left: 0;
  right: 0;
  font-size: 14px;
  letter-spacing: 2px;
}

.level-btn .stars-row .dim { opacity: 0.25; }

/* ============================================================
   Instructions page
   ============================================================ */
.help-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  text-align: left;
  margin-bottom: 14px;
}

@media (max-width: 560px) {
  .help-body { grid-template-columns: 1fr; }
}

.help-body h3 { color: #2b4a6f; margin: 6px 0 6px; font-size: 16px; }
.help-body p { color: #455a64; font-size: 14px; line-height: 1.5; }
.help-body ul { list-style: none; }
.help-body li { color: #455a64; font-size: 14px; padding: 4px 0; line-height: 1.4; }

.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chip {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  display: inline-block;
  border: 2px solid rgba(0, 0, 0, 0.25);
  flex: 0 0 auto;
}

.chip-glass  { background: linear-gradient(135deg, #e0f7fa, #4dd0e1); }
.chip-wood   { background: linear-gradient(135deg, #e0a458, #8d5524); }
.chip-stone  { background: linear-gradient(135deg, #c9ced6, #70788a); }
.chip-metal  { background: linear-gradient(135deg, #9db4c8, #44576a); }
.chip-normal { background: radial-gradient(circle at 35% 30%, #ffe082, #f9a825); }
.chip-heavy  { background: radial-gradient(circle at 35% 30%, #a1887f, #4e342e); }
.chip-speed  { background: radial-gradient(circle at 35% 30%, #80deea, #0097a7); }
.chip-explosive { background: radial-gradient(circle at 35% 30%, #ff8a80, #c62828); }

/* ============================================================
   Results (win / lose)
   ============================================================ */
.stars { font-size: 46px; margin: 6px 0 10px; letter-spacing: 8px; }
.stars .dim { opacity: 0.25; }

.result-row {
  display: flex;
  justify-content: center;
  gap: 26px;
  margin: 12px 0 16px;
}

.result-row div {
  background: #e8eef7;
  border-radius: 12px;
  padding: 8px 22px;
}

.result-row span { display: block; font-size: 11px; text-transform: uppercase; color: #78909c; }
.result-row b { font-size: 22px; color: #2b4a6f; }

/* small screens: scale things down a bit */
@media (max-width: 480px) {
  .title { font-size: 38px; }
  .panel { padding: 18px 16px; border-width: 4px; }
  .hud-item { padding: 3px 9px; }
  .hud-item b { font-size: 15px; }
}
