@font-face {
  font-family: "JiangChengYuanti";
  src: url("/static/jiangcheng-yuanti-500w.woff2?v=1") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

:root {
  color-scheme: light;
  --font: "JiangChengYuanti", "PingFang SC", "Microsoft YaHei", sans-serif;
  --paper: #f4f9fd;
  --paper-deep: #e6f2fa;
  --ink: #263e51;
  --muted: #7690a3;
  --blue: #5a9bc2;
  --deep-blue: #347596;
  --line: #c6deec;
  --rose: #ce8daa;
  --shadow: 0 24px 70px rgb(50 103 139 / 13%);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--paper);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 83% 12%, rgb(166 216 244 / 26%), transparent 32rem),
    radial-gradient(circle at 12% 75%, rgb(238 190 213 / 14%), transparent 30rem),
    repeating-linear-gradient(
      97deg,
      rgb(53 104 138 / 1.2%) 0,
      rgb(53 104 138 / 1.2%) 1px,
      transparent 1px,
      transparent 5px
    ),
    var(--paper);
  font-family: var(--font);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: inherit;
}

::selection {
  background: #cceafa;
}

.site-header,
.play-header,
.admin-header {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 3rem));
  min-height: 84px;
  margin: 0 auto;
  border-bottom: 1px solid var(--line);
}

.logo {
  color: var(--deep-blue);
  font-weight: 800;
  letter-spacing: 0.16em;
  text-decoration: none;
}

.logo span {
  color: var(--rose);
}

.site-header nav,
.play-header div,
.admin-header > div:last-child {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.inline-form {
  margin: 0;
}

.inline-form button {
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.account-name {
  color: var(--deep-blue);
  font-size: 0.76rem;
  font-weight: 800;
}

.site-header nav a,
.play-header a,
.admin-header a,
.admin-header button {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-decoration: none;
}

.site-header nav a:hover,
.play-header a:hover,
.admin-header a:hover {
  color: var(--deep-blue);
}

.home,
.admin-main {
  width: min(1180px, calc(100% - 3rem));
  margin: 0 auto;
}

.home-hero {
  position: relative;
  display: grid;
  min-height: 540px;
  align-content: center;
  justify-items: center;
  padding: 5rem 1rem;
  text-align: center;
}

.home-hero::before {
  position: absolute;
  top: 20%;
  left: 8%;
  width: 145px;
  height: 145px;
  border: 1px solid rgb(91 159 200 / 22%);
  border-radius: 50%;
  box-shadow:
    0 0 0 18px rgb(255 255 255 / 35%),
    0 0 0 38px rgb(91 159 200 / 5%);
  content: "";
}

.eyebrow {
  margin: 0 0 1.2rem;
  color: var(--blue);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.23em;
  text-transform: uppercase;
}

.home-hero h1 {
  margin: 0;
  color: var(--deep-blue);
  font-size: clamp(3.4rem, 8vw, 6.5rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: 0.08em;
  text-shadow: 0 10px 34px rgb(65 128 166 / 14%);
}

.home-hero h1 span {
  color: #6aa5c5;
  font-size: 0.46em;
  letter-spacing: 0.22em;
}

.home-hero > p:not(.eyebrow) {
  max-width: 40rem;
  margin: 2rem auto 0;
  color: #67869a;
  font-size: 1rem;
  line-height: 2;
}

.hero-code {
  margin-top: 2.2rem;
  color: #93b6cb;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  padding-bottom: 7rem;
}

.game-card,
.empty-card {
  position: relative;
  min-height: 360px;
  overflow: hidden;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 28px 8px 28px 8px;
  background: rgb(255 255 255 / 70%);
  box-shadow: var(--shadow);
}

.game-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  transition: transform 180ms ease, border-color 180ms ease;
}

.game-card:hover {
  border-color: var(--blue);
  transform: translateY(-5px);
}

.game-card::after {
  position: absolute;
  right: -38px;
  bottom: -38px;
  width: 145px;
  height: 145px;
  border: 1px solid rgb(93 159 199 / 20%);
  border-radius: 50%;
  content: "";
}

.theme-rose {
  --theme-accent: #a96b88;
  --theme-soft: #f7eaf0;
}

.theme-night {
  --theme-accent: #6789ab;
  --theme-soft: #e8eef7;
}

.theme-blue {
  --theme-accent: var(--deep-blue);
  --theme-soft: #e5f3fb;
}

.card-index {
  display: grid;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--theme-accent);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.68rem;
  place-items: center;
}

.card-meta {
  margin: 3.5rem 0 0.8rem;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
}

.game-card h2 {
  margin: 0;
  color: var(--theme-accent);
  font-size: 1.8rem;
  letter-spacing: 0.08em;
}

.game-card > p:last-of-type {
  color: #668498;
  font-size: 0.88rem;
  line-height: 1.8;
}

.game-card > .card-action {
  margin-top: auto;
  color: var(--theme-accent);
  font-size: 0.8rem;
  font-weight: 800;
}

.access-badge {
  align-self: flex-start;
  margin: 0 0 1rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 800;
}

.access-badge.public,
.status.public {
  color: #39788f;
  background: #e2f5fb;
}

.access-badge.member,
.status.member {
  color: #945f7a;
  background: #f7e9f0;
}

.empty-card {
  grid-column: 1 / -1;
  min-height: 280px;
  text-align: center;
}

.empty-card span {
  color: var(--line);
  font-size: 5rem;
}

footer {
  display: flex;
  justify-content: space-between;
  width: min(1180px, calc(100% - 3rem));
  margin: 0 auto;
  padding: 1.5rem 0 3rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
}

.detail {
  display: grid;
  min-height: calc(100vh - 84px);
  place-items: center;
  padding: 3rem 1.5rem 6rem;
}

.detail > .back {
  position: absolute;
  top: 7rem;
  left: max(1.5rem, calc((100% - 1120px) / 2));
}

.back {
  color: var(--muted);
  font-size: 0.8rem;
  text-decoration: none;
}

.detail-card {
  width: min(780px, 100%);
  padding: clamp(2rem, 7vw, 5rem);
  border: 1px solid var(--line);
  border-radius: 32px 10px 32px 10px;
  background: rgb(255 255 255 / 76%);
  box-shadow: var(--shadow);
  text-align: center;
}

.detail-card h1 {
  margin: 0;
  color: var(--theme-accent);
  font-size: clamp(3rem, 8vw, 5.5rem);
  line-height: 1.15;
  letter-spacing: 0.08em;
}

.summary {
  max-width: 38rem;
  margin: 2rem auto;
  color: #668398;
  line-height: 2;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 2.5rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stats span {
  display: grid;
  gap: 0.45rem;
  padding: 1.2rem 0.5rem;
  color: var(--muted);
  font-size: 0.7rem;
}

.stats b {
  color: var(--ink);
  font-size: 1rem;
}

.primary {
  display: inline-flex;
  min-height: 3.1rem;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.35rem;
  border: 0;
  border-radius: 14px;
  color: white;
  background: linear-gradient(135deg, #78b9d9, #4f88ab);
  box-shadow: 0 14px 30px rgb(61 125 165 / 22%);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-decoration: none;
  cursor: pointer;
}

.play-header {
  width: calc(100% - 3rem);
}

.play-shell {
  width: min(820px, calc(100% - 3rem));
  margin: 0 auto;
  padding: clamp(4rem, 9vw, 8rem) 0 10rem;
}

.play-shell article > h1 {
  margin: 0 0 3rem;
  color: var(--theme-accent);
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  text-align: center;
}

.play-shell article > .eyebrow {
  text-align: center;
}

.story p {
  margin: 0 0 1.25em;
  font-family: "Songti SC", STSong, SimSun, serif;
  font-size: clamp(1.25rem, 2.2vw, 1.58rem);
  line-height: 2;
  letter-spacing: 0.045em;
  text-align: justify;
  text-indent: 2em;
  overflow-wrap: anywhere;
}

.story-divider {
  margin: 3rem 0;
  color: var(--blue);
  text-align: center;
}

.choices {
  display: grid;
  gap: 0.8rem;
  margin-top: 5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.choices > p {
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.15em;
}

.choices form,
.choices button {
  width: 100%;
}

.choices button {
  display: grid;
  min-height: 4rem;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 16px 7px 16px 7px;
  color: var(--ink);
  background: rgb(255 255 255 / 72%);
  text-align: left;
  cursor: pointer;
}

.choices button:hover {
  border-color: var(--blue);
  background: white;
}

.choices button span,
.choices button b {
  color: var(--blue);
}

.ending {
  padding: 2rem;
  border: 1px dashed var(--line);
  border-radius: 18px;
  text-align: center;
}

.ending p {
  color: var(--rose);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
}

.variables {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 2rem;
}

.variables span {
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgb(255 255 255 / 50%);
  font-size: 0.68rem;
}

.reset-form {
  margin-top: 4rem;
  text-align: center;
}

.reset-form button,
.admin-header button,
.row-actions button {
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 2rem 1rem;
}

.login-card {
  width: min(480px, 100%);
  padding: clamp(2rem, 7vw, 4rem);
  border: 1px solid var(--line);
  border-radius: 30px 10px 30px 10px;
  background: rgb(255 255 255 / 78%);
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 1rem;
  color: var(--deep-blue);
  font-size: 2.6rem;
}

.login-card form {
  display: grid;
  gap: 1rem;
  margin: 2rem 0;
}

.login-card label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.login-card input {
  width: 100%;
  height: 3.1rem;
  padding: 0 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  background: #fbfdff;
}

.password-wrap {
  position: relative;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.5rem;
  padding: 0.35rem 0.55rem;
  border: 0;
  border-radius: 8px;
  color: var(--blue);
  background: var(--paper-deep);
  transform: translateY(-50%);
}

.flash {
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.flash.error {
  color: #9a526d;
  border-color: #e2bfd0;
  background: #fff7fa;
}

.flash.success {
  color: #39768d;
  background: #effaff;
}

.admin-page {
  background: #f1f7fb;
}

.admin-header {
  width: calc(100% - 3rem);
  min-height: 110px;
}

.admin-header h1 {
  margin: 0;
  color: var(--deep-blue);
}

.admin-header form {
  margin: 0;
}

.admin-main {
  display: grid;
  gap: 1.2rem;
  padding: 3rem 0 7rem;
}

.admin-panel {
  padding: clamp(1.3rem, 4vw, 2.5rem);
  border: 1px solid var(--line);
  border-radius: 24px 8px 24px 8px;
  background: rgb(255 255 255 / 72%);
  box-shadow: var(--shadow);
}

.admin-panel h2 {
  margin: 0 0 1rem;
  color: var(--deep-blue);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.panel-heading form {
  flex: 0 0 auto;
}

.credential-note {
  padding: 0.8rem 1rem;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: #f8fcff;
}

.credential-note code {
  color: var(--deep-blue);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 800;
}

.import-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.65fr) 1.35fr;
  gap: 2rem;
}

.import-panel form,
.import-panel label {
  display: grid;
  gap: 0.7rem;
}

.import-panel textarea {
  width: 100%;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: #fbfdff;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.76rem;
  resize: vertical;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 1rem 0.7rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.68rem;
}

td small {
  display: block;
  color: var(--muted);
}

.status {
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
}

.status.live {
  color: #37778f;
  background: #dff4fb;
}

.status.draft {
  color: #8a7180;
  background: #f3eaf0;
}

.row-actions {
  display: flex;
  gap: 0.4rem;
}

.row-actions form {
  margin: 0;
}

.row-actions .danger {
  color: #9b5971;
  border-color: #e3bdca;
}

.empty {
  padding: 3rem;
  color: var(--muted);
  text-align: center;
}

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

  .game-card {
    min-height: 310px;
  }

  .import-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .site-header,
  .play-header,
  .admin-header {
    width: calc(100% - 2rem);
  }

  .site-header {
    align-items: flex-start;
    min-height: 78px;
    flex-direction: column;
    justify-content: center;
    gap: 0.5rem;
  }

  .site-header nav {
    flex-wrap: wrap;
    gap: 0.8rem;
  }

  .home,
  .admin-main {
    width: calc(100% - 2rem);
  }

  .home-hero {
    min-height: 470px;
    padding-right: 0;
    padding-left: 0;
  }

  .home-hero::before {
    left: -15%;
  }

  .home-hero h1 {
    font-size: clamp(2.8rem, 15vw, 4rem);
    letter-spacing: 0.035em;
  }

  .home-hero > p:not(.eyebrow) {
    font-size: 0.92rem;
  }

  .hero-code {
    font-size: 0.58rem;
  }

  footer {
    width: calc(100% - 2rem);
    flex-direction: column;
    gap: 0.5rem;
  }

  .detail {
    display: block;
    padding: 2rem 1rem 5rem;
  }

  .detail > .back {
    position: static;
    display: inline-block;
    margin-bottom: 2rem;
  }

  .detail-card {
    padding: 2.4rem 1.2rem;
  }

  .detail-card h1 {
    font-size: 2.8rem;
  }

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

  .stats span {
    border-bottom: 1px solid var(--line);
  }

  .play-header {
    align-items: flex-start;
    min-height: 110px;
    flex-direction: column;
    justify-content: center;
    gap: 0.75rem;
  }

  .play-header div {
    flex-wrap: wrap;
    gap: 0.7rem;
  }

  .play-shell {
    width: calc(100% - 2rem);
    padding-top: 3rem;
  }

  .story p {
    font-size: 1.2rem;
    line-height: 1.9;
    text-align: left;
  }

  .choices button {
    min-height: 4.5rem;
  }

  .admin-header {
    align-items: flex-start;
    min-height: 145px;
    flex-direction: column;
    justify-content: center;
    gap: 1rem;
  }

  .admin-header > div:last-child {
    flex-wrap: wrap;
  }

  .admin-main {
    padding-top: 1.5rem;
  }

  .panel-heading {
    flex-direction: column;
  }
}
