:root {
  --ink: #241418;
  --cinnabar: #a61f32;
  --lacquer: #6d1522;
  --gold: #e4c78a;
  --gold-deep: #a07c3e;
  --paper: #f7f1e4;
  --paper-edge: #e7d7b8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Songti SC", "STSong", "SimSun", "Noto Serif SC", serif;
  background: #07060c;
}

h1, h2, button, .btn, .seal, .side, .side-brand p {
  font-family: "KaiTi", "STKaiti", "KaiTi_GB2312", "Songti SC", "SimSun", serif;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #c4a36a; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

.night {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(120, 70, 110, 0.28), transparent 42%),
    radial-gradient(circle at 50% 16%, #3c244c 0%, #1a1028 38%, #09070f 72%);
}

.stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1.2px 1.2px at 8% 18%, #fff 50%, transparent 52%),
    radial-gradient(1px 1px at 18% 42%, #fff 50%, transparent 52%),
    radial-gradient(1.4px 1.4px at 28% 12%, #f8e7c4 50%, transparent 52%),
    radial-gradient(1px 1px at 42% 28%, #fff 50%, transparent 52%),
    radial-gradient(1px 1px at 63% 16%, #fff 50%, transparent 52%),
    radial-gradient(1.5px 1.5px at 74% 34%, #f3d9a4 50%, transparent 52%),
    radial-gradient(1px 1px at 86% 14%, #fff 50%, transparent 52%),
    radial-gradient(1px 1px at 92% 46%, #fff 50%, transparent 52%),
    radial-gradient(1px 1px at 12% 72%, rgba(255,255,255,.7) 50%, transparent 52%),
    radial-gradient(1px 1px at 80% 68%, rgba(255,255,255,.65) 50%, transparent 52%);
  opacity: 0.85;
}

.moon-ring {
  position: absolute;
  left: 50%;
  top: 7%;
  width: 300px;
  height: 300px;
  margin-left: -150px;
  border-radius: 50%;
  border: 1px solid rgba(244, 224, 176, 0.16);
  box-shadow: inset 0 0 30px rgba(244, 214, 150, 0.05);
}

.moon {
  position: absolute;
  left: 50%;
  top: 10%;
  width: 180px;
  height: 180px;
  margin-left: -90px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.95), transparent 16%),
    radial-gradient(circle at 64% 46%, rgba(168, 140, 96, 0.28) 0 7%, transparent 8%),
    radial-gradient(circle at 42% 64%, rgba(150, 120, 80, 0.22) 0 11%, transparent 12%),
    radial-gradient(circle at 50% 45%, #fff8ea 0%, #f3e0b4 46%, #e4c78a 78%, #c6a15e 100%);
  box-shadow:
    0 0 28px 8px rgba(247, 224, 170, 0.36),
    0 0 80px 24px rgba(232, 186, 120, 0.14);
}

.sakura i {
  position: absolute;
  top: -12vh;
  width: 11px;
  height: 11px;
  background: linear-gradient(135deg, #fff 0%, #f7c3cf 45%, #e07a92 100%);
  border-radius: 70% 0 70% 0;
  animation: drift linear infinite;
}

.sakura i:nth-child(odd) {
  width: 8px;
  height: 8px;
  background: linear-gradient(135deg, #fff, #f3d2a4);
}

.sakura i:nth-child(1) { left: 6%; animation-duration: 15s; animation-delay: -2s; }
.sakura i:nth-child(2) { left: 14%; animation-duration: 18s; animation-delay: -8s; }
.sakura i:nth-child(3) { left: 24%; animation-duration: 13s; animation-delay: -4s; }
.sakura i:nth-child(4) { left: 33%; animation-duration: 17s; animation-delay: -11s; }
.sakura i:nth-child(5) { left: 46%; animation-duration: 16s; animation-delay: -6s; }
.sakura i:nth-child(6) { left: 55%; animation-duration: 19s; animation-delay: -1s; }
.sakura i:nth-child(7) { left: 64%; animation-duration: 14s; animation-delay: -9s; }
.sakura i:nth-child(8) { left: 72%; animation-duration: 18s; animation-delay: -3s; }
.sakura i:nth-child(9) { left: 80%; animation-duration: 15s; animation-delay: -12s; }
.sakura i:nth-child(10) { left: 88%; animation-duration: 17s; animation-delay: -5s; }
.sakura i:nth-child(11) { left: 94%; animation-duration: 13s; animation-delay: -7s; }
.sakura i:nth-child(12) { left: 40%; animation-duration: 20s; animation-delay: -14s; }

@keyframes drift {
  0% { transform: translate3d(0, 0, 0) rotate(0deg); opacity: 0; }
  8% { opacity: 0.9; }
  100% { transform: translate3d(36px, 115vh, 0) rotate(320deg); opacity: 0.2; }
}

.lantern {
  position: absolute;
  top: 13%;
  width: 26px;
  height: 38px;
  border-radius: 42% 42% 46% 46%;
  background:
    linear-gradient(#4a1018, #4a1018) top / 100% 4px no-repeat,
    linear-gradient(#4a1018, #4a1018) bottom / 100% 5px no-repeat,
    radial-gradient(circle at 50% 42%, #ffe0a0, #e2582c 58%, #8d1c24 100%);
  box-shadow: 0 0 18px rgba(255, 150, 60, 0.55);
  transform-origin: top center;
  animation: sway 4.6s ease-in-out infinite;
}

.lantern::before {
  content: "";
  position: absolute;
  top: -18px;
  left: 50%;
  width: 1px;
  height: 18px;
  background: rgba(180, 60, 70, 0.8);
}

.lantern.l1 { left: 18%; }
.lantern.l2 { right: 18%; animation-delay: -2.1s; }

@keyframes sway {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}

.ofuda {
  position: absolute;
  top: 8%;
  width: 46px;
  padding: 16px 0 18px;
  text-align: center;
  color: #7a1c24;
  background: linear-gradient(#fffdf8, #f3e6cc);
  border: 1px solid #d7b56a;
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.35);
}

.ofuda span {
  display: inline-block;
  letter-spacing: 0.35em;
  writing-mode: vertical-rl;
  font-size: 18px;
}

.ofuda::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 50%;
  width: 2px;
  height: 14px;
  background: #6d1522;
  transform: translateX(-50%);
}

.ofuda::after {
  content: "";
  display: block;
  width: 14px;
  height: 14px;
  margin: 12px auto 0;
  border: 1.5px solid var(--cinnabar);
  border-radius: 50%;
}

.ofuda.left { left: 8%; animation: sway 7s ease-in-out infinite; transform-origin: top center; }
.ofuda.right { right: 8%; animation: sway 6.4s ease-in-out infinite reverse; transform-origin: top center; }

.mist {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 28vh;
  background: linear-gradient(transparent, rgba(18, 8, 16, 0.72));
}

.gate {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
}

.panel, .card {
  position: relative;
  width: min(440px, 100%);
  padding: 32px 28px 26px;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--gold-deep), var(--gold-deep)),
    linear-gradient(var(--gold-deep), var(--gold-deep)),
    linear-gradient(var(--gold-deep), var(--gold-deep)),
    linear-gradient(var(--gold-deep), var(--gold-deep)),
    linear-gradient(var(--gold-deep), var(--gold-deep)),
    linear-gradient(var(--gold-deep), var(--gold-deep)),
    linear-gradient(var(--gold-deep), var(--gold-deep)),
    linear-gradient(var(--gold-deep), var(--gold-deep)),
    radial-gradient(rgba(120, 72, 40, 0.045) 0.6px, transparent 0.7px),
    linear-gradient(180deg, rgba(255, 252, 246, 0.5), rgba(236, 222, 196, 0.28));
  background-size:
    20px 2px, 2px 20px,
    20px 2px, 2px 20px,
    20px 2px, 2px 20px,
    20px 2px, 2px 20px,
    3px 3px, 100% 100%;
  background-position:
    left 10px top 10px, left 10px top 10px,
    right 10px top 10px, right 10px top 10px,
    left 10px bottom 10px, left 10px bottom 10px,
    right 10px bottom 10px, right 10px bottom 10px,
    0 0, 0 0;
  background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, repeat, no-repeat;
  border: 1px solid var(--gold);
  box-shadow:
    0 0 0 5px rgba(109, 21, 34, 0.08),
    0 0 0 6px rgba(212, 176, 106, 0.4),
    0 24px 56px rgba(0, 0, 0, 0.45);
  animation: rise 0.55s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.brand { text-align: center; margin-bottom: 14px; }
.brand p {
  margin: 0 0 4px;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: #8d6234;
  font-size: 14px;
}

.seal {
  width: 64px;
  height: 64px;
  margin: 0 auto 10px;
  display: grid;
  place-items: center;
  color: #fff6ea;
  font-size: 30px;
  background:
    radial-gradient(circle at 50% 50%, transparent 58%, rgba(244, 220, 170, 0.95) 59% 63%, transparent 64%),
    radial-gradient(circle at 32% 28%, #d45050, #8a1822 62%, #5c1018 100%);
  border: 2px solid var(--gold);
  border-radius: 4px;
  box-shadow: 0 8px 16px rgba(80, 10, 16, 0.28), inset 0 0 0 3px rgba(255, 230, 190, 0.22);
  transform: rotate(-10deg);
}

.seal.tiny {
  width: 46px;
  height: 46px;
  margin: 0 auto 10px;
  font-size: 22px;
  transform: rotate(-8deg);
}

h1 {
  margin: 0;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  font-weight: 500;
  font-size: 30px;
  color: #3a1816;
}

.brand h1 {
  position: relative;
  padding-bottom: 14px;
}

.brand h1::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 132px;
  height: 1px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, var(--cinnabar), transparent);
}

label {
  display: block;
  margin: 12px 0;
  font-size: 14px;
  letter-spacing: 0.1em;
  color: #7a3e32;
}

input, select, textarea {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--paper-edge);
  border-bottom: 2px solid var(--gold-deep);
  border-radius: 2px;
  background: rgba(255, 252, 246, 0.94);
  color: #2a1416;
  font: inherit;
  box-shadow: inset 0 1px 2px rgba(90, 40, 20, 0.05);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #c45a4a;
  border-bottom-color: var(--cinnabar);
  box-shadow: 0 0 0 3px rgba(166, 31, 50, 0.12);
}

::placeholder { color: #b7a48c; }
textarea { min-height: 110px; resize: vertical; }

.cap-row { display: flex; gap: 10px; align-items: center; }
.cap-row input { flex: 1; }

.cap-row img {
  width: 122px;
  height: 42px;
  margin-top: 6px;
  cursor: pointer;
  object-fit: cover;
  background: #fff;
  border: 1px solid var(--paper-edge);
}

.cap-row img:hover { border-color: var(--cinnabar); }

button, .btn {
  border: 1px solid #f0d7a4;
  cursor: pointer;
  color: #fff8ea;
  background: linear-gradient(180deg, #c4474a 0%, #8e1d28 58%, #64141c 100%);
  padding: 8px 14px;
  font: inherit;
  letter-spacing: 0.14em;
  box-shadow: inset 0 1px 0 rgba(255, 220, 180, 0.35);
}

button:hover, .btn:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }

button[type="submit"] {
  width: 100%;
  margin-top: 8px;
  padding: 12px 16px;
  letter-spacing: 0.36em;
  text-indent: 0.36em;
  font-size: 16px;
  box-shadow: 0 8px 16px rgba(90, 16, 24, 0.28), inset 0 1px 0 rgba(255, 220, 180, 0.4);
}

.err { color: var(--cinnabar); margin: 8px 0; font-size: 13px; }
.err:empty { display: none; }
.err:not(:empty),
#pageErr:not(:empty) {
  padding: 8px 12px;
  background: rgba(166, 31, 50, 0.07);
  border-left: 3px solid var(--cinnabar);
}

.hint { text-align: center; margin: 16px 0 0; color: #6d5346; letter-spacing: 0.06em; }

a { color: var(--lacquer); }

.hint a {
  color: var(--lacquer);
  text-decoration: none;
  border-bottom: 1px solid rgba(109, 21, 34, 0.35);
}

.hint a:hover { color: var(--cinnabar); }

.shell {
  position: relative;
  display: flex;
  min-height: 100vh;
}

.shell::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 5;
  background: linear-gradient(90deg, #4a1018, var(--gold), #4a1018);
}

.side {
  width: 232px;
  flex: none;
  display: flex;
  flex-direction: column;
  color: var(--gold);
  padding: 26px 16px 18px;
  background:
    linear-gradient(180deg, rgba(228, 199, 138, 0.16), transparent 92px),
    linear-gradient(180deg, #2a1420 0%, #160c12 46%, #0c070b 100%);
  border-right: 1px solid rgba(228, 199, 138, 0.32);
  box-shadow: inset -16px 0 28px rgba(0, 0, 0, 0.22);
}

.side-brand {
  text-align: center;
  padding-bottom: 16px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(228, 199, 138, 0.22);
}

.side h2, .side p { margin: 0; }

.side h2 {
  font-weight: 500;
  font-size: 18px;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  color: #f6ead2;
}

.side p {
  margin-top: 6px;
  letter-spacing: 0.52em;
  text-indent: 0.52em;
  font-size: 12px;
  color: var(--gold);
  opacity: 0.9;
}

.side nav {
  display: flex;
  flex-direction: column;
  margin-top: 14px;
  flex: 1;
  overflow: auto;
}

.side a {
  position: relative;
  color: #f3e6c8;
  text-decoration: none;
  padding: 10px 12px 10px 16px;
  margin: 1px 0;
  letter-spacing: 0.16em;
  border-left: 2px solid transparent;
}

.side a:hover {
  color: #fff;
  background: linear-gradient(90deg, rgba(228, 199, 138, 0.1), transparent);
}

.side a.on {
  color: #fff8e8;
  border-left-color: var(--gold);
  background: linear-gradient(90deg, rgba(228, 199, 138, 0.18), transparent 86%);
}

#logout {
  margin-top: auto;
  opacity: 0.72;
}

.main {
  position: relative;
  flex: 1;
  min-width: 0;
  padding: 32px 32px 40px;
  background:
    radial-gradient(circle at 100% 0%, rgba(228, 199, 138, 0.22), transparent 26%),
    radial-gradient(rgba(120, 72, 40, 0.035) 0.7px, transparent 0.8px),
    linear-gradient(180deg, #f8f2e6, #efe3d0);
  background-size: auto, 4px 4px, auto;
}

.main::before {
  content: "";
  position: absolute;
  right: 36px;
  top: 22px;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle at 35% 35%, rgba(255, 248, 230, 0.95), rgba(228, 199, 138, 0.28) 58%, transparent 62%);
  box-shadow: 0 0 24px rgba(228, 199, 138, 0.25);
}

#pageErr, #view { position: relative; z-index: 1; }

.main h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px;
  font-weight: 500;
  font-size: 22px;
  letter-spacing: 0.22em;
  color: #3a1816;
}

.main h2::before {
  content: "";
  width: 8px;
  height: 8px;
  flex: none;
  background: var(--cinnabar);
  transform: rotate(45deg);
  box-shadow: 0 0 0 3px rgba(166, 31, 50, 0.12);
}

.main h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--gold-deep), transparent);
}

.main > p, #view > p {
  letter-spacing: 0.06em;
  color: #5c4036;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: rgba(255, 250, 243, 0.92);
  border: 1px solid #e6d3b0;
  box-shadow: 0 10px 24px rgba(80, 30, 20, 0.06);
}

th, td {
  padding: 11px 12px;
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

th {
  background: linear-gradient(180deg, #7a1a28, #4e1018);
  color: #f6e7c4;
  font-weight: 500;
  letter-spacing: 0.14em;
}

td { border-bottom: 1px solid #f0e2cc; color: #3a221c; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td, tr:hover td { background: rgba(228, 199, 138, 0.14); }
tr:hover th { background: linear-gradient(180deg, #7a1a28, #4e1018); }

table button {
  width: auto;
  margin: 0 4px 0 0;
  padding: 5px 12px;
  letter-spacing: 0.08em;
  text-indent: 0;
  font-size: 13px;
  box-shadow: none;
}

#gmList { max-height: 420px; overflow: auto; margin: 0 0 16px; }
#gmList table { margin: 0; }

.row { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 16px; align-items: center; }
.row > * { flex: 1; min-width: 140px; }
.row input, .row select, .row button { margin-top: 0; }
.row button { flex: none; min-width: 96px; }

.stat { display: flex; gap: 14px; flex-wrap: wrap; }

.tabs { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 16px 0; }
.tabs button.active {
  color: #3a2414;
  border-color: var(--gold);
  background: linear-gradient(180deg, #f3e2bc, #c6a15e);
}
.tabs .sum { color: #7a4e38; letter-spacing: 0.08em; }
.flow-note { margin: 0 0 12px; color: #7a4e38; font-size: 14px; letter-spacing: 0.06em; }

.stat div {
  position: relative;
  min-width: 150px;
  padding: 16px 18px 14px;
  color: #7a4e38;
  letter-spacing: 0.14em;
  font-size: 13px;
  background:
    linear-gradient(var(--gold-deep), var(--gold-deep)) 0 0 / 16px 1px no-repeat,
    linear-gradient(var(--gold-deep), var(--gold-deep)) 0 0 / 1px 16px no-repeat,
    linear-gradient(var(--gold-deep), var(--gold-deep)) 100% 0 / 16px 1px no-repeat,
    linear-gradient(var(--gold-deep), var(--gold-deep)) 100% 0 / 1px 16px no-repeat,
    linear-gradient(var(--gold-deep), var(--gold-deep)) 0 100% / 16px 1px no-repeat,
    linear-gradient(var(--gold-deep), var(--gold-deep)) 0 100% / 1px 16px no-repeat,
    linear-gradient(var(--gold-deep), var(--gold-deep)) 100% 100% / 16px 1px no-repeat,
    linear-gradient(var(--gold-deep), var(--gold-deep)) 100% 100% / 1px 16px no-repeat,
    linear-gradient(180deg, #fffaf3, #f4e7d2);
  border: 1px solid rgba(160, 124, 62, 0.35);
  box-shadow: 0 8px 18px rgba(80, 30, 20, 0.05);
}

.stat b {
  display: block;
  margin-top: 8px;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--lacquer);
}

.invite { margin-top: 22px; max-width: 820px; }
.invite h3 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--lacquer);
}
.invite-item {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0 0 10px;
  padding: 12px 14px;
  background: linear-gradient(180deg, #fffaf3, #f4e7d2);
  border: 1px solid rgba(160, 124, 62, 0.35);
}
.invite-item span {
  flex: none;
  min-width: 7em;
  color: #7a4e38;
  letter-spacing: 0.12em;
}
.invite-item a {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--lacquer);
}
.invite-item button { flex: none; padding: 6px 12px; letter-spacing: 0.12em; }

.main .card { width: min(520px, 100%); margin-top: 4px; }
#view form:not(.row) { max-width: 560px; }

pre {
  white-space: pre-wrap;
  background: #fffaf3;
  border: 1px solid #e6d3b0;
  padding: 10px;
  font-size: 12px;
}

@media (max-width: 860px) {
  .ofuda, .lantern { display: none; }
  .moon { width: 120px; height: 120px; margin-left: -60px; }
  .moon-ring { width: 190px; height: 190px; margin-left: -95px; }
  .shell { display: block; }
  .side { width: auto; }
  .side nav {
    flex-direction: row;
    flex-wrap: wrap;
    max-height: none;
    gap: 6px;
  }
  .side a {
    border: 1px solid rgba(228, 199, 138, 0.28);
    border-left-width: 1px;
    padding: 7px 10px;
    background: rgba(255, 255, 255, 0.03);
  }
  .side a.on { border-color: var(--gold); }
  #logout { margin-top: 0; }
  .main { padding: 20px 14px 28px; }
  .main::before { width: 48px; height: 48px; right: 12px; top: 12px; }
  table { min-width: 640px; }
  #view { overflow-x: auto; }
  .invite-item { flex-wrap: wrap; }
  .invite-item a { flex-basis: 100%; white-space: normal; overflow: visible; }
}

@media (prefers-reduced-motion: reduce) {
  .sakura i, .lantern, .ofuda, .panel, .card { animation: none; }
}
