: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; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
  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%);
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1000;
  padding: 9px 13px;
  border: 2px solid var(--gold-bright);
  border-radius: 6px;
  color: #210605;
  background: var(--gold-bright);
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-160%);
}

.skip-link:focus {
  outline: 3px solid #fff;
  outline-offset: 2px;
  transform: translateY(0);
}

.shell {
  width: min(1080px, calc(100vw - 28px));
  margin: 0 auto;
}

.page-head {
  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);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.download-link {
  white-space: nowrap;
}

html[lang="en"] .nav-label-zh,
html[lang="zh-Hant"] .nav-label-en {
  display: none;
}

.top-link,
.guide-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid rgba(216, 166, 76, 0.68);
  border-radius: 6px;
  color: var(--gold-bright);
  background: linear-gradient(180deg, rgba(92, 19, 16, 0.98), rgba(18, 7, 6, 0.98));
  text-decoration: none;
  font: inherit;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 225, 160, 0.1), 0 8px 18px rgba(0, 0, 0, 0.22);
}

.home-link {
  width: 40px;
  padding: 0;
}

.home-icon {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lang-switch {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  min-width: 104px;
  width: 104px;
  flex: 0 0 auto;
  min-height: 36px;
  padding: 3px;
  border: 1px solid rgba(216, 166, 76, 0.68);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(18, 7, 6, 0.96);
  font: inherit;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 225, 160, 0.1), 0 8px 18px rgba(0, 0, 0, 0.22);
}

.lang-option {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.lang-thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / 2);
  border-radius: 999px;
  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);
  transition: transform 160ms ease;
}

.lang-switch.is-en .lang-thumb {
  transform: translateX(100%);
}

.lang-switch.is-zh .lang-option-zh,
.lang-switch.is-en .lang-option-en {
  color: var(--gold-bright);
}

.top-link:hover,
.top-link:focus-visible,
.lang-switch:hover,
.lang-switch:focus-visible,
.guide-link:hover,
.guide-link:focus-visible {
  border-color: var(--gold-bright);
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

main { padding: 24px 0 58px; }

.lang-panel { display: block; }
.lang-panel[hidden] { display: none !important; }
html:not(.language-ready) .lang-panel[data-lang-panel="zh"] { display: none; }

.hero {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(52, 15, 13, 0.92), rgba(13, 8, 7, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 225, 160, 0.06), 0 12px 26px rgba(0, 0, 0, 0.2);
}

.hero img {
  width: 76px;
  height: 90px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.48));
}

.kicker {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  color: var(--gold-bright);
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.08;
  text-shadow: 0 2px 0 rgba(50, 5, 3, 0.9), 0 0 18px rgba(210, 59, 48, 0.32);
}

h2 {
  margin: 0 0 10px;
  color: var(--gold-bright);
  font-size: 21px;
  line-height: 1.2;
}

p { margin: 0; }

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;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 12px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: inset 0 1px 0 rgba(255, 225, 160, 0.05), 0 10px 24px rgba(0, 0, 0, 0.18);
}

.panel { padding: 14px; }

.points {
  margin: 0;
  padding-left: 20px;
}

.points li { margin: 4px 0; }

.sequence {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

.move {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid rgba(216, 166, 76, 0.42);
  border-radius: 999px;
  color: var(--gold-bright);
  background: rgba(35, 9, 8, 0.88);
  font-size: 13px;
  line-height: 1.2;
}

.move::before {
  content: "";
  width: 17px;
  height: 17px;
  margin-right: 6px;
  background: center / contain no-repeat;
  image-rendering: pixelated;
}

.move.guard::before { background-image: url("assets/ui/icons/guard.png"); }
.move.wait::before { background-image: url("assets/ui/icons/wait.png"); }
.move.strike::before { background-image: url("assets/ui/icons/strike.png"); }
.move.fire::before {
  width: 40px;
  background-image: url("assets/ui/icons/blaze-palm.png"), url("assets/ui/icons/fire.png");
  background-position: left center, right center;
  background-size: 17px 17px, 17px 17px;
}
.move.grab::before { background-image: url("assets/ui/icons/grab.png"); }
.move.flee::before { display: none; }
.move.text::before { display: none; }
.move.bad { color: #ffb1a7; border-color: rgba(210, 59, 48, 0.62); }
.move.ok { color: #dff0b5; border-color: rgba(196, 222, 126, 0.5); }

table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid rgba(210, 143, 65, 0.28);
  vertical-align: top;
  text-align: left;
}

th {
  color: var(--gold-bright);
  background: linear-gradient(180deg, rgba(92, 19, 16, 0.98), rgba(42, 9, 7, 0.98));
}

tr:last-child td { border-bottom: 0; }

.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
}

.counter-table td:first-child {
  width: 30%;
  color: var(--gold-bright);
  font-weight: 700;
}

.counter-table td:nth-child(2) {
  width: 24%;
}

.queen-counter-table td:first-child {
  width: 10%;
}

.queen-counter-table td:nth-child(2) {
  width: 36%;
}

.queen-counter-table td:nth-child(3) {
  width: 38%;
  min-width: 300px;
}

.queen-counter-table td:nth-child(4) {
  width: 16%;
}

.move-name {
  display: block;
  color: var(--text);
  font-weight: 700;
}

.move-visual {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 310px;
}

.ready-cg {
  display: block;
  width: 132px;
  height: 101px;
  object-fit: cover;
  object-position: center;
  border: 1px solid rgba(216, 166, 76, 0.38);
  border-radius: 6px;
  background: #100605;
  box-shadow: inset 0 0 0 1px rgba(255, 225, 160, 0.04), 0 8px 16px rgba(0, 0, 0, 0.22);
}

.move-copy {
  min-width: 0;
}

.move-cue {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
}

.counter-table .move {
  margin: 2px 4px 2px 0;
}

.call-chain {
  display: flex;
  align-items: center;
  gap: 3px;
  max-width: 100%;
  margin-top: 6px;
  padding: 1px 0 3px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.call-chain-cg {
  flex: 0 0 auto;
  width: 54px;
  height: 41px;
  object-fit: cover;
  object-position: center;
  border: 1px solid rgba(216, 166, 76, 0.34);
  border-radius: 5px;
  background: #100605;
  box-shadow: inset 0 0 0 1px rgba(255, 225, 160, 0.04), 0 6px 12px rgba(0, 0, 0, 0.22);
}

.call-chain-arrow {
  flex: 0 0 auto;
  color: var(--gold-bright);
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  opacity: 0.78;
}

.counter-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 620px) {
  .hero {
    grid-template-columns: 72px minmax(0, 1fr);
    padding: 12px;
  }

  .hero img {
    width: 62px;
    height: 76px;
  }

  .topbar {
    align-items: center;
    flex-direction: row;
  }

  .topbar-actions { gap: 7px; }

  .download-link {
    min-height: 34px;
    padding: 7px 9px;
    font-size: 13px;
  }

  .move-visual {
    grid-template-columns: 112px minmax(0, 1fr);
    min-width: 270px;
  }

  .ready-cg {
    width: 112px;
    height: 86px;
  }

  .call-chain-cg {
    width: 50px;
    height: 38px;
  }

  .call-chain-arrow {
    font-size: 14px;
  }
}

@media (max-width: 420px) {
  .topbar { gap: 8px; }
  .topbar-actions { min-width: 0; }

  .download-link {
    max-width: 112px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .lang-switch {
    min-width: 92px;
    width: 92px;
  }
}

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