/* ==================== BJJ FIGHTER - STYLES ==================== */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a28;
  --bg-card-hover: #22223a;
  --text-primary: #e8e8f0;
  --text-secondary: #8888a0;
  --text-muted: #555570;
  --accent: #e11d48;
  --accent-glow: rgba(225, 29, 72, 0.3);
  --gold: #f59e0b;
  --green: #22c55e;
  --blue: #3b82f6;
  --red: #ef4444;
  --purple: #8b5cf6;
  --border: #2a2a3a;
  --radius: 12px;
  --radius-sm: 8px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* ==================== LANDING SCREEN ==================== */

.landing-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.landing-bg-pattern {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(225, 29, 72, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(139, 92, 246, 0.06) 0%, transparent 50%);
  pointer-events: none;
}

.landing-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  max-width: 400px;
  width: 100%;
}

.logo-area {
  text-align: center;
}

.logo-icon {
  font-size: 64px;
  margin-bottom: 12px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.game-title {
  font-size: 48px;
  font-weight: 900;
  letter-spacing: -2px;
  line-height: 1;
}

.title-accent {
  color: var(--accent);
}

.game-subtitle {
  color: var(--text-secondary);
  font-size: 16px;
  margin-top: 8px;
}

.belt-display-landing {
  display: flex;
  gap: 8px;
}

.mini-belt {
  width: 40px;
  height: 8px;
  border-radius: 4px;
  display: block;
}

.landing-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 15px;
}

.feature-icon {
  font-size: 20px;
}

.landing-footer {
  color: var(--text-muted);
  font-size: 13px;
}

/* ==================== BUTTONS ==================== */

.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 14px 32px;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s;
  letter-spacing: 0.5px;
}

.btn-primary:active {
  transform: scale(0.97);
  opacity: 0.9;
}

.btn-large {
  padding: 18px 32px;
  font-size: 19px;
}

.pulse-glow {
  animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 20px var(--accent-glow); }
  50% { box-shadow: 0 0 40px var(--accent-glow), 0 0 60px rgba(225, 29, 72, 0.15); }
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 14px 32px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s;
}

.btn-secondary:active {
  background: var(--bg-card-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 15px;
  cursor: pointer;
}

.btn-back {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 8px 0;
  font-size: 15px;
  cursor: pointer;
}

/* ==================== CREATE SCREEN ==================== */

.create-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.create-card {
  max-width: 380px;
  width: 100%;
  text-align: center;
}

.create-icon {
  font-size: 56px;
  margin-bottom: 16px;
}

.create-card h2 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
}

.create-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 24px;
}

.input-group {
  position: relative;
  margin-bottom: 20px;
}

.input-field {
  width: 100%;
  padding: 16px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s;
}

.input-field:focus {
  border-color: var(--accent);
}

.input-field::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.char-count {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
}

.starting-belt {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 24px;
}

.belt-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.belt-info {
  color: var(--text-secondary);
  font-size: 13px;
}

/* ==================== FIGHT SCREEN ==================== */

.fight-screen {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  padding-top: calc(8px + var(--safe-top));
  padding-bottom: calc(8px + var(--safe-bottom));
  gap: 6px;
}

.fight-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fight-quit {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-muted);
  padding: 0;
}

.round-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.round-badge {
  background: var(--bg-card);
  padding: 4px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.round-score {
  display: flex;
  gap: 8px;
  font-size: 18px;
  font-weight: 800;
}

.score-p { color: var(--green); }
.score-sep { color: var(--text-muted); }
.score-o { color: var(--red); }

.fighters-area {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.fighter-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.fighter-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fighter-label {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.belt-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.health-bar-container, .stamina-bar-container {
  position: relative;
  height: 16px;
  background: #1a1a2a;
  border-radius: 8px;
  overflow: hidden;
}

.stamina-bar-container {
  height: 10px;
}

.health-bar {
  height: 100%;
  border-radius: 8px;
  transition: width 0.4s ease;
}

.stamina-bar {
  height: 100%;
  background: var(--blue);
  border-radius: 6px;
  transition: width 0.4s ease;
}

.bar-label {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  white-space: nowrap;
}

/* ==================== FIGHTER SPRITES ==================== */

.fighters-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-shrink: 0;
  min-width: 120px;
}

.fighter-sprite {
  transition: transform 0.3s ease;
}

.fighter-sprite.attacking {
  animation: attackAnim 0.4s ease;
}

.fighter-sprite.hit {
  animation: hitAnim 0.4s ease;
}

@keyframes attackAnim {
  0% { transform: translateX(0); }
  30% { transform: translateX(10px) scale(1.05); }
  100% { transform: translateX(0); }
}

.fighter-opponent.attacking {
  animation: attackAnimReverse 0.4s ease;
}

@keyframes attackAnimReverse {
  0% { transform: translateX(0); }
  30% { transform: translateX(-10px) scale(1.05); }
  100% { transform: translateX(0); }
}

@keyframes hitAnim {
  0% { filter: brightness(1); }
  20% { filter: brightness(2) hue-rotate(20deg); }
  100% { filter: brightness(1); }
}

.fighter-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.fighter-head {
  width: 24px;
  height: 24px;
  background: #d4a57b;
  border-radius: 50%;
  border: 2px solid #c4956b;
}

.fighter-gi {
  width: 32px;
  height: 28px;
  background: #e8e8e8;
  border-radius: 4px 4px 2px 2px;
  border-bottom: 3px solid;
  position: relative;
}

.opponent-body .fighter-gi {
  background: #d0d0d0;
}

.fighter-belt {
  width: 30px;
  height: 6px;
  border-radius: 2px;
}

.fighter-legs {
  display: flex;
  gap: 4px;
}

.fighter-legs::before, .fighter-legs::after {
  content: '';
  width: 10px;
  height: 20px;
  background: #2a2a3a;
  border-radius: 2px;
}

.vs-indicator {
  font-size: 14px;
  font-weight: 900;
  color: var(--accent);
  opacity: 0.7;
}

/* ==================== EXCHANGE FLASH ==================== */

.exchange-flash {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 16px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 50;
}

.exchange-flash.show {
  opacity: 1;
}

/* ==================== LAST EXCHANGE ==================== */

.last-exchange {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  min-height: 36px;
}

.exchange-vs {
  color: var(--text-muted);
  font-size: 12px;
}

.adv-player { color: var(--green); }
.adv-opponent { color: var(--red); }

.pick-prompt {
  color: var(--text-secondary);
  font-weight: 500;
}

/* ==================== MOVES GRID ==================== */

.moves-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  flex-shrink: 0;
  padding-bottom: var(--safe-bottom);
}

.move-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 72px;
  justify-content: center;
}

.move-btn:active:not(.disabled) {
  transform: scale(0.95);
  border-color: var(--accent);
  background: var(--bg-card-hover);
}

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

.move-btn.submission { border-color: rgba(239, 68, 68, 0.3); }
.move-btn.positional { border-color: rgba(59, 130, 246, 0.3); }
.move-btn.defensive { border-color: rgba(34, 197, 94, 0.3); }

.move-btn.submission:active:not(.disabled) { border-color: var(--red); background: rgba(239, 68, 68, 0.1); }
.move-btn.positional:active:not(.disabled) { border-color: var(--blue); background: rgba(59, 130, 246, 0.1); }
.move-btn.defensive:active:not(.disabled) { border-color: var(--green); background: rgba(34, 197, 94, 0.1); }

.move-icon {
  font-size: 20px;
}

.move-name {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1.1;
  text-align: center;
}

.move-cost {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
}

/* ==================== RESULT SCREEN ==================== */

.result-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 16px;
}

.result-win { background: radial-gradient(circle at 50% 30%, rgba(34, 197, 94, 0.08), transparent 60%); }
.result-loss { background: radial-gradient(circle at 50% 30%, rgba(239, 68, 68, 0.08), transparent 60%); }

.promotion-banner {
  text-align: center;
  position: relative;
  padding: 24px;
  animation: promoIn 0.6s ease;
}

@keyframes promoIn {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.promo-glow {
  position: absolute;
  inset: -20px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.2), transparent 70%);
  border-radius: 50%;
  animation: promoGlow 2s ease-in-out infinite;
}

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

.promo-icon {
  font-size: 48px;
  position: relative;
}

.promo-title {
  font-size: 28px;
  font-weight: 900;
  color: var(--gold);
  position: relative;
  letter-spacing: 2px;
}

.promo-belt {
  margin-top: 8px;
  position: relative;
}

.belt-badge-large {
  display: inline-block;
  padding: 8px 24px;
  border-radius: 24px;
  font-size: 18px;
  font-weight: 800;
  color: white;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.result-card {
  max-width: 380px;
  width: 100%;
}

.result-header {
  text-align: center;
  margin-bottom: 20px;
}

.result-icon {
  font-size: 48px;
}

.result-title {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 1px;
}

.result-win .result-title { color: var(--green); }
.result-loss .result-title { color: var(--red); }

.result-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  margin-top: 4px;
}

.result-stats {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-value {
  font-weight: 700;
}

.xp-value {
  color: var(--gold);
}

.xp-progress-section {
  margin-bottom: 16px;
}

.xp-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.xp-bar-container {
  height: 10px;
  background: #1a1a2a;
  border-radius: 6px;
  overflow: hidden;
}

.xp-bar {
  height: 100%;
  border-radius: 6px;
  transition: width 0.6s ease;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ==================== PROFILE SCREEN ==================== */

.profile-screen, .leaderboard-screen, .fight-menu-screen {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 16px;
  padding-top: calc(16px + var(--safe-top));
  max-width: 500px;
  margin: 0 auto;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.profile-header h2 {
  font-size: 20px;
  font-weight: 800;
}

.profile-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px 16px;
  border: 1px solid var(--border);
}

.profile-avatar {
  text-align: center;
  margin-bottom: 20px;
}

.avatar-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid;
  font-size: 36px;
  background: var(--bg-secondary);
  margin-bottom: 8px;
}

.profile-name {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 6px;
}

.belt-journey {
  margin-bottom: 16px;
}

.belt-journey h4 {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.belts-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.belt-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.belt-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
}

.belt-step.locked .belt-circle {
  color: #555;
  font-size: 10px;
}

.belt-step-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
}

.belt-step.achieved .belt-step-label {
  color: var(--text-secondary);
}

.belt-connector {
  width: 12px;
  height: 2px;
  background: var(--border);
  margin-bottom: 18px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.stat-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
}

.stat-number {
  display: block;
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

/* ==================== FIGHT MENU ==================== */

.menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.menu-player-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.menu-name {
  font-size: 18px;
  font-weight: 800;
}

.menu-record {
  color: var(--text-secondary);
  font-weight: 700;
}

.menu-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.menu-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all 0.2s;
}

.menu-btn:active {
  background: var(--bg-card-hover);
  border-color: var(--accent);
}

.menu-btn.fight-btn {
  border-color: rgba(225, 29, 72, 0.3);
}

.menu-btn-icon {
  font-size: 28px;
}

.menu-btn-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.menu-btn-text strong {
  font-size: 16px;
}

.menu-btn-text small {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ==================== LEADERBOARD ==================== */

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.leaderboard-row.is-you {
  border-color: var(--accent);
  background: rgba(225, 29, 72, 0.05);
}

.lb-rank {
  font-size: 16px;
  font-weight: 800;
  width: 36px;
  text-align: center;
  flex-shrink: 0;
}

.lb-name {
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-record {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
}

.lb-xp {
  font-size: 13px;
  color: var(--gold);
  font-weight: 700;
  min-width: 48px;
  text-align: right;
}

/* ==================== LOADING ==================== */

.loading-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-secondary);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
}

/* ==================== TOAST ==================== */

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 700;
  z-index: 100;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-info {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.toast-error {
  background: rgba(239, 68, 68, 0.9);
  color: white;
}

/* ==================== SHAKE ANIMATION ==================== */

.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 360px) {
  .moves-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
  }

  .move-btn {
    padding: 8px 2px;
    min-height: 64px;
  }

  .move-icon { font-size: 18px; }
  .move-name { font-size: 9px; }
  .game-title { font-size: 40px; }
}

@media (min-height: 750px) {
  .fighters-visual {
    padding: 8px 0;
  }

  .fighter-head {
    width: 28px;
    height: 28px;
  }

  .fighter-gi {
    width: 38px;
    height: 32px;
  }

  .fighter-belt {
    width: 36px;
    height: 7px;
  }

  .move-btn {
    padding: 12px 4px;
    min-height: 80px;
  }
}
