* {
  box-sizing: border-box;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: linear-gradient(145deg, #fde3b0 0%, #e7c48b 100%);
  font-family: 'Segoe UI', system-ui, -apple-system, 'Roboto', sans-serif;
  display: flex;
  flex-direction: column; /* 🌟 Vertical layout fix: stacks elements instead of squeezing sideways */
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  padding: 16px;
  overflow-x: hidden;
}

.game-container {
  max-width: 550px;
  width: 100%;
  margin: 0 auto;
  background: rgba(255, 245, 220, 0.95);
  border-radius: 64px 64px 48px 48px;
  padding: 20px 16px 30px;
  box-shadow: 0 20px 35px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,200,0.8);
  border: 1px solid #ffdd99;
}

.stats {
  text-align: center;
  margin-bottom: 20px;
}

.sugar-count {
  background: #f7b05e;
  border-radius: 60px;
  padding: 12px 20px;
  display: inline-block;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.1), 0 5px 10px rgba(0,0,0,0.15);
}

.sugar-amount {
  font-size: 2.7rem;
  font-weight: bold;
  color: #fff3e0;
  text-shadow: 0 2px 5px #b45f2b;
  letter-spacing: 2px;
}

.sugar-label {
  font-size: 1rem;
  color: #fff0d0;
  margin-left: 6px;
}

.candy-tier {
  background: #e09d5e;
  border-radius: 40px;
  padding: 6px 16px;
  display: inline-block;
  margin-top: 10px;
  font-size: 0.9rem;
  font-weight: bold;
  color: #2c1a12;
}

.candy-area {
  display: flex;
  justify-content: center;
  margin: 20px 0;
  cursor: pointer;
  position: relative;
  min-height: 230px;
}

svg.candy-svg {
  width: 220px;
  height: 220px;
  filter: drop-shadow(0 16px 20px rgba(0,0,0,0.35));
  transform-origin: center center; 
  transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  cursor: pointer;
  will-change: transform;
}

.candy-bounce {
  transform: scale(0.85) !important;
  transition: transform 0.04s ease-out !important;
}

.float-word {
  position: fixed;
  pointer-events: none;
  font-size: 1.8rem;
  font-weight: 900;
  font-family: 'Segoe UI', cursive, sans-serif;
  color: #ff3b6f;
  text-shadow: 0 0 8px white, 0 3px 0px #ffb3c6;
  white-space: nowrap;
  z-index: 99999;
  animation: floatUpWord 0.8s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes floatUpWord {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5) rotate(-15deg); }
  15% { opacity: 1; transform: translate(-50%, -80%) scale(1.2) rotate(5deg); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1) rotate(0deg); }
}

.helpers-panel {
  background: #f7e5cf;
  border-radius: 36px;
  padding: 16px 12px;
  margin: 15px 0 10px;
  box-shadow: inset 0 0 0 1px #fff8e7, 0 5px 12px rgba(0,0,0,0.1);
}

.helpers-title {
  font-size: 1.2rem;
  font-weight: bold;
  color: #a5562c;
  padding-left: 8px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.helper-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.helper-card {
  background: #fff0e0;
  border-radius: 28px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border: 1px solid #f0bc8c;
  transition: all 0.1s;
}

.helper-name {
  font-size: 1rem;
  font-weight: bold;
  color: #6b3e1c;
}

.helper-stats {
  font-size: 0.7rem;
  color: #a05e2c;
  margin: 5px 0;
}

.helper-cost {
  background: #f0a05a;
  color: white;
  padding: 4px 10px;
  border-radius: 40px;
  font-size: 0.7rem;
  font-weight: bold;
  margin: 5px 0;
}

.helper-buy {
  background: #f0a05a;
  border: none;
  color: white;
  font-weight: bold;
  border-radius: 40px;
  padding: 6px 16px;
  cursor: pointer;
  font-size: 0.75rem;
  width: 100%;
  transition: 0.05s linear;
}

.helper-buy:active { transform: scale(0.96); background: #d47c38; }
.helper-buy.disabled { opacity: 0.5; pointer-events: none; }

.prestige-area, .glove-area, .gag-area {
  margin-top: 15px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

button {
  background: #f0a05a;
  border: none;
  padding: 10px 18px;
  border-radius: 60px;
  font-weight: bold;
  color: #2c1a12;
  cursor: pointer;
  font-size: 0.85rem;
  flex: 1;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

button:active { transform: scale(0.97); background: #e08a3a; }

.leaderboard {
  background: #fff0e0dd;
  border-radius: 32px;
  padding: 12px;
  margin-top: 18px;
  border: 1px solid #ffcf9a;
}

.leaderboard h4 { margin: 0 0 5px 0; color: #b45f2b; }
.lb-list { font-size: 0.75rem; color: #59371d; }

.multiplier-badge {
  background: #ffcc77;
  color: #6b3e1c;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: bold;
  display: inline-block;
  margin-top: 8px;
}

footer {
  font-size: 0.6rem;
  text-align: center;
  margin-top: 16px;
  color: #ad7a4a;
}

.modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: #fff5e6;
  margin: auto;
  padding: 24px;
  border-radius: 48px;
  max-width: 300px;
  text-align: center;
  position: relative;
  box-shadow: 0 10px 25px black;
  color: #4a2a16;
  border: 2px solid #ffbc6e;
}

.close-modal {
  position: absolute;
  top: 12px;
  right: 18px;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  color: #b97f4b;
}

.close-modal:hover { color: #8b4e24; }

#gamblingOkBtn {
  background: #f0a05a;
  margin-top: 12px;
  padding: 8px 20px;
  display: inline-block;
  width: auto;
}

.hud-top {
  display: flex;
  justify-content: flex-end;
  margin-bottom: -10px;
}

.icon-btn {
  background: none;
  box-shadow: none;
  font-size: 1.5rem;
  padding: 4px;
  width: auto;
  flex: none;
}

.icon-btn:active { transform: scale(0.9); background: none; }

.locked-btn {
  background: #a89485 !important;
  color: #52463e !important;
  cursor: not-allowed;
  opacity: 0.8;
}

.lb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.lb-header h4 { margin: 0; }

.mini-btn {
  padding: 4px 10px;
  font-size: 0.65rem;
  width: auto;
  flex: none;
  background: #e09d5e;
}

#usernameInput {
  width: 100%;
  padding: 10px 16px;
  border-radius: 20px;
  border: 2px solid #f0a05a;
  background: #fff;
  font-family: inherit;
  font-size: 1rem;
  text-align: center;
  outline: none;
  color: #4a2a16;
}

/* Watermark Layout Styles */
.rumpel-watermark {
  text-align: center;
  font-size: 0.9rem;
  font-weight: bold;
  color: #6b3e1c;
  margin-top: 20px;      /* Gap below game container */
  margin-bottom: 10px;   /* Clean padding on scroll viewport bottoms */
  opacity: 0.75;
  letter-spacing: 1px;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);
  font-family: 'Segoe UI', system-ui, sans-serif;
  width: auto;
}

/* ==========================================================================
   🚨 MOBILE RESPONSIVENESS AND OVERFLOW CORRECTION 🚨
   ========================================================================== */

html, body {
  max-width: 100vw !important;
  overflow-x: hidden !important;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

*, *:before, *:after {
  box-sizing: inherit;
}

.game-container {
  width: 100% !important;
  max-width: 480px !important; /* Perfect sweet spot viewport width */
  margin: 0 auto !important;   
  padding: 15px !important;
  box-sizing: border-box;
  float: none !important;      
}

.helper-grid {
  display: grid;
  grid-template-columns: 1fr !important; /* Forces tidy vertical rows on narrow viewports */
  gap: 12px;
  width: 100% !important;
}

.helper-card {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box;
  margin: 0 auto;
}

button, input, .lb-list, .stats, footer {
  max-width: 100% !important;
  white-space: normal !important; 
  word-wrap: break-word !important;
}