:root {
  --bg-color: #faf9f6;
  --text-color: #333333;
  --text-muted: #666666;
  --card-bg: #ffffff;
  --border-color: #eae8e1;

  /* Soft Morning Accents */
  --accent-primary: #8da98f; /* Sage green */
  --accent-hover: #7b977d;
  --accent-danger: #cc8b79; /* Soft terracotta */
  --accent-danger-hover: #ba7967;

  /* Typography & Structure */
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --border-radius: 16px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
}

body {
  font-family: var(--font-family);
  line-height: 1.6;
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  padding: 0;
  font-size: 16px;
  /* Improve font rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Mobile-first layout container */
.container {
  max-width: 600px; /* Kept narrow for mobile-first feel even on desktop */
  margin: 0 auto;
  padding: 16px;
}

.main-banner {
  background-color: var(--accent-primary);
  color: var(--card-bg);
  padding: 8px 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
  text-align: left;
}

.banner-inner {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 2;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--card-bg);
}

.brand-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.brand-logo:hover .brand-icon {
  transform: scale(1.18) rotate(-8deg);
}

h1.brand-name {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
  margin: 0;
  padding: 0;
  line-height: 1.2;
}

.board-badge {
  background-color: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  backdrop-filter: blur(4px);
}

/* Playful background CSS bubbles */
.banner-decoration {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 1;
}

.banner-decoration .bubble {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  animation: floatBubble 6s ease-in-out infinite alternate;
}

.banner-decoration .b1 {
  width: 45px;
  height: 45px;
  top: -12px;
  right: 15%;
  animation-duration: 7s;
}

.banner-decoration .b2 {
  width: 25px;
  height: 25px;
  bottom: -6px;
  left: 30%;
  animation-duration: 5s;
  animation-delay: 1s;
}

.banner-decoration .b3 {
  width: 60px;
  height: 60px;
  top: 6px;
  left: -15px;
  animation-duration: 8s;
  animation-delay: 2s;
}

@keyframes floatBubble {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-5px) scale(1.08); }
}

h1, h2, h3, h4 {
  color: var(--text-color);
  font-weight: 600;
  line-height: 1.3;
}

h1 { font-size: 1.75rem; margin-bottom: 8px; }
h2 { font-size: 1.4rem; margin-top: 0; margin-bottom: 12px; }
h3 { font-size: 1.25rem; margin-bottom: 12px; }

p {
  margin-top: 0;
  margin-bottom: 16px;
  color: var(--text-muted);
}

a {
  color: var(--accent-hover);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease-in-out;
}

a:hover {
  text-decoration: underline;
}

/* Cards & Sections */
section, .prop {
  background-color: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
}

/* Forms & Inputs (Mobile Optimized) */
.form-group {
  margin-bottom: 24px;
}

.label-text {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 0.95rem;
  color: var(--text-color);
}

input[type="text"] {
  width: 100%;
  padding: 14px 16px; /* Large touch target */
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background-color: var(--bg-color);
  font-family: inherit;
  font-size: 16px; /* Prevents iOS zoom */
  color: var(--text-color);
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(141, 169, 143, 0.2);
}

/* Availability Table (Tabular UI) */
.availability-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 16px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.availability-table th,
.availability-table td {
  padding: 12px;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  background-color: var(--card-bg);
}

.availability-table th {
  background-color: var(--bg-color);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.availability-table tr:last-child td {
  border-bottom: none;
}
.availability-table th:last-child,
.availability-table td:last-child {
  border-right: none;
}

.availability-table td:first-child {
  text-align: left;
  font-weight: 500;
  color: var(--text-color);
}

/* Custom Checkbox (Mobile Friendly) */
.availability-table input[type="checkbox"] {
  appearance: none;
  background-color: var(--bg-color);
  margin: 0;
  font: inherit;
  color: currentColor;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}

.availability-table input[type="checkbox"]::before {
  content: "";
  width: 12px;
  height: 12px;
  transform: scale(0);
  transition: 120ms transform ease-in-out;
  box-shadow: inset 1em 1em var(--card-bg);
  background-color: var(--card-bg);
  transform-origin: center;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

.availability-table input[type="checkbox"]:checked {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.availability-table input[type="checkbox"]:checked::before {
  transform: scale(1);
}

/* Buttons */
.actions {
  display: flex;
  gap: 12px;
  flex-direction: column; /* Stack on mobile by default */
}

@media (min-width: 480px) {
  .actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

button, .manage-select {
  display: inline-block;
  width: 100%;
  padding: 14px 20px; /* Large touch targets */
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  background-color: var(--accent-primary);
  color: #fff;
  box-sizing: border-box;
  box-shadow: var(--shadow-sm);
}

@media (min-width: 480px) {
  button, .manage-select {
    width: auto;
  }
}

button:active, .manage-select:active {
  transform: scale(0.98);
}

button:hover, .manage-select:hover {
  background-color: var(--accent-hover);
}

button.secondary {
  background-color: var(--bg-color);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  box-shadow: none;
}

button.secondary:hover {
  background-color: #f0eee6;
}

button.danger {
  background-color: var(--accent-danger);
}

button.danger:hover {
  background-color: var(--accent-danger-hover);
}

/* Manage Select Dropdown */
.manage-select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FFFFFF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 16px top 50%;
  background-size: 12px auto;
  padding-right: 40px;
}

.manage-select option {
  background: var(--card-bg);
  color: var(--text-color);
}

/* Matches */
#matches-list > p {
  margin-bottom: 0;
}

.match-card {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 16px;
  background-color: var(--card-bg);
  margin-bottom: 12px;
}

.match-card h3 {
  margin-top: 0;
  margin-bottom: 4px;
  color: var(--text-color);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.match-card h3 .match-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-weight: normal;
}

.tag-pill {
  background-color: var(--border-color);
  color: var(--text-muted);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
}

.match-card p {
  margin: 4px 0;
  font-size: 0.9em;
}

.match-card strong {
  color: var(--text-color);
  font-weight: 600;
}

/* Value Props / Welcome Screen */
.hero {
  text-align: center;
  padding: 12px 0 20px 0;
}

.hero .subtitle {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 80%;
  margin: 0 auto;
}

.value-props {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.value-props .prop {
  margin-bottom: 0;
}

.prop h3 {
  color: var(--accent-primary);
}

.cta-section {
  text-align: center;
  background-color: var(--card-bg);
  padding: 28px 24px;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

/* Autocomplete styling */
.autocomplete-wrapper {
  position: relative;
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 0 0 12px 12px;
  margin-top: -12px; /* Overlap border-radius of input */
  padding-top: 12px;
  z-index: 1000;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
  display: none;
  list-style: none;
}

.autocomplete-dropdown.active {
  display: block;
}

.autocomplete-item {
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.95em;
  color: var(--text-color);
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background-color: var(--bg-color);
}

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

/* Zero-flash view state rules */
html.has-profile #welcome-page {
  display: none !important;
}

html:not(.has-profile) #dashboard,
html:not(.has-profile) #my-profile,
html:not(.has-profile) #create-board-container {
  display: none !important;
}

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

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

.site-footer a:hover {
  text-decoration: underline;
}

/* Board Stats Card */
.board-stats-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 16px 20px;
  margin: 0 0 16px 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  text-align: center;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent-primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stats-action-call {
  margin: 14px 0 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  text-align: center;
  font-weight: 500;
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
}

/* Stats Table */
.stats-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 0.88rem;
}

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

.stats-table th {
  font-weight: 600;
  color: var(--text-color);
  border-bottom: 2px solid var(--border-color);
}

.stats-table td {
  color: var(--text-color);
}

/* Day Histogram */
.day-histogram {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  height: 54px;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.histogram-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.bar-track {
  flex: 1;
  width: 100%;
  max-width: 20px;
  background-color: var(--border-color);
  border-radius: 3px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.bar-fill {
  width: 100%;
  background-color: var(--accent-primary);
  transition: height 0.3s ease;
}

.day-code {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-color);
  margin-top: 6px;
}

/* Create Board Card & Card Section Titles */
.create-board-card {
  margin-top: 24px;
}

.create-board-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.4;
  margin-top: 4px;
}

.match-card h3.card-title {
  margin-bottom: 20px;
}
