:root {
  color-scheme: dark;
  --bg: #0d0d10;
  --bg-soft: #202025;
  --surface: #171719;
  --surface-raised: #202024;
  --line: #303137;
  --line-strong: #44464f;
  --text: #efeff2;
  --muted: #a9abb4;
  --accent: #39c8bd;
  --accent-strong: #7be3dc;
  --accent-soft: #143a3e;
  --gold: #f4bd50;
  --gold-soft: #3d2f16;
  --danger: #ff7d72;
  --danger-soft: #3b1f24;
  --info: #9fc3ff;
  --info-soft: #1b2d4a;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
  --radius: 14px;
  font-family:
    Inter, "Noto Sans JP", ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 12% 0%, rgba(57, 200, 189, 0.12), transparent 28rem),
    linear-gradient(90deg, rgba(123, 227, 220, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(244, 189, 80, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 48px 48px;
  color: var(--text);
}

a {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(57, 200, 189, 0.34);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  min-height: 44px;
  padding: 11px 16px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow);
  transform: translateY(calc(-100% - 20px));
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
  text-decoration: none;
}

.app-shell {
  width: min(1600px, calc(100% - 32px));
  margin: 0 auto;
  padding: 12px 0 40px;
}

.top-nav {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 58px;
  margin-bottom: 14px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 17, 20, 0.94);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(14px);
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  color: var(--text);
  font-size: 1rem;
  font-weight: 900;
}

.nav-brand:hover {
  text-decoration: none;
}

.nav-links {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
}

.nav-links a:hover {
  color: var(--accent-strong);
  text-decoration: none;
}

.nav-links a[data-active="true"],
.nav-links a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.nav-actions {
  display: inline-flex;
  justify-self: end;
  gap: 8px;
  align-items: center;
}

.nav-language {
  justify-self: end;
}

.site-header {
  margin-bottom: 14px;
}

.brand-block,
.filter-panel,
.results-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(18, 26, 38, 0.94);
  box-shadow: var(--shadow);
}

.brand-block {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 0;
  padding: clamp(22px, 3vw, 38px);
  background:
    linear-gradient(135deg, rgba(57, 200, 189, 0.2), rgba(244, 189, 80, 0.08) 48%, rgba(18, 26, 38, 0) 72%),
    var(--surface);
}

.brand-copy {
  min-width: 0;
}

.language-control {
  display: inline-flex;
  align-items: center;
}

.language-control select {
  width: auto;
  min-width: 112px;
  margin-top: 0;
  padding: 0 30px 0 10px;
  font-size: 0.86rem;
  font-weight: 900;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  max-width: 24ch;
  font-size: clamp(2.35rem, 5vw, 4.4rem);
  line-height: 1.04;
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 0;
  font-size: 1.2rem;
  line-height: 1.2;
}

.lead {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 14px;
}

.page-view[hidden] {
  display: none !important;
}

.filter-panel,
.results-panel {
  background: rgba(23, 23, 25, 0.96);
}

.filter-panel {
  position: sticky;
  top: 16px;
  align-self: start;
  padding: 18px;
  overflow: hidden;
}

.panel-heading {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.filter-help,
.filter-summary {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.controls {
  display: block;
}

.filter-fields {
  display: grid;
  gap: 16px;
}

.filter-toggle {
  display: none;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-raised);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 900;
  cursor: pointer;
}

.filter-toggle-icon {
  width: 8px;
  height: 8px;
  margin-left: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 160ms ease;
}

.filter-toggle[aria-expanded="false"] .filter-toggle-icon {
  transform: translateY(2px) rotate(225deg);
}

.filter-summary {
  display: none;
  color: var(--accent-strong);
  font-weight: 800;
}

label,
legend {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
}

input,
select {
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #111114;
  color: var(--text);
  font: inherit;
}

input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(57, 200, 189, 0.24);
  outline-offset: 2px;
  border-color: var(--accent);
}

input[type="search"],
select {
  padding: 0 12px;
}

input[type="range"] {
  accent-color: var(--accent);
}

fieldset {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
}

fieldset label {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  min-width: 0;
  padding: 8px 0;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 700;
}

fieldset input {
  width: 16px;
  min-height: auto;
  margin: 0;
  accent-color: var(--accent);
}

.error {
  margin: 0 18px 12px;
  padding: 13px 14px;
  border: 1px solid rgba(255, 125, 114, 0.42);
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 800;
}

.results-panel {
  min-width: 0;
  overflow: hidden;
}

.results-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--line);
}

.result-meta {
  display: grid;
  gap: 5px;
  justify-items: end;
  min-width: max-content;
}

.result-meta span {
  min-width: max-content;
  color: var(--muted);
  font-weight: 900;
}

.result-meta [data-result-count] {
  color: var(--text);
  font-size: 1rem;
}

.results[aria-busy="true"] .table-wrap {
  opacity: 0.58;
}

.updated-at {
  font-size: 0.76rem;
}

.table-wrap {
  overflow-x: auto;
}

.results-footer {
  display: flex;
  justify-content: center;
  padding: 16px 20px 20px;
  border-top: 1px solid var(--line);
}

.load-more-button {
  min-width: min(100%, 260px);
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid rgba(57, 200, 189, 0.42);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    color 160ms ease;
}

.load-more-button:hover {
  border-color: var(--accent);
  background: rgba(57, 200, 189, 0.2);
  color: var(--text);
}

.results-footer:has(.load-more-button[hidden]) {
  display: none;
}

.world-ranking {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(23, 23, 25, 0.96);
  box-shadow: var(--shadow);
}

.world-ranking-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.world-ranking-header h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.ranking-actions {
  display: grid;
  gap: 6px;
  justify-items: end;
}

.ranking-period-control {
  width: 160px;
}

.ranking-period-control select {
  margin-top: 0;
}

.ranking-lead {
  margin: 0;
  padding: 14px 20px 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.world-ranking-wrap {
  overflow-x: auto;
  padding-top: 14px;
}

.world-ranking-table {
  min-width: 940px;
}

.world-ranking-table th,
.world-ranking-table td {
  padding: 10px 12px;
}

.world-ranking-table tbody tr[data-current="true"] {
  background: var(--accent-soft);
}

.world-ranking-button {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.world-ranking-button:hover {
  text-decoration: underline;
}

.world-ranking-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

table {
  width: 100%;
  min-width: 940px;
  border-collapse: collapse;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #202024;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.sort-button:hover {
  color: var(--accent-strong);
}

.sort-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.sort-indicator {
  display: inline-flex;
  justify-content: center;
  width: 1.2em;
  color: var(--accent-strong);
}

tbody tr {
  background: var(--surface);
}

tbody tr:hover {
  background: #202024;
}

td:nth-child(2) {
  white-space: normal;
}

.rank,
.item-id {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.item-id {
  display: block;
  margin-top: 5px;
}

.item-link-row {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.eriones-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
}

.eriones-link img {
  width: 24px;
  height: 24px;
}

.positive {
  color: var(--accent-strong);
  font-weight: 900;
}

.negative {
  color: var(--danger);
  font-weight: 900;
}

.state-pill,
.recommendation {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 900;
}

.state-spiking,
.state-out-of-stock {
  background: var(--gold-soft);
  color: var(--gold);
}

.state-increasing {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.state-decreasing {
  background: var(--danger-soft);
  color: var(--danger);
}

.recommendation {
  margin-left: 6px;
  background: var(--info-soft);
  color: var(--info);
}

.empty-state {
  padding: 42px 16px;
  color: var(--muted);
  text-align: center;
}

.legal-document {
  min-width: 0;
}

.legal-header {
  align-items: flex-start;
}

.legal-header > div {
  width: 100%;
  max-width: none;
}

.legal-header h2 {
  font-size: 1.3rem;
  line-height: 1.3;
}

.legal-lead {
  max-width: none;
  margin: 0;
  padding: 16px 20px 18px;
  font-size: 1.02rem;
  line-height: 1.8;
}

.legal-content {
  display: grid;
  gap: 0;
  max-width: none;
  margin: 0;
  padding: 0 20px 12px;
}

.legal-section {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.legal-section h3 {
  margin-bottom: 10px;
  font-size: 1.08rem;
  line-height: 1.45;
}

.legal-section p,
.legal-section dd {
  max-width: 88ch;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.82;
}

.legal-section p + p {
  margin-top: 12px;
}

.legal-note {
  margin-bottom: 14px;
  padding: 12px 14px 12px 16px;
  border-left: 3px solid var(--accent);
  border-radius: 0 7px 7px 0;
  background: rgba(57, 200, 189, 0.08);
  color: var(--text);
}

.data-source-list {
  display: grid;
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.data-source-list div {
  padding: 14px 0;
}

.data-source-list div:first-child {
  padding-top: 0;
}

.data-source-list div:last-child {
  padding-bottom: 0;
}

.data-source-list div + div {
  border-top: 1px solid var(--line);
}

.data-source-list dt {
  margin-bottom: 4px;
  color: var(--text);
  font-weight: 900;
}

.data-source-list dd {
  margin-left: 0;
}

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

  .filter-panel {
    position: static;
  }

  .filter-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-fields fieldset {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
  }
}

@media (max-width: 760px) {
  #eorzeadb_tooltip {
    left: 8px !important;
  }

  #eorzeadb_tooltip .db-tooltip__wrapper {
    zoom: 0.7;
    zoom: min(1, calc((100vw - 32px) / 412px));
  }

  .app-shell {
    width: min(100% - 20px, 1600px);
    padding-top: 8px;
  }

  .top-nav {
    grid-template-columns: 1fr auto;
    gap: 8px;
    margin-bottom: 10px;
  }

  .nav-links {
    grid-column: 1 / -1;
    order: 3;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-links a {
    padding: 0 6px;
    font-size: 0.78rem;
  }

  .nav-actions {
    grid-column: 2;
  }

  .site-header {
    margin-bottom: 8px;
  }

  .brand-block {
    display: grid;
    gap: 14px;
    padding: 16px;
  }

  h1 {
    font-size: 2.3rem;
  }

  .lead {
    font-size: 0.98rem;
  }

  .dashboard-grid {
    gap: 10px;
  }

  .filter-panel {
    padding: 0;
  }

  .panel-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    align-items: center;
    margin: 0;
    padding: 14px 16px;
    border-bottom: 0;
  }

  .panel-heading-copy {
    min-width: 0;
  }

  .panel-heading .panel-kicker {
    margin-bottom: 4px;
  }

  .filter-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
  }

  .filter-help,
  .filter-summary {
    grid-column: 1 / -1;
    margin-top: 0;
  }

  .filter-toggle[aria-expanded="false"] ~ .filter-help {
    display: none;
  }

  .filter-toggle[aria-expanded="false"] ~ .filter-summary {
    display: block;
  }

  .filter-fields {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 4px 16px 16px;
    border-top: 1px solid var(--line);
  }

  .results-header {
    padding: 16px;
  }

  .result-meta {
    justify-items: start;
  }

  .table-wrap,
  .world-ranking-wrap {
    overflow: visible;
  }

  .market-results-table {
    min-width: 0;
  }

  .world-ranking-table {
    min-width: 0;
  }

  .market-results-table thead,
  .world-ranking-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .market-results-table tbody,
  .world-ranking-table tbody {
    display: grid;
    gap: 10px;
    padding: 12px;
  }

  .market-results-table tr {
    display: grid;
  }

  .world-ranking-table tr {
    display: grid;
  }

  .market-results-table tr,
  .world-ranking-table tr {
    position: relative;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px 12px;
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-raised);
  }

  .market-results-table td,
  .world-ranking-table td {
    display: grid;
    gap: 3px;
    min-width: 0;
    padding: 5px 0;
    border-bottom: 0;
    font-size: 0.82rem;
    line-height: 1.25;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .market-results-table td::before,
  .world-ranking-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 900;
    letter-spacing: 0.04em;
  }

  .market-results-table td:nth-child(2),
  .market-results-table .empty-state,
  .world-ranking-table td:nth-child(2),
  .world-ranking-table td:nth-child(8) {
    grid-column: 1 / -1;
  }

  .market-results-table td:nth-child(1):not(.empty-state),
  .world-ranking-table td:nth-child(1):not(.empty-state) {
    position: absolute;
    top: 10px;
    right: 10px;
    display: block;
    width: auto;
    padding: 3px 7px;
    border-radius: 999px;
    background: var(--bg-soft);
    color: var(--muted);
    font-size: 0.74rem;
  }

  .market-results-table td:nth-child(1):not(.empty-state)::before,
  .world-ranking-table td:nth-child(1):not(.empty-state)::before {
    display: none;
  }

  .market-results-table td:nth-child(2),
  .world-ranking-table td:nth-child(2) {
    padding: 0 42px 7px 0;
    font-size: 0.92rem;
  }

  .market-results-table td:nth-child(2)::before,
  .world-ranking-table td:nth-child(2)::before {
    display: none;
  }

  .market-results-table td:nth-child(2) .item-id {
    margin-top: 2px;
    font-size: 0.7rem;
  }

  .market-results-table td:nth-child(8) {
    display: flex;
    flex-wrap: wrap;
    align-content: start;
    align-items: center;
    gap: 4px;
  }

  .market-results-table td:nth-child(8)::before {
    flex-basis: 100%;
  }

  .market-results-table td:nth-child(8) .state-pill,
  .market-results-table td:nth-child(8) .recommendation {
    min-height: 24px;
    margin-left: 0;
    padding-inline: 7px;
    font-size: 0.72rem;
  }

  .world-ranking-table td:nth-child(3) {
    grid-column: 1 / 3;
  }

  .world-ranking-table .world-ranking-button {
    min-height: 44px;
  }

  .market-results-table .empty-state {
    justify-self: stretch;
    padding: 28px 12px;
  }

  .results-footer {
    padding: 12px 16px 16px;
  }

  .load-more-button {
    width: 100%;
    min-height: 44px;
  }

  .world-ranking-header {
    display: grid;
    padding: 16px;
  }

  .ranking-period-control {
    width: 100%;
  }

  .ranking-actions {
    width: 100%;
    justify-items: stretch;
  }

  .ranking-lead {
    padding: 12px 16px 0;
  }

  .legal-lead,
  .legal-content {
    padding-right: 16px;
    padding-left: 16px;
  }

  .legal-lead {
    padding-top: 16px;
    padding-bottom: 16px;
  }

  .legal-content {
    padding-bottom: 8px;
  }

  .legal-section {
    padding: 16px 0;
  }

  .filter-fields fieldset {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 12px;
  }
}
