/* AniWorld TCG — shared design system for /play and /database */
:root {
  --bg: #08070f;
  --bg-2: #0e0b1a;
  --panel: #130f24;
  --panel-2: #1a1430;
  --line: #2a2147;
  --line-2: #3a2e60;
  --text: #f1edff;
  --text-2: #a59cc8;
  --text-3: #6f6894;

  --pink: #ff4db3;
  --purple: #a855f7;
  --violet: #7c4dff;
  --cyan: #4fd8e8;
  --gold: #f4c542;
  --green: #3ddc97;
  --red: #ff5b6e;
  --brand-grad: linear-gradient(120deg, #ff4db3 0%, #c04df5 50%, #7c4dff 100%);

  --SECRET: #ff4db3;
  --MYTHIC: #c855f0;
  --LEGENDARY: #e8a030;
  --EPIC: #9060e0;
  --RARE: #4090e8;
  --UNCOMMON: #40c080;
  --COMMON: #808090;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --shadow: 0 10px 40px #0009;
  --nav-h: 64px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Outfit', 'Inter', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 85% -10%, #7c4dff22, transparent 60%),
    radial-gradient(700px 420px at -10% 10%, #ff4db318, transparent 60%),
    var(--bg);
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
::selection { background: #ff4db355; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--purple); }

.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--text-2); }
.grad-text { background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

/* ── Nav ─────────────────────────────────────────────── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  background: #08070fd9;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.site-nav .container { height: 100%; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; flex-shrink: 0; }
.brand img { height: 42px; width: auto; filter: drop-shadow(0 0 12px #ff4db340); }
.nav-links { display: flex; gap: 4px; margin-left: auto; }
.nav-links a {
  position: relative;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-2);
  transition: color .15s, background .15s;
}
.nav-links a:hover { color: var(--text); background: var(--panel); }
.nav-links a.active { color: var(--text); }
.nav-links a.active::after {
  content: '';
  position: absolute;
  left: 14px; right: 14px; bottom: -13px;
  height: 2px;
  border-radius: 2px;
  background: var(--brand-grad);
}
.nav-actions { display: flex; align-items: center; gap: 10px; }
.nav-actions:empty { display: none; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}
.user-chip img { width: 30px; height: 30px; border-radius: 50%; }
.user-chip .name { font-weight: 600; font-size: 14px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .logout {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  color: var(--text-3);
  transition: color .15s, background .15s;
}
.user-chip .logout:hover { color: var(--text); background: var(--panel-2); }

/* Bottom tab bar (mobile) */
.tabbar { display: none; }
@media (max-width: 760px) {
  :root { --nav-h: 56px; }
  .container { padding: 0 16px; }
  .brand img { height: 34px; }
  .nav-links { display: none; }
  .nav-actions { margin-left: auto; }
  .user-chip .name { display: none; }
  .tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: #0b0916f2;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  .tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 0;
    border-radius: var(--r-sm);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-3);
  }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a.active { color: var(--text); }
  .tabbar a.active svg { color: var(--pink); }
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .1s, filter .15s, background .15s, border-color .15s, opacity .15s;
  user-select: none;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; filter: none; transform: none; }
.btn-primary { background: var(--brand-grad); color: #fff; box-shadow: 0 6px 22px #c04df540; }
.btn-discord { background: #5865f2; color: #fff; }
.btn-ghost { background: var(--panel); border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--line-2); background: var(--panel-2); }
.btn-lg { height: 52px; padding: 0 26px; font-size: 15px; border-radius: var(--r); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ── Form controls ───────────────────────────────────── */
.input, .select {
  height: 42px;
  width: 100%;
  padding: 0 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--text-3); }
.input:focus, .select:focus { border-color: var(--purple); box-shadow: 0 0 0 3px #a855f726; }
.select {
  appearance: none;
  padding-right: 36px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23a59cc8' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.select option { background: var(--panel); }
.search { position: relative; }
.search svg { position: absolute; left: 13px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 40px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s;
}
.chip:hover { color: var(--text); border-color: var(--line-2); }
.chip.active { color: var(--text); border-color: var(--c, var(--purple)); background: color-mix(in srgb, var(--c, var(--purple)) 16%, transparent); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--purple)); box-shadow: 0 0 8px var(--c, var(--purple)); }
.chip .count { color: var(--text-3); font-weight: 500; }
.chip img { width: 18px; height: 18px; }

/* ── Panels ──────────────────────────────────────────── */
.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.section-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--pink); }

/* ── Rarity badge ────────────────────────────────────── */
.rarity {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .08em;
  color: var(--rc);
  background: color-mix(in srgb, var(--rc) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--rc) 40%, transparent);
}

/* ── Card tile ───────────────────────────────────────── */
.tile {
  --rc: var(--COMMON);
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--r);
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
  cursor: pointer;
  transition: transform .2s, border-color .2s, box-shadow .2s;
  isolation: isolate;
}
.tile:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--rc) 70%, transparent); box-shadow: 0 14px 34px #0008, 0 0 24px color-mix(in srgb, var(--rc) 30%, transparent); }
.tile-art { position: relative; aspect-ratio: 5 / 7; background: linear-gradient(160deg, var(--panel-2), var(--bg-2)); overflow: hidden; }
.tile-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity .3s; }
.tile-art img.anim { opacity: 0; }
.tile:hover .tile-art img.anim.ready, .tile.play .tile-art img.anim.ready { opacity: 1; }
.tile-art::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 60%, #0009);
}
.tile-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; border-top: 2px solid var(--rc); }
.tile-name { font-weight: 700; font-size: 14px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-meta { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tile-meta .series { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.tile-meta .attr { width: 20px; height: 20px; flex-shrink: 0; }
.tile-badge {
  position: absolute;
  z-index: 2;
  top: 8px;
  height: 22px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  backdrop-filter: blur(6px);
}
.tile-badge.left { left: 8px; }
.tile-badge.right { right: 8px; }
.tile.r-SECRET, .tile.r-MYTHIC { box-shadow: 0 0 0 1px color-mix(in srgb, var(--rc) 25%, transparent); }
.tile.r-SECRET .tile-art::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, #ffffff30 45%, transparent 60%);
  background-size: 250% 100%;
  animation: foil 4s linear infinite;
  mix-blend-mode: overlay;
}
@keyframes foil { from { background-position: 150% 0; } to { background-position: -100% 0; } }

.r-SECRET { --rc: var(--SECRET); }
.r-MYTHIC { --rc: var(--MYTHIC); }
.r-LEGENDARY { --rc: var(--LEGENDARY); }
.r-EPIC { --rc: var(--EPIC); }
.r-RARE { --rc: var(--RARE); }
.r-UNCOMMON { --rc: var(--UNCOMMON); }
.r-COMMON { --rc: var(--COMMON); }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 16px; }
@media (max-width: 760px) { .grid-cards { grid-template-columns: repeat(2, 1fr); gap: 10px; } .tile-body { padding: 8px 10px 10px; } .tile-name { font-size: 13px; } }
@media (min-width: 420px) and (max-width: 760px) { .grid-cards { grid-template-columns: repeat(3, 1fr); } }

/* ── Skeletons ───────────────────────────────────────── */
.skeleton { position: relative; overflow: hidden; background: var(--panel); border-radius: var(--r); }
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, #ffffff0a, transparent);
  animation: shimmer 1.4s infinite;
}
.skeleton.tile-sk { aspect-ratio: 5 / 8.6; }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ── Modal ───────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #05040acc;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s, visibility .2s;
}
.modal-backdrop.open { opacity: 1; visibility: visible; }
.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  z-index: 5;
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #0b0916cc;
  color: var(--text-2);
  cursor: pointer;
}
.modal-close:hover { color: var(--text); border-color: var(--line-2); }
.modal-close svg { width: 18px; height: 18px; }

/* ── Toasts ──────────────────────────────────────────── */
.toasts { position: fixed; z-index: 200; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 460px);
  padding: 12px 16px;
  border-radius: var(--r);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 500;
  animation: toast-in .25s ease-out;
}
.toast.error { border-color: #ff5b6e66; }
.toast.success { border-color: #3ddc9766; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
@media (max-width: 760px) { .toasts { bottom: calc(84px + env(safe-area-inset-bottom)); } }

/* ── Footer ──────────────────────────────────────────── */
.site-footer { margin-top: 80px; border-top: 1px solid var(--line); padding: 32px 0; color: var(--text-3); font-size: 13px; }
.site-footer .container { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.site-footer img { height: 40px; width: auto; opacity: .9; }
.site-footer nav { display: flex; gap: 18px; flex-wrap: wrap; }
.site-footer nav a:hover { color: var(--text); }
@media (max-width: 760px) { .site-footer .container { flex-direction: column; text-align: center; } }

.empty {
  grid-column: 1 / -1;
  padding: 56px 20px;
  text-align: center;
  color: var(--text-2);
}
.empty h3 { font-family: var(--font-display); color: var(--text); font-size: 18px; margin-bottom: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
