/* Song-Dynasty Movable Type UI Components */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--ink-border);
  background: linear-gradient(180deg, #30271f 0%, #231c16 100%);
  color: var(--paper-bright);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.16s ease, background 0.16s ease;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  border-color: var(--gold-foil);
  background: linear-gradient(180deg, #3c3126 0%, #2b221b 100%);
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn-gold {
  color: #1e150b;
  background: linear-gradient(180deg, #f3cf80 0%, #cc963c 100%);
  border-color: #ffe8a8;
  font-weight: 700;
}

.btn-gold:hover:not(:disabled) {
  background: linear-gradient(180deg, #fae09f 0%, #dda548 100%);
  border-color: #fff3cb;
}

.btn-cinnabar {
  color: #fff5ea;
  background: linear-gradient(180deg, #de4c3f 0%, #a82820 100%);
  border-color: #f39586;
}

.btn-cinnabar:hover:not(:disabled) {
  background: linear-gradient(180deg, #ee5b4d 0%, #bd3128 100%);
}

.btn-active-tool {
  border-color: var(--cinnabar-bright) !important;
  background: linear-gradient(180deg, #54221d 0%, #381713 100%) !important;
  color: #ffd9d2 !important;
  box-shadow: 0 0 12px rgba(217, 65, 54, 0.35);
}

.btn-sm {
  padding: 4px 9px;
  font-size: 12px;
  border-radius: 6px;
}

/* Cards inside Sidebar */
.scroll-card {
  background: linear-gradient(180deg, rgba(41, 34, 28, 0.92) 0%, rgba(28, 23, 19, 0.95) 100%);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  box-shadow: var(--shadow-block);
}

.scroll-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px dashed rgba(212, 179, 118, 0.22);
}

.scroll-card-title {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--gold-foil);
  margin: 0;
}

/* Level Badge & Selector */
.level-pill {
  display: flex;
  align-items: center;
  gap: 8px;
}

.level-num {
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--cinnabar-soft);
  border: 1px solid rgba(217, 65, 54, 0.55);
  color: #ffb0a4;
  font-size: 12px;
  font-weight: 700;
}

.level-title-text {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 800;
  color: var(--paper-bright);
  letter-spacing: 0.08em;
}

.level-vol-badge {
  font-size: 11.5px;
  color: var(--paper-muted);
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(230, 184, 92, 0.09);
  border: 1px solid rgba(230, 184, 92, 0.22);
}

.hud-metrics {
  display: flex;
  align-items: center;
  gap: 10px;
}

.metric-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 7px;
  background: rgba(15, 13, 11, 0.72);
  border: 1px solid var(--ink-border);
  font-size: 12px;
  color: var(--paper-muted);
}

.metric-chip strong {
  color: var(--gold-bright);
  font-size: 13.5px;
}

/* Poetic Banner */
.poetic-text {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--paper-bright);
}

.hint-box {
  margin-top: 8px;
  padding: 7px 9px;
  border-radius: 7px;
  background: rgba(230, 184, 92, 0.09);
  border-left: 3px solid var(--gold-foil);
  font-size: 12px;
  line-height: 1.5;
  color: #ecd6a5;
}

.hint-box.hidden {
  display: none;
}

/* Glyph Tray (字匣) */
.tray-dropzone {
  min-height: 72px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(14, 12, 10, 0.78);
  border: 1.5px dashed rgba(212, 179, 118, 0.32);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.tray-dropzone.drop-active {
  border-color: var(--gold-bright);
  background: rgba(230, 184, 92, 0.14);
}

.tray-empty {
  width: 100%;
  text-align: center;
  font-size: 12px;
  color: var(--paper-dim);
  align-self: center;
  padding: 12px 0;
}

/* Woodblock Glyph Chip (Tray / Hand / Codex) */
.glyph-chip {
  position: relative;
  width: 50px;
  height: 50px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 25px;
  font-weight: 900;
  color: #fff6e6;
  background: linear-gradient(160deg, #3c3024 0%, #241c15 100%);
  border: 1.5px solid #b89460;
  box-shadow: 0 4px 0 #140f0b, 0 6px 12px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 236, 195, 0.25);
  cursor: grab;
  transition: transform 0.13s ease, box-shadow 0.13s ease, border-color 0.13s ease;
}

.glyph-chip:hover {
  transform: translateY(-2px);
  border-color: var(--gold-bright);
  box-shadow: 0 6px 0 #140f0b, 0 8px 16px rgba(230, 184, 92, 0.28);
}

.glyph-chip.selected {
  transform: translateY(-4px) scale(1.05);
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 2px rgba(255, 226, 148, 0.45), 0 8px 18px rgba(230, 184, 92, 0.35);
}

.glyph-chip.match-glow {
  border-color: var(--gold-bright);
  box-shadow: 0 0 16px rgba(255, 226, 148, 0.55), 0 4px 0 #140f0b;
  animation: pulseGold 1.1s infinite ease-in-out;
}

.glyph-chip .chip-sub {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 700;
  opacity: 0.8;
}

.glyph-chip .chip-split-mark {
  position: absolute;
  top: 2px;
  right: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold-foil);
  opacity: 0.78;
}

@keyframes pulseGold {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 226, 148, 0.38), 0 4px 0 #140f0b; }
  50% { box-shadow: 0 0 18px rgba(255, 226, 148, 0.8), 0 4px 0 #140f0b; }
}

/* Inspector Card */
.inspector-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.inspector-glyph {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 900;
  border: 1.5px solid var(--gold-foil);
  flex-shrink: 0;
}

.inspector-meta {
  min-width: 0;
  flex: 1;
}

.inspector-title-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.inspector-pinyin {
  font-size: 12px;
  color: var(--gold-foil);
  font-family: var(--font-mono);
}

.inspector-decomp {
  font-size: 12.5px;
  color: var(--paper-bright);
  margin-top: 2px;
}

.inspector-meaning {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--paper-muted);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.mini-tag {
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 240, 210, 0.08);
  border: 1px solid rgba(255, 240, 210, 0.14);
  color: var(--paper-main);
}

/* Status Message Bar */
.status-msg {
  color: var(--paper-bright);
  font-family: var(--font-serif);
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shortcut-guide {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  color: var(--paper-muted);
  flex-shrink: 0;
}

.kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 245, 225, 0.1);
  border: 1px solid rgba(255, 245, 225, 0.22);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold-bright);
}

/* Roguelike Components */
.boss-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(28, 20, 17, 0.85);
  border: 1px solid rgba(217, 65, 54, 0.35);
}

.hp-bar-wrap {
  width: 240px;
  height: 14px;
  border-radius: 99px;
  background: #120e0c;
  border: 1px solid rgba(255, 240, 215, 0.2);
  overflow: hidden;
  position: relative;
}

.hp-bar-fill {
  height: 100%;
  transition: width 0.25s ease;
}

.hp-bar-fill.enemy {
  background: linear-gradient(90deg, #b82920, #ee5b47);
}

.hp-bar-fill.player {
  background: linear-gradient(90deg, #3c8c62, #76ce9a);
}

.siege-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex: 1;
}

.siege-label {
  font-family: var(--font-serif);
  font-size: 13px;
  letter-spacing: 0.16em;
  color: var(--paper-muted);
}

.siege-glyphs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.siege-card {
  width: 124px;
  padding: 12px 10px;
  border-radius: 12px;
  background: linear-gradient(160deg, #2d211d 0%, #1a1311 100%);
  border: 1.5px solid rgba(240, 106, 67, 0.65);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, opacity 0.2s ease;
  position: relative;
}

.siege-card:hover:not(.disabled) {
  transform: translateY(-4px) scale(1.03);
  border-color: var(--gold-bright);
}

.siege-card.disabled {
  opacity: 0.32;
  filter: grayscale(0.75);
  border-style: dashed;
  cursor: default;
}

.siege-char {
  font-family: var(--font-serif);
  font-size: 46px;
  font-weight: 900;
  line-height: 1.05;
  color: #fff4e0;
  text-shadow: 0 3px 12px rgba(240, 106, 67, 0.5);
}

.siege-intent {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(217, 65, 54, 0.22);
  color: #ffb7aa;
}

.siege-slash-tip {
  font-size: 11px;
  color: var(--gold-foil);
}

.rogue-player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(24, 20, 16, 0.9);
  border: 1px solid var(--ink-border);
}

.ap-orbs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ap-orb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff0b8, #d49b3c 70%);
  border: 1.5px solid #fff3c9;
  box-shadow: 0 0 10px rgba(230, 184, 92, 0.55);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: #24170a;
}

.ap-orb.spent {
  background: #1d1813;
  border-color: #4a3d30;
  box-shadow: none;
  color: #6b5b49;
}

.hand-cards {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hand-chip {
  width: 64px;
  height: 68px;
  font-size: 30px;
  flex-direction: column;
  gap: 2px;
}

.hand-chip .hand-label {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--paper-muted);
  font-weight: 500;
}

.rogue-synth-preview {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: var(--gold-bright);
}

.relic-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.relic-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 7px;
  background: rgba(230, 184, 92, 0.12);
  border: 1px solid rgba(230, 184, 92, 0.35);
  font-size: 12px;
  color: var(--paper-bright);
  cursor: help;
}

.battle-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  line-height: 1.45;
}

.log-line {
  padding: 4px 7px;
  border-radius: 6px;
  background: rgba(14, 12, 10, 0.55);
  border-left: 2.5px solid var(--ink-border);
}
.log-line.cast { border-left-color: var(--gold-foil); color: #f6e7c4; }
.log-line.slash { border-left-color: var(--water-bright); color: #cdeeff; }
.log-line.danger { border-left-color: var(--cinnabar-bright); color: #ffc5ba; }
.log-line.victory { border-left-color: var(--jade-green); color: #c7f0d7; }
.log-line.boss { border-left-color: var(--thunder-violet); color: #e2d1ff; font-weight: 700; }

/* Codex Grid & Forge */
.codex-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: rgba(31, 26, 21, 0.92);
  border: 1px solid var(--ink-border);
}

.input-ink {
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid var(--ink-border);
  background: #13100d;
  color: var(--paper-bright);
  font-size: 13px;
  outline: none;
}

.input-ink:focus {
  border-color: var(--gold-foil);
}

.codex-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 10px;
  padding-right: 4px;
  align-content: start;
}

.codex-item {
  padding: 10px 12px;
  border-radius: 10px;
  background: linear-gradient(180deg, #27201a 0%, #1c1713 100%);
  border: 1px solid var(--ink-border);
  display: flex;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.14s ease;
}

.codex-item:hover {
  border-color: var(--gold-foil);
  transform: translateY(-2px);
}

.codex-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.codex-char {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 900;
  color: var(--paper-bright);
}

.codex-formula {
  font-family: var(--font-serif);
  font-size: 13px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(230, 184, 92, 0.12);
  color: var(--gold-bright);
}

.codex-desc {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--paper-muted);
}

/* Modal & Overlay */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 4, 0.78);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-box {
  width: min(740px, 94vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  background: linear-gradient(180deg, #28211b 0%, #1a1511 100%);
  border: 1.5px solid var(--gold-foil);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.72), var(--shadow-glow-gold);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ink-border);
}

.modal-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 18px;
  letter-spacing: 0.1em;
  color: var(--gold-bright);
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.level-grid-modal {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.lvl-select-card {
  padding: 10px;
  border-radius: 9px;
  background: #1f1914;
  border: 1px solid var(--ink-border);
  text-align: left;
  cursor: pointer;
  color: var(--paper-main);
  transition: all 0.14s ease;
}

.lvl-select-card:hover {
  border-color: var(--gold-foil);
  transform: translateY(-2px);
}

.lvl-select-card.current {
  border-color: var(--cinnabar-bright);
  background: #2f1d19;
}

.lvl-select-card.cleared {
  border-color: rgba(109, 184, 140, 0.55);
}

/* Floating Toast (top-center safe band: never occludes board or roguelike hand cards) */
.toast-shelf {
  position: fixed;
  top: calc(var(--topbar-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 90;
  pointer-events: none;
  max-width: min(540px, 86vw);
}

.toast-item {
  padding: 8px 14px;
  border-radius: 8px;
  background: rgba(24, 19, 15, 0.94);
  border: 1px solid var(--gold-foil);
  color: var(--paper-bright);
  font-family: var(--font-serif);
  font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  animation: toastIn 0.2s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Reward Choice Overlay inside Roguelike */
.reward-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.reward-choice {
  padding: 12px;
  border-radius: 10px;
  background: linear-gradient(180deg, #2b231b 0%, #1d1712 100%);
  border: 1.5px solid var(--ink-border);
  cursor: pointer;
  text-align: left;
  color: var(--paper-main);
  transition: all 0.15s ease;
}

.reward-choice:hover,
.reward-choice.picked {
  border-color: var(--gold-bright);
  background: linear-gradient(180deg, #3b2f21 0%, #261e16 100%);
  transform: translateY(-2px);
}

/* Workshop Tool Buttons */
.brush-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.brush-btn {
  padding: 7px 6px;
  font-size: 12px;
  border-radius: 7px;
  border: 1px solid var(--ink-border);
  background: #231d17;
  color: var(--paper-main);
  cursor: pointer;
}

.brush-btn.active {
  border-color: var(--gold-bright);
  background: #3a2e1f;
  color: var(--gold-bright);
  font-weight: 700;
}

.share-preview-img {
  max-height: 58vh;
  width: auto;
  margin: 0 auto;
  border-radius: 8px;
  border: 1px solid var(--ink-border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}
