:root {
  --bg: #0b1020;
  --surface: #121939;
  --surface-2: #0f1530;
  --text: #e6ecff;
  --muted: #9aa4c7;
  --primary: #6c8cff;
  --accent: #8a5cff;
  --success: #19d3a7;
  --danger: #ff5c8a;
  --ring: rgba(108, 140, 255, 0.6);
  --card-border: rgba(255, 255, 255, 0.08);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: radial-gradient(
      1200px 800px at 80% -10%,
      rgba(138, 92, 255, 0.25),
      transparent 60%
    ),
    radial-gradient(
      900px 700px at -10% 10%,
      rgba(108, 140, 255, 0.18),
      transparent 55%
    ),
    linear-gradient(180deg, #0a0f21 0%, #0b1020 100%);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url('https://shadowverse-wb.com/uploads/card_set/eng/956aa658a12c8e71f68e1a0e4dbd7cde.png');
  background-repeat: no-repeat;
  background-position: center top;
  background-size: cover;
  opacity: 0.14;
  pointer-events: none;
  z-index: 0;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
  position: relative;
  z-index: 1;
}

@media (min-width: 768px) {
  .container {
  padding: 24px;
  }
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

@media (max-width: 767px) {
  header {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }
  
  .title {
    justify-content: center;
  }
  
  nav.tabs {
    justify-content: center;
  }
  
  .lang-toggle-container {
    justify-content: center;
  }
  #filters-mobile-toggle { display: flex; }
}

.title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.title h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.4px;
  background: linear-gradient(90deg, var(--text), #b9c4ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

@media (min-width: 768px) {
  .title h1 {
    font-size: 22px;
  }
}

nav.tabs {
  display: flex;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  padding: 4px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

@media (min-width: 768px) {
  nav.tabs {
    gap: 8px;
    padding: 6px;
  }
}

.tab-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.2px;
  transition: color 0.2s ease, background 0.2s ease;
  font-size: 14px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (min-width: 768px) {
  .tab-btn {
    padding: 8px 14px;
    font-size: 16px;
    min-height: auto;
  }
}

.tab-btn.active {
  color: var(--text);
  background: linear-gradient(
    180deg,
    rgba(108, 140, 255, 0.25),
    rgba(138, 92, 255, 0.2)
  );
  border: 1px solid var(--card-border);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 6px 14px rgba(0, 0, 0, 0.25);
}

.search-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0 22px 0;
}

.filters-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: -2px 0 18px 0;
}

.filters-row--secondary {
  margin-top: -10px;
}

.filter {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: linear-gradient(180deg, rgba(18,25,57,0.7), rgba(15,21,48,0.7));
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.25);
}

.filter label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.filter select,
.filter input[type="text"],
.filter input[type="number"] {
  color: var(--text);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 8px 10px;
  min-height: 36px;
  outline: none;
  transition: box-shadow 0.2s ease, border 0.2s ease;
}

.filter select {
  color-scheme: dark;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-color: rgba(18,25,57,0.9);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%23e6ecff'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  padding-right: 34px;
}

.filter select option {
  color: #0b1020;
  background: #ffffff;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
  position: relative;
  padding-right: 34px;
}

input[type="number"]::after,
input[type="number"]::before {
  content: '';
  position: absolute;
  right: 10px;
  width: 12px;
  height: 6px;
  pointer-events: none;
}

input[type="number"]::before {
  top: 8px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid rgba(230,236,255,0.7);
}

input[type="number"]::after {
  bottom: 8px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid rgba(230,236,255,0.7);
}

.filter input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.filter select:focus,
.filter input[type="text"]:focus,
.filter input[type="number"]:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.18), inset 0 1px 0 rgba(255,255,255,0.05);
}

#search {
  flex: 1;
  margin: 0;
  padding: 12px 14px 12px 42px;
  width: 100%;
  max-width: 560px;
  font-size: 16px;
  color: var(--text);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--card-border);
  border-radius: 12px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 10px 24px rgba(0, 0, 0, 0.25);
  transition: box-shadow 0.2s ease, border 0.2s ease;
  min-height: 44px;
}

@media (min-width: 768px) {
  #search {
    font-size: 15px;
    min-height: auto;
  }
}

#search:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.search-wrap {
  position: relative;
  width: 100%;
  max-width: 560px;
}

.waterfall #cards {
  column-count: 1;
  -webkit-column-count: 1;
  -moz-column-count: 1;
  column-gap: 16px;
  -webkit-column-gap: 16px;
  -moz-column-gap: 16px;
}

@media (min-width: 600px) {
  .waterfall #cards { column-count: 2; -webkit-column-count: 2; -moz-column-count: 2; }
}

@media (min-width: 900px) {
  .waterfall #cards { column-count: 3; -webkit-column-count: 3; -moz-column-count: 3; }
}

@media (min-width: 1200px) {
  .waterfall #cards { column-count: 4; -webkit-column-count: 4; -moz-column-count: 4; }
}

.waterfall .card {
  break-inside: avoid;
  display: inline-block;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.card {
  margin-bottom: 16px;
  padding: 14px;
  background: linear-gradient(
    180deg,
    rgba(18, 25, 57, 0.9),
    rgba(15, 21, 48, 0.9)
  );
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 10px 0;
  font-size: 18px;
  font-weight: 700;
  color: #dee6ff;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (min-width: 768px) {
  .btn-row {
  gap: 10px;
  }
}

.audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 12px 14px;
  cursor: pointer;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: linear-gradient(
    180deg,
    rgba(108, 140, 255, 0.16),
    rgba(138, 92, 255, 0.12)
  );
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.2px;
  transition: transform 0.06s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  user-select: none;
  min-height: 44px;
  font-size: 14px;
}

@media (min-width: 768px) {
  .audio-btn {
    padding: 10px 12px;
    font-size: 16px;
    min-height: auto;
  }
}

.audio-btn:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.32),
    0 0 0 2px rgba(108, 140, 255, 0.15);
}

.audio-btn:active {
  transform: translateY(1px);
}

.audio-btn .icon {
  width: 16px;
  height: 16px;
}

.audio-btn.playing {
  background: linear-gradient(
    180deg,
    rgba(25, 211, 167, 0.18),
    rgba(25, 211, 167, 0.12)
  );
  box-shadow: 0 0 0 2px rgba(25, 211, 167, 0.18), 0 6px 16px rgba(0, 0, 0, 0.32);
}

.audio-btn .time {
  margin-left: 6px;
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  opacity: 0.9;
}

section {
  display: none;
}

section.active {
  display: block;
}

.qna,
.problems {
  background: linear-gradient(
    180deg,
    rgba(18, 25, 57, 0.8),
    rgba(15, 21, 48, 0.8)
  );
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.qna h2 {
  margin: 0 0 8px 0;
  font-size: 18px;
}

.qna-item,
.problems-item {
  margin: 10px 0;
  padding: 12px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.q {
  color: var(--primary);
  font-weight: 700;
  margin: 0 0 6px 0;
}

.a {
  color: var(--muted);
  margin: 0;
}
.lang-toggle-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 900;
  margin: 0;
  gap: 8px;
}

.lang-toggle-btn {
  appearance: none;
  background: linear-gradient(180deg, rgba(108,140,255,0.16), rgba(138,92,255,0.12));
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  user-select: none;
  min-width: 48px;
  min-height: 44px;
  text-align: center;
  font-size: 14px;
}

@media (min-width: 768px) {
  .lang-toggle-btn {
    font-size: 16px;
    min-height: auto;
  }
}

.lang-toggle-btn:hover {
  box-shadow: 0 6px 16px rgba(0,0,0,0.32), 0 0 0 2px rgba(108,140,255,0.15);
}

.lang-toggle-btn:active {
  transform: translateY(1px);
}

.lang-toggle-btn.active {
  background: linear-gradient(180deg, rgba(25,211,167,0.18), rgba(25,211,167,0.12));
  box-shadow: 0 0 0 2px rgba(25,211,167,0.18), 0 6px 16px rgba(0,0,0,0.32);
}

.back-to-top-btn {
  appearance: none;
  background: linear-gradient(180deg, rgba(108,140,255,0.16), rgba(138,92,255,0.12));
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  user-select: none;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.back-to-top-btn:hover {
  box-shadow: 0 6px 16px rgba(0,0,0,0.32), 0 0 0 2px rgba(108,140,255,0.15);
}

.back-to-top-btn:active {
  transform: translateY(1px);
}

.card-image {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(18,25,57,0.6), rgba(15,21,48,0.6));
  box-shadow: 0 10px 24px rgba(0,0,0,0.28);
}

.card-image img {
  max-width: 100%;
  width: 280px;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  transition: transform 0.25s ease;
}

.card-image img:hover {
  transform: translateY(-1px) scale(1.01);
}

.img-toggle {
  margin-top: 10px;
  padding: 8px 12px;
  font-size: 14px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid var(--card-border);
  background: linear-gradient(180deg, rgba(108,140,255,0.16), rgba(138,92,255,0.12));
  color: var(--text);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  transition: transform 0.06s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.img-toggle:hover {
  box-shadow: 0 6px 16px rgba(0,0,0,0.32), 0 0 0 2px rgba(108,140,255,0.15);
}

.img-toggle:active {
  transform: translateY(1px);
}

.img-toggle[aria-pressed="true"] {
  background: linear-gradient(180deg, rgba(25,211,167,0.18), rgba(25,211,167,0.12));
  box-shadow: 0 0 0 2px rgba(25,211,167,0.18), 0 6px 16px rgba(0,0,0,0.32);
}

.filter-reset-btn {
  appearance: none;
  background: linear-gradient(180deg, rgba(255,92,138,0.18), rgba(255,92,138,0.12));
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  transition: transform 0.06s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.filter-reset-btn:hover {
  box-shadow: 0 6px 16px rgba(0,0,0,0.32), 0 0 0 2px rgba(255,92,138,0.15);
}

.filter-reset-btn:active {
  transform: translateY(1px);
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 18, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.lightbox.open { display: flex; }

.lightbox-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 1100px;
  background: linear-gradient(180deg, rgba(18,25,57,0.85), rgba(15,21,48,0.85));
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

@media (min-width: 900px) {
  .lightbox-content {
    grid-template-columns: 3fr 2fr;
    gap: 20px;
    padding: 20px;
  }
  .lightbox-meta {
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
  }
}

.lightbox-img-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-img {
  max-width: 100%;
  height: auto;
  width: 100%;
  max-height: calc(100vh - 220px);
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.4);
}

.lightbox-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lightbox-title {
  margin: 0 0 8px 0;
  font-size: 22px;
  font-weight: 800;
  color: #dee6ff;
}

.lightbox-meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px 12px;
}

.lightbox-meta .label { color: var(--muted); font-size: 12px; }
.lightbox-meta .value { color: var(--text); font-weight: 600; }

.lightbox-flavor {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.lightbox-controls {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.lightbox-btn {
  appearance: none;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: linear-gradient(180deg, rgba(108,140,255,0.16), rgba(138,92,255,0.12));
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 8px;
}
