/* Milky Summer Quest — terminal RPG / hacker green */
:root {
  --bg-color: #0d1117;
  --bg-elevated: #161b22;
  --text-color: #00ff41;
  --text-soft: #c9d1d9;
  --accent-color: #58a6ff;
  --card-bg: rgba(22, 27, 34, 0.92);
  --border-color: #30363d;
  --muted: #8b949e;
  --warn: #f1c40f;
  --danger: #ff7b72;
  --ok: #3fb950;
  --radius: 12px;
  --focus: 0 0 0 3px rgba(88, 166, 255, 0.45);
  --glow: 0 0 18px rgba(88, 166, 255, 0.22);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Roboto Mono', 'Noto Sans SC', 'Microsoft YaHei', monospace;
  background-color: var(--bg-color);
  color: var(--text-color);
  background-image:
    linear-gradient(rgba(0, 255, 65, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 65, 0.035) 1px, transparent 1px),
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(88, 166, 255, 0.18), transparent 55%);
  background-size: 28px 28px, 28px 28px, 100% 100%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
body::before {
  content: '';
  pointer-events: none;
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 2px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 4px
  );
  z-index: 0;
  opacity: 0.55;
}

.shell {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem max(3rem, env(safe-area-inset-bottom));
  padding-left: max(1.25rem, env(safe-area-inset-left));
  padding-right: max(1.25rem, env(safe-area-inset-right));
  position: relative;
  z-index: 1;
}

.back-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--accent-color);
  text-decoration: none;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.35rem 0.75rem;
  margin-bottom: 0.85rem;
  background: rgba(13, 17, 23, 0.7);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}
.back-chip:hover { border-color: var(--accent-color); box-shadow: var(--glow); }
.back-chip:focus-visible { outline: none; box-shadow: var(--focus); }

.login-card, .ring-card, .quest, .mini {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--glow);
  backdrop-filter: blur(6px);
}

.login-card {
  position: relative;
  overflow: hidden;
  padding: 1.5rem 1.25rem 1.35rem;
  margin-top: 0.5rem;
}
.login-card::after {
  content: '> READY_PLAYER_ONE';
  position: absolute;
  left: 1rem;
  bottom: 0.65rem;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  opacity: 0.7;
}
.hero-orb {
  position: absolute;
  width: 180px;
  height: 180px;
  right: -40px;
  top: -50px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(88, 166, 255, 0.4), transparent 70%);
  pointer-events: none;
  animation: pulse-orb 4s ease-in-out infinite;
}
@keyframes pulse-orb {
  50% { transform: scale(1.08); opacity: 0.85; }
}

.kicker {
  color: var(--accent-color);
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  margin: 0 0 0.55rem;
  text-transform: uppercase;
}
.login-card h1 {
  font-family: 'Press Start 2P', cursive;
  font-size: clamp(0.9rem, 3.6vw, 1.05rem);
  line-height: 1.75;
  margin: 0 0 0.75rem;
  color: var(--accent-color);
  text-shadow: 2px 2px #000, 0 0 18px rgba(88, 166, 255, 0.35);
  text-wrap: balance;
}
.lede {
  margin: 0 0 1.1rem;
  line-height: 1.55;
  color: var(--text-soft);
  font-size: 0.95rem;
}
.tiny, .muted, .day-note, .quest-desc, .mini-l, .field-label, .week-theme {
  color: var(--muted);
}

.field-label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}
.field, input[type='password'], input[type='text'] {
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: #0d1117;
  color: var(--text-color);
  font-family: inherit;
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field:focus-visible,
input[type='password']:focus-visible,
input[type='text']:focus-visible {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: var(--focus);
}

.btn {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.65rem 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  background: transparent;
  color: var(--text-color);
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { border-color: var(--accent-color); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn.primary {
  background: linear-gradient(180deg, #79b8ff 0%, var(--accent-color) 100%);
  color: #0d1117;
  border-color: var(--accent-color);
  box-shadow: 0 0 16px rgba(88, 166, 255, 0.28);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.camera {
  background: linear-gradient(180deg, #f8d56b, var(--warn));
  color: #111;
  border-color: #c9a227;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}
.btn.ghost { background: transparent; color: var(--accent-color); }
.btn.sm { padding: 0.3rem 0.6rem; font-size: 0.85rem; }
.btn.mega { width: 100%; padding: 0.95rem; font-size: 1rem; margin-top: 0.35rem; }
.btn.big-tap { min-height: 48px; }
.btn.icon { width: 44px; height: 44px; padding: 0; font-size: 1.25rem; }
.btn.loading { opacity: 0.55; pointer-events: none; }

.tiny { font-size: 0.8rem; margin-top: 0.85rem; }
.adv { margin-top: 1rem; color: var(--muted); font-size: 0.85rem; }
.adv summary { cursor: pointer; }

.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0.3rem 0 1rem;
  gap: 0.75rem;
}
.hud-left { display: flex; gap: 0.7rem; align-items: center; min-width: 0; }
.avatar-badge {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  border: 2px solid var(--accent-color);
  box-shadow: 0 0 14px rgba(88, 166, 255, 0.4);
  background: #161b22;
  flex-shrink: 0;
}
.who-line {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.72rem;
  color: var(--accent-color);
  line-height: 1.5;
}
.week-theme {
  margin-top: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 52vw;
}

.stat-row { display: grid; gap: 0.75rem; }
.ring-card {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 0.85rem;
  padding: 1rem;
  align-items: center;
  position: relative;
  overflow: hidden;
}
.ring-card::before {
  content: 'QUEST STATUS';
  position: absolute;
  top: 0.55rem;
  right: 0.75rem;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.ring-wrap { position: relative; width: 120px; height: 120px; }
.ring { width: 120px; height: 120px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: #21262d; stroke-width: 10; }
.ring-fg {
  fill: none;
  stroke: var(--text-color);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 339;
  stroke-dashoffset: 339;
  transition: stroke-dashoffset 0.55s ease;
  filter: drop-shadow(0 0 6px rgba(0, 255, 65, 0.45));
}
.ring-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
}
#ring-label {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--accent-color);
  font-variant-numeric: tabular-nums;
}
#ring-sub { font-size: 0.72rem; color: var(--muted); }
.xp-top {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.xp-bar {
  height: 10px;
  background: #21262d;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.35rem;
  border: 1px solid var(--border-color);
}
#xp-bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent-color), var(--text-color));
  transition: width 0.45s ease;
  box-shadow: 0 0 10px rgba(0, 255, 65, 0.35);
}
.next-hint {
  margin: 0.55rem 0 0;
  color: var(--warn);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.4;
}

.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.mini { padding: 0.85rem; text-align: center; }
.mini-n {
  display: block;
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--accent-color);
  font-variant-numeric: tabular-nums;
}

.day-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.45rem;
  margin: 1rem 0 0.35rem;
}
.day-chip {
  border: 1px solid var(--border-color);
  background: rgba(88, 166, 255, 0.12);
  color: var(--accent-color);
  border-radius: 8px;
  padding: 0.45rem 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  min-width: 7.5rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.day-chip:hover { border-color: var(--accent-color); }
.day-chip:focus-visible { outline: none; box-shadow: var(--focus); }
.day-note {
  text-align: center;
  font-size: 0.88rem;
  margin: 0 0 0.9rem;
  min-height: 1.2em;
  color: var(--text-soft);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}
.tab {
  border: 1px solid var(--border-color);
  background: #161b22;
  color: var(--muted);
  border-radius: 8px;
  padding: 0.55rem 0.25rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.tab:hover { border-color: var(--accent-color); color: var(--text-soft); }
.tab:focus-visible { outline: none; box-shadow: var(--focus); }
.tab.active {
  color: #0d1117;
  background: var(--accent-color);
  border-color: var(--accent-color);
  box-shadow: 0 0 12px rgba(88, 166, 255, 0.3);
}
.tab-count { display: block; font-size: 0.72rem; opacity: 0.9; font-variant-numeric: tabular-nums; }

.quest {
  padding: 0.95rem;
  margin-bottom: 0.75rem;
  position: relative;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.quest:hover { border-color: rgba(88, 166, 255, 0.55); }
.quest.is-next {
  border-color: var(--warn);
  box-shadow: 0 0 0 1px rgba(241, 196, 15, 0.35), 0 0 18px rgba(241, 196, 15, 0.12);
}
.quest.is-next::before {
  content: 'NEXT';
  position: absolute;
  top: -0.55rem;
  left: 0.85rem;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  background: #0d1117;
  color: var(--warn);
  border: 1px solid rgba(241, 196, 15, 0.5);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  font-weight: 800;
}
.quest.is-done {
  border-color: var(--ok);
  box-shadow: 0 0 12px rgba(63, 185, 80, 0.15);
  opacity: 0.92;
}
.quest-main {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 0.7rem;
  align-items: start;
}
.quest-ico {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  background: #0d1117;
  border: 1px solid var(--border-color);
}
.quest-title-row { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; min-width: 0; }
.quest h3 {
  margin: 0;
  font-size: 1.02rem;
  color: #e6edf3;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.quest-desc {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.quest-steps {
  margin: 0.4rem 0 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-color);
  letter-spacing: 0.02em;
}
.quest-link {
  display: inline-flex;
  margin-top: 0.45rem;
  color: var(--accent-color);
  font-weight: 700;
  font-size: 0.9rem;
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  padding: 0.3rem 0.55rem;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.quest-link:hover { border-color: var(--accent-color); background: rgba(88, 166, 255, 0.08); }
.quest-link:focus-visible { outline: none; box-shadow: var(--focus); }
.quest-meta { margin: 0.35rem 0 0; color: var(--ok); font-size: 0.85rem; overflow-wrap: anywhere; }
.stamp {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.5rem;
  color: var(--ok);
  border: 2px solid var(--ok);
  border-radius: 6px;
  padding: 0.35rem 0.4rem;
  transform: rotate(10deg);
  align-self: start;
}
.quest-actions { margin-top: 0.75rem; display: grid; gap: 0.5rem; }
.quest-panel { display: grid; gap: 0.5rem; }
.pill {
  font-size: 0.72rem;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  color: var(--muted);
}
.pill.soft {
  color: var(--warn);
  border-color: #6b5a1e;
  background: rgba(241, 196, 15, 0.08);
}
.thumbs { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.4rem; }
.thumbs img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}
.empty {
  text-align: center;
  color: var(--muted);
  padding: 1.6rem 1rem;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius);
  background: rgba(22, 27, 34, 0.55);
}
.quick-links {
  display: flex;
  justify-content: center;
  gap: 0.85rem;
  margin-top: 1.2rem;
  flex-wrap: wrap;
}
.quick-links a {
  color: var(--accent-color);
  font-size: 0.9rem;
  text-decoration: none;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  background: rgba(13, 17, 23, 0.65);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.quick-links a:hover { border-color: var(--accent-color); box-shadow: var(--glow); }
.quick-links a:focus-visible { outline: none; box-shadow: var(--focus); }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(1.2rem, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(12px);
  background: #161b22;
  border: 1px solid var(--accent-color);
  color: #e6edf3;
  padding: 0.7rem 1.05rem;
  border-radius: 999px;
  z-index: 50;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  font-weight: 700;
  max-width: min(92vw, 28rem);
  text-align: center;
  box-shadow: var(--glow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--danger); color: #ffb4bc; }

#fx-layer {
  pointer-events: none;
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 40;
}
.fx-bit {
  position: absolute;
  top: -10px;
  animation: fall 1.5s ease-in forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(220deg); opacity: 0; }
}

@media (max-width: 480px) {
  .ring-card { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .ring-card::before { position: static; margin-bottom: 0.25rem; }
  .xp-block { width: 100%; }
  .shell { max-width: 100%; }
  .week-theme { max-width: 58vw; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .hero-orb { animation: none; }
  .fx-bit { display: none; }
}
