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

html {
  font-size: 20px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f5f5;
  color: #1a1a1a;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* ===== Status Screen ===== */

.status-header {
  padding: 1rem 1.2rem 0.5rem;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
}

.status-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.header-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-shrink: 0;
}

.reminder-btn {
  padding: 0.4rem 0.7rem;
  font-size: 1.2rem;
  background: none;
  border: 1px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.reminder-btn.active {
  border-color: #2e7d32;
  background: #e8f5e9;
}

.app-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #333;
}

.today-date {
  font-size: 1rem;
  color: #666;
  margin-top: 0.2rem;
}

.market-cards {
  flex: 1;
  padding: 0.8rem;
  padding-bottom: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.market-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.card-summary {
  display: flex;
  align-items: center;
  padding: 1rem 1.2rem;
  gap: 0.8rem;
}

.card-thumb {
  width: 3rem;
  height: 3rem;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #e0e0e0;
}

.card-info {
  flex: 1;
  min-width: 0;
}

.card-name {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.3;
}

.card-next {
  font-size: 0.85rem;
  color: #666;
  margin-top: 0.15rem;
}

.card-status {
  flex-shrink: 0;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
}

.card-status.open {
  background: #2e7d32;
}

.card-status.warning {
  background: #e65100;
  font-size: 0.7rem;
  padding: 0.4rem 0.6rem;
  text-align: center;
  max-width: 5.5rem;
  line-height: 1.3;
}

.card-status.closed {
  background: #c62828;
}

/* Expanded card */
.card-details {
  display: none;
  padding: 0.8rem 1.2rem 1rem;
  border-top: 1px solid #eee;
}

.market-card.expanded .card-details {
  display: block;
}

.card-detail-section {
  padding: 0.6rem 0;
}

.card-detail-section + .card-detail-section {
  border-top: 1px solid #f0f0f0;
}

.card-address {
  font-size: 0.9rem;
  color: #555;
  line-height: 1.4;
}

.card-stalls {
  display: flex;
  gap: 1rem;
  margin-top: 0.4rem;
}

.card-stall-item {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

.stall-count {
  font-size: 0.9rem;
  font-weight: 600;
  color: #333;
}

.stall-label {
  font-size: 0.75rem;
  color: #888;
}

.card-status-banner {
  margin: 0.8rem 0;
  padding: 1rem;
  border-radius: 10px;
  text-align: center;
}

.card-status-banner.open {
  background: #2e7d32;
  color: #fff;
}

.card-status-banner.warning {
  background: #e65100;
  color: #fff;
}

.card-status-banner.closed {
  background: #c62828;
  color: #fff;
}

.banner-status-text {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.2;
}

.banner-reason {
  font-size: 1rem;
  margin-top: 0.3rem;
  opacity: 0.9;
}

.banner-opens-again {
  font-size: 1rem;
  margin-top: 0.5rem;
  opacity: 0.9;
}

.upcoming-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.upcoming-list {
  list-style: none;
  padding: 0;
}

.upcoming-list li {
  font-size: 0.9rem;
  padding: 0.35rem 0;
  color: #444;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  justify-content: space-between;
}

.upcoming-list li:last-child {
  border-bottom: none;
}

.upcoming-date {
  font-weight: 500;
}

.upcoming-reason {
  color: #888;
}

.card-remove {
  display: block;
  margin-top: 0.8rem;
  padding: 0.5rem 1rem;
  background: none;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #888;
  cursor: pointer;
  width: 100%;
}

.card-remove:active {
  background: #fee;
  border-color: #c62828;
  color: #c62828;
}

.data-source {
  padding: 0.6rem 1.2rem;
  font-size: 0.7rem;
  color: #999;
  text-align: center;
}

.data-source a {
  color: #999;
  text-decoration: underline;
}

/* ===== Status Footer ===== */

.status-footer {
  position: sticky;
  bottom: 0;
  padding: 0.8rem 1.2rem 1.5rem;
  background: #fff;
  border-top: 1px solid #e0e0e0;
  z-index: 20;
}

/* ===== Picker Screen ===== */

.picker-header {
  padding: 1.5rem 1.2rem 0.5rem;
  background: #fff;
}

.picker-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.picker-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
}

.subtitle {
  font-size: 0.9rem;
  color: #666;
  margin-top: 0.2rem;
}

.search-container {
  padding: 0.8rem 1.2rem;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}

.search-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.search-input {
  flex: 1;
  padding: 0.7rem 1rem;
  font-size: 1.1rem;
  border: 2px solid #ddd;
  border-radius: 10px;
  outline: none;
  -webkit-appearance: none;
}

.search-input:focus {
  border-color: #2e7d32;
}

.view-toggle {
  padding: 0.6rem 0.8rem;
  font-size: 1.2rem;
  background: #fff;
  border: 2px solid #ddd;
  border-radius: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.view-toggle.active {
  border-color: #2e7d32;
  background: #e8f5e9;
}

.market-map {
  flex: 1;
  min-height: 400px;
  height: calc(100vh - 200px);
}

.market-map.hidden {
  display: none;
}

.map-fav-btn {
  display: block;
  margin-top: 0.4rem;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  background: #2e7d32;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
}

.market-list {
  list-style: none;
  padding: 0 0.8rem 6rem;
}

.market-list-item {
  display: flex;
  align-items: center;
  padding: 0.9rem 1rem;
  margin: 0.3rem 0;
  background: #fff;
  border-radius: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-height: 3.2rem;
  gap: 0.8rem;
}

.market-list-item:active {
  background: #e8f5e9;
}

.market-list-item.favorited {
  background: #e8f5e9;
  border: 2px solid #2e7d32;
}

.market-list-item .star {
  font-size: 1.4rem;
  flex-shrink: 0;
  width: 2rem;
  text-align: center;
}

.market-list-item .market-item-info {
  flex: 1;
  min-width: 0;
}

.market-item-name {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.3;
}

.market-item-address {
  font-size: 0.75rem;
  color: #888;
  margin-top: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Picker Footer ===== */

.picker-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.8rem 1.2rem 1.5rem;
  background: #fff;
  border-top: 1px solid #e0e0e0;
  z-index: 20;
}

/* ===== Buttons ===== */

.btn-primary {
  width: 100%;
  padding: 0.9rem 1.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  background: #2e7d32;
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary:active {
  background: #1b5e20;
}

/* ===== Language Toggle ===== */

.lang-toggle {
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 500;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.lang-toggle:active {
  background: #f0f0f0;
}

/* ===== Empty State ===== */

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: #666;
}

.empty-state p {
  font-size: 1.1rem;
  line-height: 1.5;
}

/* ===== Responsive ===== */

/* ===== Install Prompt ===== */

.install-prompt {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0.5rem;
  padding-bottom: env(safe-area-inset-bottom, 0.5rem);
}

.install-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.install-sheet {
  position: relative;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  animation: slideUp 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.install-body {
  background: rgba(255, 255, 255, 0.95);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-radius: 14px;
  padding: 1.4rem 1.2rem;
  text-align: center;
}

.install-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.install-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #000;
  margin-bottom: 0.3rem;
}

.install-desc {
  font-size: 0.8rem;
  color: #666;
  line-height: 1.4;
  margin-bottom: 1rem;
}

.install-steps {
  text-align: left;
  margin: 0 0.2rem;
}

.install-steps:empty {
  display: none;
}

.install-step {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0;
  font-size: 0.85rem;
  color: #333;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.install-step:last-child {
  border-bottom: none;
}

.install-step-num {
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: #007aff;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.install-btn {
  background: rgba(255, 255, 255, 0.95);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-radius: 14px;
  border: none;
  padding: 1rem;
  font-size: 1.05rem;
  font-weight: 500;
  color: #007aff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
}

.install-btn:active {
  background: rgba(240, 240, 240, 0.95);
}

.install-dismiss {
  background: rgba(255, 255, 255, 0.95);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-radius: 14px;
  border: none;
  padding: 1rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: #007aff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
  display: block;
}

.install-dismiss:active {
  background: rgba(240, 240, 240, 0.95);
}

/* --- Android Material variant --- */

.install-android .install-backdrop {
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.install-android .install-sheet {
  gap: 0;
}

.install-android .install-body {
  background: #fff;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border-radius: 28px 28px 0 0;
  padding: 2rem 1.5rem 0.5rem;
}

.install-android .install-icon {
  font-size: 2.5rem;
  margin-bottom: 0.8rem;
}

.install-android .install-title {
  font-size: 1.2rem;
  font-weight: 500;
  color: #1a1a1a;
}

.install-android .install-desc {
  font-size: 0.85rem;
  color: #555;
}

.install-android .install-steps {
  margin: 0;
}

.install-android .install-step {
  border-bottom-color: rgba(0, 0, 0, 0.08);
  color: #1a1a1a;
  font-size: 0.9rem;
}

.install-android .install-step-num {
  background: #2e7d32;
}

.install-android .install-btn {
  background: #2e7d32;
  color: #fff;
  border-radius: 0;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  font-weight: 600;
  font-size: 1rem;
  padding: 1rem;
  letter-spacing: 0.02em;
}

.install-android .install-btn:active {
  background: #1b5e20;
}

.install-android .install-dismiss {
  background: #fff;
  color: #2e7d32;
  border-radius: 0 0 28px 28px;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.9rem;
}

.install-android .install-dismiss:active {
  background: #f5f5f5;
}

/* ===== Responsive ===== */

@media (min-width: 600px) {
  #app {
    max-width: 480px;
    margin: 0 auto;
  }
}
