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

body {
  background: #111a0a;
  color: #ddd;
  font-family: 'Segoe UI', sans-serif;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

.hidden { display: none !important; }

/* ── Lobby ── */
#lobby {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: url('/menu-bg.png') center / cover no-repeat, #111a0a;
  z-index: 20;
}

#lobby-box {
  background: rgba(10, 20, 5, 0.88);
  border: 2px solid #4caf50;
  border-radius: 14px;
  padding: 2rem 2.5rem;
  width: 320px;
  text-align: center;
  box-shadow: 0 0 60px rgba(0,0,0,0.8), 0 0 30px rgba(76,175,80,0.15);
  backdrop-filter: blur(6px);
}

h1 {
  font-size: clamp(1.6rem, 7vw, 2.4rem);
  color: #6ed672;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: 0 0 20px rgba(76,175,80,0.6);
  word-break: keep-all;
  white-space: nowrap;
}

.subtitle {
  color: #5a8a5a;
  font-size: 0.78rem;
  margin-bottom: 1.4rem;
  letter-spacing: 1px;
}

#name-input {
  width: 100%;
  padding: 0.55rem 0.8rem;
  background: #0f1f08;
  border: 1px solid #4caf50;
  color: #ddd;
  border-radius: 7px;
  font-size: 1rem;
  margin-bottom: 0.5rem;
  outline: none;
}
#name-input:focus { border-color: #88dd88; }

button {
  width: 100%;
  padding: 0.6rem;
  background: #4caf50;
  color: #0a1505;
  border: none;
  border-radius: 7px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: background 0.15s;
}
button:hover { background: #6ed672; }
button:disabled { background: #2a4a2a; color: #555; cursor: default; }

#lobby-status { color: #f44336; font-size: 0.85rem; margin: 0.4rem 0; }

#player-list {
  margin-top: 1.2rem;
  text-align: left;
  max-height: 180px;
  overflow-y: auto;
}
.player-entry {
  padding: 0.3rem 0.2rem;
  border-bottom: 1px solid #1f3a14;
  font-size: 0.9rem;
  font-weight: 600;
}

#start-btn   { margin-top: 1rem; }

.update-btn {
  margin-top: 0.5rem;
  background: #1a3a1a;
  color: #4a8a4a;
  border: 1px solid #2a5a2a;
  font-weight: 500;
}
.update-btn:hover { background: #243a24; color: #6ed672; }
.update-btn:disabled { opacity: 0.4; cursor: default; }

.update-status {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #6ed672;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.4; } }

/* ── Game UI ── */
#game-container {
  position: fixed;
  inset: 0;
}

#game-container canvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
}

#hud {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.65);
  padding: 6px 20px;
  border-radius: 20px;
  font-size: 0.85rem;
  color: #6ed672;
  z-index: 10;
  display: flex;
  gap: 1.2rem;
  pointer-events: none;
  white-space: nowrap;
}

#mount-hint {
  color: #ffdd88;
  font-weight: 600;
}

#leaderboard {
  position: fixed;
  top: 50px;
  right: 14px;
  background: rgba(0,0,0,0.65);
  border: 1px solid #2a4a2a;
  border-radius: 10px;
  padding: 8px 12px 6px;
  min-width: 210px;
  z-index: 10;
  pointer-events: none;
}

.lb-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: #4a8a4a;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 4px;
  text-align: center;
}

.lb-header, .lb-entry {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 0;
  font-size: 0.8rem;
  color: #ccc;
}

.lb-header {
  border-bottom: 1px solid #2a4a2a;
  margin-bottom: 3px;
  padding-bottom: 3px;
}

.lb-col-head {
  font-size: 0.7rem;
  color: #5a8a5a;
  width: 32px;
  text-align: right;
}

.lb-entry.lb-me { color: #fff; font-weight: 700; }

.lb-rank {
  width: 16px;
  text-align: center;
  font-size: 0.72rem;
  flex-shrink: 0;
}

.lb-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.lb-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-shame {
  color: #ff4444;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  animation: shame-pulse 1.2s ease-in-out infinite;
}

@keyframes shame-pulse { 0%,100% { opacity:1; } 50% { opacity:0.5; } }

.lb-coins {
  width: 32px;
  text-align: right;
  color: #ffd700;
  font-weight: 600;
  font-size: 0.78rem;
  white-space: nowrap;
}

.lb-tiles {
  width: 32px;
  text-align: right;
  color: #6ed672;
  font-weight: 600;
  font-size: 0.78rem;
  white-space: nowrap;
}

/* ── Complete banner buttons ── */
.next-lawn-btn {
  background: #4caf50;
  margin-bottom: 0.5rem;
}
.next-lawn-btn:hover { background: #6ed672; }
.back-lobby-btn {
  background: #1a3a1a;
  color: #6ed672;
  border: 1px solid #2a5a2a;
  font-weight: 500;
}
.back-lobby-btn:hover { background: #243a24; }

/* ── Store overlay ── */
#store {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

#store-box {
  background: rgba(8,16,4,0.97);
  border: 2px solid #4caf50;
  border-radius: 14px;
  padding: 1.4rem 1.8rem;
  width: 460px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 0 60px rgba(76,175,80,0.25);
}

.store-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}
.store-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #6ed672;
  letter-spacing: 1px;
  text-transform: uppercase;
}
#store-coins-display {
  font-size: 0.9rem;
  color: #ffd700;
  font-weight: 700;
}

.store-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}
.store-tab-btn {
  flex: 1;
  width: auto;
  padding: 0.4rem;
  background: #1a2a1a;
  color: #5a8a5a;
  border: 1px solid #2a4a2a;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}
.store-tab-btn.active {
  background: #2a5a2a;
  color: #6ed672;
  border-color: #4caf50;
}
.store-tab-btn:hover:not(.active) { background: #222a22; color: #7a9a7a; }

.store-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 0.5rem;
  border-bottom: 1px solid #1a2a1a;
  transition: background 0.1s;
}
.store-item:last-child { border-bottom: none; }
.store-item.owned { opacity: 0.7; }
.store-item-icon { font-size: 1.4rem; flex-shrink: 0; }
.store-item-info { flex: 1; }
.store-item-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #ddd;
  margin-bottom: 2px;
}
.store-item-desc {
  font-size: 0.75rem;
  color: #5a8a5a;
}
.store-item-stats {
  font-size: 0.72rem;
  color: #7a7a5a;
  margin-top: 2px;
}
.store-item-btn {
  width: auto;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  background: #2a6a2a;
  color: #aaddaa;
  border: 1px solid #4caf50;
}
.store-item-btn:hover:not(:disabled) { background: #3a8a3a; color: #fff; }
.store-item-btn.owned  { background: #1a2a1a; color: #4a7a4a; border-color: #2a4a2a; }
.store-item-btn.locked { background: #1a1a2a; color: #4a4a7a; border-color: #2a2a4a; }
.store-item-btn.poor   { background: #2a1a1a; color: #7a4a4a; border-color: #4a2a2a; }

#store-close {
  width: 100%;
  margin-top: 1rem;
  background: #1a2a1a;
  color: #5a8a5a;
  border: 1px solid #2a4a2a;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.5rem;
  border-radius: 7px;
  cursor: pointer;
}
#store-close:hover { background: #243a24; color: #6ed672; }

#controls-hint {
  position: fixed;
  bottom: 12px;
  right: 16px;
  background: rgba(0,0,0,0.5);
  color: #4a7a4a;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.72rem;
  z-index: 10;
  pointer-events: none;
}

/* ── Touch controls ── */
#touch-controls {
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none;
}

#joystick-zone {
  position: absolute;
  bottom: 24px;
  left: 24px;
  width: 140px;
  height: 140px;
  pointer-events: all;
  touch-action: none;
}

#joystick-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
}

#joystick-knob {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(110,214,114,0.55);
  border: 2px solid rgba(110,214,114,0.85);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: background 0.1s;
}

#touch-action-btns {
  position: absolute;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  pointer-events: all;
}

.touch-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid rgba(110,214,114,0.5);
  background: rgba(0,0,0,0.55);
  color: #6ed672;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  letter-spacing: 0.3px;
  transition: background 0.08s, border-color 0.08s;
}

.touch-btn:active,
.touch-btn.pressed {
  background: rgba(76,175,80,0.35);
  border-color: #6ed672;
}

#complete-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  background: rgba(10,20,5,0.92);
  border: 2px solid #4caf50;
  border-radius: 14px;
  padding: 2rem 3rem;
  text-align: center;
  z-index: 15;
  box-shadow: 0 0 60px rgba(76,175,80,0.4);
}
#complete-banner h2 { color: #6ed672; font-size: 2rem; margin-bottom: 0.4rem; }
#complete-banner p  { color: #5a8a5a; margin-bottom: 1.2rem; }
#reset-btn { width: auto; padding: 0.6rem 2rem; }
