@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap');

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

:root {
  --green: #4CAF50;
  --green-dark: #388E3C;
  --blue: #2196F3;
  --blue-dark: #1565C0;
  --orange: #FF9800;
  --pink: #E91E63;
  --purple: #9C27B0;
  --yellow: #FFC107;
  --bg: #F0F7FF;
  --card: #FFFFFF;
  --text: #333333;
  --text-light: #666666;
  --shadow: 0 4px 12px rgba(0,0,0,0.1);
  --radius: 16px;
}

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ========== LANDING PAGE ========== */
.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #E8F5E9 0%, #E3F2FD 50%, #F3E5F5 100%);
}

.logo {
  text-align: center;
  margin-bottom: 30px;
}

.logo h1 {
  font-size: 2.8em;
  font-weight: 800;
  background: linear-gradient(135deg, var(--green), var(--blue), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.logo .subtitle {
  font-size: 1.2em;
  color: var(--text-light);
  margin-top: 5px;
}

.logo .emoji-row {
  font-size: 2em;
  margin-top: 10px;
  letter-spacing: 8px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px;
  width: 100%;
  max-width: 420px;
  margin-bottom: 20px;
}

.card h2 {
  font-size: 1.4em;
  margin-bottom: 15px;
  text-align: center;
  color: var(--text);
}

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 1em;
}

.form-group input {
  width: 100%;
  padding: 14px 16px;
  font-size: 1.1em;
  font-family: 'Nunito', sans-serif;
  border: 2px solid #E0E0E0;
  border-radius: 12px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--blue);
}

.form-group input::placeholder {
  color: #BDBDBD;
}

/* Character selection */
.character-select {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.character-option {
  width: 100%;
  aspect-ratio: 1;
  border: 3px solid #E0E0E0;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6em;
  transition: all 0.2s;
  background: white;
}

.character-option:hover {
  border-color: var(--blue);
  transform: scale(1.05);
}

.character-option.selected {
  border-color: var(--green);
  background: #E8F5E9;
  transform: scale(1.08);
}

/* Avatar builder selections */
.tone-option:hover, .acc-option:hover, .tag-option:hover {
  transform: scale(1.1);
  transition: all 0.15s;
}
.tone-option.selected { border-color: #aaa !important; }
.acc-option.selected { border-color: var(--green) !important; }
.tag-option.selected { border-color: #aaa !important; }

.btn {
  display: block;
  width: 100%;
  padding: 16px 24px;
  font-size: 1.2em;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.btn:active {
  transform: translateY(0);
}

.btn-green {
  background: var(--green);
  color: white;
}

.btn-green:hover {
  background: var(--green-dark);
}

.btn-blue {
  background: var(--blue);
  color: white;
}

.btn-blue:hover {
  background: var(--blue-dark);
}

.btn-orange {
  background: var(--orange);
  color: white;
}

.divider {
  text-align: center;
  margin: 20px 0;
  color: var(--text-light);
  font-weight: 600;
}

.room-code-display {
  text-align: center;
  padding: 20px;
  background: #F5F5F5;
  border-radius: 12px;
  margin-bottom: 15px;
}

.room-code-display .code {
  font-size: 2.5em;
  font-weight: 800;
  letter-spacing: 6px;
  color: var(--blue);
  font-family: monospace;
}

.room-code-display .hint {
  font-size: 0.9em;
  color: var(--text-light);
  margin-top: 8px;
}

.copy-btn {
  display: inline-block;
  padding: 8px 20px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 8px;
  font-family: 'Nunito', sans-serif;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
  font-size: 0.95em;
}

.waiting-dots {
  display: inline-block;
  animation: dots 1.5s steps(3, end) infinite;
}

@keyframes dots {
  0% { content: ''; }
  33% { content: '.'; }
  66% { content: '..'; }
  100% { content: '...'; }
}

.players-list {
  list-style: none;
  margin: 10px 0;
}

.players-list li {
  padding: 8px 12px;
  background: #F5F5F5;
  border-radius: 8px;
  margin-bottom: 6px;
  font-weight: 600;
}

.error-msg {
  color: #D32F2F;
  text-align: center;
  margin: 10px 0;
  font-weight: 600;
}

.hidden {
  display: none !important;
}

/* ========== GAME PAGE ========== */
.game-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a2e;
  position: relative;
  overflow: hidden;
}

#gameCanvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  max-width: 100vw;
  max-height: 100vh;
}

/* Touch controls overlay */
.touch-controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 200px;
  pointer-events: none;
  display: none;
  z-index: 10;
}

.touch-controls.active {
  display: block;
}

.dpad {
  position: absolute;
  bottom: 30px;
  left: 30px;
  width: 150px;
  height: 150px;
  pointer-events: auto;
}

.dpad-btn {
  position: absolute;
  width: 50px;
  height: 50px;
  background: rgba(255,255,255,0.3);
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5em;
  color: white;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.dpad-btn:active {
  background: rgba(255,255,255,0.5);
}

.dpad-up { top: 0; left: 50px; }
.dpad-down { bottom: 0; left: 50px; }
.dpad-left { top: 50px; left: 0; }
.dpad-right { top: 50px; right: 0; }

.action-btn {
  position: absolute;
  bottom: 50px;
  right: 40px;
  width: 70px;
  height: 70px;
  background: rgba(76, 175, 80, 0.6);
  border: 3px solid rgba(76, 175, 80, 0.8);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8em;
  color: white;
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
}

.action-btn:active {
  background: rgba(76, 175, 80, 0.9);
}

/* End game overlay */
.game-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.end-game-card {
  background: white;
  border-radius: 20px;
  padding: 30px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  text-align: center;
}

.end-game-card h2 {
  font-size: 1.8em;
  margin-bottom: 20px;
  background: linear-gradient(135deg, var(--green), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.player-result {
  background: #F5F5F5;
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 10px;
  text-align: left;
}

.player-result .name {
  font-weight: 700;
  font-size: 1.1em;
}

.player-result .title {
  color: var(--purple);
  font-weight: 600;
  font-size: 0.9em;
}

.player-result .stats {
  display: flex;
  gap: 15px;
  margin-top: 8px;
  font-size: 0.9em;
  color: var(--text-light);
}

/* Responsive */
@media (max-width: 480px) {
  .logo h1 {
    font-size: 2em;
  }

  .card {
    padding: 20px;
    margin: 0 10px 15px;
  }

  .btn {
    padding: 14px 20px;
    font-size: 1.1em;
  }

  .character-select {
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
  }

  .character-option {
    font-size: 1.3em;
  }
}
