:root {
  --bg: var(--tg-theme-bg-color, #1a1a2e);
  --bg2: var(--tg-theme-secondary-bg-color, #16213e);
  --text: var(--tg-theme-text-color, #eee);
  --hint: var(--tg-theme-hint-color, #aaa);
  --accent: var(--tg-theme-button-color, #7c4dff);
  --accent-text: var(--tg-theme-button-text-color, #fff);
  --radius: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 40px;
}

#app { max-width: 480px; margin: 0 auto; padding: 16px; }

.screen { display: none; }
.screen.active { display: block; }

/* HEADER */
.header { text-align: center; padding: 24px 0 20px; }
.stars { font-size: 20px; letter-spacing: 8px; opacity: 0.6; margin-bottom: 8px; }
.header h1 { font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.subtitle { color: var(--hint); font-size: 14px; }

/* FORM */
.form { display: flex; flex-direction: column; gap: 18px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--hint); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }

input[type="text"],
input[type="number"] {
  background: var(--bg2);
  border: 1.5px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  padding: 12px 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}
input:focus { border-color: var(--accent); }
input::placeholder { color: var(--hint); }

.row { display: flex; gap: 8px; }
.row input[type="number"] { flex: 1; text-align: center; }
#year { flex: 2 !important; }

.hint { font-size: 12px; color: var(--hint); }

/* CITY DROPDOWN */
.city-wrap { position: relative; }
.dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--bg2);
  border: 1.5px solid rgba(255,255,255,0.15);
  border-radius: var(--radius);
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.dropdown.hidden { display: none; }
.dropdown-item {
  padding: 12px 14px;
  cursor: pointer;
  font-size: 15px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  transition: background 0.15s;
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover, .dropdown-item.selected { background: rgba(124,77,255,0.2); }
.dropdown-item .city-name { font-weight: 500; }
.dropdown-item .city-country { font-size: 12px; color: var(--hint); margin-top: 2px; }

/* BUTTONS */
.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  padding: 14px;
  width: 100%;
  cursor: pointer;
  margin-top: 4px;
  transition: opacity 0.2s, transform 0.1s;
}
.btn-primary:active { transform: scale(0.98); opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg2);
  color: var(--text);
  border: 1.5px solid rgba(255,255,255,0.15);
  border-radius: var(--radius);
  font-size: 15px;
  padding: 13px;
  width: 100%;
  cursor: pointer;
  margin-top: 16px;
}

/* ERROR */
.error {
  background: rgba(255, 80, 80, 0.15);
  border: 1px solid rgba(255,80,80,0.3);
  border-radius: 10px;
  color: #ff6b6b;
  padding: 12px 14px;
  font-size: 14px;
}
.error.hidden { display: none; }

/* LOADING */
#loading-screen { text-align: center; padding: 60px 20px; }
.planet-spin {
  font-size: 64px;
  display: inline-block;
  animation: spin 3s linear infinite;
  margin-bottom: 20px;
}
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
#loading-screen h2 { font-size: 22px; margin-bottom: 10px; }
#loading-text { color: var(--hint); font-size: 15px; margin-bottom: 28px; }

.loading-steps { display: flex; flex-direction: column; gap: 10px; text-align: left; max-width: 220px; margin: 0 auto; }
.step {
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--bg2);
  font-size: 14px;
  opacity: 0.4;
  transition: all 0.4s;
}
.step.active { opacity: 1; border-left: 3px solid var(--accent); }
.step.done { opacity: 0.7; }

/* RESULT */
.result-header { text-align: center; padding: 24px 0 16px; }
.result-header h2 { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
#result-meta { color: var(--hint); font-size: 14px; }

/* PLANETS GRID */
.planets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 16px 0;
}
.planet-card {
  background: var(--bg2);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.07);
}
.planet-card .pname { font-size: 12px; color: var(--hint); margin-bottom: 4px; }
.planet-card .psign { font-size: 15px; font-weight: 600; }
.planet-card .phouse { font-size: 11px; color: var(--hint); margin-top: 2px; }
.planet-card.retro .psign::after { content: ' ℞'; color: #ff8c00; font-size: 12px; }

/* READING */
.reading-section { margin-top: 8px; }
.reading-section h3 { font-size: 18px; margin-bottom: 12px; }
.reading-text {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
  border: 1px solid rgba(255,255,255,0.07);
}
.reading-text strong { color: #c8a8ff; }
