/* Reset & Base */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #242836;
  --border: #2e3345;
  --text: #e8eaed;
  --text-muted: #9aa0b0;
  --accent: #6c63ff;
  --accent-hover: #7b73ff;
  --green: #34d399;
  --yellow: #fbbf24;
  --orange: #fb923c;
  --red: #f87171;
  --blue: #60a5fa;
  --level-0: #9aa0b0;
  --level-1: #60a5fa;
  --level-2: #34d399;
  --level-3: #fbbf24;
  --level-4: #f87171;
  --radius: 8px;
  --radius-lg: 12px;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Layout */
.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* Header */
.site-header {
  text-align: center;
  margin-bottom: 32px;
}

.site-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

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

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
}

.card h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

.card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-muted);
}

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.form-group.full-width {
  grid-column: 1 / -1;
}

label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

input[type="number"],
select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239aa0b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

input:focus,
select:focus {
  border-color: var(--accent);
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* Primary result */
.result-hero {
  text-align: center;
  padding: 32px 16px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.result-hero .label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.result-hero .value {
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
}

.result-hero .sublabel {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Formula cards grid */
.formula-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.formula-card {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  cursor: help;
}

.formula-name {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}

.formula-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--surface-2);
}

/* Strength standards */
.level-badge {
  display: inline-block;
  font-size: 1.25rem;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 20px;
  margin-bottom: 8px;
}

.level-0 { color: var(--level-0); background: rgba(154, 160, 176, 0.15); }
.level-1 { color: var(--level-1); background: rgba(96, 165, 250, 0.15); }
.level-2 { color: var(--level-2); background: rgba(52, 211, 153, 0.15); }
.level-3 { color: var(--level-3); background: rgba(251, 191, 36, 0.15); }
.level-4 { color: var(--level-4); background: rgba(248, 113, 113, 0.15); }

#strength-percentile {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 4px;
}

#strength-description {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 20px;
}

/* Bar chart */
.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.bar-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  width: 90px;
  flex-shrink: 0;
  text-align: right;
}

.bar-track {
  flex: 1;
  height: 28px;
  background: var(--surface-2);
  border-radius: var(--radius);
  position: relative;
  overflow: visible;
}

.bar-fill {
  height: 100%;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  min-width: 60px;
  transition: width 0.4s ease;
}

.bar-value {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.level-bg-0 { background: rgba(154, 160, 176, 0.3); }
.level-bg-1 { background: rgba(96, 165, 250, 0.3); }
.level-bg-2 { background: rgba(52, 211, 153, 0.3); }
.level-bg-3 { background: rgba(251, 191, 36, 0.3); }
.level-bg-4 { background: rgba(248, 113, 113, 0.3); }

.bar-marker {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
  transform: translateX(-50%);
  box-shadow: 0 0 8px rgba(108, 99, 255, 0.5);
}

.bar-marker::after {
  content: "YOU";
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
}

/* Ad placeholder */
.ad-slot {
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 20px 0;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Content section */
.content-section {
  margin-top: 32px;
}

.content-section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.content-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 16px 0 8px;
  color: var(--text);
}

.content-section p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 12px;
  line-height: 1.7;
}

.content-section ul {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 12px;
  padding-left: 20px;
}

.content-section li {
  margin-bottom: 6px;
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
}

/* Utility */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 16px 12px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .result-hero .value {
    font-size: 2.25rem;
  }

  .formula-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }

  .bar-label {
    width: 70px;
    font-size: 0.7rem;
  }

  table {
    font-size: 0.8rem;
  }

  th,
  td {
    padding: 6px 8px;
  }
}
