/* ===== CSS Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Indie Flower', cursive;
  background: #ffffff;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  color: #000;
}

/* ===== App Container ===== */
#app {
  width: 100%;
  max-width: 600px;
}

/* ===== Screen Management ===== */
.screen {
  display: none;
  background: #ffffff;
  padding: 40px 30px;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 25px;
}

/* ===== Typography ===== */
.logo {
  height: 160px;
  width: auto;
  display: block;
  margin: 0 auto;
}

.app-title {
  font-family: 'Permanent Marker', cursive;
  font-size: 3rem;
  color: #000;
  margin: 0;
  text-align: center;
}

.screen-subtitle {
  font-family: 'Permanent Marker', cursive;
  font-size: 1.5rem;
  color: #000;
  margin: 0;
}

/* ===== Creation Container ===== */
.creation-container {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  width: 100%;
  justify-content: center;
  position: relative;
}

/* ===== Color Palette ===== */
.color-palette {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: absolute;
  left: 0;
}

.color-option {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  border: 2px solid #000;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.color-option:hover {
  transform: scale(1.05);
}

.color-option.active {
  border-width: 4px;
  box-shadow: inset 0 0 0 3px white;
}

/* Color backgrounds are set dynamically via inline styles from constants.js */

/* ===== Canvas Container ===== */
.canvas-container {
  position: relative;
  background: white;
  padding: 10px;
  border: 3px dashed #000;
  border-radius: 8px;
  margin: 0 auto;
}

#draw-canvas {
  display: block;
  cursor: crosshair;
  background: white;
  touch-action: none;
}

/* Canvas action buttons (reset, random blob, etc.) */
.canvas-action-btn {
  position: absolute;
  top: 15px;
  background: white;
  border: 2px solid #000;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 1.3rem;
  color: #000;
  z-index: 10;
}

#random-blob-btn {
  right: 65px; /* Position to the left of reset button */
}

#reset-canvas {
  right: 15px;
}

.canvas-action-btn:hover {
  background: #f0f0f0;
}

.canvas-action-btn:active {
  transform: scale(0.95);
}

/* Canvas Toast */
.canvas-toast {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border: 3px solid #000;
  border-radius: 20px;
  padding: 12px 24px;
  font-family: 'Permanent Marker', cursive;
  font-size: 1.2rem;
  color: #000;
  box-shadow: 4px 4px 0px #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 100;
}

.canvas-toast.show {
  opacity: 1;
  animation: toastBounce 0.5s ease;
}

@keyframes toastBounce {
  0% {
    transform: translate(-50%, -50%) scale(0.8);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.05);
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
  }
}

/* ===== Tool Container ===== */
.tool-container {
  display: flex;
  gap: 15px;
  justify-content: center;
}

.tool-btn {
  width: 45px;
  height: 45px;
  background: white;
  border: 2px solid #000;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: #000;
}

.tool-btn:hover {
  transform: scale(1.05);
}

.tool-btn.active {
  background: #000;
  color: #fff;
}

/* ===== Input Container ===== */
.input-container {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.character-input {
  width: 100%;
  padding: 12px 20px;
  font-family: 'Indie Flower', cursive;
  font-size: 1.2rem;
  border: 2px solid #000;
  border-radius: 25px;
  background: white;
  transition: all 0.15s ease;
  text-align: center;
}

.character-input:focus {
  outline: none;
  border-width: 3px;
}

.character-input::placeholder {
  color: #999;
}

/* ===== Buttons ===== */
.primary-btn {
  font-family: 'Permanent Marker', cursive;
  font-size: 1.3rem;
  padding: 12px 32px;
  background: white;
  color: #000;
  border: 2px solid #000;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.primary-btn:hover:not(:disabled) {
  background: #f0f0f0;
}

.primary-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.primary-btn:disabled {
  color: #ccc;
  border-color: #ccc;
  cursor: not-allowed;
}

/* ===== Error Message ===== */
.error-message {
  font-family: 'Indie Flower', cursive;
  font-size: 1.1rem;
  color: #000;
  text-align: center;
  padding: 10px;
  border-radius: 8px;
  border: 2px solid #000;
  display: none;
  min-height: 20px;
  background: white;
}

.error-message.show {
  display: block;
}

/* ===== Loading Screen ===== */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 40px 0;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 3px solid #e0e0e0;
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading-text {
  font-family: 'Permanent Marker', cursive;
  font-size: 1.5rem;
  color: #000;
  text-align: center;
}

.loading-subtext {
  font-size: 1.2rem;
  color: #666;
  text-align: center;
}

/* ===== Placeholder Text ===== */
.placeholder-text {
  font-family: 'Permanent Marker', cursive;
  font-size: 1.5rem;
  color: #000;
  text-align: center;
}

/* ===== Battle Screen ===== */
.round-title {
  font-family: 'Permanent Marker', cursive;
  font-size: 2rem;
  color: #000;
  text-align: center;
  margin: 0 0 30px 0;
}

.battle-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
  width: 100%;
  max-width: 800px;
}

.fighter-display {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: relative;
}

.fighter-display.attacking {
  animation: attackPulse 0.4s ease;
}

@keyframes attackPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.health-bar-container {
  width: 100%;
  max-width: 200px;
  height: 20px;
  border: 2px solid #000;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.health-bar {
  height: 100%;
  background: #000;
  width: 100%;
  transition: width 0.3s ease;
}

.health-text {
  font-family: 'Indie Flower', cursive;
  font-size: 0.9rem;
  color: #666;
}

.fighter-image {
  width: 150px;
  height: 150px;
  object-fit: contain;
  background: white;
}

.fighter-image.with-frame {
  border: 2px solid #000;
  border-radius: 8px;
}

.fighter-name {
  font-family: 'Permanent Marker', cursive;
  font-size: 1.2rem;
  color: #000;
  text-align: center;
  max-width: 200px;
  word-wrap: break-word;
}

.vs-text {
  font-family: 'Permanent Marker', cursive;
  font-size: 2rem;
  color: #000;
  flex-shrink: 0;
}

/* Damage and Miss Text */
.damage-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Permanent Marker', cursive;
  font-size: 1.5rem;
  color: #ff0000;
  animation: damageFloat 0.8s ease-out forwards;
  pointer-events: none;
  z-index: 10;
}

.miss-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Permanent Marker', cursive;
  font-size: 1.5rem;
  color: #999;
  animation: damageFloat 0.8s ease-out forwards;
  pointer-events: none;
  z-index: 10;
}

@keyframes damageFloat {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -100px);
  }
}

/* ===== Battle Chat ===== */
.battle-chat-container {
  width: 100%;
  max-width: 600px;
  margin-top: 20px;
}

.battle-chat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
}

.chat-message {
  padding: 10px 14px;
  background: white;
  border: 2px solid #000;
  border-radius: 15px;
  font-family: 'Indie Flower', cursive;
  font-size: 1rem;
  transition: opacity 0.3s ease;
  animation: messageSlideIn 0.3s ease;
  color: #000;
  max-width: 70%;
}

.chat-message.player {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-message.opponent {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

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

/* ===== Victory Screen ===== */
.victory-title {
  font-family: 'Permanent Marker', cursive;
  font-size: 4rem;
  color: #000;
  text-align: center;
  margin: 0;
}

.victory-image {
  width: 200px;
  height: 200px;
  object-fit: contain;
  border: 3px solid #000;
  border-radius: 12px;
  background: white;
}

.elo-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
}

.elo-change {
  font-family: 'Permanent Marker', cursive;
  font-size: 2rem;
  color: #4CAF50;
  font-weight: bold;
}

.elo-total {
  font-family: 'Indie Flower', cursive;
  font-size: 1.3rem;
  color: #666;
}

.victory-stats {
  font-family: 'Indie Flower', cursive;
  font-size: 1.3rem;
  color: #666;
  text-align: center;
}

/* ===== Responsive Design ===== */
@media (max-width: 600px) {
  .app-title {
    font-size: 2.5rem;
  }
  
  .screen-subtitle {
    font-size: 1.2rem;
  }
  
  .color-option {
    width: 40px;
    height: 40px;
  }
  
  #draw-canvas {
    width: 100%;
    height: auto;
    max-width: 300px;
  }
  
  .screen {
    padding: 30px 20px;
  }
  
  /* Creation screen responsive */
  .creation-container {
    flex-direction: column;
    align-items: center;
  }
  
  .color-palette {
    position: static;
    flex-direction: row;
  }
  
  /* Battle screen responsive */
  .battle-container {
    gap: 20px;
  }
  
  .fighter-image {
    width: 100px;
    height: 100px;
  }
  
  .fighter-name {
    font-size: 1rem;
  }
  
  .vs-text {
    font-size: 1.5rem;
  }
  
  .round-title {
    font-size: 1.5rem;
  }
  
  .health-bar-container {
    max-width: 120px;
  }
  
  /* Victory screen responsive */
  .victory-title {
    font-size: 3rem;
  }
  
  .victory-image {
    width: 150px;
    height: 150px;
  }
}

