/* ============ RESET & BASE ============ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --color-bg: #0f0f0f;
  --color-bg-secondary: #1a1a1a;
  --color-bg-tertiary: #252525;
  --color-surface: #2a2a2a;
  --color-border: #3a3a3a;

  --color-text: #e0e0e0;
  --color-text-muted: #888;
  --color-text-dim: #555;

  --color-primary: #D4A574;
  --color-primary-dim: #8B6914;
  --color-accent: #4CAF50;
  --color-danger: #e74c3c;

  --color-must: #e74c3c;
  --color-should: #f39c12;
  --color-could: #3498db;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============ VIEWS ============ */
.view {
  display: none;
  min-height: 100vh;
}

.view.active {
  display: block;
}

/* ============ USER VIEW ============ */
.centered {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.logo {
  text-align: center;
  margin-bottom: 2rem;
}

.logo h1 {
  font-size: 2.5rem;
  color: var(--color-primary);
  font-weight: 300;
  letter-spacing: 2px;
}

.logo .subtitle {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-top: 0.5rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ============ CARDS ============ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.card h2 {
  font-size: 1.25rem;
  color: var(--color-text);
  margin-bottom: 1.5rem;
  font-weight: 500;
}

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

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

input, select, textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 1rem;
  font-family: var(--font-sans);
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.2);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

input::placeholder, textarea::placeholder {
  color: var(--color-text-dim);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

/* ============ BUTTONS ============ */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

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

.btn-primary:hover {
  background: #e0b585;
  transform: translateY(-1px);
}

.btn-primary:disabled {
  background: var(--color-text-dim);
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-surface);
  border-color: var(--color-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
}

.btn-ghost:hover {
  color: var(--color-text);
  background: var(--color-bg-tertiary);
}

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

/* ============ DIVIDER ============ */
.divider {
  display: flex;
  align-items: center;
  margin: 1.5rem 0;
  color: var(--color-text-dim);
  font-size: 0.85rem;
}

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

.divider span {
  padding: 0 1rem;
}

/* ============ HEADER ============ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left, .header-right {
  flex: 1;
}

.header-right {
  text-align: right;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.header-center {
  text-align: center;
}

.header-center h1 {
  font-size: 1.25rem;
  color: var(--color-primary);
  font-weight: 500;
}

.header-center p {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* ============ GAMES VIEW ============ */
.main-content {
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.tier-section {
  margin-bottom: 3rem;
}

.tier-title {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  display: inline-block;
}

.tier-title.must {
  background: rgba(231, 76, 60, 0.2);
  color: var(--color-must);
  border: 1px solid rgba(231, 76, 60, 0.3);
}

.tier-title.should {
  background: rgba(243, 156, 18, 0.2);
  color: var(--color-should);
  border: 1px solid rgba(243, 156, 18, 0.3);
}

.tier-title.could {
  background: rgba(52, 152, 219, 0.2);
  color: var(--color-could);
  border: 1px solid rgba(52, 152, 219, 0.3);
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.game-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.game-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.game-card h3 {
  font-size: 1.1rem;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.game-card .platform {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.game-card .focus {
  font-size: 0.85rem;
  color: var(--color-text-dim);
  font-style: italic;
}

.game-card .status-dot {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-text-dim);
}

.game-card .status-dot.in-progress {
  background: var(--color-should);
}

.game-card .status-dot.completed {
  background: var(--color-accent);
}

/* ============ RESEARCH VIEW ============ */
.research-layout {
  display: flex;
  min-height: calc(100vh - 60px);
}

.research-nav {
  width: 220px;
  background: var(--color-bg-secondary);
  border-right: 1px solid var(--color-border);
  padding: 1rem 0;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
}

.nav-item {
  display: block;
  width: 100%;
  padding: 0.75rem 1.5rem;
  background: none;
  border: none;
  text-align: left;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
}

.nav-item.active {
  background: var(--color-bg-tertiary);
  color: var(--color-primary);
  border-left-color: var(--color-primary);
}

.nav-item.completed {
  color: var(--color-accent);
}

.nav-item.completed::after {
  content: '✓';
  margin-left: 0.5rem;
  font-size: 0.8rem;
}

.nav-item.active.completed {
  color: var(--color-accent);
  border-left-color: var(--color-accent);
}

.research-content {
  flex: 1;
  padding: 2rem;
  max-width: 900px;
}

.research-section {
  display: none;
}

.research-section.active {
  display: block;
}

.research-section h2 {
  font-size: 1.5rem;
  color: var(--color-primary);
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--color-border);
}

.research-section h3 {
  font-size: 1.1rem;
  color: var(--color-text);
  margin: 1.5rem 0 1rem;
}

.hint {
  color: var(--color-text-dim);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

/* ============ RATING STARS ============ */
.rating-item, .system-item {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1rem;
}

.rating-header, .system-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.rating-header label, .system-header label {
  font-weight: 500;
  color: var(--color-text);
}

.rating-stars {
  display: flex;
  gap: 0.25rem;
}

.rating-stars span {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--color-text-dim);
  cursor: pointer;
  transition: all 0.2s;
}

.rating-stars span:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.rating-stars span.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #000;
}

.rating-stars.large span {
  width: 40px;
  height: 40px;
  font-size: 1rem;
}

/* ============ CARD ITEMS ============ */
.card-item {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card-item h3 {
  color: var(--color-primary);
  margin-top: 0;
}

/* ============ STATUS BADGE ============ */
.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--color-bg-tertiary);
  color: var(--color-text-muted);
}

.status-badge.in-progress {
  background: rgba(243, 156, 18, 0.2);
  color: var(--color-should);
}

.status-badge.completed {
  background: rgba(76, 175, 80, 0.2);
  color: var(--color-accent);
}

/* ============ AUTO-SAVE INDICATOR ============ */
.auto-save-indicator {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  opacity: 0;
  transition: opacity 0.3s;
}

.auto-save-indicator.visible {
  opacity: 1;
}

.auto-save-indicator.saving {
  color: var(--color-should);
}

.auto-save-indicator.saved {
  color: var(--color-accent);
}

/* ============ MODAL ============ */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 450px;
  box-shadow: var(--shadow-lg);
}

.modal-content h2 {
  margin-bottom: 1.5rem;
  color: var(--color-primary);
}

.modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* ============ EMPTY STATE ============ */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--color-text-dim);
}

.empty-state p {
  margin-bottom: 1rem;
}

/* ============ SCREENSHOT UPLOAD ============ */
.screenshot-upload-area {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.screenshot-preview {
  width: 200px;
  height: 150px;
  background: var(--color-bg-tertiary);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.screenshot-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.screenshot-preview .placeholder {
  color: var(--color-text-dim);
  font-size: 0.85rem;
  text-align: center;
  padding: 1rem;
}

.screenshot-preview.has-image {
  border-style: solid;
  border-color: var(--color-accent);
}

.screenshot-input {
  display: none;
}

.upload-btn {
  cursor: pointer;
}

.upload-btn.uploading {
  opacity: 0.6;
  cursor: wait;
}

.screenshot-item .form-group {
  margin-top: 1rem;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .research-layout {
    flex-direction: column;
  }

  .research-nav {
    width: 100%;
    height: auto;
    position: relative;
    top: 0;
    display: flex;
    flex-wrap: wrap;
    padding: 0.5rem;
    gap: 0.25rem;
  }

  .nav-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    border-left: none;
    border-radius: var(--radius-sm);
  }

  .nav-item.active {
    border-left: none;
  }

  .header {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }

  .header-left, .header-right {
    text-align: center;
  }
}

/* ============ AUTH VIEWS ============ */
.auth-links {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
}

.auth-links a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.2s;
}

.auth-links a:hover {
  color: #e0b585;
  text-decoration: underline;
}

.auth-links span {
  color: var(--color-text-dim);
  margin: 0 0.5rem;
}

/* ============ MESSAGES ============ */
.error-message,
.success-message {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.error-message:empty,
.success-message:empty {
  display: none;
}

.error-message {
  background: rgba(231, 76, 60, 0.15);
  border: 1px solid rgba(231, 76, 60, 0.3);
  color: #e74c3c;
}

.success-message {
  background: rgba(76, 175, 80, 0.15);
  border: 1px solid rgba(76, 175, 80, 0.3);
  color: #4CAF50;
}

/* ============ INVITE RESULT ============ */
.invite-result {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-top: 1.5rem;
}

.invite-result h3 {
  color: var(--color-accent);
  margin-bottom: 1rem;
  font-size: 1rem;
}

.link-box {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.link-box input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.link-box .btn {
  white-space: nowrap;
}

.invite-result p {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.invite-result .email-status {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}

.invite-result .email-sent {
  color: var(--color-accent);
}

.invite-result .email-error {
  color: var(--color-danger);
}

/* ============ INVITATIONS LIST ============ */
.invitations-list {
  margin-top: 2rem;
}

.invitations-list h3 {
  font-size: 1rem;
  color: var(--color-text);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.invitation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.invitation-info {
  flex: 1;
}

.invitation-info .email {
  font-weight: 500;
  color: var(--color-text);
}

.invitation-info .no-email {
  color: var(--color-text-dim);
  font-style: italic;
}

.invitation-info .meta {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

.invitation-status {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 1rem;
}

.invitation-status.pending {
  background: rgba(243, 156, 18, 0.2);
  color: var(--color-should);
}

.invitation-status.used {
  background: rgba(76, 175, 80, 0.2);
  color: var(--color-accent);
}

.invitation-status.expired {
  background: rgba(136, 136, 136, 0.2);
  color: var(--color-text-muted);
}

.invitation-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: 1rem;
}

.invitation-actions .btn {
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
}

/* ============ ADMIN VIEW ============ */
.admin-content {
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;
}

.admin-content h2 {
  font-size: 1.5rem;
  color: var(--color-primary);
  margin-bottom: 1.5rem;
}

.admin-form {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.admin-form h3 {
  font-size: 1.1rem;
  color: var(--color-text);
  margin-bottom: 1rem;
}

.form-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
}

.form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

.form-row .btn {
  margin-bottom: 0;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.checkbox-group input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.checkbox-group label {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

/* ============ UTILITY CLASSES ============ */
.hidden {
  display: none !important;
}

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

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

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

/* ============ AUTH RESPONSIVE ============ */
@media (max-width: 768px) {
  .form-row {
    flex-direction: column;
  }

  .invitation-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .invitation-status,
  .invitation-actions {
    margin-left: 0;
  }
}
