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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  color: black;
}

.screen {
  width: 100%;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.screen.hidden {
  display: none;
}


.username-container {
  background: white;
  padding: 2rem 3rem;
  border-radius: 20px;
  text-align: center;
}

.username-container h1 {
  margin-bottom: 2rem;
  font-size: 2.5rem;
}

.username-description {
  margin-bottom: 1rem;
}

#username-input {
  width: 100%;
  padding: 1rem;
  font-size: 1.2rem;
  border: 2px solid #ddd;
  border-radius: 10px;
  margin-bottom: 1.5rem;
  outline: none;
  transition: border-color 0.3s;
}

#username-input:focus {
  border-color: black;
}

#join-button {
  padding: 1rem 2rem;
  font-size: 1.2rem;
  background: black;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.3s, transform 0.1s;
}

#join-button:active {
  transform: translateY(0);
}


.game-container {
  display: grid;
  grid-template-columns: 250px 1fr;
  grid-template-rows: auto 1fr auto;
  gap: 1rem;
  width: 100%;
  max-width: 1200px;
  padding: 1rem;
  height: 100vh;
}

.player-list {
  grid-column: 1;
  grid-row: 2;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 15px;
  padding: 1rem;
  overflow-y: auto;
  border: black;
  border-style: solid;
}

.player-list h2 {
  margin-bottom: 1rem;
  color: black;
  font-size: 1.2rem;
}

.player-item {
  padding: 0.2rem 0 0.2rem 1rem;
  margin-bottom: 0.5rem;
  background: #f5f5f5;
  border-radius: 8px;
  border-left: 4px solid black;
}

.player-item.current {
  background: #e8eaf6;
  border-left-color: #4caf50;
}

.player-name {
  font-weight: bold;
}

#sidebar { 
  grid-column: 1; 
  grid-row: 1; 
  display: flex; 
  flex-direction: column; 
  gap: 1rem;
  border: black solid;
  border-radius: 15px;
  padding: 1rem;
}


#playing-field-container {
  grid-column: 2;
  grid-row: 1 / -1;
  position: relative;
  background: #2c3e50;
  border-radius: 15px;
  overflow: hidden;
  width: 100%;
  height: 100%;
  border: black; 
  border-style: solid;
}

#playing-field {
  width: 100%;
  height: 100%;
  display: block;
}

#game-info {
  grid-column: 2;
  grid-row: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-radius: 10px;
}

.current-player {
  font-weight: bold;
  color: black;
}

.game-status {
  color: black;
}


.avatar {
  position: absolute;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid #333;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.3s, transform 0.3s;
}


.avatar-name {
  position: absolute;
  top: -25px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
}

.avatar-crown {
  position: absolute;
  top: -45px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 20px;
  z-index: 6;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
  line-height: 1.1;
  text-align: center;
}


#color-palette {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 10px;
  margin-bottom: 1rem;
}

#color-palette h3 {
  margin-bottom: 0.75rem;
  font-size: 1rem;
  color: black;
}

.color-button {
  width: 40px;
  height: 40px;
  border: 3px solid #ccc;
  border-radius: 8px;
  margin: 4px;
  cursor: pointer;
  font-weight: bold;
  color: white;
  transition: transform 0.2s, border-color 0.2s;
}

.color-button:hover {
  transform: scale(1.1);
}

.color-button.selected {
  border-color: black;
  border-width: 4px;
  transform: scale(1.15);
}

#paint-progress {
  font-weight: bold;
  margin-bottom: 0.5rem;
  margin-top: 0.5rem;
  color: #333;
}

.progress-bar-container {
  width: 100%;
  height: 20px;
  background: #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 1rem;
}

#progress-bar {
  height: 100%;
  background:  #8bc34a;
  transition: width 0.5s ease;
  border-radius: 10px;
  width: 0%;
}

#paint-supply-bar {
  height: 100%;
  transition: width 0.3s ease, background 0.3s ease;
  border-radius: 10px;
  width: 100%;
  background:  #4caf50;
}

.paint-supply-container {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 10px;
}

#paint-supply {
  font-weight: bold;
  margin-bottom: 0.5rem;
  color: #333;
}

.instructions {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 10px;
  padding: 1rem;
  font-size: 0.85rem;
}


.player-color-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 6px;
  border: 2px solid #333;
}


#connection-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

#connection-overlay.hidden {
  display: none;
}

.connection-overlay-content {
  background: white;
  padding: 2rem 3rem;
  border-radius: 15px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.connection-overlay-content p {
  margin: 1rem 0;
  font-size: 1.1rem;
  color: #333;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e0e0e0;
  border-top-color: #333;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#reconnect-button {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  background: #333;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.3s;
}

#reconnect-button:hover {
  background: #555;
}

#reconnect-button.hidden {
  display: none;
}


#gold-display {
  font-weight: bold;
  text-align: center;
  display: inline;
  margin-left: 1rem;
}


#shop-container {
  position: relative;
}

#shop-button {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: bold;
  background: #764ba2;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  border: black solid;
  transition: transform 0.2s, box-shadow 0.2s;
}

#shop-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.6);
}

#shop-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 800px;
  background: rgba(255, 255, 255, 0.98);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}

#shop-panel.hidden {
  display: none;
}

#shop-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 999;
  backdrop-filter: blur(2px);
}

#shop-backdrop.hidden {
  display: none;
}

.shop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #eee;
}

.shop-header h3 {
  margin: 0;
  color: #333;
  font-size: 2rem;
}

.shop-close {
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: #666;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  transition: background 0.2s;
  line-height: 1;
}

.shop-close:hover {
  background: #f0f0f0;
}

.shop-message {
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 1.1rem;
  text-align: center;
}

.shop-message.success {
  background: #d4edda;
  color: #155724;
}

.shop-message.error {
  background: #f8d7da;
  color: #721c24;
}

.shop-message.hidden {
  display: none;
}

#shop-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 60vh;
  padding-right: 0.5rem;
}

#shop-items::-webkit-scrollbar {
  width: 8px;
}

#shop-items::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

#shop-items::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

#shop-items::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.shop-item {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.75rem;
  background: #f8f9fa;
  border-radius: 8px;
  border: black solid;

  min-height: 180px;
}

.shop-item-info {
  flex: 1;
  margin-bottom: 0.75rem;
}

.shop-item-name {
  font-weight: bold;
  color: #333;
  font-size: 1rem;
  margin-bottom: 0.4rem;
}

.shop-item-desc {
  color: #666;
  font-size: 0.75rem;
  margin-bottom: 0.4rem;
  line-height: 1.3;
}

.shop-item-level {
  color: #888;
  font-size: 0.7rem;
  margin-bottom: 0.2rem;
}

.shop-item-effect {
  color: #4caf50;
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.3;
}

.shop-buy-btn {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-weight: bold;
  background: #ffb800;
  color: black;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  width: 100%;
}

.shop-buy-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(255, 215, 0, 0.5);
}

.shop-buy-btn.disabled {
  background: #ccc;
  color: #888;
  cursor: not-allowed;
}

.shop-buy-btn.maxed {
  background: linear-gradient(135deg, #4caf50, #8bc34a);
  color: white;
  cursor: default;
}

