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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a1a2e;
  font-family: 'Courier New', monospace;
  color: #e0e0e0;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
}

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.panel {
  background: #16213e;
  border: 2px solid #0f3460;
  border-radius: 12px;
  padding: 32px;
  min-width: 340px;
  max-width: 440px;
  text-align: center;
}

.panel h1 {
  font-size: 28px;
  color: #e94560;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 3px;
}

.panel h2 {
  font-size: 20px;
  color: #e94560;
  margin-bottom: 16px;
}

.subtitle {
  color: #888;
  margin-bottom: 24px;
  font-size: 14px;
}

.form-group {
  margin-bottom: 16px;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.form-group input[type="text"],
.form-group input[type="color"],
.form-group select {
  width: 100%;
  padding: 10px 12px;
  background: #0f3460;
  border: 1px solid #533483;
  border-radius: 6px;
  color: #e0e0e0;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  outline: none;
}

.form-group input[type="text"]:focus,
.form-group select:focus {
  border-color: #e94560;
}

.form-group input[type="color"] {
  height: 40px;
  padding: 4px;
  cursor: pointer;
}

.error {
  color: #e94560;
  font-size: 12px;
  margin-top: 6px;
  min-height: 16px;
}

button {
  padding: 12px 32px;
  background: #e94560;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: background 0.2s;
  margin-top: 8px;
}

button:hover {
  background: #c73e54;
}

.btn-secondary {
  background: #533483;
}

.btn-secondary:hover {
  background: #3d2660;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 100;
}

#hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, transparent 100%);
}

#hud-nickname {
  font-weight: bold;
  color: #e94560;
  font-size: 16px;
}

#hud-online {
  color: #aaa;
  font-size: 13px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin: 0 8px;
  vertical-align: middle;
}

.status-dot.connected {
  background: #4caf50;
  box-shadow: 0 0 6px rgba(76, 175, 80, 0.6);
}

.status-dot.disconnected {
  background: #e94560;
  box-shadow: 0 0 6px rgba(233, 69, 96, 0.6);
}

#chat-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 420px;
  max-width: 100%;
  z-index: 100;
  pointer-events: none;
}

#chat-messages {
  max-height: 240px;
  overflow-y: auto;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.5);
  scrollbar-width: thin;
  scrollbar-color: #533483 transparent;
}

#chat-messages::-webkit-scrollbar {
  width: 6px;
}

#chat-messages::-webkit-scrollbar-thumb {
  background: #533483;
  border-radius: 3px;
}

.chat-msg {
  margin-bottom: 4px;
  font-size: 13px;
  line-height: 1.4;
  word-wrap: break-word;
}

.chat-msg .nick {
  color: #e94560;
  font-weight: bold;
}

.chat-msg.emote {
  color: #b388ff;
  font-style: italic;
}

.chat-msg.system {
  color: #4caf50;
}

.chat-msg.whisper {
  color: #ff9a76;
  font-style: italic;
}

.chat-msg .whisper-dir {
  color: #b388ff;
  font-weight: bold;
}

#chat-input-wrap {
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.7);
  pointer-events: auto;
}

#chat-input {
  width: 100%;
  padding: 8px 12px;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 6px;
  color: #e0e0e0;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  outline: none;
}

#chat-input:focus {
  border-color: #e94560;
}

#controls-hint {
  position: fixed;
  bottom: 8px;
  right: 16px;
  font-size: 11px;
  color: #555;
  z-index: 99;
  pointer-events: none;
}

#avatar-preview {
  display: block;
  margin: 0 auto 16px;
  border: 1px solid #0f3460;
  border-radius: 4px;
  image-rendering: pixelated;
  background: #0f3460;
}

#toolbar {
  position: fixed;
  bottom: 60px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: row;
  gap: 6px;
  pointer-events: none;
}

#toolbar > button {
  pointer-events: auto;
}

#build-toggle {
  padding: 8px 16px;
  font-size: 12px;
  background: #533483;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 1px;
  pointer-events: auto;
  transition: background 0.2s;
  margin: 0;
}

#build-toggle:hover {
  background: #3d2660;
}

#build-toggle.active {
  background: #e94560;
  border-color: #e94560;
}

#inventory-toggle {
  padding: 8px 16px;
  font-size: 12px;
  background: #533483;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 1px;
  pointer-events: auto;
  transition: background 0.2s;
  margin: 0;
}

#inventory-toggle:hover {
  background: #3d2660;
}

#inventory-toggle.active {
  background: #e94560;
  border-color: #e94560;
}

#friends-toggle {
  padding: 8px 16px;
  font-size: 12px;
  background: #533483;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 1px;
  pointer-events: auto;
  transition: background 0.2s;
  margin: 0;
}

#friends-toggle:hover {
  background: #3d2660;
}

#friends-toggle.active {
  background: #e94560;
  border-color: #e94560;
}

#shop-toggle {
  padding: 8px 16px;
  font-size: 12px;
  background: #8B6914;
  color: #ffd700;
  border: 1px solid #a0722a;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 1px;
  pointer-events: auto;
  transition: background 0.2s;
  font-weight: bold;
  margin: 0;
}

#shop-toggle:hover {
  background: #a07a1a;
}

#shop-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 300;
  background: rgba(22, 33, 62, 0.97);
  border: 2px solid #ffd700;
  border-radius: 10px;
  padding: 20px;
  min-width: 300px;
  max-width: 420px;
  max-height: 500px;
  overflow-y: auto;
}

#shop-panel h3 {
  color: #ffd700;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#shop-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.shop-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #0f3460;
  border: 1px solid #533483;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.shop-item:hover {
  border-color: #ffd700;
  background: #1a4a7a;
}

.shop-item.owned {
  opacity: 0.5;
  cursor: default;
  border-color: #4caf50;
}

.shop-item-name {
  color: #e0e0e0;
  font-size: 12px;
}

.shop-item-price {
  color: #ffd700;
  font-size: 11px;
  text-transform: uppercase;
}

.shop-item.owned .shop-item-price {
  color: #4caf50;
}

#friends-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 300;
  background: rgba(22, 33, 62, 0.97);
  border: 2px solid #0f3460;
  border-radius: 10px;
  padding: 20px;
  min-width: 280px;
  max-width: 360px;
  max-height: 400px;
  overflow-y: auto;
}

#friends-panel h3 {
  color: #e94560;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 14px;
}

#friends-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.friend-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: #0f3460;
  border: 1px solid #533483;
  border-radius: 4px;
  font-size: 12px;
}

.friend-entry.online {
  border-color: #4caf50;
}

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

.friend-status.on {
  background: #4caf50;
  box-shadow: 0 0 4px rgba(76, 175, 80, 0.6);
}

.friend-status.off {
  background: #555;
}

.friend-name {
  flex: 1;
  color: #e0e0e0;
}

.friend-whisper {
  padding: 3px 8px;
  font-size: 10px;
  background: #533483;
  border: none;
  border-radius: 3px;
  color: #e0e0e0;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  margin-top: 0;
}

.friend-whisper:hover {
  background: #e94560;
}

.friend-empty {
  color: #555;
  font-size: 12px;
  text-align: center;
  padding: 20px;
}

#inventory-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 300;
  background: rgba(22, 33, 62, 0.97);
  border: 2px solid #0f3460;
  border-radius: 10px;
  padding: 20px;
  min-width: 300px;
  max-width: 400px;
  max-height: 400px;
  overflow-y: auto;
}

#inventory-panel h3 {
  color: #e94560;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.coins-display {
  color: #ffd700;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
}

#hud-coins {
  color: #ffd700;
  font-size: 12px;
}

#inventory-items {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.inv-item {
  background: #0f3460;
  border: 1px solid #533483;
  border-radius: 4px;
  padding: 8px 4px;
  text-align: center;
  font-size: 10px;
  color: #e0e0e0;
  cursor: default;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.inv-item .inv-icon {
  font-size: 18px;
  margin-bottom: 2px;
}

.inv-item .inv-name {
  font-size: 9px;
  text-transform: uppercase;
}

.inv-empty {
  background: rgba(15, 52, 96, 0.3);
  border: 1px dashed #333;
}

#build-toolbar {
  position: fixed;
  right: 16px;
  bottom: 100px;
  z-index: 200;
  pointer-events: auto;
}

#build-toolbar-inner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(22, 33, 62, 0.95);
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 8px;
}

.build-item {
  padding: 6px 14px;
  font-size: 11px;
  background: #0f3460;
  color: #e0e0e0;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: left;
  margin-top: 0;
  transition: all 0.15s;
  min-width: 90px;
}

.build-item:hover {
  background: #533483;
  border-color: #e94560;
}

.build-item.selected {
  background: #e94560;
  border-color: #ff6b81;
  color: #fff;
}

.build-item.build-eraser {
  color: #ff9a76;
  border-top: 1px solid #333;
  margin-top: 4px;
  padding-top: 10px;
}

.build-item.build-eraser.selected {
  background: #ff9a76;
  color: #1a1a2e;
}

#minimap-container {
  position: fixed;
  top: 50px;
  right: 16px;
  z-index: 150;
  border: 2px solid #0f3460;
  border-radius: 6px;
  overflow: hidden;
  background: #0a0a1a;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

#minimap-canvas {
  display: block;
  image-rendering: pixelated;
}

#mobile-joystick {
  display: none;
  position: fixed;
  bottom: 80px;
  left: 24px;
  z-index: 200;
  touch-action: none;
}

#joystick-base {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(22, 33, 62, 0.7);
  border: 2px solid rgba(83, 52, 131, 0.6);
  position: relative;
}

#joystick-stick {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(233, 69, 96, 0.6);
  border: 2px solid rgba(233, 69, 96, 0.8);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

@media (max-width: 600px) {
  .panel {
    min-width: unset;
    margin: 16px;
    padding: 24px;
  }

  #chat-panel {
    width: 100%;
  }

  #controls-hint {
    display: none;
  }

  #mobile-joystick {
    display: block;
  }

  #build-toolbar-inner {
    flex-direction: row;
    flex-wrap: wrap;
    max-width: 280px;
  }

  .build-item {
    min-width: 70px;
    font-size: 10px;
    padding: 5px 8px;
  }

  #minimap-container {
    top: 45px;
    right: 8px;
  }

  #minimap-canvas {
    width: 100px;
    height: 100px;
  }
}

#trade-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #0f3460;
  border: 2px solid #e94560;
  border-radius: 8px;
  padding: 16px;
  z-index: 100;
  min-width: 360px;
  color: #fff;
}

#trade-panel h3 {
  text-align: center;
  margin: 0 0 12px 0;
}

.trade-sections {
  display: flex;
  gap: 16px;
}

.trade-section {
  flex: 1;
}

.trade-section h4 {
  margin: 0 0 8px 0;
  font-size: 12px;
  color: #aaa;
  text-transform: uppercase;
}

.trade-items {
  min-height: 80px;
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
  padding: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.trade-offered-item {
  background: #1a1a2e;
  border: 1px solid #555;
  border-radius: 3px;
  padding: 2px 6px;
  font-size: 11px;
  color: #ddd;
  cursor: pointer;
}

.trade-offered-item:hover {
  border-color: #e94560;
}

.trade-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  justify-content: center;
}

.trade-btn {
  padding: 6px 16px;
  border: 1px solid #555;
  border-radius: 4px;
  background: #1a1a2e;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
}

.trade-btn:hover {
  background: #16213e;
}

.trade-accept {
  border-color: #2d8a4e;
  color: #2d8a4e;
}

.trade-accept:hover {
  background: #1a3a2e;
}

.trade-cancel {
  border-color: #e94560;
  color: #e94560;
}

#trade-add-btn {
  margin-top: 4px;
  font-size: 11px;
  width: 100%;
}

#trade-inventory-picker {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #0f3460;
  border: 2px solid #ffd700;
  border-radius: 8px;
  padding: 16px;
  z-index: 110;
  min-width: 300px;
  color: #fff;
}

#trade-inventory-picker h3 {
  text-align: center;
  margin: 0 0 12px 0;
}

#trade-picker-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.trade-pick-item {
  background: #1a1a2e;
  border: 1px solid #555;
  border-radius: 3px;
  padding: 4px 10px;
  font-size: 12px;
  color: #ddd;
  cursor: pointer;
}

.trade-pick-item:hover {
  border-color: #ffd700;
  background: #1a2a1e;
}

#trade-inventory-picker .trade-btn {
  width: 100%;
}

#toast-container {
  position: fixed;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.toast {
  background: rgba(22, 33, 62, 0.95);
  border: 1px solid #0f3460;
  border-radius: 6px;
  padding: 8px 16px;
  color: #e0e0e0;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  animation: toast-in 0.3s ease, toast-out 0.3s ease 2.7s;
  pointer-events: auto;
  white-space: nowrap;
}

.toast.toast-success {
  border-color: #4caf50;
  color: #4caf50;
}

.toast.toast-error {
  border-color: #e94560;
  color: #e94560;
}

.toast.toast-coins {
  border-color: #ffd700;
  color: #ffd700;
}

.toast.toast-reward {
  border-color: #ffd700;
  color: #ffd700;
  background: rgba(255, 215, 0, 0.1);
}

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

@keyframes toast-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

#creator-toggle {
  padding: 8px 16px;
  font-size: 12px;
  background: #e94560;
  color: #fff;
  border: 1px solid #c73e54;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 1px;
  pointer-events: auto;
  transition: background 0.2s;
  font-weight: bold;
  margin: 0;
}

#creator-toggle:hover {
  background: #c73e54;
}

#creator-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 300;
  background: rgba(22, 33, 62, 0.97);
  border: 2px solid #e94560;
  border-radius: 10px;
  padding: 20px;
  min-width: 340px;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
}

#creator-panel h3 {
  color: #e94560;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.creator-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}

.creator-tab {
  flex: 1;
  padding: 6px 8px;
  background: #0f3460;
  border: 1px solid #533483;
  border-radius: 4px;
  color: #aaa;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  text-transform: uppercase;
  cursor: pointer;
  margin-top: 0;
  letter-spacing: 0;
}

.creator-tab.active {
  background: #533483;
  color: #e0e0e0;
  border-color: #e94560;
}

#creator-canvas {
  display: block;
  margin: 0 auto 12px;
  border: 2px solid #0f3460;
  border-radius: 4px;
  image-rendering: pixelated;
  width: 256px;
  height: 256px;
  cursor: crosshair;
  background: #0f3460;
}

.creator-tools {
  margin-bottom: 12px;
}

.creator-color-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}

.creator-color-row input[type="color"] {
  width: 40px;
  height: 32px;
  padding: 2px;
  background: #0f3460;
  border: 1px solid #533483;
  border-radius: 4px;
  cursor: pointer;
}

.creator-tool-btn {
  padding: 6px 12px;
  background: #0f3460;
  border: 1px solid #533483;
  border-radius: 4px;
  color: #e0e0e0;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  cursor: pointer;
  text-transform: uppercase;
  margin-top: 0;
  letter-spacing: 0;
}

.creator-tool-btn:hover {
  background: #533483;
}

.creator-tool-btn.active {
  background: #e94560;
  border-color: #e94560;
}

.creator-palette {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.creator-preset {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.2);
  display: inline-block;
}

.creator-preset:hover {
  border-color: #fff;
  transform: scale(1.2);
}

.creator-form {
  border-top: 1px solid #0f3460;
  padding-top: 12px;
}

.gallery-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gallery-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: #0f3460;
  border: 1px solid #533483;
  border-radius: 6px;
}

.gallery-item.featured {
  border-color: #ffd700;
}

.gallery-preview {
  image-rendering: pixelated;
  flex-shrink: 0;
  border-radius: 4px;
}

.gallery-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gallery-name {
  color: #e0e0e0;
  font-size: 12px;
  font-weight: bold;
}

.gallery-creator {
  color: #aaa;
  font-size: 10px;
}

.gallery-price {
  color: #ffd700;
  font-size: 11px;
}

.gallery-sales {
  color: #666;
  font-size: 10px;
}

.gallery-buy-btn {
  padding: 4px 12px;
  background: #ffd700;
  color: #1a1a2e;
  border: none;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  text-transform: uppercase;
  margin-top: 0;
  letter-spacing: 0;
  flex-shrink: 0;
}

.gallery-buy-btn:hover {
  background: #ffed4a;
}

.gallery-empty {
  color: #555;
  font-size: 12px;
  text-align: center;
  padding: 20px;
}

.my-creation-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: #0f3460;
  border: 1px solid #533483;
  border-radius: 4px;
  margin-bottom: 4px;
}

.my-creation-item.approved {
  border-color: #4caf50;
}

.my-creation-item.pending {
  border-color: #ff9a76;
}

.gallery-status {
  font-size: 10px;
  text-transform: uppercase;
}

.my-creation-item.approved .gallery-status {
  color: #4caf50;
}

.my-creation-item.pending .gallery-status {
  color: #ff9a76;
}

.creator-stats {
  background: #0f3460;
  border-radius: 4px;
  padding: 8px 12px;
  margin-bottom: 8px;
  font-size: 11px;
  color: #aaa;
  text-align: center;
}

.contest-item {
  padding: 10px;
  margin-bottom: 8px;
  border-radius: 6px;
  border: 1px solid #444;
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  transition: border-color 0.2s;
}

.contest-item:hover {
  border-color: #e94560;
}

.contest-item-name {
  font-size: 13px;
  font-weight: bold;
  color: #e94560;
  margin-bottom: 4px;
}

.contest-item-theme {
  font-size: 11px;
  color: #aaa;
  margin-bottom: 4px;
}

.contest-item-meta {
  font-size: 10px;
  color: #666;
  display: flex;
  gap: 12px;
}

.contest-status-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 9px;
  text-transform: uppercase;
  font-weight: bold;
}

.contest-status-open {
  background: rgba(76, 175, 80, 0.2);
  color: #4caf50;
  border: 1px solid #4caf50;
}

.contest-status-voting {
  background: rgba(74, 144, 217, 0.2);
  color: #4a90d9;
  border: 1px solid #4a90d9;
}

.contest-status-completed {
  background: rgba(255, 255, 255, 0.05);
  color: #888;
  border: 1px solid #555;
}

.contest-entry-item {
  padding: 8px;
  margin-bottom: 6px;
  border-radius: 4px;
  border: 1px solid #333;
  background: rgba(255,255,255,0.03);
  display: flex;
  align-items: center;
  gap: 8px;
}

.contest-entry-item.winner-1st {
  border-color: #ffd700;
  background: rgba(255, 215, 0, 0.08);
}

.contest-entry-item.winner-2nd {
  border-color: #c0c0c0;
  background: rgba(192, 192, 192, 0.06);
}

.contest-entry-item.winner-3rd {
  border-color: #cd7f32;
  background: rgba(205, 127, 50, 0.06);
}

.contest-entry-preview {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  border: 1px solid #333;
  border-radius: 2px;
}

.contest-entry-info {
  flex: 1;
}

.contest-entry-name {
  font-size: 12px;
  font-weight: bold;
  color: #eee;
}

.contest-entry-creator {
  font-size: 10px;
  color: #aaa;
}

.contest-entry-votes {
  font-size: 11px;
  color: #ffd700;
  font-weight: bold;
}

.contest-vote-btn {
  padding: 3px 8px;
  font-size: 10px;
  font-family: 'Courier New', monospace;
  background: #4a90d9;
  color: #fff;
  border: 1px solid #357abd;
  border-radius: 3px;
  cursor: pointer;
}

.contest-vote-btn:hover {
  background: #357abd;
}

.contest-vote-btn.voted {
  background: #333;
  color: #666;
  border-color: #444;
  cursor: default;
}

@media (max-width: 768px) {
  #toolbar {
    bottom: 50px;
    right: 8px;
    gap: 4px;
  }

  #toolbar > button {
    padding: 6px 10px;
    font-size: 11px;
  }

  #mail-panel,
  #leaderboard-panel,
  #achievements-panel,
  #friends-panel,
  #shop-panel,
  #inventory-panel {
    right: 8px;
    left: 8px;
    max-width: none;
  }

  #chat-panel {
    width: 100%;
  }

  #creator-panel {
    min-width: unset;
    max-width: unset;
    width: 95vw;
    padding: 16px;
  }

  #creator-canvas {
    width: 200px;
    height: 200px;
  }

  #minimap-container {
    display: none;
  }

  #controls-hint {
    display: none;
  }
}

#achievements-toggle {
  padding: 8px 16px;
  font-size: 14px;
  background: #ffd700;
  color: #333;
  border: 1px solid #daa520;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 1px;
  pointer-events: auto;
  transition: background 0.2s;
  margin: 0;
}

#achievements-toggle:hover {
  background: #daa520;
}

#achievements-panel {
  position: fixed;
  bottom: 100px;
  right: 16px;
  z-index: 300;
  background: rgba(20, 20, 30, 0.95);
  border: 1px solid #444;
  border-radius: 8px;
  padding: 12px;
  min-width: 280px;
  max-width: 320px;
  max-height: 400px;
  overflow-y: auto;
  color: #fff;
  font-family: 'Courier New', monospace;
}

#achievements-panel h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: #ffd700;
}

.achievement-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin-bottom: 4px;
  border-radius: 4px;
  border: 1px solid #333;
  background: rgba(255,255,255,0.03);
}

.achievement-item.achievement-unlocked {
  border-color: #ffd700;
  background: rgba(255, 215, 0, 0.08);
}

.achievement-item.achievement-locked {
  opacity: 0.5;
}

.achievement-icon {
  font-size: 18px;
  color: #ffd700;
  min-width: 24px;
  text-align: center;
}

.achievement-info {
  flex: 1;
}

.achievement-name {
  font-size: 12px;
  font-weight: bold;
  color: #eee;
}

.achievement-desc {
  font-size: 10px;
  color: #888;
}

.achievement-coins {
  font-size: 11px;
  color: #ffd700;
  font-weight: bold;
}

#leaderboard-toggle {
  padding: 8px 16px;
  font-size: 14px;
  background: #4a90d9;
  color: #fff;
  border: 1px solid #357abd;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 1px;
  pointer-events: auto;
  transition: background 0.2s;
  margin: 0;
}

#leaderboard-toggle:hover {
  background: #357abd;
}

#leaderboard-panel {
  position: fixed;
  bottom: 100px;
  right: 16px;
  z-index: 300;
  background: rgba(20, 20, 30, 0.95);
  border: 1px solid #444;
  border-radius: 8px;
  padding: 12px;
  min-width: 320px;
  max-width: 380px;
  max-height: 450px;
  overflow-y: auto;
  color: #fff;
  font-family: 'Courier New', monospace;
}

#leaderboard-panel h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: #4a90d9;
}

#leaderboard-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.leaderboard-tab {
  padding: 4px 10px;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  background: rgba(255,255,255,0.05);
  border: 1px solid #333;
  border-radius: 4px;
  color: #aaa;
  cursor: pointer;
  transition: all 0.2s;
}

.leaderboard-tab.active {
  background: #4a90d9;
  color: #fff;
  border-color: #4a90d9;
}

.leaderboard-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  margin-bottom: 3px;
  border-radius: 4px;
  border: 1px solid #333;
  background: rgba(255,255,255,0.03);
}

.leaderboard-entry:nth-child(1) {
  border-color: #ffd700;
  background: rgba(255, 215, 0, 0.1);
}

.leaderboard-entry:nth-child(2) {
  border-color: #c0c0c0;
  background: rgba(192, 192, 192, 0.08);
}

.leaderboard-entry:nth-child(3) {
  border-color: #cd7f32;
  background: rgba(205, 127, 50, 0.08);
}

.leaderboard-rank {
  min-width: 24px;
  font-size: 12px;
  font-weight: bold;
  color: #888;
  text-align: center;
}

.leaderboard-entry:nth-child(1) .leaderboard-rank { color: #ffd700; }
.leaderboard-entry:nth-child(2) .leaderboard-rank { color: #c0c0c0; }
.leaderboard-entry:nth-child(3) .leaderboard-rank { color: #cd7f32; }

.leaderboard-name {
  flex: 1;
  font-size: 12px;
  color: #eee;
}

.leaderboard-name .online-dot {
  color: #4caf50;
  font-size: 8px;
}

.leaderboard-score {
  font-size: 12px;
  color: #4a90d9;
  font-weight: bold;
}

#event-banner {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  background: linear-gradient(135deg, #e94560 0%, #ffd700 100%);
  color: #fff;
  padding: 8px 24px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  box-shadow: 0 2px 12px rgba(233, 69, 96, 0.4);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: eventSlideIn 0.3s ease-out;
  pointer-events: none;
}

@keyframes eventSlideIn {
  from { transform: translateX(-50%) translateY(-100%); }
  to { transform: translateX(-50%) translateY(0); }
}

#event-icon {
  font-size: 18px;
}

#event-name {
  font-size: 14px;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

#event-desc {
  font-weight: normal;
  font-size: 11px;
  opacity: 0.9;
}

#event-timer {
  font-size: 11px;
  background: rgba(0,0,0,0.2);
  padding: 2px 8px;
  border-radius: 4px;
}

#mail-toggle {
  padding: 8px 16px;
  font-size: 14px;
  background: #e94560;
  color: #fff;
  border: 1px solid #c1334d;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 1px;
  pointer-events: auto;
  transition: background 0.2s;
  margin: 0;
}

#mail-toggle:hover {
  background: #c1334d;
}

#mail-panel {
  position: fixed;
  bottom: 100px;
  right: 16px;
  z-index: 300;
  background: rgba(20, 20, 30, 0.95);
  border: 1px solid #444;
  border-radius: 8px;
  padding: 12px;
  min-width: 320px;
  max-width: 380px;
  max-height: 500px;
  overflow-y: auto;
  color: #fff;
  font-family: 'Courier New', monospace;
}

#mail-panel h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: #e94560;
}

#mail-compose {
  border-bottom: 1px solid #333;
  padding-bottom: 10px;
  margin-bottom: 10px;
}

#mail-compose .form-group {
  margin-bottom: 6px;
}

#mail-compose label {
  display: block;
  font-size: 10px;
  color: #888;
  margin-bottom: 2px;
}

#mail-compose input, #mail-compose textarea {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid #444;
  border-radius: 4px;
  color: #fff;
  padding: 6px 8px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  box-sizing: border-box;
}

#mail-compose textarea {
  resize: none;
}

#mail-send-btn {
  width: 100%;
  padding: 6px;
  background: #e94560;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  cursor: pointer;
}

#mail-send-btn:hover {
  background: #c1334d;
}

.mail-item {
  padding: 8px;
  margin-bottom: 6px;
  border-radius: 4px;
  border: 1px solid #333;
  background: rgba(255,255,255,0.03);
}

.mail-item.mail-unread {
  border-color: #e94560;
  background: rgba(233, 69, 96, 0.08);
}

.mail-from {
  font-size: 12px;
  font-weight: bold;
  color: #eee;
}

.mail-subject {
  font-size: 11px;
  color: #aaa;
  margin-top: 2px;
}

.mail-body {
  font-size: 11px;
  color: #ccc;
  margin-top: 4px;
  white-space: pre-wrap;
}

.mail-time {
  font-size: 10px;
  color: #666;
  margin-top: 4px;
}

.mail-actions {
  margin-top: 4px;
  display: flex;
  gap: 6px;
}

.mail-action-btn {
  padding: 2px 8px;
  font-size: 10px;
  font-family: 'Courier New', monospace;
  background: rgba(255,255,255,0.05);
  border: 1px solid #444;
  border-radius: 3px;
  color: #aaa;
  cursor: pointer;
}

.mail-action-btn:hover {
  background: rgba(255,255,255,0.1);
}

#player-context-menu {
  position: fixed;
  background: #16213e;
  border: 2px solid #0f3460;
  border-radius: 8px;
  z-index: 900;
  min-width: 160px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.context-menu-header {
  background: #0f3460;
  padding: 8px 12px;
  font-weight: bold;
  font-size: 13px;
  color: #e94560;
  text-align: center;
}

.context-menu-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  border-top: 1px solid #0f3460;
  color: #e0e0e0;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.context-menu-item:hover {
  background: #1a1a3e;
  color: #e94560;
}

.context-close:hover {
  background: #2a1a1e;
  color: #cc3333;
}

#profile-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #16213e;
  border: 2px solid #0f3460;
  border-radius: 12px;
  padding: 20px;
  min-width: 320px;
  max-width: 400px;
  z-index: 600;
  color: #e0e0e0;
  font-family: 'Courier New', monospace;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #0f3460;
}

.profile-header canvas {
  border-radius: 8px;
  border: 2px solid #533483;
  image-rendering: pixelated;
}

.profile-info {
  flex: 1;
}

.profile-info h3 {
  margin: 0 0 4px;
  font-size: 18px;
  color: #e94560;
}

.profile-role {
  display: inline-block;
  background: #ffd700;
  color: #1a1a2e;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 10px;
  text-transform: uppercase;
  font-weight: bold;
  margin-right: 4px;
}

.profile-status-text {
  font-size: 11px;
  color: #888;
  font-style: italic;
}

.profile-body {
  font-size: 13px;
}

.profile-field {
  margin-bottom: 10px;
}

.profile-field label {
  display: block;
  font-size: 10px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.profile-field p,
.profile-field span {
  color: #e0e0e0;
  word-wrap: break-word;
}

.profile-actions {
  display: flex;
  gap: 6px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.profile-action-btn {
  padding: 6px 12px;
  background: #0f3460;
  border: 1px solid #533483;
  border-radius: 4px;
  color: #e0e0e0;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.2s;
}

.profile-action-btn:hover {
  background: #533483;
}

#sound-toggle {
  padding: 8px 14px;
  font-size: 14px;
  background: #533483;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  pointer-events: auto;
  transition: background 0.2s;
  margin: 0;
}

#sound-toggle:hover {
  background: #3d2660;
}

#admin-toggle {
  padding: 8px 14px;
  font-size: 14px;
  background: #ffd700;
  color: #1a1a2e;
  border: 1px solid #e6c200;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  pointer-events: auto;
  transition: background 0.2s;
  font-weight: bold;
}

#admin-toggle:hover {
  background: #e6c200;
}

#admin-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #16213e;
  border: 2px solid #ffd700;
  border-radius: 12px;
  padding: 20px;
  min-width: 380px;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 600;
  color: #e0e0e0;
  font-family: 'Courier New', monospace;
}

#admin-panel h3 {
  color: #ffd700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.admin-tab {
  padding: 6px 14px;
  background: #0f3460;
  border: 1px solid #533483;
  border-radius: 4px 4px 0 0;
  color: #e0e0e0;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  cursor: pointer;
  margin-right: 4px;
}

.admin-tab.active {
  background: #533483;
  border-color: #e94560;
}

.admin-creation-item {
  padding: 10px;
  background: #0f3460;
  border: 1px solid #1a4a8a;
  border-radius: 6px;
  margin-bottom: 8px;
}

.admin-creation-info {
  margin-bottom: 8px;
  font-size: 12px;
}

.admin-creation-info strong {
  color: #e94560;
}

.admin-creation-actions {
  display: flex;
  gap: 6px;
}

.admin-approve-btn {
  padding: 4px 12px;
  background: #2d8a4e;
  border: 1px solid #1a6a3a;
  border-radius: 4px;
  color: #fff;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  cursor: pointer;
}

.admin-approve-btn:hover {
  background: #1a6a3a;
}

.admin-reject-btn {
  padding: 4px 12px;
  background: #8a2d2d;
  border: 1px solid #6a1a1a;
  border-radius: 4px;
  color: #fff;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  cursor: pointer;
}

.admin-reject-btn:hover {
  background: #6a1a1a;
}

.admin-player-item {
  padding: 6px 10px;
  background: #0f3460;
  border: 1px solid #1a4a8a;
  border-radius: 4px;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

#tutorial-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
}

.tutorial-box {
  background: #16213e;
  border: 2px solid #e94560;
  border-radius: 12px;
  padding: 24px;
  min-width: 300px;
  max-width: 420px;
  text-align: center;
  font-family: 'Courier New', monospace;
  color: #e0e0e0;
}

.tutorial-progress {
  margin-bottom: 12px;
}

#tutorial-step-indicator {
  font-size: 11px;
  color: #888;
  letter-spacing: 2px;
}

.tutorial-box h3 {
  color: #e94560;
  font-size: 18px;
  margin-bottom: 10px;
}

.tutorial-box p {
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 18px;
  color: #ccc;
}

.tutorial-nav {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.tutorial-skip-btn {
  padding: 8px 16px;
  background: #333;
  border: 1px solid #555;
  border-radius: 6px;
  color: #aaa;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  cursor: pointer;
}

.tutorial-next-btn {
  padding: 8px 20px;
  background: #e94560;
  border: 1px solid #c33;
  border-radius: 6px;
  color: #fff;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  cursor: pointer;
  font-weight: bold;
}

.tutorial-next-btn:hover {
  background: #c33;
}

#mobile-toolbar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #16213e;
  border-top: 2px solid #0f3460;
  padding: 4px 2px;
  z-index: 800;
  gap: 2px;
  justify-content: space-around;
}

.mobile-btn {
  background: #0f3460;
  border: 1px solid #1a4a8a;
  border-radius: 6px;
  color: #e0e0e0;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  padding: 8px 6px;
  cursor: pointer;
  flex: 1;
  max-width: 60px;
}

.mobile-btn:active {
  background: #e94560;
}

#mobile-more-menu {
  position: fixed;
  bottom: 50px;
  right: 4px;
  background: #16213e;
  border: 2px solid #0f3460;
  border-radius: 8px;
  z-index: 850;
  min-width: 120px;
  overflow: hidden;
}

.mobile-more-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  border-top: 1px solid #0f3460;
  color: #e0e0e0;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.mobile-more-item:hover {
  background: #1a1a3e;
  color: #e94560;
}

@media (max-width: 768px) {
  #mobile-toolbar {
    display: flex;
  }
  #controls-hint {
    display: none;
  }
  #hud-top {
    font-size: 10px;
    padding: 4px 8px;
  }
  .panel {
    min-width: 280px;
    max-width: 95vw;
    padding: 16px;
  }
  #chat-panel {
    height: 120px;
  }
}


