/* ===== RESET & BASE ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0a0a0f;
  --bg2: #12121a;
  --bg3: #1a1a25;
  --text: #e0e0e0;
  --text2: #888;
  --accent: #7c5cbf;
  --accent2: #9b7fd4;
  --gold: #ffd700;
  --red: #ff4444;
  --green: #44ff88;
  --blue: #4488ff;
  --border: #2a2a3a;
  --card-bg: #15151f;
  --radius: 8px;
}

body {
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--accent2);
  text-decoration: none;
}

a:hover {
  color: var(--gold);
}

img {
  image-rendering: pixelated;
}

/* ===== HEADER ===== */
header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.2em;
  font-weight: bold;
  color: var(--text) !important;
}

.logo-icon {
  font-size: 1.5em;
}

#nav-links {
  display: flex;
  gap: 20px;
}

#nav-links a {
  color: var(--text2);
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

#nav-links a:hover,
#nav-links a.active {
  color: var(--text);
  background: var(--bg3);
}

#auth-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

#user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge {
  color: var(--accent2) !important;
  font-weight: 600;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
  text-align: center;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent2);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-small {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-large {
  padding: 12px 24px;
  font-size: 16px;
}

.btn-full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== INPUTS ===== */
.input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.input:focus {
  border-color: var(--accent);
}

.textarea {
  min-height: 150px;
  resize: vertical;
  font-family: inherit;
}

.textarea-small {
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
}

select.input,
select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: var(--radius);
  cursor: pointer;
}

/* ===== HERO ===== */
.hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 60px 20px;
  text-align: center;
}

.hero h1 {
  font-size: 3em;
  margin-bottom: 10px;
  background: linear-gradient(135deg, var(--accent2), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.2em;
  color: var(--text2);
  margin-bottom: 30px;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 30px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-number {
  font-size: 2em;
  font-weight: bold;
  color: var(--gold);
}

.stat-label {
  color: var(--text2);
  font-size: 0.9em;
}

.hero-buttons {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 40px;
}

.hero-showcase {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.showcase-item img {
  width: 128px;
  height: 128px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  transition: transform 0.2s, border-color 0.2s;
}

.showcase-item img:hover {
  transform: scale(1.1);
  border-color: var(--accent);
}

/* ===== SECTIONS ===== */
.section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
}

.section-title {
  font-size: 1.5em;
  margin-bottom: 20px;
  text-align: center;
}

.page-title {
  font-size: 2em;
  text-align: center;
  margin-bottom: 30px;
}

.center {
  text-align: center;
  margin-top: 20px;
}

.center-text {
  text-align: center;
  color: var(--text2);
}

/* ===== FILTERS ===== */
.filters {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  margin-bottom: 30px;
  padding: 15px;
  background: var(--bg2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  color: var(--text2);
  font-size: 14px;
  white-space: nowrap;
}

.filter-group .input {
  width: 200px;
}

/* ===== ARTIFACT GRID ===== */
.artifact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.artifact-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s;
  display: block;
  color: var(--text) !important;
}

.artifact-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
}

.artifact-card.rarity-rare {
  border-color: #4488ff44;
}

.artifact-card.rarity-legendary {
  border-color: #ffd70044;
}

.artifact-card.rarity-mythical {
  border-color: #ff444444;
}

.artifact-card:hover.rarity-rare {
  border-color: var(--blue);
}

.artifact-card:hover.rarity-legendary {
  border-color: var(--gold);
}

.artifact-card:hover.rarity-mythical {
  border-color: var(--red);
}

.artifact-card-image {
  aspect-ratio: 1;
  overflow: hidden;
  background: #1a1a1a;
}

.artifact-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.artifact-card-info {
  padding: 12px;
}

.artifact-card-rarity {
  font-size: 11px;
  margin-bottom: 4px;
  color: var(--text2);
}

.artifact-card-title {
  font-size: 14px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.artifact-card-author {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 8px;
}

.artifact-card-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text2);
}

/* ===== ARTIFACT DETAIL ===== */
.artifact-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
}

.artifact-detail-image img {
  width: 100%;
  max-width: 512px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: #1a1a1a;
}

.artifact-detail-info h1 {
  font-size: 1.8em;
  margin-bottom: 10px;
}

.artifact-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.rarity-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.rarity-badge.rarity-common {
  background: #33333366;
  color: #999;
}

.rarity-badge.rarity-rare {
  background: #4488ff22;
  color: var(--blue);
}

.rarity-badge.rarity-legendary {
  background: #ffd70022;
  color: var(--gold);
}

.rarity-badge.rarity-mythical {
  background: #ff444422;
  color: var(--red);
}

.hall-badge {
  font-size: 13px;
  color: var(--text2);
}

.artifact-author {
  color: var(--text2);
  margin-bottom: 20px;
}

.artifact-story-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.artifact-story-box h3 {
  margin-bottom: 10px;
  font-size: 1em;
}

.artifact-story-box p {
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.7;
}

.artifact-actions {
  display: flex;
  gap: 10px;
}

.btn-like,
.btn-collect {
  padding: 10px 20px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
}

.btn-like:hover {
  border-color: var(--red);
}

.btn-collect:hover {
  border-color: var(--gold);
}

.btn-like.liked {
  border-color: var(--red);
  background: #ff444422;
}

.btn-collect.collected {
  border-color: var(--gold);
  background: #ffd70022;
}

/* ===== COMMENTS ===== */
.comments-section {
  max-width: 700px;
}

.comments-section h3 {
  margin-bottom: 15px;
}

#comment-form {
  margin-bottom: 20px;
  display: flex;
  gap: 10px;
}

#comment-form textarea {
  flex: 1;
}

.comment {
  padding: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
}

.comment-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.comment-author {
  font-weight: 600;
  color: var(--accent2);
}

.comment-time {
  font-size: 12px;
  color: var(--text2);
}

.comment-text {
  color: var(--text);
  font-size: 14px;
}

.no-comments {
  color: var(--text2);
  font-style: italic;
}

/* ===== EDITOR ===== */
.editor-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 30px;
  align-items: start;
}

.editor-canvas-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.canvas-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding: 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.tool-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.tool-btn:hover {
  border-color: var(--accent);
}

.tool-btn.active {
  background: var(--accent);
  border-color: var(--accent);
}

.canvas-wrapper {
  position: relative;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #ffffff;
  cursor: crosshair;
}

.canvas-wrapper canvas {
  display: block;
  image-rendering: pixelated;
}

#grid-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  opacity: 0.5;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

#zoom-level {
  font-weight: 600;
  min-width: 30px;
  text-align: center;
}

/* ===== COLORS ===== */
.color-section {
  width: 100%;
  max-width: 520px;
}

.current-colors {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.color-preview {
  width: 40px;
  height: 40px;
  border: 2px solid var(--border);
  border-radius: 4px;
}

#color-input {
  width: 40px;
  height: 40px;
  border: none;
  cursor: pointer;
  background: none;
}

.color-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.color-swatch {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  transition: transform 0.1s;
}

.color-swatch:hover {
  transform: scale(1.3);
  z-index: 1;
}

/* ===== FORM ===== */
.editor-details-section {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-weight: 600;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
}

.char-count {
  font-weight: 400;
  color: var(--text2);
  font-size: 12px;
}

.rarity-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rarity-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.rarity-option:hover {
  border-color: var(--accent);
}

.rarity-option input[type="radio"] {
  accent-color: var(--accent);
}

.rarity-option small {
  color: var(--text2);
}

.rarity-option.rarity-rare {
  border-color: #4488ff33;
}

.rarity-option.rarity-legendary {
  border-color: #ffd70033;
}

.rarity-option.rarity-mythical {
  border-color: #ff444433;
}

.error-text {
  color: var(--red);
  font-size: 14px;
}

.success-text {
  color: var(--green);
  font-size: 14px;
}

/* ===== PROFILE ===== */
.profile-header {
  text-align: center;
  margin-bottom: 30px;
}

.profile-header h1 {
  font-size: 2em;
  margin-bottom: 5px;
}

.profile-header p {
  color: var(--text2);
  margin-bottom: 20px;
}

.profile-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 15px;
}

.badges-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  font-size: 1.5em;
}

.badge-item {
  cursor: default;
}

.profile-tabs {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}

.tab-btn {
  padding: 8px 20px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.tab-btn:hover,
.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
}

/* ===== HALL OF FAME ===== */
.hall-podium {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

.podium-item {
  text-align: center;
  padding: 20px;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  transition: transform 0.2s;
  color: var(--text) !important;
}

.podium-item:hover {
  transform: translateY(-5px);
}

.podium-1 {
  border-color: var(--gold);
}

.podium-2 {
  border-color: #c0c0c0;
}

.podium-3 {
  border-color: #cd7f32;
}

.podium-medal {
  font-size: 2em;
  display: block;
  margin-bottom: 10px;
}

.podium-item img {
  width: 128px;
  height: 128px;
  border-radius: var(--radius);
  margin-bottom: 10px;
}

.podium-item h3 {
  font-size: 14px;
  margin-bottom: 5px;
}

/* ===== MODAL ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px;
  max-width: 400px;
  width: 90%;
  position: relative;
}

.modal-content h2 {
  margin-bottom: 20px;
  text-align: center;
}

.modal-content .input {
  margin-bottom: 12px;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 15px;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 20px;
  cursor: pointer;
}

.auth-switch {
  text-align: center;
  margin-top: 12px;
  font-size: 14px;
  color: var(--text2);
}

/* ===== AD ===== */
.ad-container {
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 20px;
  text-align: center;
}

/* ===== FOOTER ===== */
footer {
  text-align: center;
  padding: 30px 20px;
  color: var(--text2);
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
  }

  #nav-links {
    gap: 10px;
  }

  .hero h1 {
    font-size: 2em;
  }

  .hero-buttons {
    flex-direction: column;
    align-items: center;
  }

  .artifact-detail {
    grid-template-columns: 1fr;
  }

  .editor-layout {
    grid-template-columns: 1fr;
  }

  .filters {
    flex-direction: column;
  }

  .filter-group .input {
    width: 100%;
  }

  .artifact-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }

  .hall-podium {
    flex-direction: column;
    align-items: center;
  }

  .hero-stats {
    gap: 20px;
  }

  .profile-stats {
    gap: 20px;
  }

  #comment-form {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .hero h1 {
    font-size: 1.5em;
  }

  .artifact-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
  }

  .canvas-toolbar {
    justify-content: center;
  }
}