/*
 * c64ermu — Commodore 64™ Emulator Web Platform
 * Authentic C64 CRT Retro-Futuristic Aesthetic
 */

:root {
  /* Commodore 64 Palette */
  --c64-black: #000000;
  --c64-white: #ffffff;
  --c64-red: #880000;
  --c64-cyan: #70a4b2;
  --c64-purple: #a00088;
  --c64-green: #588d43;
  --c64-blue: #352879;
  --c64-yellow: #b8c76f;
  --c64-orange: #6c5eb5;
  --c64-brown: #503000;
  --c64-light-red: #ca5454;
  --c64-dark-grey: #404040;
  --c64-grey: #6c6c6c;
  --c64-light-green: #9ad284;
  --c64-light-blue: #6c5eb5;
  --c64-light-grey: #959595;

  /* Theme Tokens */
  --bg-dark: #0f0c29;
  --bg-gradient: radial-gradient(circle at 50% 20%, #241c59 0%, #110d2e 60%, #080617 100%);
  --card-bg: rgba(30, 23, 74, 0.78);
  --card-border: rgba(108, 94, 181, 0.45);
  --card-hover: rgba(45, 36, 107, 0.9);
  --text-main: #f3f4f6;
  --text-muted: #a5b4fc;
  --text-c64: #70a4b2;
  --accent-gold: #fbbf24;
  --accent-green: #34d399;
  --accent-altstore: #8b5cf6;
  --accent-altstore-hover: #a78bfa;

  --font-c64: "Courier New", Courier, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
}

/* CRT Scanlines Overlay */
.crt-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%, 
    rgba(0, 0, 0, 0.28) 50%
  ), linear-gradient(
    90deg,
    rgba(255, 0, 0, 0.03),
    rgba(0, 255, 0, 0.01),
    rgba(0, 0, 255, 0.03)
  );
  background-size: 100% 4px, 6px 100%;
  z-index: 9999;
  opacity: 0.85;
  transition: opacity 0.3s ease;
}

body.no-scanlines .crt-overlay {
  display: none;
}

/* Navigation Bar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  background: rgba(17, 13, 46, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(108, 94, 181, 0.3);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #ffffff;
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: -0.5px;
}

.nav-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  list-style: none;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: color 0.2s ease;
}

.nav-links a:hover {
  color: #ffffff;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-toggle-crt {
  background: rgba(108, 94, 181, 0.2);
  border: 1px solid var(--c64-light-blue);
  color: var(--c64-cyan);
  font-family: var(--font-c64);
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-toggle-crt:hover {
  background: rgba(108, 94, 181, 0.4);
  color: #ffffff;
}

/* Page Container */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 24px 80px 24px;
}

/* Commodore 64 Monitor Frame */
.c64-monitor {
  background-color: var(--c64-blue);
  border: 20px solid var(--c64-light-blue);
  border-radius: 28px;
  box-shadow: 
    0 24px 80px rgba(0, 0, 0, 0.75), 
    inset 0 0 32px rgba(0, 0, 0, 0.5),
    0 0 0 2px rgba(255, 255, 255, 0.1);
  padding: 32px;
  margin-bottom: 56px;
  font-family: var(--font-c64);
  color: var(--c64-light-blue);
  position: relative;
  overflow: hidden;
}

.c64-screen-header {
  text-align: center;
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: 1px;
  font-weight: bold;
  text-transform: uppercase;
  margin-bottom: 24px;
  color: var(--c64-light-blue);
  text-shadow: 0 0 8px rgba(108, 94, 181, 0.6);
}

.c64-cursor {
  display: inline-block;
  width: 12px;
  height: 18px;
  background-color: var(--c64-light-blue);
  animation: cursorBlink 1s step-start infinite;
  vertical-align: middle;
  margin-left: 4px;
}

@keyframes cursorBlink {
  50% { opacity: 0; }
}

/* Hero Content */
.hero-content {
  display: flex;
  align-items: center;
  gap: 32px;
  margin-top: 16px;
}

.hero-icon {
  width: 116px;
  height: 116px;
  border-radius: 28px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

.hero-text h1 {
  font-size: 2.6rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  font-family: var(--font-sans);
}

.hero-text p.tagline {
  font-size: 1.15rem;
  color: var(--c64-cyan);
  font-weight: 500;
  margin-bottom: 12px;
  font-family: var(--font-sans);
}

.hero-badges {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  font-family: var(--font-sans);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.badge-version {
  background: rgba(108, 94, 181, 0.3);
  border: 1px solid var(--c64-light-blue);
  color: #ffffff;
}

.badge-status {
  background: rgba(52, 211, 153, 0.15);
  border: 1px solid rgba(52, 211, 153, 0.4);
  color: #6ee7b7;
}

.badge-status::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

.badge-license {
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: #fde68a;
}

/* Buttons */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
  font-family: var(--font-sans);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 24px;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.2s ease-in-out;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: linear-gradient(135deg, #7952b3 0%, #5d3b94 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 8px 24px rgba(121, 82, 179, 0.45);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #8a60cc 0%, #6e46b0 100%);
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(121, 82, 179, 0.6);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.btn-outline {
  background: transparent;
  color: var(--c64-cyan);
  border: 1px solid var(--c64-cyan);
}

.btn-outline:hover {
  background: rgba(112, 164, 178, 0.15);
  transform: translateY(-2px);
}

/* Sections */
.section {
  margin-bottom: 64px;
}

.section-header {
  margin-bottom: 28px;
}

.section-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.section-subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* Cards Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 22px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 26px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
  transition: all 0.25s ease;
}

.card:hover {
  background: var(--card-hover);
  border-color: rgba(108, 94, 181, 0.7);
  transform: translateY(-3px);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
}

.card-icon {
  font-size: 2rem;
  margin-bottom: 14px;
  display: inline-block;
}

.card h3 {
  font-size: 1.25rem;
  color: #ffffff;
  margin-bottom: 10px;
  font-weight: 700;
}

.card p {
  color: #cbd5e1;
  font-size: 0.95rem;
  line-height: 1.55;
}

/* AltStore Hub Card */
.altstore-hub {
  background: linear-gradient(135deg, rgba(38, 28, 94, 0.85) 0%, rgba(20, 15, 52, 0.95) 100%);
  border: 1px solid rgba(139, 92, 246, 0.4);
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.altstore-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 24px 0;
}

.source-url-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(108, 94, 181, 0.5);
  border-radius: 10px;
  padding: 10px 16px;
  margin-top: 14px;
}

.source-url-text {
  font-family: var(--font-c64);
  color: var(--c64-cyan);
  font-size: 0.95rem;
  flex-grow: 1;
  word-break: break-all;
}

.btn-copy {
  background: rgba(108, 94, 181, 0.3);
  border: 1px solid var(--c64-light-blue);
  color: #ffffff;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.btn-copy:hover {
  background: var(--c64-light-blue);
}

/* Form Styles */
.form-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 36px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group.full-width {
  grid-column: span 2;
}

.form-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.form-label small {
  color: var(--text-muted);
  font-weight: 400;
}

.form-input, .form-textarea, .form-select {
  background: rgba(15, 12, 41, 0.7);
  border: 1px solid rgba(108, 94, 181, 0.5);
  border-radius: 10px;
  padding: 12px 16px;
  color: #ffffff;
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.2s ease;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--c64-cyan);
  box-shadow: 0 0 0 3px rgba(112, 164, 178, 0.25);
  background: rgba(20, 16, 56, 0.85);
}

.form-textarea {
  min-height: 90px;
  resize: vertical;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 4px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  color: #e2e8f0;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--c64-light-blue);
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.btn-submit {
  grid-column: span 2;
  margin-top: 12px;
  padding: 15px;
  font-size: 1.1rem;
}

.form-status {
  grid-column: span 2;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 0.95rem;
  display: none;
  margin-top: 8px;
}

.form-status.success {
  display: block;
  background: rgba(52, 211, 153, 0.15);
  border: 1px solid rgba(52, 211, 153, 0.4);
  color: #6ee7b7;
}

.form-status.error {
  display: block;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

/* UDID Modal / Help Box */
.udid-help-link {
  color: var(--c64-cyan);
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
}

.udid-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.udid-modal.open {
  display: flex;
}

.udid-modal-content {
  background: #17123d;
  border: 2px solid var(--c64-light-blue);
  border-radius: 20px;
  max-width: 620px;
  width: 100%;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  position: relative;
}

.udid-modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.udid-modal-close:hover {
  color: #ffffff;
}

/* Leaderboard Preview Table */
.table-container {
  overflow-x: auto;
  margin-top: 16px;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.leaderboard-table th {
  padding: 12px 16px;
  background: rgba(108, 94, 181, 0.25);
  color: var(--c64-cyan);
  font-family: var(--font-c64);
  font-size: 0.9rem;
  text-transform: uppercase;
}

.leaderboard-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(108, 94, 181, 0.2);
  color: #e2e8f0;
  font-size: 0.95rem;
}

.leaderboard-table tr:hover td {
  background: rgba(108, 94, 181, 0.15);
}

.rank-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.85rem;
}

.rank-1 { background: #fbbf24; color: #78350f; }
.rank-2 { background: #94a3b8; color: #0f172a; }
.rank-3 { background: #d97706; color: #451a03; }

/* Platform Matrix Cards */
.platform-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.platform-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 20px;
  text-align: center;
  transition: all 0.2s ease;
}

.platform-card:hover {
  transform: translateY(-3px);
  border-color: var(--c64-cyan);
}

.platform-card .icon {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.platform-card h4 {
  color: #ffffff;
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.platform-card p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 14px;
}

/* Beta Notice Banner & Platform Badges */
.beta-notice-banner {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.14) 0%, rgba(200, 142, 40, 0.08) 100%);
  border: 1px solid rgba(234, 179, 8, 0.45);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.beta-notice-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.beta-notice-content > strong,
.beta-notice-title {
  color: #fbbf24;
  font-size: 1rem;
  display: block;
  margin-bottom: 4px;
}

.beta-notice-content p strong {
  display: inline;
  color: #fbbf24;
  font-size: inherit;
  margin: 0;
}

.beta-notice-content p {
  color: #cbd5e1;
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0;
}

.badge-beta-only {
  display: inline-block;
  background: rgba(234, 179, 8, 0.18);
  color: #fde047;
  border: 1px solid rgba(234, 179, 8, 0.4);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.download-soon-hint {
  display: block;
  margin-top: 8px;
  font-size: 0.75rem;
  color: #94a3b8;
  font-style: italic;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: #10b981;
  color: #ffffff;
  padding: 14px 22px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  font-weight: 600;
  font-size: 0.95rem;
  z-index: 10001;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Footer */
.footer {
  background: #080617;
  border-top: 1px solid rgba(108, 94, 181, 0.3);
  padding: 48px 24px 32px 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.footer a {
  color: var(--c64-cyan);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

.platform-notice {
  background: rgba(112, 164, 178, 0.12);
  border: 1px dashed rgba(112, 164, 178, 0.45);
  border-radius: 10px;
  padding: 14px 18px;
  color: var(--c64-cyan);
  font-size: 0.95rem;
  line-height: 1.5;
  transition: all 0.3s ease;
}

.platform-notice strong {
  color: #ffffff;
}

.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
  .hero-content {
    flex-direction: column;
    text-align: center;
  }
  .hero-badges, .btn-group {
    justify-content: center;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-group.full-width, .btn-submit, .form-status {
    grid-column: span 1;
  }
  .navbar {
    padding: 12px 16px;
  }
  .nav-links {
    display: none; /* simple mobile drawer or hide */
  }
}

/* Closed Beta Authorization Gate */
.auth-gate-card {
  background: rgba(18, 22, 34, 0.9);
  border: 2px solid var(--c64-blue);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 28px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.auth-gate-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.auth-gate-icon {
  font-size: 2rem;
}

.auth-gate-header h3 {
  color: var(--c64-cyan);
  font-size: 1.2rem;
  margin-bottom: 4px;
}

.auth-gate-header p {
  color: #94a3b8;
  font-size: 0.9rem;
}

.auth-gate-input-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.auth-gate-input-row input {
  flex-grow: 1;
}

.auth-gate-status {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 10px;
}

.auth-gate-status.success {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #86efac;
}

.auth-gate-status.pending {
  background: rgba(234, 179, 8, 0.15);
  border: 1px solid rgba(234, 179, 8, 0.4);
  color: #fde047;
}

.auth-gate-status.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.auth-gate-status.hidden {
  display: none;
}

@media (max-width: 640px) {
  .auth-gate-input-row {
    flex-direction: column;
  }
}
