:root {
  --paper: #f7f6ef;
  --surface: #fffef9;
  --ink: #263e33;
  --primary: #ea580c;
  --primary-hover: #c2410c;
  --primary-soft: #ffedd5;
  --accent: #f59e0b;
  --accent-soft: #fef3c7;
  --green: #2e5848;
  --green-soft: #e9eddc;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --muted: #64748b;
  --line: #dfe3d5;
  --soft: #f1f3e8;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --font-base: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --font-serif: Georgia, serif;
}

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

body {
  font-family: var(--font-base);
  background-color: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Beefnoodle Return Home Bar */
#bn-home-return {
  display: block;
  position: relative;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 6px max(18px, calc((100% - 1100px) / 2 + 18px));
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

#bn-home-return a {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 84px;
  height: 48px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  color: var(--green);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

#bn-home-return a:hover {
  background: var(--soft);
}

#bn-home-return .bn-return-arrow {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#bn-home-return .bn-return-logo {
  width: 32px;
  height: 32px;
}

/* Offline Banner */
.offline-banner {
  background: #fef08a;
  color: #854d0e;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  border-bottom: 1px solid #fde047;
  display: none;
}
.offline-banner.active {
  display: block;
}

/* Main Container */
.app-shell {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 20px 80px;
  flex: 1;
}

/* Top App Header */
header.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
  box-shadow: 0 4px 10px rgba(234, 88, 12, 0.25);
}

.brand-text h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--ink);
}

.brand-text h1 em {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: normal;
  color: var(--primary);
}

.brand-text p {
  font-size: 13px;
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Language Switcher Buttons */
.lang-selector {
  display: inline-flex;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 3px;
}

.lang-btn {
  border: none;
  background: transparent;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  min-height: 40px;
  transition: all 0.2s;
}

.lang-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

/* Common Buttons */
button, input, select, textarea {
  font: inherit;
  color: inherit;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.18s ease;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 3px 10px rgba(234, 88, 12, 0.22);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.btn-secondary:hover {
  background: var(--soft);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

.btn-sm {
  min-height: 38px;
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 10px;
}

/* Cards & Panels */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 22px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.02);
}

.eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 6px;
}

/* Habit Disclaimer Banner */
.disclaimer-banner {
  background: var(--accent-soft);
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 13px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Entry Flow Cards (Solo, Group, Join) */
.entry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 18px;
  margin: 24px 0;
}

.entry-card {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px 22px;
  cursor: pointer;
  transition: all 0.22s ease;
  display: flex;
  flex-direction: column;
  position: relative;
}

.entry-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(234, 88, 12, 0.08);
}

.entry-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin-bottom: 16px;
}

.entry-card h3 {
  font-size: 20px;
  font-weight: 750;
  margin-bottom: 8px;
}

.entry-card p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 20px;
  flex: 1;
}

/* Catalogue Browser */
.category-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.pill-btn {
  padding: 8px 16px;
  border-radius: 30px;
  background: var(--soft);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-height: 42px;
}

.pill-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.template-card {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px;
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  flex-direction: column;
}

.template-card:hover, .template-card.selected {
  border-color: var(--primary);
  background: #fffbf7;
}

.template-card.selected {
  box-shadow: 0 0 0 2px var(--primary);
}

.template-card h4 {
  font-size: 17px;
  font-weight: 750;
  margin-bottom: 6px;
}

.template-card p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 12px;
  flex: 1;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  align-self: flex-start;
}

.badge-honesty { background: #e0f2fe; color: #0369a1; }
.badge-photo-req { background: #fef3c7; color: #b45309; }
.badge-photo-opt { background: #f3e8ff; color: #7e22ce; }

/* Duration Slider */
.slider-container {
  margin: 20px 0;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.slider-val {
  font-size: 26px;
  font-weight: 850;
  color: var(--primary);
}

input[type=range] {
  width: 100%;
  accent-color: var(--primary);
  height: 8px;
  cursor: pointer;
}

/* Game Board */
.game-header-card {
  background: linear-gradient(135deg, #fff7ed, var(--surface));
  border: 1.5px solid #fed7aa;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 22px;
}

.game-topline {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.game-title-group h2 {
  font-size: 26px;
  font-weight: 850;
  letter-spacing: -0.5px;
}

.game-meta-badge {
  background: #ffedd5;
  color: #9a3412;
  font-weight: 750;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 20px;
}

.game-countdown {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 16px;
}

.game-countdown strong {
  color: var(--primary);
}

/* Player Board Grid */
.players-board {
  display: grid;
  gap: 16px;
  margin: 20px 0;
}

.player-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.player-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.player-name-avatar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 750;
  font-size: 16px;
}

.player-score {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary);
}

/* 14 Days Tactile Grid */
.days-grid {
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  gap: 6px;
}

@media (max-width: 768px) {
  .days-grid {
    grid-template-columns: repeat(7, 1fr);
  }
}

.day-box {
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1.5px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  background: var(--paper);
  color: var(--muted);
  position: relative;
  transition: all 0.15s;
}

.day-box.completed {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.day-box.pending {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.day-box.missed {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
}

.day-box.rejected {
  background: #fecaca;
  color: #991b1b;
  border-color: #ef4444;
}

.day-box.awaiting {
  border: 2px dashed var(--primary);
  background: var(--surface);
  color: var(--primary);
}

.day-box.not-joined {
  background: #f1f5f9;
  color: #94a3b8;
  border-style: dotted;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(38, 62, 51, 0.45);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.16);
  position: relative;
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  border: none;
  background: var(--soft);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--ink);
}

.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  min-height: 48px;
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

/* Reactions Bar */
.reactions-bar {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.react-btn {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 14px;
  cursor: pointer;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.react-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* Toast Notifications */
.toast-msg {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 22px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 200;
  display: none;
}
.toast-msg.show {
  display: block;
  animation: toastFade 2.5s forwards;
}

@keyframes toastFade {
  0% { opacity: 0; transform: translate(-50%, 15px); }
  15% { opacity: 1; transform: translate(-50%, 0); }
  85% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -10px); }
}
