:root {
  --bg-color: #0f172a;
  --panel-bg: rgba(30, 41, 59, 0.7);
  --border-color: rgba(255, 255, 255, 0.1);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-1: #06b6d4; /* Cyan */
  --accent-2: #10b981; /* Emerald green */
  --error: #ef4444;
  --success-bg: rgba(16, 185, 129, 0.15);
  --success-border: rgba(16, 185, 129, 0.3);
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  background-image: 
    radial-gradient(circle at 15% 50%, rgba(6, 182, 212, 0.15), transparent 25%),
    radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.15), transparent 25%);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
}

.container {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

header {
  text-align: center;
  margin-bottom: 1rem;
}

h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
  letter-spacing: -0.025em;
}

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

.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 1.5rem;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-panel:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
}

.section-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Forms & Inputs */
.input-group {
  margin-bottom: 1.25rem;
}

.input-group label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper input,
.input-wrapper select {
  width: 100%;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 1rem;
  transition: all 0.2s ease;
  appearance: none;
}

.input-wrapper select {
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%2394a3b8%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
}

input[type="number"]:not(#minLegsInput)::-webkit-inner-spin-button,
input[type="number"]:not(#minLegsInput)::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"]:not(#minLegsInput) {
  -moz-appearance: textfield;
}

.input-wrapper input:focus,
.input-wrapper select:focus {
  outline: none;
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2);
}

.input-wrapper select option {
  background: var(--bg-color);
  color: var(--text-main);
}

.help-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  line-height: 1.4;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.75rem;
  border-radius: 0.5rem;
  border-left: 3px solid var(--accent-1);
}

.section-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.legs-warnings {
  margin-bottom: 1rem;
}

.warning {
  padding: 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.warning.error {
  background: rgba(239, 68, 68, 0.1);
  border-left: 3px solid var(--error);
  color: #fca5a5;
}

.warning.info {
  background: rgba(6, 182, 212, 0.1);
  border-left: 3px solid var(--accent-1);
  color: #67e8f9;
}

.input-suffix {
  position: absolute;
  right: 1rem;
  color: var(--text-muted);
  font-weight: 500;
  pointer-events: none;
}

/* Legs Manager */
.legs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.btn-small {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.4rem 0.8rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn-small:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--text-muted);
}

.leg-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(15, 23, 42, 0.4);
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  margin-bottom: 0.75rem;
  border: 1px solid transparent;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.leg-number {
  font-weight: 600;
  color: var(--accent-1);
  min-width: 3.5rem;
}

.leg-input {
  flex-grow: 1;
}

.leg-input input {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 0.5rem;
  color: white;
}

.btn-remove {
  background: transparent;
  border: none;
  color: var(--error);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-remove:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* Results Display */
.results-panel {
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.1), rgba(6, 182, 212, 0.1));
  border-color: rgba(16, 185, 129, 0.3);
  text-align: center;
}

.results-panel.error {
  background: linear-gradient(145deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05));
  border-color: rgba(239, 68, 68, 0.3);
}

.results-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.results-value {
  font-size: 3rem;
  font-weight: 800;
  color: var(--text-main);
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
  margin-bottom: 0.5rem;
}

.results-panel.error .results-value {
  font-size: 1.5rem;
  color: var(--error);
}

.results-sub {
  font-size: 1rem;
  color: var(--accent-2);
  font-weight: 500;
}

.info-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 2rem;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  transition: .3s;
  border-radius: 24px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-muted);
  transition: .3s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: rgba(16, 185, 129, 0.2);
  border-color: var(--accent-2);
}
input:checked + .slider:before {
  transform: translateX(20px);
  background-color: var(--accent-2);
}

/* Advanced Options */
.leg-advanced {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.use-default-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.use-default-label input {
  accent-color: var(--accent-1);
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

.market-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.market-type-boxes {
  display: flex;
  gap: 0.5rem;
}

.market-box {
  flex: 1;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.5rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.market-box:hover {
  background: rgba(255, 255, 255, 0.05);
}

.market-box.active {
  background: rgba(6, 182, 212, 0.15);
  border-color: var(--accent-1);
  color: var(--accent-1);
  font-weight: 600;
}

/* Insights Panel */
.insight-item {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-left-width: 4px;
  border-radius: 0.75rem;
  padding: 1rem;
  font-size: 0.9rem;
  line-height: 1.4;
  animation: slideIn 0.3s ease;
  color: var(--text-main);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.insight-item strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.95rem;
}

.insight-warning {
  border-left-color: #f59e0b;
  background: rgba(245, 158, 11, 0.05);
}
.insight-warning strong { color: #fbbf24; }

.insight-success {
  border-left-color: var(--accent-2);
  background: rgba(16, 185, 129, 0.05);
}
.insight-success strong { color: #34d399; }

.insight-error {
  border-left-color: var(--error);
  background: rgba(239, 68, 68, 0.05);
}
.insight-error strong { color: #f87171; }

.insight-info {
  border-left-color: var(--accent-1);
  background: rgba(6, 182, 212, 0.05);
}
.insight-info strong { color: #67e8f9; }

/* Calculate Button */
.btn-primary {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff;
  border: none;
  border-radius: 0.75rem;
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(6, 182, 212, 0.4);
}

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

.btn-primary:disabled {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
}

/* Stale State */
.stale {
  opacity: 0.5;
  filter: grayscale(0.5);
  transition: all 0.3s ease;
  pointer-events: none;
}

.info-text {
  text-align: center;
  color: var(--text-main);
  font-size: 1.1rem;
  font-weight: 500;
  margin-top: 2rem;
  line-height: 1.6;
}

.disclaimer {
  text-align: center;
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.65rem;
  margin-top: 1.5rem;
  padding: 0 1rem;
  line-height: 1.4;
}

.ad-banner {
  width: 100%;
  min-height: 90px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.ad-banner-bottom {
  margin-top: 1.5rem;
  margin-bottom: 0;
}

.ad-placeholder-text {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

@media (max-width: 480px) {
  h1 { font-size: 2rem; }
  .glass-panel { padding: 1.25rem; }
  .results-value { font-size: 2.5rem; }
}
