:root {
  color-scheme: light;
  --ink: #24302c;
  --muted: rgba(36, 48, 44, 0.66);
  --paper: #f6efe3;
  --paper-deep: #eadbc8;
  --cream: #fff9ed;
  --line: rgba(36, 48, 44, 0.14);
  --green: #4c8063;
  --coral: #d9684a;
  --blue: #4c6f91;
  --gold: #d69a2d;
  --shadow: 0 22px 70px rgba(68, 50, 34, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(36, 48, 44, 0.045) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(rgba(36, 48, 44, 0.04) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(145deg, #fbf5eb 0%, #f2e3d0 48%, #dfece2 100%);
  font-family: "Avenir Next", "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 9px, rgba(36, 48, 44, 0.018) 9px 10px),
    linear-gradient(120deg, rgba(217, 104, 74, 0.1), transparent 35%, rgba(76, 111, 145, 0.12));
  mix-blend-mode: multiply;
}

.neighborhood {
  width: min(1680px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 70px;
}

.gatehouse {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 28px;
  align-items: end;
  min-height: 210px;
  padding: 18px 0 22px;
  border-bottom: 2px solid rgba(36, 48, 44, 0.75);
}

.kicker,
.card-title,
.confirm-row,
.search-box span,
.board-meta,
.identity-label,
.blessing-from span {
  letter-spacing: 0;
  text-transform: uppercase;
}

.kicker {
  margin: 0 0 14px;
  color: var(--coral);
  font-size: 13px;
  font-weight: 900;
}

h1 {
  max-width: none;
  margin: 0;
  font-size: 58px;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

.subtitle {
  max-width: 660px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.58;
  font-weight: 650;
}

.gatehouse__panel {
  position: relative;
  border: 2px solid rgba(36, 48, 44, 0.78);
  border-radius: 8px;
  background: rgba(255, 249, 237, 0.76);
  box-shadow: var(--shadow);
  padding: 22px;
}

.gatehouse__panel::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px dashed rgba(36, 48, 44, 0.24);
  border-radius: 5px;
  pointer-events: none;
}

.signal {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
}

.signal span {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #5dbb7f;
  box-shadow: 0 0 0 7px rgba(93, 187, 127, 0.18);
}

dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 26px 0 0;
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

dd {
  margin: 6px 0 0;
  font-size: 32px;
  font-weight: 900;
}

.notice-board {
  display: grid;
  grid-template-columns: minmax(260px, 460px) auto minmax(220px, 1fr);
  align-items: end;
  gap: 20px;
  margin: 24px 0 30px;
}

.search-box {
  display: grid;
  gap: 8px;
  width: min(460px, 100%);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.search-box input {
  width: 100%;
  height: 48px;
  border: 2px solid rgba(36, 48, 44, 0.76);
  border-radius: 8px;
  background: rgba(255, 249, 237, 0.82);
  color: var(--ink);
  outline: none;
  padding: 0 14px;
  font: inherit;
  font-size: 16px;
}

.search-box input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(76, 128, 99, 0.18);
}

.board-meta {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.card-actions button,
.card-actions a {
  height: 48px;
  min-width: 82px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(36, 48, 44, 0.76);
  border-radius: 8px;
  background: rgba(255, 249, 237, 0.86);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  font-weight: 900;
  padding: 0 14px;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.card-actions button:hover,
.card-actions button:focus-visible,
.card-actions a:hover,
.card-actions a:focus-visible {
  background: var(--ink);
  color: var(--cream);
  box-shadow: 0 10px 24px rgba(36, 48, 44, 0.16);
  transform: translateY(-2px);
  outline: none;
}

.card-actions button:disabled {
  cursor: wait;
  opacity: 0.55;
  transform: none;
}

.draw-desk {
  position: relative;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 30px;
  align-items: center;
  --fly-x: clamp(190px, 34vw, 430px);
  --fly-mid: clamp(88px, 16vw, 190px);
  margin: 0 0 28px;
  border-top: 2px solid rgba(36, 48, 44, 0.2);
  border-bottom: 2px solid rgba(36, 48, 44, 0.2);
  background:
    repeating-linear-gradient(90deg, rgba(36, 48, 44, 0.035) 0 1px, transparent 1px 26px),
    rgba(255, 249, 237, 0.54);
  padding: 22px 20px;
  overflow: hidden;
}

.deck-zone {
  position: relative;
  height: 188px;
  perspective: 900px;
}

.deck-stack {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 132px;
  height: 168px;
  transform: translate(-50%, -50%);
}

.deck-stack span {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(36, 48, 44, 0.74);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(217, 104, 74, 0.24), transparent 44%),
    repeating-linear-gradient(45deg, rgba(76, 128, 99, 0.14) 0 7px, transparent 7px 14px),
    var(--cream);
  box-shadow: 0 16px 28px rgba(68, 50, 34, 0.18);
  transform-origin: 50% 86%;
  transition: transform 260ms ease, box-shadow 260ms ease;
}

.deck-stack span::before {
  content: "LINJU";
  position: absolute;
  left: 14px;
  top: 13px;
  color: rgba(36, 48, 44, 0.72);
  font-size: 13px;
  font-weight: 900;
}

.deck-stack span::after {
  content: "";
  position: absolute;
  inset: 34px 24px;
  border: 2px solid rgba(36, 48, 44, 0.22);
  border-radius: 50%;
}

.deck-stack span:nth-child(1) { transform: translate(-10px, 8px) rotate(-10deg); --dx: -62px; --dy: -30px; --rot: -26deg; }
.deck-stack span:nth-child(2) { transform: translate(-8px, 6px) rotate(-8deg); --dx: 54px; --dy: -34px; --rot: 22deg; }
.deck-stack span:nth-child(3) { transform: translate(-6px, 5px) rotate(-6deg); --dx: -42px; --dy: 46px; --rot: -18deg; }
.deck-stack span:nth-child(4) { transform: translate(-4px, 4px) rotate(-4deg); --dx: 62px; --dy: 34px; --rot: 18deg; }
.deck-stack span:nth-child(5) { transform: translate(-2px, 3px) rotate(-2deg); --dx: -80px; --dy: 12px; --rot: -31deg; }
.deck-stack span:nth-child(6) { transform: translate(0, 2px) rotate(0deg); --dx: 78px; --dy: -4px; --rot: 28deg; }
.deck-stack span:nth-child(7) { transform: translate(2px, 1px) rotate(2deg); --dx: -28px; --dy: -56px; --rot: -12deg; }
.deck-stack span:nth-child(8) { transform: translate(4px, 0) rotate(4deg); --dx: 30px; --dy: 56px; --rot: 12deg; }
.deck-stack span:nth-child(9) { transform: translate(6px, -1px) rotate(6deg); --dx: -92px; --dy: -12px; --rot: -36deg; }
.deck-stack span:nth-child(10) { transform: translate(8px, -2px) rotate(8deg); --dx: 92px; --dy: 12px; --rot: 36deg; }
.deck-stack span:nth-child(11) { transform: translate(10px, -3px) rotate(10deg); --dx: -16px; --dy: 72px; --rot: -8deg; }
.deck-stack span:nth-child(12) { transform: translate(12px, -4px) rotate(12deg); --dx: 18px; --dy: -72px; --rot: 8deg; }

.draw-desk.is-shuffling .deck-stack span {
  animation: shuffleSpread 840ms cubic-bezier(0.16, 0.88, 0.3, 1) both;
  animation-delay: var(--delay, 0ms);
}

.deck-stack span:nth-child(1) { --delay: 99ms; }
.deck-stack span:nth-child(2) { --delay: 90ms; }
.deck-stack span:nth-child(3) { --delay: 81ms; }
.deck-stack span:nth-child(4) { --delay: 72ms; }
.deck-stack span:nth-child(5) { --delay: 63ms; }
.deck-stack span:nth-child(6) { --delay: 54ms; }
.deck-stack span:nth-child(7) { --delay: 45ms; }
.deck-stack span:nth-child(8) { --delay: 36ms; }
.deck-stack span:nth-child(9) { --delay: 27ms; }
.deck-stack span:nth-child(10) { --delay: 18ms; }
.deck-stack span:nth-child(11) { --delay: 9ms; }
.deck-stack span:nth-child(12) { --delay: 0ms; }

.flying-card {
  position: absolute;
  left: calc(50% - 66px);
  top: calc(50% - 84px);
  width: 132px;
  height: 168px;
  display: grid;
  align-content: space-between;
  border: 2px solid rgba(36, 48, 44, 0.78);
  border-radius: 10px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.88), rgba(255, 249, 237, 0.92)),
    var(--cream);
  box-shadow: 0 18px 42px rgba(68, 50, 34, 0.24);
  color: var(--ink);
  opacity: 0;
  padding: 14px;
  transform: translate(0, 0) rotate(0deg) scale(0.96);
  pointer-events: none;
  z-index: 4;
}

.flying-card span {
  color: var(--coral);
  font-size: 11px;
  font-weight: 900;
}

.flying-card strong {
  font-size: 23px;
  line-height: 1;
}

.draw-desk.is-drawing .flying-card {
  animation: flyOutCard 820ms cubic-bezier(0.17, 0.84, 0.23, 1) both;
}

.draw-reveal {
  min-width: 0;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  border: 2px solid rgba(36, 48, 44, 0.16);
  border-radius: 10px;
  background: rgba(255, 249, 237, 0.7);
  padding: 16px;
}

.draw-copy {
  min-width: 0;
}

.draw-label {
  color: var(--coral);
  font-size: 12px;
  font-weight: 900;
}

.draw-copy strong {
  display: block;
  margin-top: 4px;
  font-size: 28px;
  line-height: 1.1;
}

.draw-copy small {
  display: block;
  margin-top: 6px;
  color: rgba(36, 48, 44, 0.58);
  font-size: 12px;
  font-weight: 900;
}

.draw-copy p {
  max-width: 860px;
  margin: 8px 0 0;
  color: var(--muted);
  font-family: "Songti SC", "STSong", serif;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.55;
}

#drawAvatar {
  width: 86px;
  height: 86px;
  border: 5px solid var(--green);
  border-radius: 50%;
  background: var(--paper-deep);
  display: block;
  object-fit: cover;
  opacity: 0;
  transform: scale(0.9) rotate(-4deg);
  transition: opacity 180ms ease, transform 180ms ease;
}

.draw-desk.is-active #drawAvatar {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.card-grid {
  column-count: 6;
  column-gap: 16px;
}

.neighbor-card {
  --accent: var(--coral);
  --accent-2: var(--green);
  --card-bg: var(--cream);
  position: relative;
  width: 100%;
  display: inline-flex;
  flex-direction: column;
  vertical-align: top;
  margin: 0 0 16px;
  overflow: hidden;
  break-inside: avoid;
  border: 2px solid rgba(36, 48, 44, 0.72);
  border-radius: 8px;
  background: var(--card-bg);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, transparent), transparent 34%),
    linear-gradient(180deg, var(--card-bg), #fffdf6);
  box-shadow: var(--shadow);
  cursor: pointer;
  padding: 14px;
  transform: rotate(var(--tilt));
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
  will-change: transform;
}

.neighbor-card:hover {
  border-color: var(--accent);
  box-shadow: 0 24px 62px rgba(68, 50, 34, 0.24);
  transform: rotate(var(--tilt)) translateY(-7px);
}

.neighbor-card.is-drawn {
  border-color: var(--accent);
  box-shadow: 0 30px 80px rgba(68, 50, 34, 0.3);
  transform: rotate(0deg) translateY(-8px);
  z-index: 2;
}

.card-grid.is-dealing .neighbor-card {
  animation: dealIn 460ms cubic-bezier(0.2, 0.9, 0.25, 1) both;
  animation-delay: var(--deal-delay);
}

.export-stage {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 420px;
  min-height: 1px;
  pointer-events: none;
  opacity: 0;
}

.export-stage .neighbor-card {
  width: 360px;
  display: flex;
  margin: 0;
  transform: none;
  box-shadow: none;
}

.export-stage .neighbor-card.is-drawn,
.export-stage .neighbor-card:hover {
  transform: none;
}

.neighbor-card::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px dashed rgba(36, 48, 44, 0.22);
  border-radius: 5px;
  pointer-events: none;
}

.neighbor-card::after {
  content: "已确认";
  position: absolute;
  right: 12px;
  top: 106px;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 3px solid var(--accent);
  border-radius: 50%;
  color: var(--accent);
  font-size: 15px;
  font-weight: 900;
  transform: rotate(10deg);
  opacity: 0.82;
}

.card-topline,
.confirm-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: rgba(36, 48, 44, 0.74);
  font-size: 10px;
  font-weight: 900;
}

.card-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar-wrap {
  width: 112px;
  height: 112px;
  margin: 18px auto 12px;
  border: 7px solid var(--accent-2);
  border-radius: 42% 58% 48% 52%;
  background: var(--paper-deep);
  overflow: hidden;
  box-shadow: 0 14px 30px rgba(36, 48, 44, 0.2);
}

.avatar-wrap img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.identity {
  text-align: center;
}

.identity-label,
.blessing-from span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
}

h2 {
  margin: 5px 0 0;
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: 0;
}

.floor {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.blessing-from {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(36, 48, 44, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.45);
}

.blessing-from strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

blockquote {
  margin: 12px 0 0;
  border-left: 5px solid var(--accent);
  padding: 1px 0 0 12px;
  color: rgba(36, 48, 44, 0.88);
  font-family: "Songti SC", "STSong", serif;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.48;
}

.confirm-row {
  align-items: center;
  border-top: 1px solid rgba(36, 48, 44, 0.16);
  margin-top: 12px;
  padding-top: 10px;
}

.confirm-row strong {
  color: var(--accent-2);
}

.theme-0 { --accent: #d9684a; --accent-2: #4c8063; --card-bg: #fff7e9; }
.theme-1 { --accent: #4c6f91; --accent-2: #d69a2d; --card-bg: #f7f3e8; }
.theme-2 { --accent: #b2576b; --accent-2: #5b8f86; --card-bg: #fff1f2; }
.theme-3 { --accent: #3f7562; --accent-2: #cc6b49; --card-bg: #f4fbf0; }
.theme-4 { --accent: #875d9a; --accent-2: #d18a39; --card-bg: #faf3ff; }
.theme-5 { --accent: #2e6f88; --accent-2: #bd503c; --card-bg: #edf8fb; }
.theme-6 { --accent: #a55f2b; --accent-2: #4f7b6d; --card-bg: #fff3df; }
.theme-7 { --accent: #5369a6; --accent-2: #c98539; --card-bg: #f1f5ff; }
.theme-8 { --accent: #a04452; --accent-2: #68884f; --card-bg: #fff5f7; }
.theme-9 { --accent: #416a54; --accent-2: #496b9b; --card-bg: #f1f8f2; }
.theme-10 { --accent: #6b5aa6; --accent-2: #559d91; --card-bg: #f7f1ff; }
.theme-11 { --accent: #2f5f74; --accent-2: #d27755; --card-bg: #f2f8f6; }

.motif-1 .avatar-wrap { border-radius: 55% 45% 54% 46%; }
.motif-2 .avatar-wrap { border-radius: 8px; }
.motif-3 .neighbor-card, .motif-3 { background-image: linear-gradient(135deg, color-mix(in srgb, var(--accent-2) 14%, transparent), transparent 32%), repeating-linear-gradient(45deg, rgba(36, 48, 44, 0.035) 0 8px, transparent 8px 16px), linear-gradient(180deg, var(--card-bg), #fffdf6); }
.motif-4::after { border-radius: 8px; transform: rotate(-7deg); }
.motif-5 blockquote { border-left-color: var(--accent-2); }
.motif-6 .avatar-wrap { border-width: 6px; outline: 3px solid var(--accent); outline-offset: 5px; }
.motif-7::before { border-style: solid; opacity: 0.7; }

@keyframes dealIn {
  from {
    opacity: 0;
    transform: translateY(24px) rotate(calc(var(--tilt) - 4deg)) scale(0.94);
  }

  to {
    opacity: 1;
    transform: translateY(0) rotate(var(--tilt)) scale(1);
  }
}

@keyframes shuffleSpread {
  42% {
    transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(1.05);
    box-shadow: 0 24px 42px rgba(68, 50, 34, 0.22);
  }
}

@keyframes flyOutCard {
  0% {
    opacity: 0;
    transform: translate(0, 0) rotate(0deg) scale(0.94) rotateY(0deg);
  }

  12% {
    opacity: 1;
  }

  42% {
    opacity: 1;
    transform: translate(var(--fly-mid), -34px) rotate(9deg) scale(1.06) rotateY(14deg);
  }

  74% {
    opacity: 1;
    transform: translate(var(--fly-x), -6px) rotate(0deg) scale(1) rotateY(180deg);
  }

  100% {
    opacity: 0;
    transform: translate(var(--fly-x), -6px) rotate(0deg) scale(0.98) rotateY(180deg);
  }
}

@media (max-width: 1360px) {
  h1 {
    font-size: 48px;
  }
}

@media (max-width: 1180px) {
  .card-grid {
    column-count: 4;
  }
}

@media (max-width: 1020px) {
  .card-grid {
    column-count: 3;
  }
}

@media (max-width: 820px) {
  .neighborhood {
    width: min(100% - 28px, 1480px);
    padding-top: 22px;
  }

  .gatehouse {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  h1 {
    font-size: 34px;
  }

  .gatehouse__panel {
    width: min(100%, 420px);
  }

  .notice-board {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .card-actions,
  .board-meta {
    justify-content: stretch;
  }

  .card-actions button {
    flex: 1 1 0;
  }

  .card-actions a {
    flex: 1 1 100%;
  }

  .card-grid {
    column-count: 2;
    column-gap: 18px;
  }

  .neighbor-card {
    transform: none;
  }

  .neighbor-card:hover,
  .neighbor-card.is-drawn {
    transform: translateY(-4px);
  }

  .draw-desk {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 16px 12px;
    --fly-x: 92px;
    --fly-mid: 48px;
  }

  .deck-zone {
    height: 150px;
  }

  .deck-stack,
  .flying-card {
    width: 104px;
    height: 132px;
  }

  .flying-card {
    left: calc(50% - 52px);
    top: calc(50% - 66px);
    padding: 12px;
  }

  .flying-card strong {
    font-size: 19px;
  }

  .draw-reveal {
    grid-template-columns: 68px minmax(0, 1fr);
    padding: 12px;
  }

  .draw-copy strong {
    font-size: 23px;
  }

  .draw-copy p {
    font-size: 15px;
  }

  #drawAvatar {
    width: 62px;
    height: 62px;
  }
}

@media (max-width: 560px) {
  .neighborhood {
    width: min(100% - 22px, 1480px);
  }

  h1 {
    font-size: 24px;
  }

  .subtitle {
    font-size: 14px;
  }

  .card-grid {
    column-count: 1;
  }

  .draw-reveal {
    grid-template-columns: 1fr;
    text-align: center;
  }

  #drawAvatar {
    margin: 0 auto;
  }
}
