/* the landing page (index.html); the game's own styles are in style.css */
:root {
  --paper: #f3e7cf;
  --ink: #2a2118;
  --ink-soft: #5b4a38;
  --cinnabar: #b3261e;
  --cinnabar-dark: #7e1812;
  --jade: #7fe0c4;       /* the beam over the gate home */
  --crimson: #ff5a4a;    /* the beam over the gate deeper */
  --lantern: #ffb070;
  --moon: #c9d5ea;
  --night: #1d2633;      /* the maze sky; landing.js reddens it as the level goes down */
  --serif: 'Noto Serif TC', 'Songti TC', 'PMingLiU', Georgia, serif;
  --brush: 'LXGW WenKai TC', 'DFKai-SB', 'BiauKai', 'KaiTi', var(--serif);
  --edge: clamp(20px, 5vw, 72px);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--serif); font-size: 18px; line-height: 1.65; }
img, svg { display: block; max-width: 100%; }
h1, h2, p, figure, blockquote, dl, ul { margin: 0; padding: 0; }
h2 { font-size: clamp(30px, 4.2vw, 50px); line-height: 1.15; font-weight: 700; letter-spacing: -0.015em; text-wrap: balance; }
html[lang='zh-Hant'] h2 { font-family: var(--brush); font-weight: 400; letter-spacing: 0.04em; line-height: 1.3; }
p { text-wrap: pretty; max-width: 58ch; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 var(--edge); }
:focus-visible { outline: 3px solid var(--lantern); outline-offset: 3px; }

.btn {
  display: inline-block; padding: 15px 34px; font-size: 20px; font-weight: 600; line-height: 1.2; text-decoration: none;
  color: #fff3e6; background: linear-gradient(var(--cinnabar), var(--cinnabar-dark)); border-radius: 3px;
  box-shadow: 0 3px 0 #4f0e0a, 0 8px 18px rgba(60, 15, 5, 0.3); transition: transform 0.12s, box-shadow 0.12s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 0 #4f0e0a, 0 12px 22px rgba(60, 15, 5, 0.35); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #4f0e0a; }
.btn.small { padding: 10px 20px; font-size: 16px; }

/* ---------- top bar ---------- */
.top { position: absolute; z-index: 2; inset: 0 0 auto; display: flex; justify-content: space-between; align-items: flex-start; padding: 20px var(--edge); }
/* a name seal, read like one: right column first, top to bottom */
.seal {
  display: grid; grid-template: repeat(2, 1fr) / repeat(2, 1fr); grid-auto-flow: column; direction: rtl; padding: 5px;
  width: 58px; height: 58px; background: var(--cinnabar); border-radius: 4px; box-shadow: inset 0 0 0 2px var(--cinnabar), inset 0 0 0 3px rgba(255, 230, 210, 0.6);
  color: #fbe9d7; font-family: var(--brush); font-size: 21px; line-height: 1; text-decoration: none;
}
.seal span { display: grid; place-items: center; }
.top nav { display: flex; gap: 10px; align-items: center; }
.lang-btn { font: inherit; font-size: 16px; line-height: 1.2; padding: 10px 14px; min-height: 40px; color: var(--ink); background: none; border: 0; border-radius: 3px; cursor: pointer; }
.top-link, .lang-btn, .top .btn { white-space: nowrap; }
.top-link { padding: 10px 14px; font-size: 16px; line-height: 1.2; color: var(--ink); text-decoration: none; }
.lang-btn:hover, .top-link:hover { text-decoration: underline; text-underline-offset: 4px; }

/* ---------- hero: the town under its own sky ---------- */
.hero { position: relative; min-height: min(100svh, 1100px); overflow: hidden; background: #b9c2be; }
.hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 100%; }
.hero-text { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; padding: clamp(84px, 11svh, 130px) var(--edge) 0; }
.hero h1 { font-size: clamp(46px, 7.4vw, 108px); line-height: 1; font-weight: 700; letter-spacing: -0.03em; text-wrap: balance; }
html[lang='zh-Hant'] .hero h1 { font-family: var(--brush); font-weight: 400; letter-spacing: 0.12em; margin-right: -0.12em; }
.hero p { margin: clamp(14px, 2.4svh, 24px) 0 clamp(18px, 3svh, 30px); max-width: 46ch; font-size: clamp(17px, 1.5vw, 21px); line-height: 1.5; text-wrap: balance; }
.hero .note { margin: 18px 0 0; font-size: 15px; color: #463829; }

/* ---------- the maze ---------- */
.maze, .fight { background: var(--night); color: var(--moon); transition: background-color 0.8s; }
.maze { padding: clamp(72px, 11vw, 150px) 0 clamp(56px, 8vw, 110px); }
.maze h2, .fight h2 { color: #f4f1ea; }
.maze-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: clamp(36px, 6vw, 96px); align-items: center; }
.maze-text p { margin-top: 22px; }
.gates { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 34px; align-items: center; }
.gates button { font: inherit; font-size: 17px; line-height: 1.2; min-height: 48px; padding: 10px 22px; border-radius: 3px; cursor: pointer; }
.gate { color: #14100e; border: 0; font-weight: 600 !important; }
.gate.deeper { background: var(--crimson); }
.gate.home { background: var(--jade); }
.gate:hover { filter: brightness(1.12); }
.plain { color: var(--moon); background: none; border: 1px solid rgba(201, 213, 234, 0.4); }
.plain:hover, .plain[aria-pressed='true'] { border-color: var(--lantern); color: var(--lantern); }

.plan svg { width: 100%; height: auto; aspect-ratio: 1; overflow: visible; }
.plan .lit { animation: lantern 1.1s cubic-bezier(0.2, 0.7, 0.3, 1) both; }
/* the map opens outward from where you stand, as lantern light would */
@keyframes lantern { from { clip-path: circle(0 at var(--x) var(--y)); } to { clip-path: circle(150% at var(--x) var(--y)); } }
.plan .floor { fill: rgba(8, 11, 17, 0.5); }
.plan .walls { fill: none; stroke: var(--moon); stroke-linecap: square; }
.plan .way { fill: none; stroke: var(--lantern); stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 0.1 0.36; visibility: hidden; }
.plan .way.on { visibility: visible; }
.plan .home { fill: var(--jade); }
.plan .deeper { fill: var(--crimson); }
.plan .halo { opacity: 0.22; }
.plan .you { fill: var(--lantern); }
.plan .robe { fill: #e8c15a; }
.plan .hat { fill: var(--cinnabar); }
figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 28px; margin-top: 22px; font-size: 16px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 20px; list-style: none; }
.legend li { display: flex; align-items: center; gap: 8px; }
.k { width: 11px; height: 11px; border-radius: 50%; }
.k.start { background: var(--lantern); }
.k.home { background: var(--jade); }
.k.deeper { background: var(--crimson); }
.k.jiangshi { background: linear-gradient(#d8443a 45%, #e8c15a 45%); border-radius: 2px; width: 8px; height: 13px; }

/* ---------- combat ---------- */
.fight { padding-bottom: clamp(80px, 11vw, 150px); }
.strikes { display: grid; grid-template-columns: 2fr 3fr; gap: 10px; }
.strikes img { width: 100%; height: clamp(230px, 38vw, 500px); object-fit: cover; border-radius: 3px; }
.strikes .cut { object-position: 58% 38%; }
.strikes .burst { object-position: 55% 36%; }
.fight-text { display: grid; grid-template-columns: 1fr 1fr; gap: 20px clamp(36px, 6vw, 96px); margin-top: clamp(32px, 4vw, 54px); }
.fight-text h2 { grid-row: span 2; }

/* ---------- the town ---------- */
.town { padding: clamp(72px, 10vw, 140px) 0; }
.lead { margin-top: 22px; font-size: clamp(18px, 1.6vw, 21px); max-width: 62ch; }
.folk { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px clamp(28px, 4vw, 60px); margin: clamp(40px, 5vw, 68px) 0; }
.folk p { font-size: clamp(20px, 1.9vw, 25px); line-height: 1.45; }
html[lang='en'] .folk p::before { content: '“'; margin-left: -0.45em; }
html[lang='en'] .folk p::after { content: '”'; }
html[lang='zh-Hant'] .folk p { font-family: var(--brush); }
html[lang='zh-Hant'] .folk p::before { content: '「'; margin-left: -1em; }
html[lang='zh-Hant'] .folk p::after { content: '」'; }
.folk footer { margin-top: 10px; color: var(--cinnabar); font-weight: 600; font-size: 16px; }
.loot { display: grid; grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); gap: 22px clamp(24px, 3vw, 44px); list-style: none; border-top: 1px solid rgba(90, 60, 30, 0.3); padding-top: clamp(32px, 4vw, 48px); }
.loot li { display: grid; grid-template: auto 1fr / 52px 1fr; gap: 0 16px; align-items: start; font-size: 16px; line-height: 1.5; color: var(--ink-soft); }
.loot .tile { grid-row: span 2; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 3px; color: #fff3e6; font: 30px/1 var(--brush); }
.loot b { color: var(--ink); font-size: 18px; }

/* ---------- land: the panel is paper laid over the field ---------- */
.land { position: relative; background: #8f9645; }
.land > img { width: 100%; height: clamp(560px, 64vw, 900px); object-fit: cover; object-position: 100% 60%; }
.land-panel {
  position: absolute; left: var(--edge); bottom: clamp(24px, 5vw, 72px); width: min(470px, calc(100% - 2 * var(--edge))); padding: clamp(26px, 3vw, 42px);
  background: var(--paper); border-top: 12px solid #5a3a22; border-bottom: 12px solid #5a3a22; border-radius: 4px; box-shadow: 0 20px 50px rgba(30, 25, 5, 0.4);
}
.land-panel h2 { font-size: clamp(28px, 3vw, 38px); }
.land-panel p { margin-top: 14px; font-size: 17px; line-height: 1.6; }
.land-panel dl { margin-top: 20px; display: grid; gap: 8px; }
.land-panel dl div { display: flex; justify-content: space-between; gap: 16px; border-top: 1px solid rgba(90, 60, 30, 0.28); padding-top: 8px; font-size: 16px; }
.land-panel dt { font-weight: 700; }
.land-panel dd { margin: 0; color: var(--ink-soft); text-align: right; }

/* ---------- controls ---------- */
.controls { padding: clamp(72px, 10vw, 130px) 0; }
.scroll-x { overflow-x: auto; margin-top: 34px; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 17px; line-height: 1.45; }
th, td { padding: 13px 24px 13px 0; vertical-align: top; }
thead th { color: var(--cinnabar); font-weight: 600; }
tbody tr { border-top: 1px solid rgba(90, 60, 30, 0.28); }
tbody th { font-weight: 600; }

/* ---------- what's new ---------- */
.news { scroll-margin-top: 48px; padding-bottom: clamp(72px, 10vw, 130px); }
.news article { display: grid; grid-template-columns: minmax(150px, 1fr) 3fr; gap: 8px clamp(24px, 4vw, 60px); margin-top: 34px; padding-top: 28px; border-top: 1px solid rgba(90, 60, 30, 0.3); }
.news time { color: var(--cinnabar); font-weight: 600; font-size: 16px; line-height: 30px; }
.news h3 { margin: 0; font-size: clamp(21px, 2vw, 25px); line-height: 30px; }
.news h4 { margin: 24px 0 0; font-size: 17px; }
.news ul { margin-top: 12px; padding-left: 1.15em; max-width: 68ch; }
.news li { margin-top: 7px; line-height: 1.55; }
.news li::marker { color: var(--cinnabar); }

/* ---------- the way in ---------- */
.last { background: #1d2633; color: #f4f1ea; text-align: center; padding: clamp(84px, 12vw, 160px) var(--edge); }
.last h2 { margin: 0 auto 36px; max-width: 26ch; }
html[lang='zh-Hant'] .last h2 { max-width: none; }

@media (max-width: 1100px) {
  .land > img { height: auto; aspect-ratio: 3 / 2; object-position: 60% 50%; }
  .land-panel { position: relative; left: auto; bottom: auto; width: auto; margin: -40px var(--edge) 0; transform: translateY(40px); }
  .controls { padding-top: 120px; }
}
@media (max-width: 860px) {
  body { font-size: 17px; }
  .maze-grid, .fight-text, .folk, .news article { grid-template-columns: minmax(0, 1fr); }
  .fight-text h2 { grid-row: auto; }
  .strikes { grid-template-columns: 1fr; }
  .strikes img { height: auto; aspect-ratio: 4 / 3; }
  th, td { padding-right: 16px; }
}
@media (max-width: 520px) {
  .land > img { aspect-ratio: 5 / 4; }
  .top nav { gap: 0; }
  .top-link, .lang-btn { padding: 10px 9px; }
  .top .btn { margin-left: 8px; padding: 10px 14px; }
  .hero .note { font-size: 14px; margin-top: 14px; text-wrap: wrap; }
  .loot { grid-template-columns: 1fr; }
  html[lang='zh-Hant'] .folk p::before { margin-left: 0; }
  table { font-size: 15px; }
}
@media (max-width: 360px) {
  .top-link, .lang-btn { padding: 10px 5px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .plan .lit { animation: none; }
  .btn, .maze, .fight { transition: none; }
}
