/* Playing to Learn Battle - Main Styles */

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --secondary: #10b981;
  --danger: #ef4444;
  --bg: #0f172a;
  --bg-card: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --success: #22c55e;
  --warning: #f59e0b;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
}

h1, h2, h3 {
  font-weight: 600;
}

h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

/* Layout */
main {
  width: 100%;
  max-width: 480px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

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

.btn-secondary:hover:not(:disabled) {
  background: #059669;
}

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

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--text);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

.btn-block {
  width: 100%;
}

/* Round images */
.round-image {
  max-width: 300px;
  max-height: 200px;
  margin: 1rem auto;
  display: block;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.round-image.flag {
  border: 2px solid var(--border);
}

.round-image.silhouette {
  border: 2px solid var(--border);
  background: var(--bg);
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-input.input-lg {
  padding: 1rem;
  font-size: 1.25rem;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.25em;
}

/* Room Code Display */
.room-code {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-align: center;
  color: var(--primary);
  background: var(--bg);
  padding: 1rem;
  border-radius: 8px;
  font-family: 'Monaco', 'Consolas', monospace;
}

.room-code.clickable {
  cursor: pointer;
  transition: all 0.15s ease;
}

.room-code.clickable:hover {
  background: var(--primary);
  color: white;
}

.room-code-label {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

/* Player List */
.player-list {
  list-style: none;
}

.player-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.player-item:last-child {
  margin-bottom: 0;
}

.player-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.player-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
}

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

.player-badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  background: var(--primary);
  color: white;
}

.player-badge.host {
  background: var(--warning);
  color: var(--bg);
}

.player-badge.you {
  background: var(--secondary);
}

/* Status */
.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  background: var(--bg);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status.connected .status-dot {
  background: var(--success);
}

.status.connecting .status-dot {
  background: var(--warning);
  animation: pulse 1s infinite;
}

.status.disconnected .status-dot {
  background: var(--danger);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Error Message */
.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

/* Loading */
.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Utility Classes */
.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-muted);
}

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

.hidden {
  display: none !important;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 2rem;
}

.header h1 {
  color: var(--primary);
}

.header p {
  color: var(--text-muted);
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Lobby specific */
.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.waiting-text {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 1rem;
}

.player-count {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* Timer urgency */
.timer-urgent {
  color: var(--danger);
  animation: timer-pulse 0.5s ease-in-out infinite;
}

.timer-urgent #timerValue {
  font-weight: 700;
  font-size: 1.25em;
}

@keyframes timer-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Small spinner for buttons */
.spinner-small {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 0.5rem;
  vertical-align: middle;
}

/* Score animation */
@keyframes score-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); color: var(--success); }
  100% { transform: scale(1); }
}

.score-changed {
  animation: score-pop 0.4s ease-out;
}

/* Round type styling */
.round-kind-calc {
  background: var(--primary);
}

.round-kind-word {
  background: var(--warning);
  color: var(--bg);
}

.round-kind-flag {
  background: var(--secondary);
}

.round-kind-silhouette {
  background: var(--success);
  color: var(--bg);
}

/* Prompt styling by round type */
.prompt-calc {
  font-size: 1.75rem;
  min-height: 2.5rem;
  font-family: 'Monaco', 'Consolas', monospace;
}

.prompt-word {
  font-size: 2.5rem;
  min-height: 3rem;
  font-family: 'Monaco', 'Consolas', monospace;
  letter-spacing: 0.15em;
  text-transform: lowercase;
}

.prompt-flag {
  font-size: 1.5rem;
  min-height: 2rem;
  font-weight: 500;
}

.prompt-silhouette {
  font-size: 1.5rem;
  min-height: 2rem;
  font-weight: 500;
}

/* Letter buttons for word rounds */
.btn-letter {
  width: 80px;
  height: 80px;
  font-size: 2rem;
  font-weight: 700;
  text-transform: uppercase;
  border-radius: 12px;
}

/* Horizontal layout helper */
.justify-center {
  justify-content: center;
}

/* History link */
.history-link {
  display: inline-block;
  margin-top: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.15s ease;
}

.history-link:hover {
  color: var(--primary);
}
