@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@700&family=Nunito:wght@400;600;700;800&display=swap');

:root {
  --sky-top: #0a1628;
  --sky-mid: #1a3a6e;
  --sky-low: #e8975a;
  --ground: #4a3728;
  --tile-bg: #f5e9c8;
  --tile-border: #b8923a;
  --tile-active: #fff3d0;
  --accent-gold: #f0c040;
  --accent-green: #4ecb71;
  --accent-red: #e05050;
  --accent-grey: #aaa;
  --ui-bg: rgba(10, 22, 50, 0.85);
  --ui-border: rgba(240,192,64,0.4);
  --font-title: 'Cinzel Decorative', serif;
  --font-body: 'Nunito', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #0a1628;
  font-family: var(--font-body);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#gameCanvas {
  display: block;
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 15px 12px;
  background: linear-gradient(to bottom, var(--ui-bg), transparent);
  z-index: 10;
  pointer-events: none;
}

#biomeLabel {
  font-family: var(--font-title);
  font-size: 16px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent-gold);
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
  margin-bottom: 4px;
}

#levelTracker {
  font-family: 'monospace';
  font-size: 14px;
  color: rgba(255,255,255,0.3);
  letter-spacing: 8px;
  display: flex;
  gap: 4px;
}

.lvl-active {
  color: #fff;
  font-weight: 800;
  text-shadow: 0 0 12px var(--accent-gold);
  transform: scale(1.3);
  display: inline-block;
}

#bottomPanel {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--ui-bg);
  border-top: 1px solid var(--ui-border);
  padding: 12px 10px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#wordArea {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; min-height: 48px;
}
#wordLabel { font-size: 10px; color: var(--accent-gold); letter-spacing: 1px; text-transform: uppercase; opacity: 0.7; }
#activeWord { display: flex; gap: 4px; }

.tile {
  width: 42px; height: 48px;
  background: var(--tile-bg);
  border: 2px solid var(--tile-border);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800;
  color: #3a2500;
  cursor: pointer;
  box-shadow: 0 4px 0 #8a6020;
  position: relative;
  transition: transform 0.1s;
}
.tile:active { transform: translateY(2px); box-shadow: 0 1px 0 #8a6020; }
.tile.vowel { background: #34b855ad; border-color: #e0a830; }
.tile.consonant { background: #ff4c4ca1; border-color: #6080c0; }
.tile.active-tile { background: var(--tile-active); border-color: var(--accent-gold); box-shadow: 0 0 15px rgba(240,192,64,.4), 0 4px 0 #8a6020; }
.tile-score { position: absolute; bottom: 2px; right: 3px; font-size: 8px; opacity: .5; }

#rack { display: flex; gap: 6px; justify-content: center; }

#btnRow { display: flex; gap: 8px; }
.game-btn {
  padding: 10px 16px; border-radius: 10px; border: none;
  font-family: var(--font-body); font-weight: 800; cursor: pointer;
}
#btnSubmit { background: var(--accent-green); color: #000; flex: 2; }
#btnClear { background: rgba(255,255,255,0.1); color: #fff; flex: 1; }
#btnSandbag { background: var(--accent-gold); color: #000; flex: 1; display: flex; align-items: center; gap: 5px; }

#physicsBar { display: flex; gap: 12px; font-size: 11px; justify-content: center; opacity: 0.8; }
#sandbagPips { display: flex; gap: 3px; }
.pip { width: 6px; height: 6px; border-radius: 50%; background: #000; opacity: 0.3; }
.pip.used { opacity: 1; background: #fff; }

.overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.85); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.overlay-card { background: #112244; border: 1px solid var(--accent-gold); padding: 40px; border-radius: 24px; width: 100%; max-width: 360px; text-align: center; }
.overlay h1 { font-family: var(--font-title); color: var(--accent-gold); margin-bottom: 15px; }
.overlay p { color: #8ea0b0; font-size: 14px; margin-bottom: 20px; }
.big-btn { width: 100%; padding: 15px; background: var(--accent-gold); border: none; border-radius: 12px; font-weight: 800; font-size: 16px; cursor: pointer; }

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  margin-bottom: 10px;
}

/* Style for the nickname/submit score row */
.stat-row input[type="text"], .stat-row input[type="text"], .stat-row input[type="input"], .stat-row input[type="input"] {
  background: #1a2333;
  color: #fff;
  border: 1.5px solid var(--accent-gold);
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 1em;
  font-family: var(--font-body);
  width: 90px;
  margin-right: 8px;
  outline: none;
  transition: border 0.2s;
}
.stat-row input[type="text"]:focus, .stat-row input[type="input"]:focus {
  border: 1.5px solid var(--accent-green);
}
.stat-row button#submitScoreBtn {
  background: var(--accent-gold);
  color: #222;
  border: none;
  border-radius: 7px;
  font-weight: 700;
  font-size: 1em;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.2s;
}
.stat-row button#submitScoreBtn:disabled {
  background: #aaa;
  color: #fff;
  cursor: not-allowed;
}

#dictHint, .lc-badge {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

#dictHint { 
  background: var(--accent-red); 
  color: white; 
  opacity: 0; 
  transition: 0.3s; 
}
#dictHint.show { opacity: 1; }

#levelComplete { 
  position: absolute; 
  pointer-events: none; 
  inset: 0; 
  display: none; 
  align-items: flex-start;
  justify-content: center; 
  z-index: 1100; 
}
#levelComplete.show { display: flex; }

.lc-badge { 
  background: var(--ui-bg); 
  color: var(--accent-gold);
  border: 2px solid var(--accent-gold); 
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

#helpBtnContainer {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1000;
}

#helpBtn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--accent-green, #2ecc40);
  color: #fff;
  font-size: 1.5em;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: background 0.9s;
}

#helpBtn:hover {
  background: #27ae60;
}

#helpTooltip {
  opacity: 0;
  visibility: hidden;
  position: absolute;
  top: 40px;
  right: 0;
  width: 240px;
  background: #22222285;
  color: #fff;
  padding: 14px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  font-size: 1em;
  line-height: 1.5;
  pointer-events: none;
  transition: opacity 0.9s ease, visibility 0.9s ease;
}

#helpBtnContainer:hover #helpTooltip {
  opacity: 1;
  visibility: visible;
}

.logo {
  font-family: var(--font-title);
  font-size: 42px;
  color: var(--accent-gold);
  display: inline-flex;          /* key change */
  align-items: center;
  justify-content: center;
  white-space: nowrap;           /* prevents breaking */
  gap: 0;
  letter-spacing: -1px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.logo-balloons {
  display: inline-flex;
  flex-wrap: nowrap;     /* critical */
  align-items: center;
  gap: 0;
  margin: 0 -9px;
  white-space: nowrap;
}

.logo-balloons svg {
  display: inline-block;  /* instead of block */
  vertical-align: middle;
}

.balloon {
  transform-origin: center bottom;
  display: block;
  animation: balloonFloat 3.4s ease-in-out infinite;
  will-change: transform;
}

.balloon ellipse {
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.25));
}

/* slight variation so they never sync */
.balloon.b1 {
  margin-right: -23px; /* main overlap */
  animation-delay: 0s;
  animation-duration: 3.2s;
}

.balloon.b2 {
  animation-delay: 0.55s;
  animation-duration: 3.7s;
}

@keyframes balloonFloat {
  0%, 100% {
    transform: translateY(0px) rotate(-1deg);
  }
  50% {
    transform: translateY(-5px) rotate(1.8deg);
  }
}

@keyframes popIn { 
  from { transform: translateX(-50%) scale(0.5); opacity: 0; } 
  to { transform: translateX(-50%) scale(1); opacity: 1; } 
}

#gameTimer {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 1000;
  background: rgba(20,30,40,0.55);
  color: #fff;
  font-size: 15px;
  font-family: 'Nunito', sans-serif;
  padding: 4px 12px;
  border-radius: 12px;
  opacity: 0.7;
  pointer-events: none;
  letter-spacing: 1px;
}

/* Stats Button Styles */
#statsBtnContainer {
  position: fixed;
  top: 18px;
  right: 68px; /* Place left of help button */
  z-index: 1000;
}

#statsBtn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--accent-gold, #f0c040);
  color: #222;
  font-size: 1.5em;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: background 0.2s;
  margin-right: 0;
}

#statsBtn:hover {
  background: #ffe082;
}

/* Stats Button Tooltip */
#statsTooltip {
  opacity: 0;
  visibility: hidden;
  position: absolute;
  top: 40px;
  right: 0;
  width: 120px;
  background: #22222285;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  font-size: 1em;
  line-height: 1.5;
  pointer-events: none;
  text-align: center;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

#statsBtnContainer:hover #statsTooltip {
  opacity: 1;
  visibility: visible;
}

/* Style for the nickname input field */
#screenGameOver #nicknameInput,
#screenVictory #nicknameInput {
  background: #1a2333;
  color: #fff;
  border: 1.5px solid var(--accent-gold);
  border-radius: 7px;
  padding: 7px 12px;
  font-size: 1em;
  font-family: var(--font-body, 'Nunito', sans-serif);
  width: 120px;
  margin-right: 8px;
  outline: none;
  transition: border 0.2s;
  box-sizing: border-box;
}
#screenGameOver #nicknameInput:focus,
#screenVictory #nicknameInput:focus {
  border: 1.5px solid var(--accent-green);
}