/* ManaScope — Mock v12 */
:root {
  --panel: #f8f7fc;
  --panel2: #ffffff;
  --text: #333333;
  --muted: #6f6887;
  --line: #ddd7ef;
  --accent: #7c5cff;
  --accent2: #a78bfa;
  --blue: #eef5ff;
  --purple: #f5f1ff;
  --badge-banned: #e74c3c;
  --badge-gc: #f39c12;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
img { max-width: 100%; height: auto; }
p, li, td, th { word-break: break-word; }

body {
  font-family: 游ゴシック, YuGothic, "Yu Gothic", Roboto, Arial, メイリオ, Meiryo, sans-serif;
  background-color: #f5f3fa;
  color: var(--text);
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.site-header { flex-shrink: 0; }
.wrap { flex: 1 0 auto; }
.site-footer { flex-shrink: 0; }

/* ── Arcane background (hidden on light theme) ── */
.arcane-bg { display: none; }

/* ── Site header ── */
.site-header {
  position: relative; z-index: 2;
  background: linear-gradient(135deg, #2d1b69 0%, #4a2c8a 50%, #6b3fa0 100%);
  border-bottom: 1px solid rgba(124,92,255,.30);
  box-shadow: 0 2px 12px rgba(45,27,105,.25);
}
.site-header::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, transparent 0%, var(--accent) 20%, var(--accent2) 50%, var(--accent) 80%, transparent 100%);
}
.site-header-inner {
  max-width: 960px; margin: 0 auto; padding: 18px 24px;
  display: flex; align-items: center; gap: 18px; position: relative;
}
.logo {
  width: 64px; height: 64px; background: white; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.25), 0 0 0 1px rgba(124,92,255,.20);
  flex: 0 0 auto;
}
.logo img { width: 48px; height: 48px; object-fit: contain; }
.header-text { flex: 1 1 auto; }
.title {
  font-size: 30px; font-weight: 900; letter-spacing: .03em; line-height: 1.1;
  font-family: Georgia, "Palatino Linotype", "Book Antiqua", serif;
}
.title-mana { color: rgba(255,255,255,.92); }
.title-finder { color: #e0d4ff; }
.subtitle { font-size: 11.5px; color: rgba(255,255,255,.70); margin-top: 6px; letter-spacing: .08em; }
.header-deco { flex: 0 0 auto; width: 120px; display: flex; align-items: center; }
.header-deco svg { width: 100%; height: auto; }

/* ── Navigation bar ── */
.site-nav {
  background: #ece8f4;
  border-bottom: 1px solid #d8d0e8;
  position: relative; z-index: 2;
}
.site-nav-inner {
  max-width: 960px; margin: 0 auto;
  padding: 0 24px;
  display: flex; gap: 0;
}
.nav-link {
  display: inline-block;
  padding: 10px 20px;
  font-size: 13.5px; font-weight: 600;
  color: #6f6887;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.nav-link:hover {
  color: var(--accent);
  background: rgba(124,92,255,.05);
}
.nav-link.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Layout ── */
.wrap { max-width: 960px; margin: auto; padding: 32px 20px 40px; position: relative; z-index: 1; }

/* ── Panel ── */
.panel {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  color: var(--text);
  border-radius: 18px; padding: 20px; margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,.06);
  border: 1px solid var(--line);
}

/* ── Search ── */
textarea {
  display: block; width: 100%; max-width: 100%; min-height: 110px;
  border-radius: 12px; border: 1px solid var(--line);
  padding: 14px; font: inherit; color: var(--text);
  resize: vertical; background: #fff;
}
textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(124,92,255,.12); }

.hint { margin-top: 10px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.actions { margin-top: 14px; }

button {
  padding: 10px 16px; border: none; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white; font: inherit; font-weight: 700; cursor: pointer;
  transition: all 0.2s;
}
button:hover { opacity: 0.9; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Search button (wide) ── */
.actions button[type="submit"] {
  width: 100%; padding: 14px; font-size: 16px;
  border-radius: 12px; letter-spacing: .05em;
  box-shadow: 0 4px 12px rgba(124,92,255,.25);
}
.actions button[type="submit"]:hover {
  box-shadow: 0 6px 20px rgba(124,92,255,.35);
  transform: translateY(-1px);
}

/* ── Example chips ── */
.hint-label { font-size: 13px; color: var(--muted); }
.example-chips {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px;
}
.example-chip {
  padding: 7px 16px; font-size: 12.5px; font-weight: 600;
  background: #fff; color: #4b3e7c;
  border: 1.5px solid #d0c8e8; border-radius: 20px;
  cursor: pointer; transition: all 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.example-chip:hover {
  background: #f0ecf8; border-color: var(--accent); color: var(--accent);
  box-shadow: 0 2px 8px rgba(124,92,255,.15);
  transform: translateY(-1px);
}

/* ── Interpret ── */
.interpret { font-size: 14px; color: #4b3e7c; }

/* ── Loading ── */
.loading {
  text-align: center; padding: 40px; color: var(--muted);
  display: flex; align-items: center; justify-content: center; gap: 12px;
}
.spinner {
  width: 24px; height: 24px; border: 3px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error ── */
.error-msg {
  text-align: center; padding: 16px; margin: 16px 0;
  background: rgba(231,76,60,.15); border: 1px solid var(--badge-banned);
  border-radius: 12px; color: #e74c3c;
}

/* ── Results header ── */
.results-header {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 8px; margin-bottom: 14px;
}
.result-count { font-size: 13px; color: var(--muted); }

/* ── Sort controls ── */
.sort-controls { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.sort-label { font-size: 12px; color: var(--muted); margin-right: 4px; }
.sort-btn {
  padding: 4px 10px; font-size: 12px; font-weight: 600;
  background: #f0ecf8; color: #6f6887;
  border: 1px solid var(--line); border-radius: 6px;
  cursor: pointer; transition: all 0.15s;
}
.sort-btn:hover { background: #e4dcff; color: #4b3e7c; }
.sort-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white; border-color: var(--accent);
}

/* ── Card list (1 column) ── */
.results { display: grid; gap: 14px; }

/* ── Relevance score with gauge ── */
.relevance-wrap {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 10px; vertical-align: middle;
}
.relevance-gauge {
  display: inline-block;
  width: 64px; height: 8px;
  background: #e8e4f0; border-radius: 4px;
  overflow: hidden; vertical-align: middle;
}
.relevance-gauge-fill {
  display: block;
  height: 100%; border-radius: 4px;
  min-width: 2px;
}
.relevance-gauge-fill.score-high   { background: linear-gradient(90deg, #7c5cff, #5cb85c); }
.relevance-gauge-fill.score-mid    { background: linear-gradient(90deg, #a78bfa, #7c5cff); }
.relevance-gauge-fill.score-low    { background: linear-gradient(90deg, #d0c8e8, #a78bfa); }
.relevance-pct {
  font-size: 10.5px; color: var(--muted); font-weight: 700;
  letter-spacing: .02em; white-space: nowrap;
  vertical-align: middle;
}

/* ── Card item ── */
.item {
  border-radius: 14px;
  border: 2px solid var(--fc, #cfc3ff);
  background: #ffffff;
  position: relative; overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.item.has-combat  { padding-bottom: 50px; }
.item.has-loyalty { padding-bottom: 62px; }
.item::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 7px;
  background: var(--fa, linear-gradient(180deg, #7c5cff, #a78bfa));
  z-index: 1;
}

.card-head {
  display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
  padding: 14px 16px 12px 22px;
  background: var(--fh, transparent);
  border-bottom: 1.5px solid var(--fc, #e0d8f8);
}
.name-ja {
  font-weight: 800; font-size: 18px; line-height: 1.25; margin: 0 0 3px;
  font-family: 游ゴシック, YuGothic, "Yu Gothic", Roboto, Arial, メイリオ, Meiryo, sans-serif;
  color: #333333; letter-spacing: .01em;
}
.name-en { font-size: 11.5px; color: var(--muted); margin: 0; letter-spacing: .02em; word-break: break-word; }

.card-head-right {
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
  flex-shrink: 0;
}

/* ── Mana separator (DFC) ── */
.mana-separator {
  font-size: 16px; color: #888; font-weight: 700;
  margin: 0 4px; vertical-align: middle;
  line-height: 22px;
}

/* ── Mana cost (sprite: Mana.png 1046x731, 10 cols x 7 rows) ── */
.mana-cost { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; flex-shrink: 0; justify-content: flex-end; max-width: 220px; }
.ms {
  display: inline-block; width: 22px; height: 22px;
  background-image: url('/static/Mana.png');
  background-size: 220px 154px;
  background-repeat: no-repeat;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.25), 0 0 0 0.5px rgba(0,0,0,.10);
}
/* Colorless mana {C} */
.ms-colorless {
  background-image: url('/static/colorless.png');
  background-size: 22px 22px;
  background-position: center;
}
/* Fallback for unknown symbols */
.ms-fallback {
  background-image: none;
  background: rgba(100,90,130,.6);
  line-height: 22px; text-align: center;
  font-size: 11px; font-weight: 700; color: white;
}

/* ── Type line ── */
.type-line {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 16px 5px 22px;
  background: var(--ft, rgba(200,190,230,.07));
  border-bottom: 1px solid var(--fc, #e0d8f8);
  font-size: 12px; font-style: italic; color: #333333;
  letter-spacing: .015em; line-height: 1.5;
}

/* ── Badges ── */
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 700; margin-left: 6px; vertical-align: middle;
}
.badge-banned { background: var(--badge-banned); color: #fff; }
.badge-gc { background: var(--badge-gc); color: #fff; }

/* ── Oracle text ── */
.oracle-wrap { display: grid; gap: 6px; padding: 12px 16px 10px 22px; }
.oracle {
  font-size: 13px; margin: 0; padding: 9px 12px; color: #333333;
  border-radius: 10px; border: 1px solid var(--line); line-height: 1.75;
  background-image: repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(0,0,0,.018) 27px, rgba(0,0,0,.018) 28px);
}
.oracle em { font-style: italic; }
.oracle-ja { background-color: #f4f8ff; }
.oracle-en { background-color: #f8f5ff; }
.oracle-label {
  display: block; font-size: 10.5px; font-weight: 700;
  color: #8880aa; letter-spacing: .06em; text-transform: uppercase;
  margin-bottom: 5px; font-style: normal;
}

/* ── P/T box ── */
.pt-box {
  position: absolute; bottom: 12px; right: 16px;
  background: linear-gradient(160deg, #faf6ec, #ede5cf);
  border: 1.5px solid #9e8a58; border-radius: 6px;
  padding: 3px 12px;
  font-family: "Trebuchet MS", Georgia, serif;
  font-weight: 900; font-size: 15px; color: #1c1200;
  letter-spacing: .04em; line-height: 1.5;
  box-shadow: 0 2px 6px rgba(0,0,0,.18), inset 0 1px 0 rgba(255,255,255,.70);
  white-space: nowrap;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(180,155,90,.06) 3px, rgba(180,155,90,.06) 4px),
    linear-gradient(160deg, #faf6ec, #ede5cf);
}
.pt-slash { color: #7a6030; font-weight: 400; margin: 0 1px; }

/* ── Loyalty box ── */
.loyalty-box {
  position: absolute; bottom: 10px; right: 14px;
  width: 48px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  padding-bottom: 16px;
  font-family: "Trebuchet MS", Georgia, serif;
  font-weight: 900; font-size: 19px; color: #1c1200;
  letter-spacing: .04em;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,.22));
}
.loyalty-box .loyalty-shape { position: absolute; inset: 0; width: 100%; height: 100%; }
.loyalty-box .loyalty-num { position: relative; z-index: 1; margin-bottom: 2px; }

/* ── Pagination ── */
.pagination {
  display: flex; justify-content: center; gap: 6px;
  margin: 20px 0 30px; flex-wrap: wrap;
}
.page-btn {
  padding: 8px 14px; font-size: 14px;
  background: #fff; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  cursor: pointer; transition: all 0.2s;
}
.page-btn:hover { background: #f0ecf8; border-color: var(--accent); }
.page-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: var(--accent); color: #fff;
}
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── Site footer ── */
.site-footer {
  position: relative; z-index: 2;
  background: linear-gradient(135deg, #2d1b69 0%, #3a2478 100%);
  border-top: 1px solid rgba(124,92,255,.30);
}
.site-footer::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--accent2) 30%, var(--accent2) 70%, transparent 100%);
}
.site-footer-inner {
  max-width: 960px; margin: 0 auto; padding: 20px 24px;
  display: flex; align-items: baseline; gap: 20px; flex-wrap: wrap;
}
.footer-brand {
  font-family: "Trebuchet MS", "Avenir Next", sans-serif;
  font-size: 15px; font-weight: 800; letter-spacing: .06em;
  color: rgba(167,139,250,.80); flex-shrink: 0; white-space: nowrap;
}
.footer-legal { font-size: 11px; color: rgba(255,255,255,.38); line-height: 1.7; }
.footer-legal p { margin-bottom: 4px; }
.footer-legal a { color: rgba(167,139,250,.70); text-decoration: none; }
.footer-legal a:hover { color: rgba(167,139,250,1); }
.footer-policy { margin-top: 8px; color: rgba(255,255,255,.30); }

/* ── Card image icon ── */
.card-image-icon {
  cursor: pointer;
  margin-right: 5px;
  font-size: 15px;
  opacity: 0.5;
  transition: opacity 0.15s;
  vertical-align: middle;
}
.card-image-icon:hover {
  opacity: 1;
}

/* Image modal (click to show full card) */
.image-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; cursor: pointer;
}
.image-modal img {
  max-width: 90vw; max-height: 90vh;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
}

/* ── Synergy search ── */
.synergy-label {
  font-size: 14px; font-weight: 700; color: #333;
  margin-bottom: 8px;
}
.commander-search-wrap { position: relative; }
.commander-input {
  display: block; width: 100%; padding: 12px 16px;
  border-radius: 10px; border: 1px solid var(--line);
  font: inherit; color: var(--text); background: #fff;
}
.commander-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(124,92,255,.12);
}
.commander-suggestions {
  position: absolute; top: 100%; left: 0; right: 0;
  background: #fff; border: 1px solid var(--line);
  border-radius: 0 0 10px 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
  max-height: 300px; overflow-y: auto; z-index: 10;
}
.suggestion-item {
  padding: 10px 16px; font-size: 13px; cursor: pointer;
  border-bottom: 1px solid #f0ecf8;
}
.suggestion-item:hover { background: #f8f6ff; }
.suggestion-item:last-child { border-bottom: none; }

.commander-card {
  margin-top: 16px;
  border: 2px solid var(--accent2); border-radius: 14px;
  overflow: hidden; background: #fff;
  box-shadow: 0 4px 12px rgba(124,92,255,.08);
}
.commander-display {
  position: relative;
}

.view-toggle {
  font-size: 13px; color: #555; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
}
.view-toggle input { cursor: pointer; }

/* Type group headers */
.type-group-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.type-group-name {
  font-size: 16px; font-weight: 800; color: var(--accent);
}
.type-group-count {
  font-size: 12px; color: var(--muted); font-weight: 600;
  background: #f0ecf8; padding: 2px 10px; border-radius: 10px;
}

/* ── Content pages (help, news) ── */
.content-page {
  line-height: 1.8;
}
.content-page h2 {
  font-size: 20px; font-weight: 800; color: var(--accent);
  margin: 32px 0 12px; padding-bottom: 8px;
  border-bottom: 2px solid #e8e4f0;
}
.content-page h2:first-child { margin-top: 0; }
.content-page h3 {
  font-size: 16px; font-weight: 700; color: #333;
  margin: 24px 0 8px;
}
.content-page p { margin: 8px 0; }
.content-page ul, .content-page ol {
  margin: 8px 0 8px 24px;
}
.content-page li { margin: 4px 0; }
.content-page code {
  background: #f0ecf8; padding: 2px 6px; border-radius: 4px;
  font-size: 13px; color: var(--accent);
}
.content-page .example-box {
  background: #f8f6ff; border: 1px solid #e0d8f0;
  border-radius: 12px; padding: 16px; margin: 12px 0;
}
.content-page .example-box .example-label {
  font-size: 12px; font-weight: 700; color: var(--accent);
  margin-bottom: 6px;
}
.content-page .faq-q {
  font-weight: 700; color: #333; margin: 16px 0 4px;
}
.content-page .faq-a {
  margin: 0 0 16px 0; color: #555;
}
.news-date {
  font-size: 12px; color: var(--muted); font-weight: 600;
  margin-bottom: 4px;
}
.news-item {
  margin-bottom: 24px; padding-bottom: 20px;
  border-bottom: 1px solid #e8e4f0;
}
.news-item:last-child { border-bottom: none; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .wrap { padding: 16px 12px 24px; }
  .site-header-inner { padding: 12px 14px; gap: 10px; }
  .logo { width: 44px; height: 44px; }
  .logo img { width: 34px; height: 34px; }
  .title { font-size: 22px; }
  .subtitle { font-size: 10.5px; }
  .header-deco { display: none; }
  .site-nav-inner { padding: 0 10px; gap: 0; }
  .nav-link { padding: 8px 10px; font-size: 11.5px; }
  .panel { padding: 14px; border-radius: 14px; }
  textarea { min-height: 80px; font-size: 14px; }
  .example-chips { gap: 6px; }
  .example-chip { padding: 5px 10px; font-size: 11px; }
  .actions button[type="submit"] { padding: 12px; font-size: 15px; }

  /* Card layout */
  .card-head { flex-direction: column; padding: 10px 12px 8px 16px; }
  .card-head-right { flex-direction: row; align-items: center; gap: 8px; }
  .mana-cost { justify-content: flex-start; max-width: none; }
  .name-ja { font-size: 16px; }
  .type-line { padding: 4px 12px 4px 16px; font-size: 11px; }
  .oracle-wrap { padding: 8px 12px 8px 16px; }
  .oracle { padding: 7px 10px; font-size: 12px; line-height: 1.6; }

  /* Results header */
  .results-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .sort-controls { width: 100%; }
  .sort-btn { padding: 4px 8px; font-size: 11px; }

  /* Relevance */
  .relevance-gauge { width: 40px; height: 6px; }
  .relevance-pct { font-size: 9.5px; }

  /* P/T and Loyalty */
  .pt-box { font-size: 13px; padding: 2px 8px; }
  .loyalty-box { width: 40px; height: 48px; font-size: 16px; }

  /* Pagination */
  .page-btn { padding: 6px 10px; font-size: 13px; }

  /* Footer */
  .site-footer-inner { flex-direction: column; gap: 8px; padding: 16px 14px; }
  .footer-legal { font-size: 10px; }

  /* Content pages */
  .content-page h2 { font-size: 18px; }
  .content-page h3 { font-size: 14px; }

  /* Synergy */
  .commander-input { font-size: 14px; }
  .synergy-label { font-size: 13px; }
}
