:root {
  --paper: #d7d1bd;
  --paper-dark: #aca58e;
  --ink: #20241e;
  --green: #3c5643;
  --red: #7d2824;
  --line: #777466;
  --black: #080a08;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 3px),
    #10130f;
  font-family: "Courier New", "SimSun", monospace;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

/* 入场预警 */
.warning-screen {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}

.warning-box {
  width: min(520px, 100%);
  padding: 34px;
  color: #d6d8d1;
  border: 1px solid #454b41;
  background: #151914;
  box-shadow: 0 0 70px rgba(0, 0, 0, 0.8), inset 0 0 35px rgba(255, 255, 255, 0.025);
}

.warning-kicker {
  color: #899482;
  font-size: 11px;
  letter-spacing: 0.18em;
}

.warning-box h1 {
  margin: 22px 0 12px;
  color: #e2ded0;
  font-family: "SimSun", serif;
  font-size: clamp(34px, 9vw, 58px);
  font-weight: normal;
}

.warning-box p {
  color: #a8aea2;
  line-height: 1.8;
}

.sound-option {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 22px 0;
  color: #b8beb2;
  font-size: 13px;
}

.warning-box button {
  width: 100%;
  padding: 13px;
  color: #d7dbd2;
  border: 1px solid #596254;
  background: #293128;
}

.warning-box small {
  display: block;
  margin-top: 15px;
  color: #737b70;
  text-align: center;
}

/* 旧式主页 */
.site-shell {
  width: min(960px, calc(100% - 24px));
  margin: 28px auto;
  border: 2px ridge #b7b19d;
  background: var(--paper);
  box-shadow: 0 25px 90px #000;
  transition: filter 0.4s;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 25px 28px;
  color: #d8d5c8;
  background:
    linear-gradient(rgba(21, 33, 24, 0.75), rgba(21, 33, 24, 0.9)),
    repeating-linear-gradient(90deg, #304235 0 2px, #28382d 2px 4px);
}

.tiny-label {
  margin: 0 0 8px;
  color: #89988b;
  font-size: 10px;
  letter-spacing: 0.16em;
}

.site-header h1 {
  margin: 0;
  font-family: "SimSun", serif;
  font-size: clamp(28px, 6vw, 46px);
  font-weight: normal;
}

.subtitle {
  margin: 7px 0 0;
  color: #a6afa4;
  font-size: 12px;
}

.counter-box {
  padding: 10px;
  border: 1px solid #69756a;
  background: #111710;
  color: #9ca89b;
  font-size: 10px;
  text-align: center;
}

.counter-box strong {
  display: block;
  margin: 4px 0;
  color: #cfd7cb;
  font-family: monospace;
  font-size: 18px;
  letter-spacing: 0.12em;
}

.old-marquee {
  padding: 7px 0;
  color: #493e2d;
  border-top: 1px solid #efe9d5;
  border-bottom: 1px solid var(--line);
  background: #c1b99e;
  font-size: 12px;
}

.page-grid {
  display: grid;
  grid-template-columns: 190px 1fr;
  min-height: 560px;
}

.sidebar {
  padding: 18px 12px;
  border-right: 1px solid var(--line);
  background:
    repeating-linear-gradient(45deg, rgba(50, 60, 48, 0.04) 0 2px, transparent 2px 6px),
    #beb8a3;
}

.profile-card {
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid #8e8978;
  background: #ccc5af;
  text-align: center;
}

.avatar {
  position: relative;
  width: 82px;
  height: 92px;
  margin: 0 auto 9px;
  overflow: hidden;
  border: 4px ridge #b0aa96;
  background: radial-gradient(circle at 48% 34%, #97998c 0 10%, #686d64 11% 21%, #30352f 22% 100%);
  filter: grayscale(1) contrast(1.4) blur(0.5px);
}

.avatar-head,
.avatar-body {
  position: absolute;
  left: 50%;
  background: #222721;
  transform: translateX(-50%);
}

.avatar-head {
  width: 31px;
  height: 38px;
  top: 17px;
  border-radius: 48% 48% 40% 40%;
}

.avatar-body {
  width: 58px;
  height: 50px;
  top: 51px;
  border-radius: 50% 50% 0 0;
}

.profile-card h2 {
  margin: 0;
  font-size: 16px;
}

.profile-card p {
  margin-bottom: 0;
  font-size: 11px;
}

.online-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #556c52;
  border-radius: 50%;
  box-shadow: 0 0 7px #788f70;
}

.nav-title {
  margin: 0 0 6px;
  color: #625e51;
  font-size: 11px;
}

.nav-button {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 5px;
  padding: 9px;
  color: #393d35;
  border: 1px solid #999380;
  background: #cbc4ad;
  text-align: left;
}

.nav-button:hover,
.nav-button.active {
  color: #d6d9d1;
  border-color: #354237;
  background: #435346;
}

.sidebar-note {
  margin-top: 22px;
  padding: 10px;
  border: 1px dashed #7e796b;
  font-size: 10px;
  line-height: 1.6;
}

.sidebar-note p {
  margin: 0 0 5px;
  color: #565246;
  font-weight: bold;
}

.content-panel {
  padding: 20px 25px 30px;
  background:
    linear-gradient(rgba(215, 209, 189, 0.92), rgba(215, 209, 189, 0.92)),
    repeating-linear-gradient(0deg, #333 0 1px, transparent 1px 4px);
}

.system-line {
  display: flex;
  justify-content: space-between;
  margin-bottom: 25px;
  padding-bottom: 8px;
  color: #656154;
  border-bottom: 1px dotted #7b7769;
  font-size: 10px;
}

.page-view {
  display: none;
  animation: page-in 0.25s steps(4);
}

.page-view.active {
  display: block;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-view h2 {
  margin: 0 0 20px;
  color: #344036;
  font-family: "SimSun", serif;
  font-size: 25px;
  font-weight: normal;
}

.page-view p,
.page-view li {
  font-size: 13px;
  line-height: 1.8;
}

.notice-board {
  margin: 25px 0;
  padding: 14px 18px;
  border: 1px solid #98927f;
  background: rgba(238, 232, 210, 0.5);
}

.notice-board h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.last-update {
  color: #696557;
  text-align: right;
}

.diary-entry {
  display: grid;
  grid-template-columns: 105px 1fr;
  width: 100%;
  padding: 13px 10px;
  color: #30352d;
  border: 0;
  border-bottom: 1px dotted #888271;
  background: transparent;
  text-align: left;
}

.diary-entry:hover {
  background: rgba(80, 91, 74, 0.1);
}

.diary-entry time {
  grid-row: span 2;
  color: #777163;
  font-size: 11px;
}

.diary-entry span {
  margin-top: 4px;
  color: #696559;
  font-size: 11px;
}

.diary-reader {
  min-height: 90px;
  margin-top: 20px;
  padding: 15px;
  border-left: 3px solid #526152;
  background: rgba(238, 232, 210, 0.45);
  font-size: 12px;
  line-height: 1.9;
  white-space: pre-line;
}

.album-tip {
  color: #625e52;
  font-size: 11px !important;
}

.photo-frame {
  position: relative;
  display: block;
  width: min(100%, 470px);
  aspect-ratio: 4 / 3;
  margin: 15px auto;
  overflow: hidden;
  border: 8px ridge #9b9583;
  background: linear-gradient(#4b5148 0 70%, #292d29 70%);
}

.window-light {
  position: absolute;
  width: 24%;
  height: 43%;
  top: 9%;
  left: 10%;
  border: 5px solid #282d28;
  background: #879087;
  box-shadow: 0 0 35px rgba(190, 198, 185, 0.2);
}

.room-floor {
  position: absolute;
  inset: 70% 0 0;
  background: repeating-linear-gradient(90deg, #242823 0 40px, #292d28 40px 42px);
}

.figure {
  position: absolute;
  width: 11%;
  height: 35%;
  bottom: 25%;
  background: #171b17;
  border-radius: 44% 44% 12% 12%;
  box-shadow: 0 0 16px #111;
  transition: 0.7s ease;
}

.figure::before {
  position: absolute;
  width: 60%;
  aspect-ratio: 1;
  top: -28%;
  left: 20%;
  background: #181c18;
  border-radius: 50%;
  content: "";
}

.figure-owner {
  left: 48%;
}

.figure-other {
  right: -18%;
  opacity: 0;
}

.photo-frame.watched .figure-other {
  right: 8%;
  opacity: 0.72;
}

.photo-frame.watched-twice .figure-other {
  width: 20%;
  height: 60%;
  right: 0;
  bottom: 8%;
  opacity: 0.95;
}

.photo-noise {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 3px);
  pointer-events: none;
}

.messages {
  min-height: 230px;
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 18px;
  border-top: 1px dotted #858071;
}

.message-item {
  padding: 11px 5px;
  border-bottom: 1px dotted #858071;
  font-size: 12px;
}

.message-item strong {
  color: #4a584a;
}

.message-item.owner-message strong {
  color: var(--red);
}

.empty-message {
  color: #777265;
}

.message-compose {
  display: flex;
  gap: 7px;
  margin-top: 8px;
}

.message-compose input {
  min-width: 0;
  flex: 1;
  padding: 10px;
  border: 1px inset #a09a87;
  background: #e8e1ca;
}

.message-compose button {
  padding: 8px 13px;
  color: #e1e3dc;
  border: 1px outset #657064;
  background: #485748;
}

footer {
  display: flex;
  justify-content: space-between;
  padding: 8px 14px;
  color: #7f887e;
  border-top: 1px solid #697168;
  background: #222a22;
  font-size: 9px;
}

/* 损坏效果 */
.damage-overlay {
  position: fixed;
  z-index: 20;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.035) 3px 4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s;
}

body.damage-1 .damage-overlay { opacity: 0.25; }
body.damage-2 .damage-overlay { opacity: 0.5; }
body.damage-2 .site-shell { filter: saturate(0.7) contrast(1.1); }
body.damage-3 .damage-overlay { opacity: 0.78; }
body.damage-3 .site-shell { filter: grayscale(0.7) contrast(1.3); }

.glitch {
  animation: glitch 0.34s steps(2) 3;
}

@keyframes glitch {
  0%, 100% { transform: translate(0); }
  25% { transform: translate(-5px, 2px); }
  50% { transform: translate(6px, -2px); }
  75% { transform: translate(-2px, -1px); }
}

.system-toast {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 25px;
  padding: 9px 12px;
  color: #c9cec6;
  border: 1px solid #525c51;
  background: #171c17;
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: 0.25s;
}

.system-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* 最终场景 */
.finale {
  position: fixed;
  z-index: 100;
  display: grid;
  inset: 0;
  overflow: hidden;
  color: #b8beb6;
  background: #030403;
  place-items: center;
}

.finale-message {
  display: grid;
  gap: 12px;
  text-align: center;
  transition: opacity 0.3s;
}

.finale-message span {
  color: #747d73;
  font-size: 11px;
  letter-spacing: 0.2em;
}

.finale-message strong {
  font-size: 15px;
  font-weight: normal;
}

.face {
  position: absolute;
  width: min(70vw, 460px);
  aspect-ratio: 0.78;
  top: 50%;
  left: 50%;
  border-radius: 48% 52% 45% 46%;
  background:
    radial-gradient(circle at 30% 40%, #c4c6b8 0 3%, transparent 4%),
    radial-gradient(circle at 70% 40%, #c4c6b8 0 3%, transparent 4%),
    radial-gradient(ellipse at center, #72796f 0 18%, #292e29 50%, #0c0f0c 76%);
  box-shadow: 0 0 90px #1d251e;
  filter: grayscale(1) contrast(1.8);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.05);
}

.eye {
  position: absolute;
  width: 16%;
  height: 8%;
  top: 38%;
  background: #060806;
  border-radius: 50%;
  box-shadow: 0 0 18px #000;
}

.eye-left { left: 21%; transform: rotate(8deg); }
.eye-right { right: 17%; transform: rotate(-12deg); }

.mouth {
  position: absolute;
  width: 18%;
  height: 26%;
  top: 59%;
  left: 44%;
  background: #020302;
  border-radius: 50% 45% 60% 40%;
}

.face.appear {
  animation: face-rush 0.42s cubic-bezier(0.05, 0.8, 0.1, 1) forwards, face-breathe 1.8s 0.42s ease-in-out infinite;
}

@keyframes face-rush {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.05); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1.2) rotate(2deg); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes face-breathe {
  50% { transform: translate(-50%, -50%) scale(1.035); filter: grayscale(1) contrast(2.1); }
}

.ending {
  position: absolute;
  z-index: 2;
  bottom: 8%;
  text-align: center;
  opacity: 0;
  transition: opacity 1s;
}

.ending.show {
  opacity: 1;
}

.ending p {
  margin-bottom: 15px;
  font-size: 12px;
}

.ending button {
  padding: 9px 15px;
  color: #adb5aa;
  border: 1px solid #414941;
  background: #111511;
}

@media (max-width: 700px) {
  .site-shell {
    margin: 10px auto;
  }

  .site-header {
    align-items: flex-start;
    padding: 18px;
  }

  .counter-box {
    display: none;
  }

  .page-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .profile-card,
  .nav-title,
  .sidebar-note {
    display: none;
  }

  .nav-button {
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 9px 4px;
    font-size: 11px;
    text-align: center;
  }

  .nav-button span {
    display: none;
  }

  .content-panel {
    min-height: 570px;
    padding: 18px;
  }

  .diary-entry {
    grid-template-columns: 1fr;
  }

  .diary-entry time {
    grid-row: auto;
    margin-bottom: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
