:root {
  color-scheme: dark;
  --bg: #060816;
  --surface: #12172e;
  --surface-2: #1a2140;
  --border: rgba(255,255,255,0.08);
  --text: #f4f7ff;
  --muted: #97a2c7;
  --accent: #6d7cff;
  --accent-2: #2dd4bf;
  --warn: #ffb84d;
  --danger: #ff6b6b;
  --shadow: 0 14px 40px rgba(2, 7, 23, 0.35);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', 'Noto Sans JP', sans-serif;
  background: radial-gradient(circle at top, #18214b 0%, var(--bg) 70%);
  color: var(--text);
  min-height: 100vh;
}
body.light {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #eef2ff;
  --border: rgba(3, 7, 18, 0.08);
  --text: #0f172a;
  --muted: #475569;
  --accent: #4f46e5;
  --accent-2: #0f766e;
  --warn: #d97706;
  --danger: #dc2626;
  --shadow: 0 12px 34px rgba(15, 23, 42, 0.09);
}

.app-shell {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px 16px 96px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  background: rgba(18, 23, 46, 0.92);
  backdrop-filter: blur(18px);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.eyebrow { margin: 0 0 4px; color: var(--accent-2); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; }
.topbar h1 { margin: 0; font-size: 1.2rem; }
.topbar-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.coin-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.9rem;
  border: 1px solid var(--border);
}

main { display: block; }
.view-section { display: none; }
.view-section.active { display: block; animation: fadeUp 0.25s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: translateY(0);} }

.card {
  background: linear-gradient(145deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2, .card h3 { margin: 0 0 10px; font-size: 1rem; }
.card p { margin: 0 0 10px; color: var(--muted); line-height: 1.5; }

.hero-card {
  position: relative;
  overflow: hidden;
}
.hero-card::before {
  content: '';
  position: absolute;
  inset: auto -40px -40px auto;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(109,124,255,0.4), transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.hero-level { font-size: 1.5rem; font-weight: 700; }
.hero-sub { color: var(--muted); font-size: 0.95rem; }
.progress-bar {
  width: 100%; height: 10px; border-radius: 999px; background: rgba(255,255,255,0.12); overflow: hidden; margin: 8px 0 10px;
}
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: inherit; transition: width 0.25s ease; }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.stat-item { background: var(--surface-2); border-radius: 16px; padding: 10px; border: 1px solid var(--border); }
.stat-item strong { display: block; font-size: 1.1rem; }
.stat-item span { color: var(--muted); font-size: 0.82rem; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
button { border: 0; cursor: pointer; font: inherit; }
.btn { padding: 10px 12px; border-radius: 999px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); }
.btn.primary { background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: white; }
.btn.warn { background: rgba(255,184,77,0.16); color: var(--warn); }
.btn.danger { background: rgba(255,107,107,0.16); color: var(--danger); }
.btn.small { padding: 7px 10px; font-size: 0.85rem; }

.mission-list, .reward-list, .history-list { display: flex; flex-direction: column; gap: 10px; }
.list-item { padding: 12px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); }
.list-item-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 999px; background: rgba(109,124,255,0.16); color: #c7d2fe; font-size: 0.78rem; }
.tag.daily { background: rgba(45,212,191,0.18); color: #99f6e4; }
.meta { color: var(--muted); font-size: 0.84rem; margin-top: 6px; }

.form-grid { display: grid; gap: 10px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--muted); }
input, select, textarea { width: 100%; border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; background: var(--surface); color: var(--text); }
textarea { min-height: 72px; resize: vertical; }

.bottom-nav {
  position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%);
  width: min(92vw, 760px); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px;
  padding: 8px; background: rgba(10, 14, 29, 0.92); border-radius: 20px; border: 1px solid var(--border); backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border-radius: 14px; color: var(--muted); background: transparent; }
.nav-item.active { background: rgba(109,124,255,0.18); color: var(--text); }
.nav-item span { font-size: 0.72rem; }

.toast-stack { position: fixed; right: 12px; bottom: 90px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { padding: 10px 12px; border-radius: 14px; background: rgba(18, 23, 46, 0.95); border: 1px solid var(--border); min-width: 220px; box-shadow: var(--shadow); animation: toastIn 0.2s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px);} to { opacity:1; transform: translateY(0);} }

.modal { position: fixed; inset: 0; background: rgba(2,6,23,0.7); display: grid; place-items: center; padding: 20px; z-index: 70; }
.modal.hidden { display: none; }
.modal-card { width: min(92vw, 460px); background: var(--surface); border-radius: 24px; padding: 18px; position: relative; border: 1px solid var(--border); box-shadow: var(--shadow); }
.modal-close { position: absolute; top: 10px; right: 10px; background: transparent; color: var(--muted); font-size: 1rem; }

.loader-overlay { position: fixed; inset: 0; background: rgba(2,6,23,0.8); display: grid; place-items: center; z-index: 100; transition: opacity 0.25s ease; }
.loader-overlay.hidden { opacity: 0; pointer-events: none; }
.loader-card { text-align: center; }
.loader-orb { width: 72px; height: 72px; margin: 0 auto 12px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(0.95); opacity: 0.8; } 50% { transform: scale(1.05); opacity: 1; } }

.gacha-card { text-align: center; }
.gacha-symbol { font-size: 2.2rem; margin: 8px 0; }
.badge-list, .title-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.badge-item, .title-item { padding: 6px 10px; border-radius: 999px; background: rgba(109,124,255,0.16); color: #dbeafe; font-size: 0.84rem; }
.ai-card { background: linear-gradient(120deg, rgba(109,124,255,0.18), rgba(45,212,191,0.18)); }
.ai-card strong { display: block; margin-bottom: 6px; }
.small { font-size: 0.82rem; color: var(--muted); }
.muted { color: var(--muted); }

@media (min-width: 700px) {
  .app-shell { padding: 24px 24px 110px; }
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .bottom-nav { bottom: 20px; }
}
