:root {
  --meadow-top: #eef6e8;
  --meadow-mid: #dff0d8;
  --meadow-deep: #cbe3c4;
  --wood-dark: #5c3718;
  --wood-mid: #8a5529;
  --wood-light: #b97d45;
  --parchment: #fdf4dc;
  --parchment-deep: #f4e2bc;
  --ink: #352114;
  --ink-soft: #6e4e37;
  --orchid: #b856e8;
  --orchid-deep: #7f29b0;
  --petal: #e86ca8;
  --petal-deep: #b83c79;
  --leaf: #5ca447;
  --leaf-deep: #3d7a2d;
  --gold: #ffca3a;
  --gold-deep: #c98508;
  --shadow-soft: 0 10px 22px rgba(61, 40, 18, 0.16);
  --radius-tile: 16px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 18%, rgba(184, 86, 232, 0.12) 0%, transparent 36%),
    radial-gradient(circle at 86% 32%, rgba(232, 108, 168, 0.12) 0%, transparent 40%),
    radial-gradient(#b7d7ad 1.5px, transparent 1.5px),
    linear-gradient(180deg, var(--meadow-top) 0%, var(--meadow-mid) 52%, var(--meadow-deep) 100%);
  background-size: auto, auto, 24px 24px, auto;
}

.app-shell {
  max-width: 820px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

/* Stardew Wooden HUD Header */
.hud-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #9f6737 0%, #835026 100%);
  color: #fff8e7;
  border-bottom: 4px solid var(--wood-dark);
  box-shadow: 0 4px 12px rgba(53, 33, 20, 0.22);
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.hud-heart {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--parchment);
  border: 2.5px solid var(--wood-dark);
  box-shadow: inset 0 -2px 0 #dfc79a;
  font-size: 20px;
  flex-shrink: 0;
}

.hud-brand h1 {
  margin: 0;
  font-family: 'Fredoka', sans-serif;
  font-size: 1.12rem;
  line-height: 1.15;
  text-shadow: 0 2px 0 var(--wood-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-subtitle {
  margin: 2px 0 0;
  font-size: 0.76rem;
  font-weight: 800;
  color: #f7dfb9;
}

.hud-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--ink);
  background: var(--parchment);
  border: 2px solid var(--wood-dark);
  box-shadow: 0 2px 0 var(--wood-dark);
}

.stat-stars .stat-icon {
  color: var(--gold-deep);
}

.stat-done .stat-icon {
  color: var(--leaf-deep);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 2px solid var(--wood-dark);
  background: var(--parchment);
  box-shadow: 0 2px 0 var(--wood-dark);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
}

.icon-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 4px;
  flex-wrap: wrap;
}

.filter-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.chip {
  border: 2px solid var(--wood-mid);
  background: var(--parchment);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 5px 11px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
}

.chip.active {
  background: linear-gradient(180deg, var(--orchid) 0%, var(--orchid-deep) 100%);
  border-color: #5c1984;
  color: #fff;
  box-shadow: 0 2px 0 #5c1984;
}

.btn-jump {
  border: 2px solid var(--leaf-deep);
  background: #e8f6e1;
  color: var(--leaf-deep);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 5px 11px;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--leaf-deep);
}

/* Willow & Orchid Banner */
.garden-banner {
  position: relative;
  margin: 10px 14px 2px;
  border-radius: 18px;
  border: 3px solid var(--wood-mid);
  box-shadow: 0 4px 0 var(--wood-dark);
  overflow: hidden;
  background: #e6f3df;
}

.willow-svg {
  display: block;
  width: 100%;
  height: 92px;
}

.garden-caption {
  position: absolute;
  right: 10px;
  bottom: 6px;
  font-family: 'Fredoka', sans-serif;
  font-size: 0.74rem;
  color: #fff;
  background: rgba(61, 122, 45, 0.85);
  padding: 3px 9px;
  border-radius: 999px;
  border: 1.5px solid #d9f2cf;
}

/* Map Canvas */
.map-viewport {
  padding: 14px 14px 28px;
}

.map-canvas {
  position: relative;
  width: 100%;
}

.path-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.tiles-layer {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.board-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

.board-row.single {
  grid-template-columns: minmax(0, 260px);
  justify-content: center;
}

@media (min-width: 640px) {
  .board-row {
    gap: 28px;
    padding: 0 18px;
  }
  .board-row.single {
    grid-template-columns: minmax(0, 300px);
  }
}

/* Stardew Wooden Parchment Plaque */
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(180deg, var(--parchment) 0%, var(--parchment-deep) 100%);
  border: 3px solid var(--wood-mid);
  border-radius: var(--radius-tile);
  box-shadow:
    inset 0 0 0 2px #fff7e6,
    0 6px 0 var(--wood-dark),
    var(--shadow-soft);
  padding: 12px 11px 10px;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
  text-align: left;
  min-height: 150px;
  user-select: none;
  overflow: hidden;
}

.tile:hover {
  transform: translateY(-2px);
}

.tile:active {
  transform: translateY(4px);
  box-shadow: inset 0 0 0 2px #fff7e6, 0 2px 0 var(--wood-dark);
}

/* Orchid / Leaf top ribbon */
.tile-stripe {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 10px;
  background: linear-gradient(90deg, #b856e8, #e86ca8);
}

.tile.status-completed {
  border-color: var(--leaf-deep);
  box-shadow: inset 0 0 0 2px #f0fae9, 0 6px 0 #26571b, var(--shadow-soft);
}
.tile.status-completed .tile-stripe {
  background: linear-gradient(90deg, var(--leaf), #8bd46a);
}

.tile.status-in_progress {
  border-color: var(--orchid-deep);
  box-shadow: inset 0 0 0 2px #fff2fc, 0 6px 0 #5b1882, 0 10px 24px rgba(127, 41, 176, 0.24);
}
.tile.status-in_progress .tile-stripe {
  background: linear-gradient(90deg, var(--petal), var(--orchid));
}

.tile.is-tbd .tile-stripe {
  background: linear-gradient(90deg, #a792b5, #c6b5d1);
}

.tile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 6px;
}

.level-badge {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 8px;
  background: #efe2fa;
  color: var(--orchid-deep);
  border: 1.5px solid #cda4e8;
}

.date-pill {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 8px;
  background: #e8f5e1;
  color: var(--leaf-deep);
  border: 1.5px solid #b8deb0;
  white-space: nowrap;
}

.tile-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 5px;
  margin: 8px 0;
}

.tile-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #fffaf0;
  border: 2px solid #d5b68a;
  font-size: 1.45rem;
  line-height: 1;
}

.tile-title {
  margin: 0;
  font-family: 'Fredoka', sans-serif;
  font-size: 0.94rem;
  line-height: 1.2;
  color: var(--ink);
  word-break: break-word;
}

.tile-note-preview {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.25;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(255, 250, 240, 0.85);
  border: 1.5px solid #dfc59c;
}

.tile-stars {
  display: inline-flex;
  gap: 2px;
  font-size: 1rem;
  line-height: 1;
}

.tile-stars .star {
  color: #d6c3a5;
}

.tile-stars .star.earned {
  color: var(--gold);
  text-shadow: 0 1px 0 var(--gold-deep);
}

.status-tag {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
}

.status-completed .status-tag {
  color: var(--leaf-deep);
}
.status-in_progress .status-tag {
  color: var(--orchid-deep);
}

/* Present Day Marker Node */
.tile-present {
  background: linear-gradient(165deg, #f9ecff 0%, #ead6f7 100%);
  border-color: var(--orchid-deep);
  box-shadow: inset 0 0 0 2px #fff7ff, 0 6px 0 #5b1882, var(--shadow-soft);
  cursor: default;
  min-height: 130px;
}

.tile-present:hover {
  transform: none;
}

.tile-present .tile-stripe {
  background: linear-gradient(90deg, var(--leaf), var(--orchid), var(--petal));
}

.present-avatar {
  font-size: 1.9rem;
  animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.present-badge {
  background: var(--orchid-deep);
  color: #fff;
  border-color: var(--orchid-deep);
}

/* Floating Add Button */
.fab-add {
  position: fixed;
  right: max(16px, calc(50% - 394px));
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 14px;
  border: 3px solid var(--wood-dark);
  background: linear-gradient(180deg, var(--orchid) 0%, var(--orchid-deep) 100%);
  color: #fff;
  font-family: 'Fredoka', sans-serif;
  font-size: 0.96rem;
  box-shadow: 0 5px 0 var(--wood-dark), 0 10px 22px rgba(92, 25, 132, 0.3);
  cursor: pointer;
}

.fab-add:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--wood-dark);
}

.fab-plus {
  font-size: 1.2rem;
  line-height: 1;
}

/* Bottom Sheet / Modal */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(34, 22, 12, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px 0 0;
}

.sheet-backdrop[hidden] {
  display: none;
}

@media (min-width: 600px) {
  .sheet-backdrop {
    align-items: center;
    padding: 20px;
  }
}

.sheet {
  width: 100%;
  max-width: 480px;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--parchment);
  border-radius: 20px 20px 0 0;
  border: 3px solid var(--wood-dark);
  border-bottom: none;
  padding: 10px 18px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 30px rgba(34, 22, 12, 0.25);
}

@media (min-width: 600px) {
  .sheet {
    border-radius: 20px;
    border-bottom: 3px solid var(--wood-dark);
    padding-bottom: 20px;
  }
}

.sheet-handle {
  width: 42px;
  height: 5px;
  border-radius: 999px;
  background: #cfa97a;
  margin: 2px auto 10px;
}

@media (min-width: 600px) {
  .sheet-handle {
    display: none;
  }
}

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

.sheet-header h2 {
  margin: 0;
  font-family: 'Fredoka', sans-serif;
  font-size: 1.2rem;
}

.close-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 2px solid var(--wood-mid);
  background: #fffaf0;
  cursor: pointer;
  font-weight: 800;
}

.sheet-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.icon-title-row {
  grid-template-columns: 74px 1fr;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--ink-soft);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  background: #fffdf7;
  border: 2px solid #cfa97a;
  border-radius: 10px;
  padding: 9px 11px;
  outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--orchid);
}

.field-icon input {
  text-align: center;
  font-size: 1.25rem;
}

/* Star Picker */
.star-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 41px;
}

.star-btn {
  border: 2px solid #cfa97a;
  background: #fffdf7;
  color: #d6c3a5;
  font-size: 1.3rem;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
  line-height: 1;
}

.star-btn.active {
  color: var(--gold);
  background: #fff9e6;
  border-color: var(--gold-deep);
}

.star-clear {
  border: 2px solid #cfa97a;
  background: #fffdf7;
  color: var(--ink-soft);
  font-weight: 800;
  font-size: 0.8rem;
  height: 38px;
  padding: 0 10px;
  border-radius: 10px;
  cursor: pointer;
}

.sheet-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.spacer {
  flex: 1;
}

.btn-primary,
.btn-secondary,
.btn-danger {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.95rem;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(180deg, var(--leaf) 0%, var(--leaf-deep) 100%);
  color: #fff;
  border: 2px solid #26571b;
  box-shadow: 0 3px 0 #26571b;
}

.btn-secondary {
  background: #fffdf7;
  color: var(--ink);
  border: 2px solid #cfa97a;
}

.btn-danger {
  background: #fff0f5;
  color: #b83c79;
  border: 2px solid #e6a6c5;
}

.options-note {
  margin: 0 0 12px;
  font-size: 0.86rem;
  line-height: 1.4;
  color: var(--ink-soft);
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  border: 2px solid #cfa97a;
  background: #fffdf7;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
}

.btn-option.danger {
  color: #b83c79;
  border-color: #e6a6c5;
  background: #fff5f9;
}
