:root {
  --red: #c62828;
  --red-dark: #8e1515;
  --screen: #eef4f0;
  --screen-ink: #1c2a32;
  --muted: #5b6b73;
  --line: #c5d0d4;
  --led: #7cfc00;
  --blue: #3d7dca;
  --gold: #c9a227;
  --ok: #3d8b5a;
  --danger: #c4453c;
  --shadow: rgba(20, 8, 8, 0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Nunito", "Segoe UI", sans-serif;
  font-size: 16px;
  color: var(--screen-ink);
  background:
    radial-gradient(1200px 600px at 50% -10%, #ef9a9a 0%, transparent 55%),
    linear-gradient(#5a1212, #2b0707);
}

#app { min-height: 100vh; padding: 18px 12px 32px; }

.dex-shell {
  max-width: 1080px;
  margin: 0 auto;
  background: linear-gradient(#d32f2f, var(--red) 18%, var(--red-dark));
  border-radius: 28px 28px 36px 36px;
  padding: 14px 14px 22px;
  box-shadow: 0 18px 40px var(--shadow), inset 0 1px 0 rgba(255,255,255,.25);
}

.dex-lid {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px 14px;
  color: #fff;
}
.dex-led {
  width: 18px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, var(--led) 45%, #2e7d32);
  box-shadow: 0 0 10px var(--led);
}
.dex-lid h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  font-weight: 800;
}
.dex-lid .meta { margin-left: auto; font-size: 0.92rem; opacity: 0.92; }

.dex-screen {
  background: var(--screen);
  border-radius: 18px;
  min-height: 70vh;
  padding: 12px;
  box-shadow: inset 0 0 0 3px #9aaea8, inset 0 8px 18px rgba(0,0,0,.08);
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.nav-primary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}
@media (min-width: 720px) {
  .nav-primary { grid-template-columns: repeat(6, 1fr); }
}
.hub {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 12px;
  align-items: start;
}
@media (max-width: 860px) {
  .hub { grid-template-columns: 1fr; }
}
.hub-note {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: #f7fbf9;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: inherit;
}
.day-agenda li { margin: 6px 0; }
.nav-primary button { width: 100%; padding: 10px 8px; }
.btn.big { width: 100%; padding: 14px; font-size: 1.05rem; }

.today-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 8px; }
.today-head h2 { margin: 0; }
.empty-lead { font-size: 1.1rem; margin: 0 0 12px; }
.habit-row {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  font-family: inherit;
  background: #f7fbf9;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 12px;
  margin-bottom: 8px;
  cursor: pointer;
}
.habit-row .box {
  width: 26px; height: 26px; border-radius: 8px;
  border: 2px solid var(--blue); flex: 0 0 auto;
}
.habit-row .box.on { background: var(--ok); border-color: var(--ok); }
.habit-row.done { opacity: 0.55; cursor: default; background: transparent; }
.habit-copy { display: flex; flex-direction: column; gap: 2px; }
.quick-add { margin-top: 8px; }
.done-block { margin-top: 12px; padding-top: 8px; border-top: 1px dashed var(--line); }
.party-row.quiet { justify-content: flex-end; }
.party-row.quiet .mon-card { width: 72px; padding: 4px; border: 0; background: transparent; cursor: pointer; font-family: inherit; }
.party-row.quiet .mon-card img { width: 48px; height: 48px; }
.wallet-chip {
  margin-left: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
}
nav { display: flex; flex-wrap: wrap; gap: 6px; }
nav button, .btn {
  font-family: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  color: var(--screen-ink);
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(0,0,0,.08);
}
nav button.active { background: var(--blue); color: #fff; }
.btn { background: var(--blue); color: #fff; }
.btn.ghost { background: #fff; color: var(--screen-ink); border: 1px solid var(--line); }
.btn.good { background: var(--ok); }
.btn.danger { background: var(--danger); color: #fff; }

.layout { padding: 4px 2px 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.panel h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
  color: var(--red-dark);
}

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.check:last-child { border-bottom: 0; }
.muted { color: var(--muted); font-size: 0.92rem; }
.streak { color: var(--gold); font-weight: 800; }

input, textarea, select {
  font-family: inherit;
  font-size: 1rem;
  background: #f7fbf9;
  color: var(--screen-ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  width: 100%;
}
textarea { min-height: 120px; }
label { display: block; margin: 8px 0 4px; font-weight: 700; font-size: 0.85rem; }

.party-row { display: flex; gap: 8px; flex-wrap: wrap; }
.mon-card {
  width: 104px;
  text-align: center;
  background: #f7fbf9;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
}
.mon-card img { width: 72px; height: 72px; object-fit: contain; }
.mon-card.lead { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(201,162,39,.25); }

.dex-layout { display: grid; grid-template-columns: 280px 1fr; gap: 12px; min-height: 520px; }
@media (max-width: 800px) { .dex-layout { grid-template-columns: 1fr; } }
.dex-list {
  overflow: auto;
  max-height: 640px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.dex-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
  width: 100%;
  background: transparent;
  font-family: inherit;
}
.dex-row img { width: 40px; height: 40px; object-fit: contain; }
.dex-row.missing img { filter: brightness(0); opacity: 0.45; }
.dex-row.active { background: #e3f0ff; }
.dex-num { font-variant-numeric: tabular-nums; color: var(--muted); width: 3.2em; }
.dex-detail {
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 16px;
  text-align: center;
}
.dex-detail img { width: 180px; height: 180px; object-fit: contain; }
.gens { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { font-size: 0.75rem; text-align: center; color: var(--muted); font-weight: 800; }
.cal .day {
  min-height: 72px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
  font-size: 0.85rem;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
}
.cal .day.today { border-color: var(--blue); }
.cal .day.selected { background: #eef6ff; box-shadow: inset 0 0 0 2px var(--blue); }
.dot { width: 8px; height: 8px; display: inline-block; background: var(--blue); border-radius: 50%; margin-right: 2px; }
.dot.done { background: var(--ok); }
.dot.event { background: #c45c26; }
.day-event {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.modal-back {
  position: fixed; inset: 0; background: rgba(40, 8, 8, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 40;
}
.modal {
  width: min(420px, 94vw);
  background: var(--screen);
  border-radius: 20px;
  padding: 18px;
  text-align: center;
  box-shadow: 0 16px 40px var(--shadow);
}
.modal img { width: 160px; height: 160px; object-fit: contain; }

.login-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  width: min(420px, 100%);
  background: var(--screen);
  border-radius: 20px;
  padding: 28px 22px;
  box-shadow: 0 16px 40px var(--shadow);
}
.err { color: var(--danger); min-height: 1.2em; }

.shop-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}
.toast {
  position: fixed; bottom: 16px; right: 16px;
  background: #fff; border-radius: 12px;
  padding: 10px 14px; z-index: 50; max-width: 280px;
  box-shadow: 0 8px 24px var(--shadow);
}
.credit { text-align: center; color: #ffd6d6; font-size: 0.8rem; margin-top: 10px; }
.credit a { color: #fff; }

.trainer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.trainer-pick {
  border: 2px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 8px;
  text-align: center;
  cursor: pointer;
  font-family: inherit;
}
.trainer-pick img { width: 80px; height: 80px; object-fit: contain; }
.trainer-pick.selected { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(61,125,202,.25); }
.trainer-hero { display: flex; gap: 16px; align-items: center; }
.trainer-hero img { width: 120px; height: 120px; object-fit: contain; }
