@font-face {
  font-family: 'SmileySans';
  src: url('/fonts/SmileySans-Oblique.woff2') format('woff2');
  font-display: swap;
}

:root {
  --ink: #12121A;
  --paper: #FFFFFF;
  --desk: #FCFBF8;
  --desk-line: #EDEAF2;
  --slot-band: #F4F1F8;
  --rule-tape: #EEECF3;
  --muted: #5A5A6E;
  --slot-num: #82808F;
  --foil: #8E7BF2;
  --purple: #A98BFB;
  --gold: #E6C27A;
  --lime: #A6F05C;
  --danger: #FF6B6B;
  --water: #3BA0E6;
  --track: #2B2A35;
  --led: #7DFFA8;
  --dock: #34333F;
  --disabled-bg: #E9E7EF;
  --disabled-fg: #8C8998;
  --font-head: 'SmileySans', 'PingFang SC', 'Hiragino Sans GB', system-ui, sans-serif;
  --font-body: 'PingFang SC', 'Hiragino Sans GB', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--desk);
  background-image:
    linear-gradient(to right, var(--desk-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--desk-line) 1px, transparent 1px);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

input, textarea, select {
  font-family: var(--font-body);
  user-select: text;
}

/* 通用按键：遵循 BrandStyle 实心墨线描边 + 硬投影 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-head);
  font-size: 16px;
  letter-spacing: 0.02em;
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
  transition: transform 80ms ease, box-shadow 80ms ease, background 120ms ease;
}
.btn:hover:not(:disabled) { background: #F7F5FC; }
.btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}
.btn:disabled {
  background: var(--disabled-bg);
  color: var(--disabled-fg);
  border-color: #B9B6C6;
  box-shadow: none;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--ink);
  color: var(--paper);
}
.btn-primary:hover:not(:disabled) { background: #262636; }
.btn-foil {
  background: var(--foil);
  color: var(--paper);
}
.btn-foil:hover:not(:disabled) { background: #7D68EA; }
.btn-danger {
  background: #FFF0F0;
  color: #B4232A;
  border-color: #B4232A;
  box-shadow: 0 3px 0 #B4232A;
}
.btn-sm {
  padding: 5px 10px;
  font-size: 14px;
  border-radius: 8px;
  box-shadow: 0 2px 0 var(--ink);
}

/* 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: rgba(252, 251, 248, 0.94);
  backdrop-filter: blur(6px);
  border-bottom: 2px solid var(--ink);
}
.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.brand-badge {
  font-family: var(--font-head);
  font-size: 21px;
  padding: 3px 10px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 8px;
  letter-spacing: 0.03em;
}
.beta-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #EFEAFE;
  border: 1.5px solid var(--ink);
}

/* 登录卡包页 */
.gate-wrap {
  min-height: calc(100vh - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.pack-gate {
  width: 100%;
  max-width: 410px;
  background: var(--foil);
  border: 3px solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 8px 0 var(--ink);
  padding: 24px 22px 22px;
  color: var(--paper);
  position: relative;
}
.pack-crimp {
  height: 10px;
  margin: -24px -22px 18px;
  border-bottom: 2px dashed rgba(18, 18, 26, 0.45);
  background: repeating-linear-gradient(90deg, rgba(255,255,255,0.22) 0 6px, transparent 6px 12px);
  border-radius: 15px 15px 0 0;
}
.pack-paper-label {
  background: var(--paper);
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  padding: 20px 18px;
}
.pack-title {
  font-family: var(--font-head);
  font-size: 32px;
  margin: 0 0 4px;
  line-height: 1.1;
}
.pack-sub {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 16px;
  line-height: 1.5;
}
.input-field {
  width: 100%;
  padding: 10px 12px;
  font-size: 16px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  outline: none;
}
.input-field:focus {
  box-shadow: 0 0 0 3px rgba(142, 123, 242, 0.35);
}

/* 选关页 */
.page-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 18px 48px;
}
.chapter-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.tab-btn {
  padding: 7px 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font-family: var(--font-head);
  font-size: 16px;
  cursor: pointer;
}
.tab-btn.active {
  background: var(--ink);
  color: var(--paper);
}
.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 14px;
}
.level-pack-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 126px;
  padding: 14px;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  text-align: left;
  transition: transform 80ms ease;
}
.level-pack-card:hover:not(.locked) {
  transform: translateY(-2px);
}
.level-pack-card.cleared {
  background: #FBF9FF;
}
.level-pack-card.current {
  background: #FFF9E6;
  border-width: 3px;
}
.level-pack-card.locked {
  background: var(--disabled-bg);
  color: var(--disabled-fg);
  border-color: #B9B6C6;
  box-shadow: none;
  cursor: not-allowed;
}
.lp-num {
  font-family: var(--font-head);
  font-size: 15px;
  color: var(--muted);
}
.lp-name {
  font-family: var(--font-head);
  font-size: 21px;
  margin: 6px 0;
  line-height: 1.2;
}
.lp-stamp {
  display: inline-block;
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1.5px solid currentColor;
}
.lp-stamp.ok { color: #1D6F42; background: #E9FBEF; }
.lp-stamp.skip { color: #8A5A00; background: #FFF4D6; }
.lp-stamp.go { color: var(--ink); background: var(--gold); }

/* 关卡游玩桌面 */
.play-layout {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 58px);
}
.rule-tape {
  background: var(--rule-tape);
  border-bottom: 2px solid var(--ink);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
}
.recipe-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 11px;
  box-shadow: 0 2px 0 var(--ink);
  flex-shrink: 0;
  cursor: pointer;
}
.recipe-pill.active-fire {
  background: #FFF1B8;
  box-shadow: 0 0 0 3px var(--ink);
}
.recipe-pill.fatal {
  border-color: #C92A2A;
}
.recipe-name {
  font-family: var(--font-head);
  font-size: 14px;
  margin-right: 3px;
}
.recipe-arrow {
  font-weight: 900;
  font-size: 14px;
  padding: 0 2px;
}
.chip {
  width: 30px;
  height: 36px;
  border-radius: 7px;
  border: 2px solid var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}
.chip.keep-ring::after {
  content: '';
  position: absolute;
  inset: -4px;
  border: 2px dashed var(--ink);
  border-radius: 9px;
}
.chip.end-chip {
  width: 24px;
  height: 28px;
  transform: translateY(-4px);
}
.cell-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1.5px solid var(--ink);
  background: #E7F5FF;
}

/* 状态辅助条（用例、订单、回忆、全局资源） */
.hud-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 18px 0;
}
.hud-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.badge-box {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
}

/* 卡栈横带 */
.table-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  padding: 14px 18px;
}
.stack-band-wrap {
  background: var(--slot-band);
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  padding: 22px 18px 18px;
  position: relative;
  overflow-x: auto;
}
.stack-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}
.goal-sign {
  font-family: var(--font-head);
  font-size: 19px;
  padding: 4px 12px;
  border-radius: 8px;
  border: 2px solid var(--ink);
  background: var(--paper);
}
.goal-sign.passed {
  background: var(--lime);
}
.slots-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  min-height: 158px;
  padding-bottom: 6px;
  position: relative;
}
.slot-cell {
  width: 98px;
  min-height: 144px;
  border: 2px dashed #B8B4C7;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 6px;
  position: relative;
  flex-shrink: 0;
  transition: background 120ms ease, border-color 120ms ease;
}
.slot-cell.drag-over {
  border-color: var(--foil);
  background: #EFEAFE;
}
.slot-cell.limit-after::after {
  content: '限高线';
  position: absolute;
  right: -8px;
  top: -14px;
  bottom: -6px;
  width: 4px;
  background: var(--danger);
  border-radius: 2px;
  font-size: 0;
  z-index: 6;
}
.slot-idx {
  position: absolute;
  top: 5px;
  left: 8px;
  font-family: var(--font-head);
  font-size: 13px;
  color: var(--slot-num);
}
.env-badge {
  position: absolute;
  top: 4px;
  right: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1.5px solid var(--ink);
  cursor: pointer;
}
.slot-cell.env-water {
  background: linear-gradient(180deg, rgba(59,160,230,0.14), rgba(59,160,230,0.34));
  border-style: solid;
  border-color: var(--water);
}
.slot-cell.env-track {
  background: var(--track);
  border-style: solid;
  border-color: var(--ink);
}
.slot-cell.env-track .slot-idx { color: #B8B5C8; }
.slot-cell.env-track .env-badge { background: var(--led); color: var(--ink); }
.slot-cell.env-rail {
  background: #23222B;
  border-style: dashed;
  border-color: #6E6C7E;
}
.slot-cell.env-rail .slot-idx { color: #9A98A8; }
.slot-cell.env-rail .env-badge { background: #43414E; color: #DDD; }
.slot-cell.env-mirror {
  background: linear-gradient(180deg, #F4F6FA, #E3E8EF 52%, #D3DAE4);
  border-style: solid;
  border-color: #6B789E;
}
.slot-cell.env-wormhole {
  background: linear-gradient(180deg, #EEE7FF, #D3C4FD);
  border-style: solid;
  border-color: #7048E8;
}
.slot-cell.env-dock {
  background: linear-gradient(180deg, #34333F, #1C1B24);
  border-style: solid;
  border-color: var(--ink);
}
.slot-cell.env-dock .slot-idx { color: #CBD0DC; }
.slot-cell.env-dock .env-badge { background: var(--gold); color: var(--ink); }

/* 单张游戏卡牌 */
.game-card {
  width: 86px;
  height: 116px;
  border: 2.5px solid var(--ink);
  border-radius: 11px;
  box-shadow: 0 3px 0 var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 7px 6px;
  position: relative;
  cursor: grab;
  transition: transform 100ms ease;
  flex-shrink: 0;
}
.game-card:hover {
  transform: translateY(-3px);
}
.game-card.isolated {
  border-style: solid;
  cursor: pointer;
}
.game-card.matched {
  outline: 3px solid var(--foil);
  outline-offset: 2px;
}
.card-title {
  font-family: var(--font-head);
  font-size: 14px;
  line-height: 1.1;
  text-align: center;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-art {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-cd {
  position: absolute;
  top: -7px;
  left: -7px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  border: 2px solid var(--paper);
  font-family: var(--font-head);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-tag-dot {
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  border: 1.5px solid var(--ink);
}
.card-info-btn {
  font-size: 11px;
  opacity: 0.78;
  text-decoration: underline;
  cursor: pointer;
}

/* 手牌/收纳轨 */
.hand-tray {
  background: rgba(255, 255, 255, 0.82);
  border: 2px solid var(--ink);
  border-radius: 14px;
  padding: 14px 16px;
}
.hand-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--muted);
}
.hand-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  min-height: 120px;
  align-items: center;
}

/* 底栏控制 */
.bottom-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  background: rgba(252, 251, 248, 0.96);
  border-top: 2px solid var(--ink);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.ctrl-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* 结算横幅 */
.result-banner {
  margin: 0 18px;
  padding: 12px 16px;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 4px 0 var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.result-banner.win { background: #F1FDE8; }
.result-banner.fail { background: #FFF4F4; }

/* 弹窗（卡牌检视 / 教程阅读 / 提示） */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(18, 18, 26, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.inspect-card {
  width: 100%;
  max-width: 460px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 8px 0 var(--ink);
  padding: 20px;
}

/* 吐司提示 */
#toast-layer {
  position: fixed;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast-msg {
  background: var(--ink);
  color: var(--paper);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}

/* 编辑器与管理后台面板 */
.panel-box {
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 4px 0 var(--ink);
  padding: 18px;
  margin-bottom: 18px;
}
.panel-title {
  font-family: var(--font-head);
  font-size: 22px;
  margin: 0 0 12px;
}
.split-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 860px) {
  .split-2 { grid-template-columns: 1fr; }
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table .session-limit { width: 4em; }
.data-table th, .data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--desk-line);
  text-align: left;
}
.curation-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  padding: 8px;
  border: 1.5px solid var(--desk-line);
  border-radius: 10px;
}
.matrix-item {
  font-size: 12px;
  padding: 5px 8px;
  border-radius: 7px;
  border: 1.5px solid var(--ink);
  background: #F6FEF0;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 4px;
}
.matrix-item.off {
  background: var(--disabled-bg);
  color: var(--disabled-fg);
  border-color: #C5C2D1;
  text-decoration: line-through;
}
