:root {
  --ink: #171717;
  --paper: #f4ecd7;
  --card: #fff8e8;
  --line: #222;
  --red: #d63a2f;
  --blue: #223f96;
  --green: #0f6d4f;
  --yellow: #ffd35c;
  --shadow: 6px 6px 0 rgba(0, 0, 0, .22);
}

* {
  box-sizing: border-box;
}

html {
  color: var(--ink);
  background: #e7d4ae;
  font-family: "Microsoft YaHei", system-ui, sans-serif;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(rgba(255, 255, 255, .45) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .28) 1px, transparent 1px),
    #dfc28d;
  background-size: 28px 28px;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
a.button {
  font: inherit;
}

.site-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 4vw, 42px);
  border-bottom: 3px solid var(--ink);
  background: rgba(255, 248, 232, .94);
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  color: #fff;
  background: var(--ink);
  padding: 4px 12px;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0;
  transform: rotate(-1.5deg);
  box-shadow: 4px 4px 0 var(--red);
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.top-nav a,
.nav-button,
.button,
.small-button,
.icon-button,
.sort-tabs button,
.like-button {
  border: 2px solid var(--ink);
  background: #fff;
  color: var(--ink);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .25);
  cursor: pointer;
}

.top-nav a,
.nav-button {
  min-height: 36px;
  padding: 6px 11px;
  font-weight: 800;
}

.top-nav [aria-current="page"],
.primary,
.nav-button.primary {
  background: var(--yellow);
}

.nav-button.danger {
  background: #ffb9b3;
}

.date-pill,
.date-line {
  margin: 0;
  font-family: monospace;
  font-weight: 800;
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 520px);
  gap: clamp(24px, 5vw, 70px);
  align-items: center;
  min-height: calc(100vh - 72px);
  padding: clamp(26px, 5vw, 64px);
  padding-bottom: 34px;
}

.hero-copy h1,
.page-head h1 {
  margin: 10px 0;
  font-size: clamp(54px, 11vw, 138px);
  line-height: .9;
  letter-spacing: 0;
  text-shadow: 5px 5px 0 #fff, 9px 9px 0 var(--red);
}

.hero-lead,
.page-subtitle {
  max-width: 760px;
  font-size: clamp(20px, 3vw, 34px);
  font-weight: 800;
  line-height: 1.35;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 18px;
  font-weight: 900;
}

.button.primary {
  background: var(--red);
  color: #fff;
}

.button.ghost {
  background: #bce4ff;
}

.hero-board {
  position: relative;
  min-height: 600px;
  border: 4px solid var(--ink);
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, .22), transparent 24%),
    #8b5c34;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero-board::before {
  content: "";
  position: absolute;
  inset: 22px;
  border: 2px dashed rgba(0, 0, 0, .35);
}

.paper-chip {
  position: absolute;
  display: inline-block;
  padding: 9px 14px;
  border: 2px solid var(--ink);
  font-weight: 900;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, .22);
}

.c1 { top: 80px; left: 54px; background: #fff8df; transform: rotate(-7deg); font-size: 28px; }
.c2 { top: 190px; right: 36px; background: #ff9f43; transform: rotate(4deg); font-size: 23px; }
.c3 { top: 330px; left: 110px; background: #182f6f; color: #fff; transform: rotate(-2deg); font-size: 34px; }
.c4 { bottom: 120px; right: 82px; background: #ffbad8; transform: rotate(8deg); font-size: 25px; }
.c5 { bottom: 58px; left: 42px; background: #9fe36d; transform: rotate(-4deg); font-size: 22px; }

.section-band,
.page-wrap {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 54px;
}

.section-head,
.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 20px 0;
}

.section-head h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 52px);
}

.section-head a {
  padding: 7px 12px;
  border: 2px solid var(--ink);
  background: #fff;
  font-weight: 800;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .25);
}

.creator-shell {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.word-panel,
.canvas-zone {
  min-width: 0;
}

.word-panel {
  align-self: start;
  max-height: calc(100vh - 105px);
  overflow: auto;
  padding: 15px;
  border: 3px solid var(--ink);
  background: rgba(255, 248, 232, .92);
  box-shadow: var(--shadow);
}

.panel-title,
.board-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-title {
  justify-content: space-between;
}

.panel-title h2 {
  margin: 0;
  font-size: 28px;
}

.word-date {
  padding: 5px 9px;
  border: 2px solid var(--ink);
  background: #fff;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .22);
  font-family: monospace;
  font-weight: 900;
}

.hint {
  margin: 10px 0 16px;
  line-height: 1.6;
  font-weight: 700;
}

.word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.word-chip,
.board-item {
  padding: 7px 11px;
  border-width: 2px;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, .2);
  cursor: pointer;
  touch-action: none;
}

.word-chip:hover,
.board-item.selected {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}

.board-toolbar {
  flex-wrap: wrap;
  min-height: 48px;
  margin-bottom: 12px;
  padding: 8px;
  border: 3px solid var(--ink);
  background: #fff8e8;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, .2);
}

.small-button,
.icon-button,
.sort-tabs button,
.like-button {
  min-height: 34px;
  padding: 5px 10px;
  font-weight: 900;
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 20px;
}

.status-text {
  flex: 1;
  min-width: 210px;
  font-weight: 800;
}

.board-frame {
  width: min(100%, calc((100vh - 170px) * .75));
  margin: 0 auto;
}

.poem-board {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 4px solid var(--ink);
  box-shadow: var(--shadow);
}

.poem-board::before,
.poem-board::after {
  content: "";
  position: absolute;
  z-index: 0;
  pointer-events: none;
}

.poem-board::before {
  inset: 6% 8% 28% 7%;
  background:
    linear-gradient(7deg, transparent 0 18%, rgba(255, 248, 223, .52) 18% 36%, transparent 36% 44%, rgba(168, 216, 255, .28) 44% 64%, transparent 64%),
    linear-gradient(-5deg, rgba(255, 186, 216, .26) 0 32%, transparent 32% 52%, rgba(255, 211, 92, .22) 52% 78%, transparent 78%);
  clip-path: polygon(4% 2%, 96% 6%, 91% 92%, 1% 98%);
  border: 2px dashed rgba(20, 20, 20, .16);
  transform: rotate(-2deg);
}

.poem-board::after {
  inset: 56% 10% 9% 9%;
  background:
    linear-gradient(12deg, rgba(159, 227, 109, .2) 0 42%, transparent 42% 50%, rgba(255, 248, 223, .38) 50% 100%);
  clip-path: polygon(2% 8%, 97% 0, 94% 96%, 5% 90%);
  border: 2px dashed rgba(20, 20, 20, .13);
  transform: rotate(3deg);
}

.poem-board.dark::before,
.poem-board.dark::after {
  border-color: rgba(255, 255, 255, .12);
  opacity: .72;
}

.poem-board.beige {
  background:
    linear-gradient(rgba(80, 55, 20, .04) 1px, transparent 1px),
    #f4ecd7;
  background-size: 18px 18px;
}

.poem-board.wood {
  background:
    repeating-linear-gradient(6deg, rgba(61, 35, 17, .22) 0 2px, transparent 2px 76px),
    #92643c;
}

.poem-board.dark {
  background:
    radial-gradient(circle, rgba(255, 255, 255, .13) 1px, transparent 1px),
    #15161b;
  background-size: 19px 19px;
}

.board-item {
  position: absolute;
  z-index: 2;
  max-width: 620px;
  border-width: 3px;
  white-space: nowrap;
  user-select: none;
}

.poem-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}

.poem-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.poem-card,
.rank-row {
  position: relative;
  border: 3px solid var(--ink);
  background: #fff8e8;
  box-shadow: var(--shadow);
}

.poem-card img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-bottom: 3px solid var(--ink);
}

.poem-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  font-weight: 800;
}

.rank-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
  padding: 4px 9px;
  border: 2px solid var(--ink);
  background: var(--yellow);
  font-weight: 900;
}

.empty-note {
  padding: 24px;
  border: 3px dashed var(--ink);
  background: rgba(255, 248, 232, .82);
  font-size: 20px;
  font-weight: 800;
}

.sort-tabs {
  display: flex;
  gap: 8px;
}

.sort-tabs button.active {
  background: var(--yellow);
}

.rank-list {
  display: grid;
  gap: 16px;
}

.rank-row {
  display: grid;
  grid-template-columns: 60px 126px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 12px;
}

.rank-row strong {
  font-size: 42px;
  text-align: center;
}

.rank-row img {
  width: 126px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border: 2px solid var(--ink);
}

.rank-row h2,
.rank-row p {
  margin: 0;
}

.rank-row h2 {
  font-size: 24px;
}

@media (max-width: 900px) {
  .site-top {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .home-hero,
  .creator-shell {
    grid-template-columns: 1fr;
  }

  .home-hero {
    min-height: auto;
  }

  .hero-board {
    min-height: 430px;
  }

  .word-panel {
    max-height: none;
  }

  .board-frame {
    width: min(100%, 560px);
  }

  .rank-row {
    grid-template-columns: 44px 88px 1fr;
  }

  .rank-row .like-button {
    grid-column: 2 / -1;
    justify-self: start;
  }

  .rank-row img {
    width: 88px;
  }
}

@media (max-width: 560px) {
  .top-nav {
    justify-content: flex-start;
  }

  .hero-copy h1,
  .page-head h1 {
    font-size: 58px;
  }

  .page-head,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .creator-shell {
    padding: 12px;
  }

  .poem-meta {
    align-items: flex-start;
    flex-direction: column;
  }
}
