:root {
  --bg: #f4f1ea;
  --bg-2: #e9dfce;
  --panel: #fff9ef;
  --ink: #2f2a22;
  --muted: #6d6356;
  --primary: #28666e;
  --primary-2: #7c9885;
  --danger: #a62929;
  --line: #d4c8b5;
  --action: #d86018;
  --check: #1f7a8c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, #fff6e8 0%, transparent 30%),
    radial-gradient(circle at 90% 20%, #d8ead3 0%, transparent 25%),
    linear-gradient(135deg, var(--bg), var(--bg-2));
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  background: rgba(255, 248, 236, 0.9);
  backdrop-filter: blur(4px);
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar h1 {
  margin: 0 0 18px;
  font-size: 24px;
}

.nav-item {
  display: block;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.nav-item.active,
.nav-item:hover {
  background: #ffe5bb;
}

.sidebar-footer {
  margin-top: 24px;
  display: grid;
  gap: 10px;
}

.content {
  padding: 24px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 8px 22px rgba(80, 60, 30, 0.08);
  animation: fadeIn 0.4s ease;
}

.role-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}

.role-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fffef9;
}

.role-card h3 {
  margin: 0;
}

.role-no {
  color: #8c8c8c;
  font-weight: 600;
  margin-right: 6px;
}

.tags {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.stats {
  margin: 10px 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
}

.badge.action {
  background: rgb(216 96 24 / 50%);
}

.badge.check {
  background: rgb(31 122 140 / 50%);
}

.trait-line {
  margin: 6px 0 8px;
}

.trait-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  width: fit-content;
}

.trait-main {
  display: block;
  width: 100%;
  border-radius: 8px;
  padding: 6px 10px;
  background: rgb(91 78 119 / 50%);
}

.trait-front {
  background: rgb(73 255 1 / 50%);
}

.trait-back {
  background: rgb(12 175 239 / 50%);
}

.trait-special {
  background: rgb(247 119 64 / 50%);
}

.section-list {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.section-item {
  display: grid;
  gap: 5px;
}

.section-item .trait-badge {
  justify-self: start;
}

.desc {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
}

.notice-list,
.notice-admin-list,
.role-admin-list {
  display: grid;
  gap: 14px;
}

.notice-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fffef9;
}

.notice-time {
  color: var(--muted);
  font-size: 13px;
}

.notice-title-gold {
  color: #c89d2b;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}

.btn.secondary {
  background: var(--primary-2);
}

.btn.danger {
  background: var(--danger);
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
}

.stack-form,
.grid-form {
  display: grid;
  gap: 10px;
}

.search-form {
  margin: 8px 0 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.search-form input[type="text"] {
  flex: 1;
  min-width: 220px;
}

.grid-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-form .full {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  font: inherit;
  background: #fff;
}

.admin-header {
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: #fff8ec;
}

.admin-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.admin-main {
  padding: 20px;
  display: grid;
  gap: 16px;
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
}

.admin-side {
  border-right: 1px solid var(--line);
  background: rgba(255, 248, 236, 0.92);
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 10px;
}

.admin-side h1 {
  margin: 0;
  font-size: 24px;
}

.admin-menu {
  display: grid;
  gap: 8px;
  align-content: start;
}

.admin-menu-item {
  display: block;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.admin-menu-item:hover,
.admin-menu-item.active {
  background: #ffe5bb;
}

.admin-side-actions {
  align-self: end;
  display: grid;
  gap: 8px;
}

.admin-workspace {
  padding: 18px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.admin-page-head h2 {
  margin: 0;
}

.admin-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.panel h3 {
  margin: 12px 0 8px;
}

.admin-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.admin-panel-wide {
  grid-column: 1 / -1;
}

.admin-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.name-gold {
  color: #c89d2b;
  font-weight: 700;
}

.admin-account-list,
.log-list {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.log-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fffef9;
}

.log-item p {
  margin: 4px 0;
}

.history-log-list.is-scrollable {
  overflow-y: auto;
  padding-right: 6px;
}

.inline-form {
  margin-top: -6px;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.error {
  color: var(--danger);
  margin: 0;
}

.success-msg {
  color: #2d7d46;
  margin: 0;
  font-weight: 700;
}

.account-panel {
  max-width: 640px;
}

.link {
  color: var(--primary);
  text-decoration: none;
}

.markdown-body {
  line-height: 1.7;
}

.notice-reminder-modal {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 45%);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 1000;
}

.notice-reminder-modal[hidden] {
  display: none !important;
}

.notice-reminder-card {
  width: min(680px, 100%);
  max-height: 80vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffef9;
  padding: 16px;
  box-shadow: 0 14px 30px rgb(0 0 0 / 20%);
}

.notice-reminder-card h3,
.notice-reminder-card h4 {
  margin-top: 0;
}

.notice-reminder-card .row-actions {
  margin-top: 14px;
}

.game-beta-page {
  grid-template-columns: 1fr;
}

.game-status-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 12px;
  align-items: stretch;
}

.game-status-row>.panel {
  min-height: 0;
}

.game-status-row>.panel:last-child {
  display: flex;
  flex-direction: column;
}

.game-status-compact .game-self-overview {
  margin-bottom: 0;
}

.game-self-backline {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.game-self-backline .game-self-role {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: 999px;
  background: #fff8e9;
  border: 1px solid #e8d6b5;
  font-size: 14px;
}

.role-link {
  color: inherit;
  text-decoration: none;
}

.role-link:hover {
  text-decoration: underline;
}

.check-card {
  display: inline-flex;
  min-width: 24px;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 999px;
  background: #f1f1f1;
  color: #4a4a4a;
  font-size: 12px;
  font-weight: 800;
  margin-right: 4px;
}

.check-card.self {
  background: #ffdede;
  color: #a33a3a;
}

.recent-check-wrap {
  border: 1px dashed #e1d0b1;
  border-radius: 8px;
  padding: 8px;
  background: #fffdf8;
}

.recent-check-title {
  margin: 0 0 6px;
  color: #7a6542;
  font-size: 12px;
  font-weight: 700;
}

.recent-check-cards {
  margin: 0 0 6px;
}

.game-super-controls {
  margin-top: 2px;
}

.super-remove-wrap {
  flex-wrap: wrap;
}

.turn-banner {
  border: 1px solid #d8be8f;
  border-radius: 12px;
  background: linear-gradient(120deg, #fff0ce, #ffe2b1 45%, #fff3da);
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.turn-banner-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.turn-label {
  font-size: 12px;
  font-weight: 800;
  color: #7c5b1f;
}

.turn-player {
  font-size: 18px;
}

.turn-phase {
  display: inline-flex;
  border-radius: 999px;
  padding: 3px 10px;
  background: #fff9ea;
  border: 1px solid #e8c98a;
  font-weight: 700;
  color: #7f6028;
}

.game-beta-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.game-mini-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fffef9;
}

.game-mini-card h3 {
  margin: 0 0 8px;
}

.game-mini-card p {
  margin: 4px 0;
}

.game-beta-top-actions {
  margin-top: 10px;
}

.game-self-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.game-self-stat {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: linear-gradient(135deg, #fffef7, #fff3dd);
  display: grid;
  gap: 4px;
}

.game-self-stat-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.game-self-stat-value {
  font-size: 26px;
  line-height: 1;
  font-weight: 800;
}

.game-self-role {
  font-size: 16px;
  font-weight: 800;
}

.game-op-form {
  margin-top: 4px;
  border: 1px solid #d6c8ae;
  background: linear-gradient(135deg, #fff7e8, #fffef6);
}

.game-op-group {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 8px;
}

.hand-sort-actions {
  margin-bottom: 8px;
}

.game-beta-panel-inner {
  margin: 0;
  box-shadow: none;
}

.game-checkbox-list {
  display: grid;
  gap: 4px;
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.hand-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.hand-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid #d7c39b;
  border-radius: 10px;
  padding: 8px 12px;
  background: linear-gradient(180deg, #fffdf8, #ffefd1);
  font-size: 13px;
  font-weight: 700;
}

.hand-card {
  min-width: 88px;
  justify-content: center;
}

.hand-chip.muted {
  color: var(--muted);
  font-weight: 600;
}

.game-player-boards {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  overflow: auto;
  flex: 1;
}

.player-board {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(135deg, #fffef8, #fff4df);
  display: grid;
  gap: 10px;
}

.player-board.big-win-ready {
  position: relative;
  overflow: hidden;
  border-color: #e0b536;
  box-shadow:
    0 0 0 1px #f4d16a,
    0 0 22px rgb(234 189 60 / 70%),
    0 0 40px rgb(255 226 130 / 55%);
  animation: big-win-glow 0.8s steps(2, end) infinite, big-win-pop 1.8s ease-in-out infinite;
}

.player-board.big-win-ready::before {
  content: "";
  position: absolute;
  inset: -45%;
  z-index: 0;
  pointer-events: none;
  background: conic-gradient(from 0deg,
      rgb(255 241 171 / 0%) 0deg,
      rgb(255 241 171 / 75%) 45deg,
      rgb(255 220 109 / 0%) 90deg,
      rgb(255 246 203 / 72%) 140deg,
      rgb(255 204 74 / 0%) 180deg,
      rgb(255 232 143 / 76%) 240deg,
      rgb(255 214 95 / 0%) 300deg,
      rgb(255 250 207 / 72%) 340deg,
      rgb(255 241 171 / 0%) 360deg);
  filter: blur(16px);
  animation: big-win-spin 2.2s linear infinite;
}

.player-board.big-win-ready::after {
  content: "";
  position: absolute;
  top: 0;
  left: -140%;
  width: 80%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(112deg, rgb(255 244 192 / 0%) 0%, rgb(255 255 255 / 88%) 45%, rgb(255 222 115 / 0%) 100%);
  transform: skewX(-22deg);
  animation: big-win-sweep 1.15s ease-in-out infinite;
}

.player-board.big-win-ready>* {
  position: relative;
  z-index: 2;
}

.player-board.is-self {
  border-color: #b89d5d;
  box-shadow: inset 0 0 0 1px #dfcf9e;
}

.player-board-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.player-name-alert {
  color: #c81d1d;
}

.player-role-tag {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #5d4820;
  background: #ffe5bb;
}

.player-hp-line {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.player-backline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.player-backline-item {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fff8e9;
  border: 1px solid #ead9bb;
  font-size: 12px;
  color: #6c572f;
  font-weight: 700;
}

.player-hp-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #efe4d2;
  overflow: hidden;
}

.player-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #dc3737, #f17a3f);
}

.player-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.player-meta-item {
  border: 1px solid #e8dbc5;
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  display: grid;
  gap: 4px;
}

.meta-inline-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.meta-action-buttons {
  display: inline-flex;
  gap: 4px;
}

.btn.mini {
  min-width: 28px;
  padding: 2px 8px;
  line-height: 1.2;
}

.deck-top-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.deck-top-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.deck-top-item {
  border: 1px solid #e8dbc5;
  border-radius: 8px;
  background: #fffdf7;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.deck-top-item[draggable="true"] {
  cursor: move;
}

.deck-top-item.dragging {
  opacity: 0.55;
}

.deck-top-handle {
  color: #8b7341;
  font-weight: 700;
  user-select: none;
}

.meta-label {
  color: var(--muted);
  font-size: 12px;
}

.meta-value {
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.action-tag {
  display: inline-flex;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.action-draw {
  background: #dff3ff;
  color: #175b7f;
}

.action-check {
  background: #e7ecff;
  color: #373ea0;
}

.action-card {
  background: #ffeccd;
  color: #8d4f10;
}

.action-damage {
  background: #ffe2e2;
  color: #932727;
}

.action-heal {
  background: #e3f7e8;
  color: #1f6a34;
}

.action-system {
  background: #ececec;
  color: #4c4c4c;
}

.role-name-chip {
  cursor: help;
}

.role-hover-preview {
  position: fixed;
  z-index: 1200;
  width: min(360px, calc(100vw - 16px));
  max-height: min(70vh, 460px);
  overflow: auto;
  pointer-events: none;
  border: 1px solid #d6c39f;
  border-radius: 12px;
  background: linear-gradient(160deg, #fffdf7, #fff4de 60%, #ffefd1);
  box-shadow: 0 14px 28px rgb(0 0 0 / 20%);
  padding: 10px 12px;
}

.role-hover-title {
  margin: 0 0 4px;
  font-size: 18px;
  line-height: 1.2;
}

.role-hover-meta {
  margin: 0 0 4px;
  color: #5f513a;
  font-size: 12px;
  font-weight: 700;
}

.role-hover-desc {
  margin: 8px 0;
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: 13px;
}

.role-hover-line {
  margin: 5px 0;
  line-height: 1.45;
  font-size: 13px;
}

.role-hover-badge {
  display: inline-flex;
  align-items: center;
  margin-right: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #ddc798;
  background: #fff9eb;
  color: #6b5527;
  font-size: 11px;
  font-weight: 800;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .grid-form {
    grid-template-columns: 1fr;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-panel-wide {
    grid-column: auto;
  }

  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-side {
    position: static;
    height: auto;
    grid-template-rows: auto auto auto;
  }

  .admin-side-actions {
    align-self: start;
  }

  .game-beta-status-grid,
  .game-status-row,
  .game-self-overview,
  .game-player-boards,
  .deck-top-grid,
  .player-meta-grid {
    grid-template-columns: 1fr;
  }

  .turn-banner {
    flex-direction: column;
    align-items: stretch;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes big-win-glow {
  from {
    border-color: #e0b536;
    box-shadow:
      0 0 0 1px #f4d16a,
      0 0 14px rgb(226 184 66 / 45%),
      0 0 24px rgb(246 221 151 / 46%);
  }

  to {
    border-color: #ffd86d;
    box-shadow:
      0 0 0 1px #ffe69f,
      0 0 34px rgb(255 221 120 / 95%),
      0 0 58px rgb(255 240 179 / 86%);
  }
}

@keyframes big-win-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes big-win-sweep {
  0% {
    left: -140%;
    opacity: 0;
  }

  15% {
    opacity: 1;
  }

  55% {
    left: 125%;
    opacity: 1;
  }

  100% {
    left: 125%;
    opacity: 0;
  }
}

@keyframes big-win-pop {

  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  45% {
    transform: translateY(-1px) scale(1.012);
  }

  65% {
    transform: translateY(0) scale(0.998);
  }
}