:root {
  --bg: #0f1220;
  --bg-card: #1a1e33;
  --text: #eef0f8;
  --text-dim: #a3a8c2;
  --accent: #4caf50;
  --accent-2: #ffd54f;
  --danger: #ef5350;
  --border: #2a2f4a;
  --radius: 14px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5fb;
    --bg-card: #ffffff;
    --text: #1a1e33;
    --text-dim: #5a5f7a;
    --border: #e1e3f0;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 40px;
}

.app-header {
  background: linear-gradient(135deg, #1e3a8a, #4c1d95);
  padding: 28px 20px;
  color: white;
}

.header-content {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
}

.avatar {
  font-size: 52px;
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
}

.header-text h1 {
  margin: 0 0 6px 0;
  font-size: 24px;
}

.belt {
  height: 18px;
  width: 160px;
  border-radius: 4px;
  position: relative;
  border: 1px solid rgba(0,0,0,0.2);
}

.belt::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 24px;
  background: repeating-linear-gradient(
    90deg,
    #000 0px, #000 3px, transparent 3px, transparent 6px
  );
}

.tabs {
  display: flex;
  overflow-x: auto;
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 20px 0;
  gap: 8px;
}

.tab-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

h2 { margin-top: 0; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--text-dim);
}

input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
}

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

.hidden { display: none !important; }

.card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.event-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.event-info { flex: 1; }

.event-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.event-meta {
  font-size: 13px;
  color: var(--text-dim);
}

.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-right: 6px;
}

.tag.vitoria { background: rgba(76,175,80,0.2); color: #4caf50; }
.tag.derrota { background: rgba(239,83,80,0.2); color: #ef5350; }
.tag.empate { background: rgba(255,213,79,0.2); color: #f9a825; }
.tag.treino { background: rgba(100,150,255,0.2); color: #6496ff; }
.tag.medalha-ouro { background: rgba(255,213,79,0.25); color: #d4a017; }
.tag.medalha-prata { background: rgba(176,176,176,0.25); color: #8a8a8a; }
.tag.medalha-bronze { background: rgba(205,127,50,0.25); color: #cd7f32; }

.btn-delete {
  background: transparent;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 18px;
}

.empty-msg {
  color: var(--text-dim);
  text-align: center;
  padding: 30px 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.badge {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  opacity: 0.35;
  filter: grayscale(1);
}

.badge.unlocked {
  opacity: 1;
  filter: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 1px var(--accent-2) inset;
}

.badge-icon { font-size: 32px; margin-bottom: 8px; }
.badge-name { font-weight: 600; font-size: 14px; }
.badge-desc { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

#progressChart { width: 100%; height: auto; }

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--accent);
  color: white;
  padding: 12px 20px;
  border-radius: 20px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 100;
}

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