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

:root {
  --bg: #0f1923;
  --bg-light: #162231;
  --text: #b0bec5;
  --text-bright: #e1e8ed;
  --primary: #4d8ae5;
  --primary-dark: #3a6fc2;
  --primary-light: rgba(77, 138, 229, 0.12);
  --completed: #43a047;
  --completed-light: rgba(67, 160, 71, 0.12);
  --locked: #546e7a;
  --locked-light: rgba(84, 110, 122, 0.1);
  --link: #4d8ae5;
  --link-hover: #7aabf0;
  --border: #263545;
  --success: #43a047;
  --error: #ef5350;
}

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

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  color: var(--link-hover);
}

/* === Main Content === */
#app {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
}

/* === Footer === */
.site-footer {
  text-align: center;
  padding: 1rem 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--locked);
}

/* === Landing Page === */
.landing-hero {
  text-align: center;
  padding: 3rem 0 1.5rem;
}

.landing-hero h1 {
  font-size: 2.5rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.landing-hero .tagline {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 2rem;
}

.landing-layout {
  display: flex;
  gap: 3rem;
  align-items: flex-start;
  margin-top: 2rem;
}

.landing-left {
  flex: 1;
  min-width: 0;
}

.landing-right {
  flex-shrink: 0;
  width: 340px;
}

.landing-how {
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-light);
}

.landing-how h2 {
  color: var(--text-bright);
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

.landing-how ol {
  padding-left: 1.5rem;
}

.landing-how li {
  margin-bottom: 0.75rem;
  color: var(--text);
}

.landing-how li code {
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.9em;
}

.cta-button {
  display: inline-block;
  padding: 0.75rem 2rem;
  background: var(--primary);
  color: var(--text-bright);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, box-shadow 0.2s;
}

.cta-button:hover {
  background: var(--primary-dark);
  color: var(--text-bright);
  box-shadow: 0 2px 8px rgba(50, 108, 229, 0.3);
}

/* === Challenges List === */
.challenges-list {
  margin: 2rem 0;
}

.challenges-list h2 {
  color: var(--text-bright);
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.challenge-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  text-decoration: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.challenge-row.unlocked {
  border-color: var(--primary);
  background: var(--primary-light);
}

.challenge-row.unlocked:hover {
  box-shadow: 0 2px 8px rgba(50, 108, 229, 0.15);
}

.challenge-row.completed {
  border-color: var(--completed);
  background: var(--completed-light);
}

.challenge-row.completed:hover {
  box-shadow: 0 2px 8px rgba(26, 138, 63, 0.15);
}

.challenge-day {
  font-weight: 600;
  color: var(--text-bright);
  min-width: 3.5rem;
}

.challenge-title {
  flex: 1;
  color: var(--text);
}

.challenge-status {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.challenge-row.completed .challenge-status {
  color: var(--completed);
}

/* === Calendar Grid === */
.calendar-header {
  text-align: center;
  margin-bottom: 2rem;
}

.calendar-header h1 {
  color: var(--primary);
  font-size: 1.8rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
}

.day-tile {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1.5rem;
  font-weight: 600;
  cursor: default;
  transition: border-color 0.2s, box-shadow 0.2s;
  text-decoration: none;
  position: relative;
}

.day-tile .day-number {
  font-size: 1.5rem;
}

.day-tile .day-status {
  font-size: 0.6rem;
  margin-top: 0.25rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Locked */
.day-tile.locked {
  color: var(--locked);
  background: var(--locked-light);
  border-color: var(--border);
}

/* Unlocked */
.day-tile.unlocked {
  color: var(--primary);
  background: var(--primary-light);
  border-color: var(--primary);
  cursor: pointer;
}

.day-tile.unlocked:hover {
  box-shadow: 0 2px 8px rgba(50, 108, 229, 0.2);
}

/* Completed */
.day-tile.completed {
  color: var(--completed);
  background: var(--completed-light);
  border-color: var(--completed);
  cursor: pointer;
}

.day-tile.completed:hover {
  box-shadow: 0 2px 8px rgba(26, 138, 63, 0.2);
}

/* === Day Zero Row === */
.day-zero-row {
  margin-bottom: 0.5rem;
}

.day-tile.day-zero {
  aspect-ratio: auto;
  flex-direction: row;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  width: 100%;
  font-size: 1rem;
}

.day-tile.day-zero .day-number {
  font-size: 1.1rem;
  font-weight: 600;
}

.day-tile.day-zero .day-title {
  flex: 1;
  font-size: 0.95rem;
  font-weight: normal;
  color: var(--text);
}

.day-tile.day-zero .day-status {
  font-size: 0.6rem;
  margin-top: 0;
}

/* === Day Page === */
.day-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.day-page h1 {
  color: var(--primary);
  font-size: 1.6rem;
}

.day-page .day-description {
  color: var(--text);
  margin-bottom: 0.75rem;
  line-height: 1.5;
  font-size: 0.95rem;
}

.day-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.day-left {
  flex: 1;
  min-width: 0;
}

.day-right {
  flex-shrink: 0;
  width: 280px;
}

.day-page .chart-link {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: 6px;
  color: var(--primary);
  font-weight: 500;
  margin-bottom: 1.5rem;
  transition: background 0.2s, box-shadow 0.2s;
}

.day-page .chart-link:hover {
  background: var(--primary);
  color: var(--text-bright);
}

/* === Setup & Hints === */
.setup-section {
  margin-bottom: 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-light);
}

.setup-section h2 {
  color: var(--text-bright);
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.setup-steps {
  line-height: 1.6;
  font-size: 0.9rem;
}

.setup-steps code {
  display: block;
  background: #1e293b;
  color: #e2e8f0;
  padding: 0.35rem 0.65rem;
  border-radius: 4px;
  margin: 0.15rem 0 0.5rem;
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
  font-size: 0.85rem;
  overflow-x: auto;
}

.hints-section {
  margin-bottom: 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-light);
}

.hints-section h2 {
  color: var(--text-bright);
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.hint-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.5rem;
  background: var(--bg);
}

.hint-item:last-child {
  margin-bottom: 0;
}

.hint-item summary {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.9rem;
}

.hint-item summary:hover {
  color: var(--primary-dark);
}

.hint-item p {
  padding: 0.5rem 0.75rem 0.75rem;
  color: var(--text);
  line-height: 1.6;
}

.hint-item code {
  background: #1e293b;
  color: #e2e8f0;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
  font-size: 0.85em;
}

.stopwatch {
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-light);
  font-weight: 500;
}

.flag-section {
  margin-top: 1rem;
}

.flag-section label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-bright);
  font-weight: 500;
}

.flag-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.flag-input-row input[type="text"] {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-bright);
  font-family: inherit;
  font-size: 0.9rem;
}

.flag-input-row input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(50, 108, 229, 0.1);
}

.flag-input-row button {
  padding: 0.5rem 1.25rem;
  background: var(--primary);
  color: var(--text-bright);
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.flag-input-row button:hover {
  background: var(--primary-dark);
}

.flag-result {
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: 8px;
  font-weight: 600;
}

.flag-result.success {
  color: var(--success);
  border: 1px solid var(--success);
  background: var(--completed-light);
}

.flag-result.error {
  color: var(--error);
  border: 1px solid var(--error);
  background: rgba(239, 83, 80, 0.12);
}

.day-completed-banner {
  padding: 1rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--completed);
  border-radius: 8px;
  background: var(--completed-light);
  color: var(--completed);
  font-weight: 600;
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-light);
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}

.back-link:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.back-link svg {
  display: block;
}

.start-btn {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  background: var(--primary);
  color: var(--text-bright);
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 0.75rem;
  transition: background 0.2s, box-shadow 0.2s;
}

.start-btn:hover {
  background: var(--primary-dark);
  box-shadow: 0 2px 8px rgba(50, 108, 229, 0.3);
}

/* === Responsive === */
@media (max-width: 768px) {
  .landing-layout {
    flex-direction: column;
  }

  .landing-right {
    width: 100%;
  }

  .day-layout {
    flex-direction: column;
  }

  .day-right {
    width: 100%;
  }
}

@media (max-width: 600px) {
  .calendar-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
  }

  .day-tile {
    font-size: 1.1rem;
  }

  .day-tile .day-status {
    font-size: 0.5rem;
  }

  .landing-hero h1 {
    font-size: 1.8rem;
  }

  #app {
    padding: 1rem;
  }
}
