:root {
  --bg: #15131a;
  --bg-card: #211e26;
  --bg-card-hi: #2a2630;
  --fg: #ece5d5;
  --fg-muted: #8e8579;
  --accent: #c0392b;        /* shu / vermilion */
  --accent-hi: #e0594a;
  --gold: #d8a657;
  --good: #6cae5b;
  --border: #3a343f;
  --border-hi: #524854;
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  --serif: "Cormorant Garamond", "Hoefler Text", "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--fg);
  margin: 0;
  font-family: var(--sans);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold); text-decoration: none; border-bottom: 1px dashed transparent; }
a:hover { border-bottom-color: var(--gold); }

code { font-family: var(--mono); background: #00000033; padding: 1px 5px; border-radius: 3px; font-size: 0.92em; }

/* ---------- Header ---------- */

header {
  position: relative;
  padding: 4.5rem 2rem 2.5rem;
  text-align: center;
  background:
    radial-gradient(ellipse at center top, #2a1f25 0%, #15131a 60%),
    var(--bg);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.kanji-bg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: serif;
  font-size: 22rem;
  color: var(--accent);
  opacity: 0.06;
  pointer-events: none;
  user-select: none;
  line-height: 1;
}

h1 {
  position: relative;
  margin: 0 0 0.5rem;
  font-family: var(--serif);
  font-size: 2.6rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h1::before, h1::after {
  color: var(--accent);
  font-weight: 400;
}
h1::before { content: "「"; margin-right: 0.15em; }
h1::after  { content: "」"; margin-left:  0.15em; }

.tagline {
  position: relative;
  color: var(--fg-muted);
  font-style: italic;
  margin: 0;
  font-size: 1.05rem;
}

/* ---------- Layout ---------- */

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.6rem 1.8rem;
  margin-bottom: 1.6rem;
  box-shadow: var(--shadow);
}

.card.legal   { border-left: 4px solid var(--gold); }
.card.classes { border-left: 4px solid var(--good); }
.card.cap     { border-left: 4px solid var(--accent-hi); }
.card.classes ul { margin: 0.4rem 0 0.7rem; padding-left: 1.2rem; }
.card.classes li { color: var(--fg); margin-bottom: 0.3rem; }
.card.classes li::marker { color: var(--good); }

.screenshot {
  margin: 1.2rem auto 0;
  text-align: center;
}
.screenshot img {
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: var(--shadow);
}
.screenshot figcaption {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--fg-muted);
  font-style: italic;
}

h2 {
  margin: 0 0 1rem;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-left: 3px solid var(--accent);
  padding-left: 0.7rem;
}

h3 {
  font-family: var(--serif);
  font-size: 1.25rem;
  margin: 0 0 0.4rem;
  color: var(--gold);
  font-weight: 600;
}

p { margin: 0 0 0.7rem; }
p:last-child { margin-bottom: 0; }

.muted { color: var(--fg-muted); }
.hint  { color: var(--fg-muted); font-size: 0.9rem; }

/* ---------- ROM input ---------- */

.rom-input { margin-bottom: 1.6rem; }

.rom-input label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

input[type="file"] {
  display: block;
  width: 100%;
  background: #0d0c12;
  color: var(--fg);
  border: 1px dashed var(--border-hi);
  border-radius: 6px;
  padding: 0.7rem;
  font-family: var(--mono);
  font-size: 0.88rem;
}

input[type="file"]::file-selector-button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.4rem 0.9rem;
  margin-right: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
}

.rom-status {
  margin: 0.6rem 0 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--fg-muted);
}
.rom-status.ok    { color: var(--good); }
.rom-status.error { color: var(--accent-hi); }

/* ---------- Slider ---------- */

.slider-block { margin: 1.4rem 0; }

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  margin-bottom: 0.5rem;
}
.slider-labels .easy   { color: var(--good); }
.slider-labels .grindy { color: var(--accent); }
.slider-labels .middle { font-weight: 500; letter-spacing: 0.08em; }

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 24px;
}

input[type="range"]:focus { outline: none; }

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: linear-gradient(90deg, var(--good) 0%, var(--gold) 50%, var(--accent) 100%);
  border-radius: 3px;
  border: 1px solid var(--border-hi);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--bg);
  margin-top: -9px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
input[type="range"]::-moz-range-track {
  height: 6px;
  background: linear-gradient(90deg, var(--good) 0%, var(--gold) 50%, var(--accent) 100%);
  border-radius: 3px;
  border: 1px solid var(--border-hi);
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--bg);
  cursor: pointer;
}

.slider-explainer {
  margin-top: 0.7rem;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.92rem;
  color: var(--gold);
  min-height: 1.4em;
}

.patch-summary {
  margin: 1.5rem 0 0;
  background: #0d0c1280;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.5rem 0.9rem;
}
.patch-summary summary {
  cursor: pointer;
  color: var(--fg-muted);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  user-select: none;
  list-style: none;
  position: relative;
  padding-left: 1.1rem;
}
.patch-summary summary::-webkit-details-marker { display: none; }
.patch-summary summary::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--accent);
  transition: transform 120ms ease;
  display: inline-block;
}
.patch-summary[open] summary::before { transform: rotate(90deg); }
.patch-summary summary:hover { color: var(--fg); }
.patch-summary ul {
  margin: 0.6rem 0 0.3rem;
  padding-left: 1.4rem;
  font-size: 0.88rem;
  color: var(--fg);
  line-height: 1.55;
}
.patch-summary li { margin-bottom: 0.25rem; }
.patch-summary li::marker { color: var(--gold); }

/* ---------- Buttons ---------- */

.actions {
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

button {
  background: var(--accent);
  color: white;
  border: 1px solid var(--accent);
  padding: 0.65rem 1.3rem;
  border-radius: 5px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: background 120ms ease, border-color 120ms ease;
}
button:hover:not(:disabled) {
  background: var(--accent-hi);
  border-color: var(--accent-hi);
}

button#download-ips {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold);
}
button#download-ips:hover:not(:disabled) {
  background: var(--gold);
  color: var(--bg);
}

button:disabled {
  background: #2c2630;
  color: var(--fg-muted);
  border-color: var(--border);
  cursor: not-allowed;
}

/* ---------- Tables ---------- */

.tables { display: block; }

.table-pane {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.2rem 1.4rem;
  box-shadow: var(--shadow);
}

.table-meta {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--fg-muted);
  margin: 0 0 0.4rem;
  line-height: 1.6;
}

.table-legend {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--fg-muted);
  margin: 0 0 0.7rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px dashed var(--border);
}
.table-legend .val { font-size: 0.78rem; }

.table-scroll {
  max-height: 460px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #0d0c12;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.85rem;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-card-hi);
  color: var(--fg);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-align: right;
  padding: 0.65rem 0.7rem;
  border-bottom: 2px solid var(--accent);
  box-shadow: 0 2px 0 #00000040;
}
thead th:first-child { text-align: left; }

tbody td {
  padding: 0.35rem 0.7rem;
  text-align: right;
  border-bottom: 1px solid #20192080;
  white-space: nowrap;
}
tbody td.lvl { text-align: left; color: var(--fg-muted); font-size: 0.78rem; }

tbody tr:hover td { background: var(--bg-card-hi); }

td .val { font-family: var(--mono); }
td .val.same {
  color: var(--fg-muted);
}
td .val.orig {
  color: #b56666;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  opacity: 0.85;
  font-size: 0.82rem;
}
td .val.new {
  color: var(--good);
  font-weight: 600;
}
td .arrow {
  color: var(--fg-muted);
  margin: 0 0.45em;
  opacity: 0.7;
}

td.lvl .lvl-num {
  display: inline-block;
  font-family: var(--mono);
}
td.lvl .lvl-note {
  display: block;
  font-size: 0.68rem;
  font-style: italic;
  color: var(--fg-muted);
  margin-top: 1px;
  letter-spacing: 0;
  text-transform: none;
}

/* ---------- Footer ---------- */

footer {
  text-align: center;
  padding: 2rem 1rem 3rem;
  color: var(--fg-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

/* ---------- Responsive ---------- */

@media (max-width: 820px) {
  h1 { font-size: 2rem; }
  .kanji-bg { font-size: 16rem; }
  main { padding: 1.5rem 1rem 2rem; }
  .card { padding: 1.2rem 1.2rem; }
  td .val.orig { font-size: 0.76rem; }
  td .arrow { margin: 0 0.25em; }
}
