:root {
  color-scheme: light;
  --paper: #f7f2ea;
  --ink: #163239;
  --muted: #5c7074;
  --line: rgba(22, 50, 57, 0.16);
  --panel: rgba(255, 255, 255, 0.78);
  --green: #14786f;
  --coral: #e76643;
  --gold: #c79a31;
  --blue: #426f9f;
  --danger: #b84531;
  --shadow: 0 18px 42px rgba(22, 50, 57, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background:
    linear-gradient(90deg, rgba(22, 50, 57, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(22, 50, 57, 0.04) 1px, transparent 1px),
    var(--paper);
  background-size: 42px 42px, 42px 42px, auto;
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
}

button {
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  padding: 0.65rem 0.85rem;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

button:hover {
  border-color: rgba(20, 120, 111, 0.4);
  box-shadow: 0 8px 18px rgba(20, 120, 111, 0.12);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

input,
select,
textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  padding: 0.7rem 0.75rem;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(20, 120, 111, 0.14);
}

textarea {
  resize: vertical;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.9rem min(4vw, 2rem);
  background: rgba(247, 242, 234, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--ink);
  font-weight: 800;
  font-size: 1.15rem;
  text-decoration: none;
}

nav {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
}

nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
}

nav a:hover {
  background: rgba(20, 120, 111, 0.1);
  color: var(--ink);
}

.language {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.language select {
  width: auto;
  min-width: 7rem;
  padding: 0.45rem 0.55rem;
}

main {
  display: grid;
  gap: 3rem;
}

.hero {
  position: relative;
  min-height: 72vh;
  display: grid;
  align-items: end;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}

.hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.86) contrast(0.92);
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(247, 242, 234, 0.96), rgba(247, 242, 234, 0.55), rgba(247, 242, 234, 0.18));
}

.hero-copy {
  position: relative;
  z-index: 1;
  width: min(760px, 92vw);
  padding: 0 min(4vw, 2rem) 4rem;
}

.eyebrow {
  margin: 0 0 0.7rem;
  color: var(--green);
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.7rem;
  font-size: clamp(3rem, 9vw, 6.5rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 0.7rem;
  font-size: 1.65rem;
}

.hero-copy p:last-child {
  max-width: 34rem;
  font-size: 1.15rem;
  line-height: 1.75;
  color: #24464c;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.25rem;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.65rem;
  padding: 0.65rem 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 10px 22px rgba(22, 50, 57, 0.1);
}

.link-button.primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.section {
  width: min(1160px, 92vw);
  margin: 0 auto;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: end;
  margin-bottom: 1rem;
}

.section-head p {
  max-width: 42rem;
  color: var(--muted);
  line-height: 1.7;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
}

.stats article,
.composer,
.feed,
.game-section,
.spark {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stats article {
  padding: 1rem;
  display: grid;
  gap: 0.35rem;
}

.stats strong {
  color: var(--green);
}

.stats span {
  color: var(--muted);
  line-height: 1.55;
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(280px, 370px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.composer,
.feed,
.game-section,
.spark {
  padding: 1rem;
}

.composer {
  position: sticky;
  top: 5.25rem;
  display: grid;
  gap: 0.8rem;
}

.composer label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
}

.button-row,
.feed-tools,
.game-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.primary {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.status-line,
.summary {
  min-height: 1.2rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-line.error {
  color: var(--danger);
}

.status-line.success {
  color: var(--green);
}

.feed {
  display: grid;
  gap: 0.8rem;
}

.feed-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(9rem, auto);
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.segmented button {
  padding: 0.45rem 0.7rem;
}

.segmented button.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.utility button {
  border-style: dashed;
}

.post-list {
  display: grid;
  gap: 0.75rem;
}

.post-card {
  display: grid;
  gap: 0.75rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.post-card.pinned {
  border-color: rgba(199, 154, 49, 0.72);
  box-shadow: inset 4px 0 0 var(--gold);
}

.pin-badge {
  justify-self: start;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: rgba(199, 154, 49, 0.14);
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
}

.post-top,
.post-foot {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: start;
}

.post-title {
  margin: 0;
  font-size: 1.1rem;
}

.post-meta,
.badge {
  color: var(--muted);
  font-size: 0.82rem;
}

.post-body {
  margin: 0;
  color: #294a50;
  line-height: 1.65;
  white-space: pre-wrap;
}

.post-media {
  width: 100%;
  max-height: 430px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.post-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.post-actions button,
.post-foot button {
  padding: 0.4rem 0.55rem;
  font-size: 0.85rem;
}

.pin {
  color: var(--gold);
  font-weight: 800;
}

.danger {
  color: var(--danger);
}

.game-section {
  display: grid;
  gap: 0.9rem;
}

.game-controls label,
.score-card {
  display: grid;
  gap: 0.2rem;
  min-width: 7.5rem;
}

.score-card {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.score-card span,
.game-controls span {
  color: var(--muted);
  font-size: 0.83rem;
}

.score-card strong {
  font-size: 1.35rem;
}

canvas {
  width: min(100%, 420px);
  height: auto;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfffc;
  image-rendering: pixelated;
}

.pad {
  display: none;
}

.spark {
  text-align: center;
  margin-bottom: 1rem;
}

.spark p {
  margin: 0 auto 1rem;
  max-width: 42rem;
  color: #294a50;
  font-size: 1.2rem;
  line-height: 1.65;
}

footer {
  width: min(1160px, 92vw);
  margin: 0 auto 2rem;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  nav {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .section-head,
  .app-layout,
  .stats {
    grid-template-columns: 1fr;
  }

  .section-head {
    display: grid;
  }

  .composer {
    position: static;
  }

  .pad {
    display: grid;
    width: min(230px, 75vw);
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
  }

  .pad [data-dir="up"] {
    grid-column: 2;
  }

  .pad [data-dir="left"] {
    grid-column: 1;
  }

  .pad [data-dir="right"] {
    grid-column: 3;
  }

  .pad [data-dir="down"] {
    grid-column: 2;
  }
}

@media (max-width: 560px) {
  .hero {
    min-height: 64vh;
  }

  .hero-copy {
    padding-bottom: 2.5rem;
  }

  .feed-tools,
  .post-top,
  .post-foot {
    display: grid;
    grid-template-columns: 1fr;
  }
}
