:root {
  --bg-dark: #0a0e1a;
  --bg-panel: #151a2e;
  --bg-card: #1a1f35;
  --text: #e0e8ff;
  --muted: #9099b8;
  --accent-blue: #5b8ff9;
  --accent-green: #5ad8a6;
  --accent-yellow: #f6bd16;
  --accent-red: #e8684a;
  --accent-purple: #9270ca;
  --accent-cyan: #6dc8ec;
  --border: #2a3454;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

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

html,
body {
  height: 100%;
  overflow-x: hidden;
}

body {
  background: linear-gradient(135deg, #0a0e1a 0%, #1a1f35 100%);
  color: var(--text);
  font-family:
    "Lexend",
    system-ui,
    -apple-system,
    sans-serif;
  line-height: 1.6;
}

/* Header */
.app-header {
  background: var(--bg-panel);
  border-bottom: 2px solid var(--border);
  padding: 20px 32px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.title-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.limit-badge {
  font-size: 36px;
  font-weight: 900;
  color: var(--accent-cyan);
  font-family: "Space Mono", monospace;
  text-shadow: 0 0 10px rgba(109, 200, 236, 0.5);
}

.game-title {
  font-size: 36px;
  font-weight: 900;
  color: var(--accent-blue);
  text-shadow: 0 0 10px rgba(91, 143, 249, 0.5);
}

.help-btn {
  margin-left: 12px;
  padding: 6px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--accent-cyan);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.help-btn:hover {
  background: var(--bg-dark);
  border-color: var(--accent-cyan);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(109, 200, 236, 0.3);
}

.help-btn:active {
  transform: translateY(0);
}

.meta-info {
  display: flex;
  align-items: center;
  gap: 24px;
}

.date-display {
  font-family: "Space Mono", monospace;
  font-size: 18px;
  color: var(--accent-green);
}

.oas-threshold {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.oas-threshold label {
  white-space: nowrap;
}

.oas-threshold input {
  width: 120px;
  padding: 6px 12px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent-yellow);
  font-family: "Space Mono", monospace;
  font-size: 14px;
  font-weight: 700;
}

.oas-threshold input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(91, 143, 249, 0.2);
}

.warning {
  color: var(--accent-yellow);
  font-size: 13px;
  text-align: center;
  padding: 12px;
  background: rgba(246, 189, 22, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(246, 189, 22, 0.3);
}

/* Game Container */
.game-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px;
  min-height: calc(100vh - 180px);
}

/* Screen Management */
.screen {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 500px;
  animation: fadeIn 0.5s ease-in-out;
}

.screen.hidden {
  display: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 600px;
  max-height: 70vh;
  overflow-y: auto;
}

.card.results-card {
  max-width: 1200px;
  max-height: 85vh;
}

.card h2 {
  color: var(--accent-blue);
  font-size: 24px;
  margin-bottom: 16px;
  text-align: center;
}

.card h3 {
  color: var(--accent-green);
  font-size: 16px;
  margin: 16px 0 8px;
}

/* Instructions */
.instructions-content {
  max-height: 45vh;
  overflow-y: auto;
  padding-right: 12px;
  margin-bottom: 20px;
  font-size: 14px;
}

.instructions-content ul {
  margin-left: 24px;
  margin-bottom: 16px;
}

.instructions-content li {
  margin-bottom: 8px;
  color: var(--muted);
}

.instructions-content strong {
  color: var(--text);
}

.instructions-content p {
  color: var(--muted);
  margin-bottom: 12px;
}

.timer-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 20px;
}

.timer-bar::before {
  content: "";
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
  animation: timerProgress 60s linear forwards;
}

@keyframes timerProgress {
  from {
    width: 100%;
  }
  to {
    width: 0%;
  }
}

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

#countdown {
  color: var(--accent-yellow);
}

/* Form Groups */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: "Space Mono", monospace;
  transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(91, 143, 249, 0.2);
}

.input-helper {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
  margin-bottom: 8px;
}

/* Slider */
.slider {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  outline: none;
  -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  background: var(--accent-blue);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(91, 143, 249, 0.5);
}

.slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  background: var(--accent-blue);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 8px rgba(91, 143, 249, 0.5);
}

.slider-value {
  margin-top: 12px;
  font-family: "Space Mono", monospace;
  color: var(--accent-cyan);
  font-size: 14px;
  text-align: center;
}

.slider-value span {
  color: var(--accent-yellow);
  font-weight: 700;
}

/* Buttons */
.primary-btn,
.secondary-btn {
  padding: 14px 32px;
  border: none;
  border-radius: 10px;
  font-family: "Lexend", sans-serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  color: white;
  box-shadow: 0 4px 15px rgba(91, 143, 249, 0.4);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(91, 143, 249, 0.6);
}

.primary-btn:active {
  transform: translateY(0);
}

.secondary-btn {
  background: var(--bg-panel);
  color: var(--accent-cyan);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.secondary-btn:hover {
  background: var(--bg-dark);
  border-color: var(--accent-cyan);
}

/* Choice Buttons */
.choice-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 32px;
}

/* Status Content */
.status-content {
  background: rgba(91, 143, 249, 0.1);
  border: 1px solid rgba(91, 143, 249, 0.3);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  font-family: "Space Mono", monospace;
  line-height: 1.8;
  color: var(--muted);
}

.status-content strong {
  color: var(--accent-yellow);
}

.annuity-info {
  background: rgba(90, 216, 166, 0.1);
  border: 1px solid rgba(90, 216, 166, 0.3);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.annuity-info h3 {
  margin-top: 0;
}

.annuity-info p {
  color: var(--muted);
  margin-bottom: 12px;
}

/* Summary Stats */
.summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

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

.stat-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  font-family: "Space Mono", monospace;
  color: var(--accent-yellow);
}

.stat-value.positive {
  color: var(--accent-green);
}

.stat-value.negative {
  color: var(--accent-red);
}

/* Table Controls */
.table-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  justify-content: center;
}

/* Results Table */
.results-table-container {
  overflow-x: auto;
  margin-bottom: 32px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-family: "Space Mono", monospace;
  font-size: 12px;
}

.results-table thead {
  background: var(--bg-panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

.results-table th {
  padding: 12px 8px;
  text-align: right;
  color: var(--accent-cyan);
  font-weight: 700;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.results-table th:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--bg-panel);
  z-index: 11;
}

.results-table td {
  padding: 8px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

.results-table td:first-child {
  text-align: left;
  color: var(--accent-yellow);
  font-weight: 700;
  position: sticky;
  left: 0;
  background: var(--bg-card);
  z-index: 5;
}

.results-table tbody tr:hover {
  background: rgba(91, 143, 249, 0.05);
}

.results-table tbody tr:nth-child(12n) {
  border-bottom: 2px solid var(--accent-blue);
}

.results-table .highlight {
  color: var(--accent-green);
  font-weight: 700;
}

.results-table .negative {
  color: var(--accent-red);
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 26, 0.95);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.loading-overlay.hidden {
  display: none;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid var(--border);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  margin-top: 24px;
  font-size: 18px;
  color: var(--accent-cyan);
}

/* Help Overlay */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(10, 14, 26, 0.95);
  backdrop-filter: blur(8px);
  z-index: 1000;
}

.overlay.visible {
  display: grid;
}

.help-card {
  width: min(750px, 90vw);
  max-height: 90vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  flex-shrink: 0;
}

.help-header h2 {
  color: var(--accent-blue);
  margin: 0;
  font-size: 24px;
}

.close-btn {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  font-size: 32px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.close-btn:hover {
  background: var(--accent-red);
  border-color: var(--accent-red);
  transform: rotate(90deg);
}

.help-content {
  padding: 24px 32px;
  overflow-y: auto;
  flex: 1;
}

.help-content h3 {
  color: var(--accent-green);
  margin-top: 20px;
  margin-bottom: 12px;
  font-size: 18px;
}

.help-content h3:first-child {
  margin-top: 0;
}

.help-content h4 {
  color: var(--accent-cyan);
  margin-top: 16px;
  margin-bottom: 8px;
  font-size: 15px;
}

.help-content ul,
.help-content p {
  color: var(--muted);
  line-height: 1.8;
  font-size: 14px;
}

.help-content ul {
  margin: 12px 0;
  margin-left: 20px;
}

.help-content li {
  margin-bottom: 8px;
}

.help-content strong {
  color: var(--text);
}

.help-content em {
  color: var(--muted);
  font-style: italic;
  font-size: 13px;
}

/* Formula Box */
.formula-box {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-yellow);
  border-radius: 8px;
  padding: 16px 20px;
  margin: 16px 0;
  font-family: "Space Mono", monospace;
  font-size: 13px;
  color: var(--accent-yellow);
  line-height: 2;
}

.formula-box strong {
  color: var(--accent-cyan);
}

/* Help Table */
.help-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 13px;
}

.help-table th,
.help-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.help-table th {
  background: var(--bg-dark);
  color: var(--accent-blue);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.help-table td {
  color: var(--muted);
}

.help-table tr:hover td {
  background: rgba(91, 143, 249, 0.05);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-dark);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-blue);
}

/* Responsive */
@media (max-width: 768px) {
  .app-header {
    padding: 16px;
  }

  .title-wrap {
    flex-direction: column;
    align-items: flex-start;
  }

  .limit-badge,
  .game-title {
    font-size: 28px;
  }

  .game-container {
    padding: 16px;
  }

  .card {
    padding: 24px;
  }

  .card h2 {
    font-size: 24px;
  }

  .results-table {
    font-size: 10px;
  }

  .results-table th,
  .results-table td {
    padding: 6px 4px;
  }
}
