@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;700&family=Noto+Sans+JP:wght@400;700;900&family=Zen+Kaku+Gothic+New:wght@500;700;900&display=swap");

:root {
  --bg-0: #0a0614;
  --bg-1: #160b24;
  --bg-2: #241136;
  --ink: #f6eef8;
  --muted: #c9b3d4;
  --sakura: #ff6b9d;
  --sakura-2: #ffb3cb;
  --gold: #ffd36e;
  --cyan: #7ae1ff;
  --card: rgba(22, 10, 36, 0.72);
  --stroke: rgba(255, 179, 203, 0.35);
  --glow: 0 0 24px rgba(255, 107, 157, 0.35);
  --font: "Noto Sans TC", "Noto Sans JP", "Zen Kaku Gothic New", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --display: "Zen Kaku Gothic New", "Noto Sans JP", "Noto Sans TC", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(255, 107, 157, 0.18), transparent 55%),
    radial-gradient(900px 600px at 110% 0%, rgba(122, 225, 255, 0.12), transparent 50%),
    radial-gradient(800px 500px at 50% 120%, rgba(255, 211, 110, 0.08), transparent 50%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 45%, var(--bg-2));
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.7;
}

body.anime-app {
  overflow-x: hidden;
}

body.anime-app::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.18;
  background-image: url("data:image/svg+xml,%3Csvg width='120' height='104' viewBox='0 0 120 104' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M60 0l20 34.64h-40L60 0zm0 104L40 69.36h40L60 104zM0 52l20-34.64 20 34.64L20 86.64 0 52zm120 0L100 17.36 80 52l20 34.64L120 52z' fill='none' stroke='%23ffb3cb' stroke-width='1'/%3E%3C/svg%3E");
  animation: pattern-drift 40s linear infinite;
}

@keyframes pattern-drift {
  from { background-position: 0 0; }
  to { background-position: 120px 104px; }
}

.sakura-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 3;
}

.petal {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 8px;
  border-radius: 10px 0 10px 0;
  background: linear-gradient(135deg, #ffd0e0, var(--sakura));
  opacity: 0.8;
  animation: fall var(--dur, 12s) linear var(--delay, 0s) infinite;
  filter: drop-shadow(0 0 4px rgba(255, 107, 157, 0.5));
}

@keyframes fall {
  0% { transform: translate3d(0, -10vh, 0) rotate(0deg); opacity: 0; }
  8% { opacity: 0.85; }
  100% { transform: translate3d(var(--drift, 80px), 110vh, 0) rotate(420deg); opacity: 0.15; }
}

.site-header,
.card-grid,
.site-pager {
  position: relative;
  z-index: 1;
}

.site-header {
  text-align: center;
  padding: 42px 20px 18px;
}

.site-kicker {
  display: inline-block;
  letter-spacing: 0.42em;
  font-size: 11px;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 8px;
  animation: flicker 3.6s ease-in-out infinite;
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  48% { opacity: 0.7; }
  52% { opacity: 1; }
}

.site-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(32px, 6vw, 64px);
  line-height: 1.15;
  background: linear-gradient(120deg, #fff, var(--sakura-2) 40%, var(--cyan) 75%, var(--gold));
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: title-shine 8s ease-in-out infinite;
  text-shadow: none;
}

@keyframes title-shine {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.site-sub {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.site-sub strong {
  color: var(--sakura-2);
  font-weight: 700;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 22px;
  padding: 16px 28px 28px;
  max-width: 1280px;
  margin: 0 auto;
  min-height: 52vh;
}

.anime-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  overflow: hidden;
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  transform: translateY(16px);
  opacity: 0;
  animation: card-in 0.6s ease forwards;
  animation-delay: var(--stagger, 0s);
  transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
}

.anime-card.is-hidden {
  display: none;
}

@keyframes card-in {
  to { transform: translateY(0); opacity: 1; }
}

.anime-card:hover {
  transform: translateY(-8px) scale(1.015);
  border-color: rgba(255, 107, 157, 0.8);
  box-shadow: var(--glow), 0 16px 36px rgba(0, 0, 0, 0.4);
}

.anime-poster {
  position: relative;
  margin: 0;
  height: 180px;
  overflow: hidden;
  background: #1a0a2e;
  order: -1;
}

.anime-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.6s ease;
}

.anime-card:hover .anime-poster img {
  transform: scale(1.08);
}

.anime-poster::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 45%, rgba(10, 6, 20, 0.88));
  pointer-events: none;
}

.anime-card > h2 {
  margin: 14px 16px 6px;
  font-family: var(--display);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  color: #fff;
}

.anime-card > p {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 16px 10px;
  font-size: 12px;
  color: var(--muted);
}

.anime-card > p span,
.anime-card > p a {
  display: inline-block;
  max-width: 100%;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.anime-card > p span:first-child {
  color: var(--gold);
  border-color: rgba(255, 211, 110, 0.25);
}

.anime-card > p a {
  color: var(--cyan);
  text-decoration: none;
  max-width: 100%;
}

.anime-card > p a:hover {
  background: rgba(122, 225, 255, 0.15);
}

.anime-synopsis {
  margin: 0 16px 12px;
  color: var(--muted);
  font-size: 13px;
  flex: 1;
}

.anime-synopsis p {
  margin: 0;
}

.anime-detail {
  display: none;
}

.card-more {
  margin: auto 16px 16px;
  padding: 8px 12px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sakura), #ff8a4d);
  color: #2a0814;
  font-family: inherit;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.12em;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(255, 107, 157, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-more:hover {
  transform: scale(1.04);
  box-shadow: 0 8px 20px rgba(255, 107, 157, 0.5);
}

.site-pager {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 16px 18px;
  background: linear-gradient(180deg, transparent, rgba(10, 6, 20, 0.92) 30%);
  backdrop-filter: blur(10px);
  z-index: 4;
}

.page-btn,
.page-num {
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid rgba(255, 179, 203, 0.25);
  border-radius: 10px;
  background: rgba(22, 10, 36, 0.85);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.page-btn:hover,
.page-num:hover {
  transform: translateY(-2px);
  border-color: var(--sakura);
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
}

.page-num.is-current {
  background: linear-gradient(180deg, var(--sakura), #d9487c);
  border-color: transparent;
  color: #fff;
  font-weight: 700;
  box-shadow: var(--glow);
}

.page-ellipsis {
  color: var(--muted);
  padding: 0 2px;
}

.page-status {
  width: 100%;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.modal-root.is-open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 2, 12, 0.72);
  backdrop-filter: blur(8px);
  animation: fade-in 0.25s ease;
}

.modal-panel {
  position: relative;
  width: min(920px, 100%);
  max-height: min(86vh, 860px);
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(42, 16, 60, 0.96), rgba(16, 8, 28, 0.98));
  border: 1px solid rgba(255, 179, 203, 0.4);
  border-radius: 22px;
  box-shadow: var(--glow), 0 24px 80px rgba(0, 0, 0, 0.55);
  animation: modal-pop 0.35s cubic-bezier(0.2, 0.9, 0.25, 1);
  padding: 0 0 28px;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

@keyframes modal-pop {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: sticky;
  top: 12px;
  float: right;
  margin: 12px 12px 0 0;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.modal-hero img {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  display: block;
}

.modal-body {
  padding: 8px 28px 0;
  clear: both;
}

.modal-body h2 {
  margin: 8px 0 10px;
  font-family: var(--display);
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.3;
}

.modal-body .modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.modal-body .modal-meta span,
.modal-body .modal-meta a {
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
}

.modal-body .modal-meta a { color: var(--cyan); text-decoration: none; }

.modal-detail {
  color: #efe6f3;
  font-size: 15px;
}

.modal-detail p { margin: 0 0 1em; }

body.modal-open { overflow: hidden; }

.load-error {
  position: relative;
  z-index: 2;
  max-width: 640px;
  margin: 15vh auto;
  padding: 24px;
  text-align: center;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 16px;
}

@media (max-width: 1100px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 800px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); padding: 12px 14px 24px; }
  .anime-poster { height: 150px; }
}

@media (max-width: 560px) {
  .card-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  body.anime-app::before { animation: none; }
  .anime-card { opacity: 1; transform: none; }
}
