:root {
  color-scheme: dark;
  --bg: #070303;
  --bg-red: #170607;
  --panel: rgba(20, 12, 11, 0.94);
  --panel-2: rgba(40, 13, 11, 0.96);
  --text: #f7ead2;
  --muted: #b9a58a;
  --line: rgba(210, 143, 65, 0.34);
  --gold: #d8a64c;
  --gold-bright: #ffe1a0;
  --red-hot: #d23b30;
}

* { box-sizing: border-box; }

html { min-width: 300px; }

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(82, 13, 10, 0.42) 0, rgba(7, 3, 3, 0) 360px),
    repeating-linear-gradient(90deg, rgba(216, 166, 76, 0.035) 0 1px, transparent 1px 96px),
    linear-gradient(180deg, var(--bg-red) 0, var(--bg) 52%, #040202 100%);
  font-family: "Segoe UI", "Microsoft JhengHei", Arial, sans-serif;
  line-height: 1.5;
}

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

.shell {
  width: min(1080px, calc(100vw - 28px));
  margin: 0 auto;
}

.page-head {
  min-height: 146px;
  border-bottom: 1px solid rgba(216, 166, 76, 0.5);
  background:
    linear-gradient(180deg, rgba(5, 2, 2, 0.12), rgba(5, 2, 2, 0.9)),
    url("assets/throne-room.png") center 18% / cover no-repeat;
  box-shadow: inset 0 -70px 70px rgba(7, 3, 3, 0.95);
}

.portal-main {
  position: relative;
  z-index: 1;
  margin-top: -62px;
  padding-bottom: 72px;
}

.hero {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 126px;
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(52, 15, 13, 0.94), rgba(13, 8, 7, 0.97));
  box-shadow: inset 0 1px 0 rgba(255, 225, 160, 0.06), 0 16px 32px rgba(0, 0, 0, 0.3);
}

.hero img {
  width: 70px;
  height: 86px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.48));
}

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

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-self: end;
}

.language-switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid rgba(216, 166, 76, 0.36);
  border-radius: 999px;
  background: rgba(7, 4, 4, 0.68);
  box-shadow: inset 0 1px 0 rgba(255, 225, 160, 0.05);
}

.language-button {
  min-width: 54px;
  min-height: 34px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  transition: color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.language-button:hover { color: var(--gold-bright); }

.language-button.active {
  color: #2a0b08;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28);
}

h1 {
  margin: 0;
  color: var(--gold-bright);
  font-size: clamp(32px, 5vw, 48px);
  line-height: 1.05;
  text-shadow: 0 2px 0 rgba(50, 5, 3, 0.9), 0 0 18px rgba(210, 59, 48, 0.32);
}

.portal-sections {
  display: grid;
  gap: 14px;
}

.portal-section {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(42, 14, 12, 0.95), rgba(14, 8, 7, 0.97));
  box-shadow: inset 0 1px 0 rgba(255, 225, 160, 0.04), 0 10px 24px rgba(0, 0, 0, 0.18);
}

.section-heading {
  display: flex;
  align-items: center;
  min-height: 58px;
  padding: 14px 16px;
}

.section-title {
  margin: 0;
  color: var(--gold-bright);
  font-size: 21px;
  line-height: 1.15;
}

.section-body {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-top: 1px solid rgba(216, 166, 76, 0.18);
}

.release-section-body { gap: 14px; }

.release-list {
  display: grid;
  gap: 14px;
}

.version-release {
  overflow: hidden;
  border: 1px solid rgba(216, 166, 76, 0.26);
  border-radius: 8px;
  background: rgba(8, 5, 5, 0.42);
}

.version-release.is-latest {
  border-color: rgba(255, 225, 160, 0.54);
  box-shadow: 0 0 0 1px rgba(210, 59, 48, 0.08), 0 12px 28px rgba(0, 0, 0, 0.2);
}

.version-release.is-pending-build {
  border-color: rgba(89, 171, 111, 0.48);
  box-shadow: 0 0 0 1px rgba(89, 171, 111, 0.08), 0 12px 28px rgba(0, 0, 0, 0.18);
}

.version-body {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.download-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  min-height: 142px;
  padding: 20px 24px;
  overflow: hidden;
  border: 1px solid rgba(216, 166, 76, 0.3);
  border-radius: 8px;
  background:
    radial-gradient(circle at 85% 15%, rgba(210, 59, 48, 0.2), transparent 38%),
    linear-gradient(145deg, rgba(56, 17, 14, 0.98), rgba(12, 7, 6, 0.97));
}

.download-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold), #7d3d22);
}

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

.release-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 32px;
  margin: 0;
}

.release-meta div { min-width: 128px; }

.release-meta .release-file-meta {
  flex-basis: 100%;
}

.release-meta dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.release-meta dd {
  margin: 2px 0 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 750;
}

.release-file-meta code {
  overflow-wrap: anywhere;
}

.download-actions {
  display: grid;
  gap: 9px;
  justify-items: stretch;
  min-width: 270px;
}

.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  padding: 12px 18px;
  border: 1px solid rgba(255, 225, 160, 0.72);
  border-radius: 7px;
  color: var(--gold-bright);
  background: linear-gradient(180deg, rgba(116, 26, 20, 0.98), rgba(42, 9, 7, 0.98));
  box-shadow: inset 0 1px 0 rgba(255, 225, 160, 0.16), 0 10px 22px rgba(0, 0, 0, 0.28);
  font-weight: 800;
  text-decoration: none;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.download-button:hover {
  transform: translateY(-1px);
  border-color: var(--gold-bright);
  box-shadow: inset 0 1px 0 rgba(255, 225, 160, 0.2), 0 13px 28px rgba(0, 0, 0, 0.36);
}

.download-button.provider-google-drive {
  border-color: rgba(216, 166, 76, 0.48);
  color: #f0d69c;
  background: linear-gradient(180deg, rgba(70, 39, 24, 0.96), rgba(29, 17, 12, 0.98));
}

.download-button.provider-google-drive:hover {
  border-color: rgba(255, 225, 160, 0.8);
}

.download-mirror-note {
  max-width: 270px;
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
}

.download-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 225, 160, 0.38);
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
}

.download-actions .history-download-note {
  margin: 0;
  max-width: 230px;
  padding: 12px;
  border: 1px solid rgba(216, 166, 76, 0.24);
  border-radius: 7px;
  color: var(--muted);
  background: rgba(12, 8, 7, 0.72);
  font-size: 12px;
}

.runtime-note {
  display: flex;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid rgba(222, 163, 68, 0.38);
  border-radius: 7px;
  color: var(--muted);
  background: rgba(91, 55, 10, 0.24);
  font-size: 12px;
}

.runtime-note strong {
  flex: 0 0 auto;
  color: #ffe0a4;
}

.runtime-link {
  color: #ffe0a4;
  font-weight: 750;
  text-decoration-color: rgba(255, 224, 164, 0.58);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.runtime-link:hover {
  color: var(--gold-bright);
  text-decoration-color: currentColor;
}

code {
  padding: 1px 5px;
  border: 1px solid rgba(216, 166, 76, 0.42);
  border-radius: 4px;
  color: #ffe6ad;
  background: #190908;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.95em;
}

.version-issue-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(216, 166, 76, 0.2);
  border-radius: 8px;
  background: rgba(8, 5, 5, 0.4);
}

.version-issue-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.version-issue-head h4 {
  margin: 0;
  color: var(--gold-bright);
  font-size: 15px;
}

.version-issue-summary {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.issue-list {
  display: grid;
  overflow: hidden;
  border: 1px solid rgba(216, 166, 76, 0.2);
  border-radius: 8px;
  background: rgba(8, 5, 5, 0.4);
}

.issue-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 15px;
  border-bottom: 1px solid rgba(216, 166, 76, 0.13);
}

.issue-row:last-child { border-bottom: 0; }
.issue-row.is-reported { background: linear-gradient(90deg, rgba(134, 42, 31, 0.1), transparent 46%); }
.issue-row.is-fixed { background: linear-gradient(90deg, rgba(49, 116, 64, 0.1), transparent 46%); }
.issue-row.is-pending { background: linear-gradient(90deg, rgba(91, 126, 50, 0.13), transparent 46%); }
.issue-row.is-priority-critical {
  background: linear-gradient(90deg, rgba(174, 32, 22, 0.24), rgba(134, 42, 31, 0.08) 58%, transparent);
  box-shadow: inset 3px 0 0 #ef5b4c;
}

.issue-badges {
  display: grid;
  gap: 6px;
}

.status-badge,
.priority-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 27px;
  padding: 4px 8px;
  border: 1px solid;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.status-reported {
  border-color: rgba(210, 72, 60, 0.62);
  color: #ffc1b7;
  background: rgba(108, 27, 21, 0.32);
}

.status-fixed {
  border-color: rgba(93, 175, 111, 0.54);
  color: #b8edc2;
  background: rgba(40, 105, 56, 0.35);
}

.status-pending {
  border-color: rgba(93, 175, 111, 0.54);
  color: #b8edc2;
  background: rgba(40, 105, 56, 0.35);
}

.priority-critical {
  border-color: rgba(255, 152, 69, 0.78);
  color: #ffe1a0;
  background: rgba(151, 49, 17, 0.6);
  box-shadow: 0 0 0 1px rgba(255, 199, 111, 0.08), 0 0 16px rgba(210, 59, 48, 0.18);
}

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

.issue-copy.has-attachments {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  grid-template-areas:
    "title attachments"
    "detail attachments"
    "meta attachments";
  column-gap: 16px;
  align-items: start;
}

.issue-copy.has-attachments .issue-title { grid-area: title; }
.issue-copy.has-attachments .issue-detail { grid-area: detail; }
.issue-copy.has-attachments .issue-meta { grid-area: meta; }
.issue-copy.has-attachments .issue-attachments { grid-area: attachments; }

.issue-title {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
}

.issue-detail {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.issue-fix {
  margin: 9px 0 0;
  padding: 8px 10px;
  border-left: 2px solid rgba(93, 175, 111, 0.72);
  border-radius: 0 6px 6px 0;
  color: #cfe8d4;
  background: rgba(40, 105, 56, 0.18);
  font-size: 12px;
  line-height: 1.5;
}

.issue-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.issue-attachments {
  display: grid;
  gap: 8px;
  margin-top: 0;
  padding: 10px;
  border: 1px solid rgba(216, 166, 76, 0.2);
  border-radius: 7px;
  background: rgba(6, 4, 4, 0.5);
}

.attachment-heading,
.attachment-subheading {
  margin: 0;
  color: var(--gold-bright);
  font-size: 12px;
  line-height: 1.3;
}

.attachment-subheading {
  padding-top: 2px;
  color: #d8c39f;
}

.savefile-attachment {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(216, 166, 76, 0.2);
  border-radius: 6px;
  background: rgba(31, 13, 10, 0.72);
}

.attachment-copy {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 9px;
  min-width: 0;
  align-items: baseline;
}

.attachment-kind {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.attachment-filename {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
}

.savefile-attachment.is-missing .attachment-filename {
  color: var(--muted);
  font-family: inherit;
  font-style: italic;
}

.attachment-size,
.screenshot-caption {
  color: #9f8f79;
  font-size: 10px;
}

.savefile-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 225, 160, 0.46);
  border-radius: 6px;
  color: var(--gold-bright);
  background: rgba(82, 24, 18, 0.66);
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
}

.savefile-download:hover {
  border-color: var(--gold-bright);
  background: rgba(111, 31, 23, 0.78);
}

.screenshot-gallery {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 150px;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 0 5px;
  overscroll-behavior-inline: contain;
  scroll-snap-type: inline proximity;
  scrollbar-color: rgba(216, 166, 76, 0.45) rgba(8, 5, 5, 0.55);
}

.screenshot-figure {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(216, 166, 76, 0.2);
  border-radius: 6px;
  background: rgba(2, 2, 2, 0.72);
  scroll-snap-align: start;
}

.screenshot-link {
  display: grid;
  place-items: center;
  width: 100%;
  height: 120px;
  overflow: hidden;
  padding: 4px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.025) 25%, transparent 25% 75%, rgba(255, 255, 255, 0.025) 75%),
    #050303;
  background-size: 16px 16px;
}

.issue-screenshot {
  display: block;
  width: 100%;
  height: 120px;
  max-height: 120px;
  object-fit: contain;
}

.screenshot-caption {
  padding: 7px 9px;
  overflow-wrap: anywhere;
  border-top: 1px solid rgba(216, 166, 76, 0.14);
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 7px;
  border: 1px solid rgba(216, 166, 76, 0.24);
  border-radius: 999px;
  color: #bcae98;
  background: rgba(12, 8, 7, 0.68);
  font-size: 10px;
  font-weight: 750;
  line-height: 1.2;
}

.issue-id { color: #e7c27f; }

.version-empty-state,
.noscript-message {
  margin: 0;
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

.version-empty-state {
  border: 1px dashed rgba(216, 166, 76, 0.22);
  border-radius: 7px;
  background: rgba(7, 4, 4, 0.36);
}

.noscript-message {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.download-button:focus-visible,
.language-button:focus-visible,
.runtime-link:focus-visible,
.savefile-download:focus-visible,
.screenshot-link:focus-visible {
  border-color: var(--gold-bright);
  outline: 2px solid rgba(255, 225, 160, 0.22);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  .page-head { min-height: 126px; }
  .portal-main { margin-top: -48px; }

  .hero {
    grid-template-columns: 66px minmax(0, 1fr);
    row-gap: 8px;
    min-height: 112px;
    padding: 14px;
  }

  .hero img {
    width: 58px;
    height: 72px;
  }

  .hero-actions {
    grid-column: 2;
    justify-self: start;
  }

  .download-card {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 20px;
  }

  .download-actions { min-width: 0; }

  .download-mirror-note { max-width: none; }

  .runtime-note {
    display: grid;
    gap: 4px;
  }

  .issue-copy.has-attachments {
    grid-template-columns: 1fr;
    grid-template-areas:
      "title"
      "detail"
      "meta"
      "attachments";
  }

  .issue-copy.has-attachments .issue-attachments {
    margin-top: 10px;
  }
}

@media (max-width: 520px) {
  .section-body { padding: 10px; }

  .version-body { padding: 9px; }

  .issue-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 13px;
  }

  .issue-badges { justify-self: start; }
  .release-meta { gap: 10px 20px; }

  .savefile-attachment {
    grid-template-columns: 1fr;
  }

  .savefile-download {
    width: 100%;
  }
}

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