:root {
  --roblox-red: #E2231A;
  --roblox-green: #00A651;
  --roblox-blue: #0066FF;
  --roblox-yellow: #FFFF00;
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-panel: #0f3460;
  --text-primary: #ffffff;
  --text-secondary: #a0a0c0;
  --border-color: #000000;
  --shop-bg: #1a1a3e;
  --btn-bg: #2a2a4e;
}

body.light-mode {
  --bg-primary: #e8e8f0;
  --bg-secondary: #d0d0e0;
  --bg-panel: #b0c4de;
  --text-primary: #1a1a2e;
  --text-secondary: #4a4a6e;
  --shop-bg: #c8c8e0;
  --btn-bg: #d8d8f0;
}

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

body {
  font-family: 'Fredoka', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  user-select: none;
  -webkit-user-select: none;
}

#game-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

#hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-bottom: 3px solid var(--border-color);
  z-index: 10;
  min-height: 60px;
}

#hud-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

#avatar-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

#avatar-canvas {
  border: 3px solid var(--border-color);
  border-radius: 8px;
  background: var(--roblox-yellow);
  image-rendering: pixelated;
}

#username-input {
  font-family: 'Fredoka', sans-serif;
  font-size: 14px;
  font-weight: 600;
  background: transparent;
  border: 2px solid transparent;
  color: var(--text-primary);
  padding: 2px 6px;
  border-radius: 6px;
  width: 130px;
  transition: border-color 0.2s;
}

#username-input:focus {
  border-color: var(--roblox-blue);
  outline: none;
}

#hud-center {
  text-align: center;
}

#robux-display {
  font-size: 28px;
  font-weight: 700;
  transition: transform 0.1s;
}

#robux-display.bounce {
  transform: scale(1.15);
}

#robux-symbol {
  color: var(--roblox-green);
  margin-right: 4px;
}

#income-display {
  font-size: 13px;
  color: var(--roblox-green);
  font-weight: 500;
}

#hud-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

#level-area {
  text-align: right;
}

#level-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--roblox-yellow);
}

#xp-bar-outer {
  width: 100px;
  height: 10px;
  background: #333;
  border-radius: 5px;
  border: 2px solid var(--border-color);
  overflow: hidden;
  margin-top: 2px;
}

#xp-bar-inner {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--roblox-green), #00ff88);
  border-radius: 3px;
  transition: width 0.3s ease;
}

#settings-btn {
  font-size: 24px;
  background: none;
  border: none;
  cursor: pointer;
  filter: grayscale(0.3);
  transition: transform 0.2s;
}

#settings-btn:hover {
  transform: scale(1.2);
  filter: none;
}

#main-area {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

#canvas {
  flex: 1;
  cursor: pointer;
  display: block;
}

#shop-panel {
  width: 260px;
  background: var(--shop-bg);
  border-left: 3px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#shop-header {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  padding: 10px;
  background: var(--bg-secondary);
  border-bottom: 3px solid var(--border-color);
  text-transform: uppercase;
  letter-spacing: 2px;
}

#shop-items {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  scrollbar-width: thin;
}

.shop-item {
  background: var(--btn-bg);
  border: 3px solid var(--border-color);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.shop-item.affordable {
  box-shadow: 0 0 12px rgba(0, 166, 81, 0.5);
  border-color: var(--roblox-green);
}

.shop-item.unaffordable {
  opacity: 0.5;
  cursor: not-allowed;
}

.shop-item.locked {
  opacity: 0.3;
  cursor: not-allowed;
}

.shop-item:not(.unaffordable):not(.locked):hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 102, 255, 0.4);
}

.shop-item:not(.unaffordable):not(.locked):active {
  transform: scale(0.97);
}

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

.item-name {
  font-weight: 700;
  font-size: 14px;
}

.item-count {
  background: var(--roblox-blue);
  color: white;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid var(--border-color);
}

.item-details {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}

.item-cost {
  color: var(--roblox-yellow);
  font-weight: 600;
}

.item-income {
  color: var(--roblox-green);
}

.item-lock-text {
  font-size: 11px;
  color: var(--roblox-red);
  font-weight: 600;
}

#prestige-area {
  padding: 10px;
  border-top: 3px solid var(--border-color);
  text-align: center;
}

#prestige-btn {
  font-family: 'Fredoka', sans-serif;
  font-size: 14px;
  font-weight: 700;
  padding: 8px 16px;
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  color: white;
  border: 3px solid var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.2s;
  width: 100%;
}

#prestige-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 16px rgba(255, 107, 107, 0.6);
}

#prestige-info {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

#bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: var(--bg-secondary);
  border-top: 3px solid var(--border-color);
  font-size: 12px;
  min-height: 36px;
}

#players-online {
  color: var(--text-secondary);
  font-weight: 500;
}

#achievements-area {
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.achievement-badge {
  background: var(--roblox-blue);
  color: white;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  border: 2px solid var(--border-color);
  white-space: nowrap;
}

#save-indicator {
  color: var(--roblox-green);
  font-weight: 600;
  transition: opacity 0.5s;
}

.hidden {
  display: none !important;
}

#toast-container {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-panel);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: 12px;
  border: 3px solid var(--roblox-yellow);
  font-weight: 600;
  font-size: 14px;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.8); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-10px); }
}

#settings-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

#settings-content {
  background: var(--bg-secondary);
  border: 4px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  min-width: 280px;
  text-align: center;
}

#settings-content h2 {
  margin-bottom: 16px;
  font-size: 22px;
}

#settings-content label {
  display: block;
  margin: 12px 0;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}

#settings-content input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-right: 8px;
  vertical-align: middle;
}

#reset-btn {
  font-family: 'Fredoka', sans-serif;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 20px;
  background: var(--roblox-red);
  color: white;
  border: 3px solid var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  margin-top: 16px;
  width: 100%;
}

#close-settings {
  font-family: 'Fredoka', sans-serif;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 20px;
  background: var(--roblox-blue);
  color: white;
  border: 3px solid var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  margin-top: 8px;
  width: 100%;
}

#server-message {
  position: fixed;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: var(--roblox-yellow);
  padding: 8px 20px;
  border-radius: 8px;
  border: 2px solid var(--roblox-yellow);
  font-size: 13px;
  font-weight: 500;
  z-index: 50;
  animation: toastIn 0.3s ease, toastOut 0.4s ease 3.5s forwards;
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

#footer {
  position: fixed;
  bottom: 2px;
  right: 10px;
  z-index: 10;
}

#footer a {
  color: var(--text-secondary);
  font-size: 11px;
  text-decoration: none;
  opacity: 0.5;
}

#footer a:hover {
  opacity: 1;
}

/* Scrollbar */
#shop-items::-webkit-scrollbar { width: 6px; }
#shop-items::-webkit-scrollbar-track { background: transparent; }
#shop-items::-webkit-scrollbar-thumb { background: #555; border-radius: 3px; }

/* Mobile */
@media (max-width: 700px) {
  #main-area {
    flex-direction: column;
  }

  #shop-panel {
    width: 100%;
    max-height: 40vh;
    border-left: none;
    border-top: 3px solid var(--border-color);
  }

  #robux-display {
    font-size: 22px;
  }

  #username-input {
    width: 90px;
    font-size: 12px;
  }

  #hud-bar {
    padding: 6px 10px;
    min-height: 50px;
  }

  #xp-bar-outer {
    width: 70px;
  }
}