/* The game's own look, in CSS.
   Colors come from DESIGN.md (mirrored in tools/ui/pix.py PAL); every frame, bar, slot and key cap
   is a 9-slice of the kit PNG in promo/kit/ (tools/promo/site_kit.py copies it at 2x).
   Type is the game's two bitmap fonts from fonts.css. One font pixel is 1/16 em, so font sizes and
   line heights stay multiples of 16px (24px only where the device pixel ratio is 2 or more). */

:root {
  --lacquer-900: #0f1320;
  --lacquer-800: #161c2e;
  --lacquer-700: #1f2740;
  --lacquer-600: #2a3452;
  --bronze-900: #3a2a17;
  --bronze-700: #6b4f2a;
  --bronze-500: #a07a3c;
  --bronze-300: #d4ae62;
  --bronze-100: #f0d894;
  --paper-700: #9c8358;
  --paper-500: #c6ae80;
  --paper-300: #e0cfa6;
  --paper-100: #f1e6c8;
  --ink: #2b2118;
  --seal-700: #6e1f1c;
  --seal-500: #a3302a;
  --seal-300: #d0493b;
  --jade-700: #1f5a4c;
  --jade-500: #2d7a68;
  --jade-300: #5fc4a0;
  --jade-100: #a8e6cf;
  --text-1: #efe6cf;
  --text-2: #b8ad94;
  --text-3: #7d7563;
  --grade-pham: #c9c2b0;
  --grade-ha: #6fc28b;
  --grade-trung: #5a9ae0;
  --grade-thuong: #b07ad8;
  --grade-cuc: #ff4b3e;

  --body: "CuuThien Body", system-ui, sans-serif;
  --title: "CuuThien Title", system-ui, sans-serif;

  /* Sizes in whole font pixels: body 16px is 1x, 32px is 2x, title 48px is 3x. */
  --fs: 32px;
  --lh: 48px;
  --fs-sm: 16px;
  --lh-sm: 24px;
  --fs-h2: 48px;
  --lh-h2: 57px;
  --fs-h3: 32px;
  --lh-h3: 38px;
  --gap: 24px;
  --pad: 24px;
  /* Height of the sticky header, so a jumped-to section clears it. */
  --head: 132px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

.hero, .sec { scroll-margin-top: calc(var(--head) + 16px); }

body {
  margin: 0;
  overflow-x: clip;
  color: var(--text-1);
  font-family: var(--body);
  font-size: var(--fs);
  line-height: var(--lh);
  font-weight: 400;
  font-synthesis: none;
  -webkit-font-smoothing: none;
  background:
    radial-gradient(circle, rgba(212, 174, 98, .05) 1px, transparent 1.5px) 0 0 / 8px 8px,
    linear-gradient(180deg, var(--lacquer-900), #0b0f1a 60%, var(--lacquer-900));
  background-attachment: fixed, scroll;
}

img { image-rendering: pixelated; max-width: 100%; }
a { color: var(--jade-100); }
:focus-visible { outline: 3px solid var(--jade-300); outline-offset: 2px; }

/* The language switch rewrites text after load; keep the page hidden for that one frame. */
html.i18n-wait body { visibility: hidden; }

h1, h2, h3 { margin: 0; font-family: var(--title); font-weight: 400; }
h2 { font-size: var(--fs-h2); line-height: var(--lh-h2); color: var(--bronze-100); }
h3 { font-size: var(--fs-h3); line-height: var(--lh-h3); color: var(--bronze-300); }
p { margin: 0; }
strong { color: var(--bronze-100); font-weight: 400; }
em { color: var(--paper-100); font-style: normal; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 var(--pad); }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: var(--pad); top: var(--pad); z-index: 90; padding: 8px 12px; background: var(--paper-100); color: var(--ink); }

/* --- Kit frames --------------------------------------------------------- */

.card {
  position: relative;
  border-style: solid;
  border-width: 40px 50px;
  border-image: url(kit/panel.png) 40 50 40 50 stretch;
  background: var(--lacquer-800);
  image-rendering: pixelated;
  min-height: 180px;
}

.sheet {
  border-style: solid;
  border-width: 16px;
  border-image: url(kit/paper.png) 16 repeat;
  color: var(--ink);
  image-rendering: pixelated;
}

.plate {
  display: inline-block;
  border-style: solid;
  border-width: 24px 30px 10px;
  border-image: url(kit/plaque.png) 24 30 10 30 fill stretch;
  color: var(--bronze-100);
  font-family: var(--body);
  font-size: 32px;
  line-height: 38px;
  text-align: center;
  image-rendering: pixelated;
}

.seal {
  display: inline-block;
  width: 32px; height: 32px;
  background: url(kit/seal.png) 0 0 / 32px 32px;
  image-rendering: pixelated;
}

.rule {
  display: block;
  height: 10px;
  background: url(kit/divider.png) repeat-x 0 0 / 48px 10px;
  image-rendering: pixelated;
}

.btn {
  display: inline-block;
  border-style: solid;
  border-width: 8px;
  border-image: url(kit/button.png) 8 stretch;
  background: transparent;
  color: var(--text-1);
  font-family: var(--body);
  font-size: var(--fs);
  line-height: 32px;
  padding: 0;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  image-rendering: pixelated;
}
.btn:hover, .btn:focus-visible { border-image-source: url(kit/button_hover.png); }
.btn.primary { color: var(--bronze-100); }

/* A tu vi bar over the realm ladder: the frame is the kit's, the fill is a strip inside it. */
.bar {
  position: relative;
  border-style: solid;
  border-width: 4px;
  border-image: url(kit/bar_frame.png) 4 stretch;
  background: var(--lacquer-900);
  image-rendering: pixelated;
}
.bar i {
  position: absolute;
  inset: 4px;
  background: url(kit/bar_fill_tuvi.png) repeat 0 0 / 16px 8px;
  image-rendering: pixelated;
}
.bar i::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url(kit/sparkle.png) repeat-x 0 0 / 64px 16px;
  animation: shimmer 3s linear infinite;
}
@keyframes shimmer { to { background-position: 64px 0; } }

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

.head {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 12px var(--pad);
  background: rgba(15, 19, 32, .92);
  border-bottom: 2px solid var(--bronze-700);
  backdrop-filter: blur(2px);
}
.head-row { display: flex; align-items: center; gap: 16px; }
.head .brand { display: flex; align-items: center; text-decoration: none; }
.head .brand img { height: 32px; width: auto; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.nav a {
  padding: 0 8px;
  color: var(--text-2);
  font-size: var(--fs);
  line-height: var(--lh);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.nav a:hover, .nav a:focus-visible { color: var(--bronze-100); border-bottom-color: var(--bronze-500); }
.lang { display: flex; margin-left: auto; border: 2px solid var(--bronze-700); }
.lang button {
  font: inherit;
  font-size: var(--fs);
  line-height: var(--lh);
  padding: 0 8px;
  color: var(--text-2);
  background: transparent;
  border: 0;
  cursor: pointer;
}
.lang button + button { border-left: 2px solid var(--bronze-700); }
.lang button[aria-pressed="true"] { color: var(--ink); background: var(--bronze-300); }
.nav-toggle { display: none; }

@media (max-width: 1080px) {
  :root { --head: 78px; }
  .head .nav {
    position: absolute;
    left: 0; right: 0; top: 100%;
    flex-direction: column;
    gap: 0;
    margin: 0;
    padding: 4px var(--pad) 12px;
    background: rgba(15, 19, 32, .97);
    border-bottom: 2px solid var(--bronze-700);
  }
  .head .nav[hidden] { display: none; }
  .head .nav a { padding: 8px 0; }
  .nav-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    font: inherit;
    font-size: var(--fs);
    line-height: var(--lh);
    color: var(--bronze-100);
    background: var(--lacquer-700);
    border: 2px solid var(--bronze-700);
    cursor: pointer;
  }
  .nav-toggle::after { content: ""; width: 9px; height: 9px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translate(-2px, -2px); }
  .head-row .btn { display: none; }
}

/* --- Hero --------------------------------------------------------------- */

.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100svh;
  padding: 96px 20px 72px;
  overflow: hidden;
  text-align: center;
  background: var(--lacquer-800);
}
.hero-art { position: absolute; inset: 0; }
.hero-art img {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: 50% 100%;
}
.hero > * { position: relative; z-index: 1; }
.hero-art, .hero-fade { z-index: 0; }
.hero h1 { margin: 0; }
.hero .logo { display: block; width: min(720px, 92vw); height: auto; }
.hero .tagline {
  margin-top: 24px;
  font-family: var(--title);
  font-size: var(--fs-h3);
  line-height: var(--lh-h3);
  color: var(--bronze-300);
}
.hero .tagline span { display: block; }
.hero .lead {
  max-width: 720px;
  margin-top: var(--gap);
  color: var(--paper-100);
  text-shadow: 2px 2px 0 rgba(15, 19, 32, .8);
}
.hero .plays, .play-card .plays { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--gap); }
.hero .plays { margin-top: 32px; }
.hero .plays .btn { padding: 0 8px; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 32px; padding: 0; list-style: none; }
.chips li {
  padding: 4px 12px;
  color: var(--text-1);
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
  background: rgba(31, 39, 64, .85);
  border: 2px solid var(--bronze-700);
}
.hero-fade { position: absolute; inset: auto 0 0; height: 96px; background: linear-gradient(180deg, transparent, var(--lacquer-900)); }

/* --- Sections ----------------------------------------------------------- */

main { display: block; }
.sec { padding: 72px 0; }
.sec + .sec { border-top: 2px solid rgba(107, 79, 42, .35); }
.sec-head { margin-bottom: 40px; }
.sec-head .plate { margin-bottom: 16px; }
.sec-head h2 { margin-bottom: 8px; }
.sec-head .rule { margin: 16px 0; }
.sec-head .lead { max-width: 760px; color: var(--paper-300); }
.grid { display: grid; gap: var(--gap); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card > * + * { margin-top: 16px; }
.card p { color: var(--paper-300); }
.card h3 { margin-bottom: 8px; }
.card ul { margin: 0; padding-left: 24px; color: var(--paper-300); }
.card li + li { margin-top: 8px; }
.step { display: flex; gap: 16px; align-items: flex-start; }
.step .seal { flex: none; }
.step b { display: block; font-family: var(--title); color: var(--bronze-100); font-size: var(--fs-h3); line-height: var(--lh-h3); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.stats li { padding: 12px 16px; background: var(--lacquer-700); border: 2px solid var(--bronze-700); }
.stats b { display: block; font-family: var(--title); font-size: var(--fs-h3); line-height: var(--lh-h3); color: var(--bronze-100); }
.stats span { color: var(--text-2); font-size: var(--fs-sm); line-height: var(--lh-sm); }

.ladder { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; padding: 0; list-style: none; }
.ladder li {
  padding: 4px 10px;
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
  color: var(--text-2);
  background: var(--lacquer-900);
  border: 2px solid var(--lacquer-600);
}
.ladder li.on { color: var(--ink); background: var(--bronze-300); border-color: var(--bronze-100); }
.bar-wrap { position: relative; margin-top: 8px; }
.bar-wrap .bar { height: 32px; }
.bar-wrap .bar-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
  color: var(--text-2);
}

.roots { display: flex; flex-wrap: wrap; gap: 16px; margin: 16px 0 0; padding: 0; list-style: none; }
.roots li { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 88px; }
.roots .slot { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; background: url(kit/slot.png) 0 0 / 40px 40px; image-rendering: pixelated; }
.roots img { width: 24px; height: 24px; }
.roots span { font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--text-2); text-align: center; }
.roots .hon .slot { background: none; border: 2px solid var(--bronze-300); color: var(--bronze-100); font-family: var(--title); }

.grades { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0 0; padding: 0; list-style: none; }
.grades li { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); line-height: var(--lh-sm); }
.grades i { width: 16px; height: 16px; border: 2px solid var(--bronze-900); }

/* Boss cards: the sprite on the lacquer, the name on the kit's boss plate. */
.boss { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.boss img { height: 96px; width: auto; }
.boss .boss_plate {
  border-style: solid;
  border-width: 8px;
  border-image: url(kit/boss_plate.png) 8 stretch;
  padding: 0 4px;
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
  color: var(--bronze-100);
  text-align: center;
  image-rendering: pixelated;
}

/* Full-bleed screenshot band with a caption plate over it. */
.band { position: relative; margin: 0; }
.band img { display: block; width: 100%; height: 46vw; max-height: 520px; min-height: 260px; object-fit: cover; }
.band figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 40px 0 24px;
  background: linear-gradient(180deg, transparent, rgba(11, 15, 26, .95) 60%);
}
.band figcaption .wrap { max-width: 1120px; }
.band figcaption p { max-width: 760px; color: var(--paper-100); }

.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: var(--gap); }
.shots figure { margin: 0; }
.shots img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border: 2px solid var(--bronze-700); }
.shots figcaption { margin-top: 8px; color: var(--text-2); font-size: var(--fs-sm); line-height: var(--lh-sm); }

.keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 12px 24px; margin: 0; padding: 0; list-style: none; }
.keys li { display: flex; align-items: center; gap: 12px; }
.key {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-width: 34px;
  height: 42px;
  padding: 0 4px;
  border-style: solid;
  border-width: 6px 8px 10px;
  border-image: url(kit/keycap.png) 6 8 10 8 stretch;
  color: var(--bronze-100);
  font-family: var(--body);
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
  image-rendering: pixelated;
}
.keys span { color: var(--paper-300); font-size: var(--fs-sm); line-height: var(--lh-sm); }
.hotbar { display: block; margin: 0 auto; width: 240px; height: 56px; }

.faq details { margin-top: 16px; }
.faq summary {
  cursor: pointer;
  font-family: var(--title);
  font-size: var(--fs-h3);
  line-height: var(--lh-h3);
  color: var(--ink);
}
.faq summary::marker { color: var(--seal-500); }
.faq p { margin-top: 12px; }

.play-card { display: grid; gap: var(--gap); align-items: center; justify-items: center; text-align: center; }
.store {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--gap);
  margin: 0;
  padding: 0;
  list-style: none;
}
.store li { color: var(--text-2); font-size: var(--fs-sm); line-height: var(--lh-sm); }
.note { color: var(--text-3); font-size: var(--fs-sm); line-height: var(--lh-sm); }

footer {
  padding: 40px 0 64px;
  border-top: 2px solid var(--bronze-700);
  color: var(--text-3);
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
}
footer .wrap { display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: center; }
footer .links { display: flex; flex-wrap: wrap; gap: 16px; }
footer a { color: var(--jade-100); }

/* --- Reveal on scroll --------------------------------------------------- */

.js .reveal { opacity: 0; transform: translateY(16px); transition: opacity .5s ease-out, transform .5s ease-out; }
.js .reveal.on { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .bar i::after { animation: none; }
  .hero-art img { transform: none !important; }
}

/* --- Narrow screens ----------------------------------------------------- */

@media (max-width: 900px) {
  :root {
    --fs: 16px;
    --lh: 24px;
    --fs-h2: 32px;
    --lh-h2: 38px;
    --fs-h3: 16px;
    --lh-h3: 24px;
    --gap: 16px;
    --pad: 16px;
    --head: 54px;
  }
  .grid.two, .grid.three { grid-template-columns: minmax(0, 1fr); }
  .head .brand img { height: 24px; }
  .hero { padding-top: 72px; }
  .hero .tagline { margin-top: 16px; }
  .hero .plays { flex-direction: column; }
  .plays .btn { display: block; width: 100%; }
  .band img { height: 60vw; }
  .band figcaption { position: static; padding: 16px 0; background: var(--lacquer-800); }
  .sec { padding: 48px 0; }
  .sec-head { margin-bottom: 24px; }
  .roots li { width: 72px; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(min(132px, 100%), 1fr)); }
  .hero { min-height: 0; }
}
