* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --t0: #8a97a8;
  --t1: #3b82f6;
  --t2: #a855f7;
  --t3: #f59e0b;
  --ink: #23304a;
  --card: #ffffff;
}

html, body { height: 100%; }
body {
  font-family: "Jua", "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  /* System fonts remain a readable fallback when web fonts are unavailable. */
  background: linear-gradient(180deg, #bfe3ff 0%, #dff3ff 45%, #e8f7dd 100%);
  color: var(--ink);
  padding: 10px;
}

/* Fit two columns to viewport height and scroll overflowing lists internally. Narrow-screen media queries restore a single scrolling column. */
.wrap {
  display: flex;
  gap: 12px;
  max-width: 1320px;
  height: calc(100dvh - 20px);
  margin: 0 auto;
  align-items: stretch;
}
.left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.right {
  width: 340px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}
/* Fixed top cards retain their size; tab contents use and scroll the remaining height. */
.right .fixed { flex: 0 0 auto; }
.tabbody {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Top bar. */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.topbar h1 { font-size: 25px; letter-spacing: -0.5px; }
.top-right { display: flex; gap: 8px; align-items: center; }
.weekly-badge {
  order: 3;
  margin-left: auto;
  border: 1px solid #d6bdff;
  border-radius: 999px;
  padding: 5px 10px;
  background: linear-gradient(135deg, #4b397f, #7554a8);
  color: #fff3bc;
  box-shadow: 0 2px 10px #59418c55;
  font-size: 11px;
  white-space: nowrap;
}
.playtest-badge { background: #196c75; border-color: #62d4de; }
.playtest-badge.invalid { background: #8a352f; border-color: #ff9d8e; }
.record {
  background: #fff7d6;
  border: 2px solid #f2cf5b;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  white-space: nowrap;
}
.record.shard { background: #efe6ff; border-color: #c4a8f0; }
#metaBtn {
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(180deg, #9d7bff, #6d43e8);
  box-shadow: 0 2px 0 #4d2bb0;
  font-family: inherit;
}
#metaBtn:active { transform: translateY(2px); box-shadow: none; }

/* Castle health bar with delayed damage trail. */
.castlebar-wrap { margin-bottom: 8px; }
.castlebar-label {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 3px;
  display: flex;
  justify-content: space-between;
}
.castlebar {
  position: relative;
  height: 20px;
  background: #d9e2ec;
  border-radius: 999px;
  overflow: hidden;
  border: 2px solid #b8c4d0;
}
#castleFill, #castleGhost {
  position: absolute;
  inset: 0 auto 0 0;
  height: 100%;
  border-radius: 999px;
}
#castleFill {
  background: linear-gradient(90deg, #ff5d5d, #ff9d5d);
  transition: width 0.15s;
  z-index: 2;
}
#castleGhost {
  background: #ffd76e;
  transition: width 0.6s ease 0.3s;   /* Show recently lost health as a trailing segment. */
  z-index: 1;
}

/* The 3D battlefield uses remaining vertical space, down to a 320px minimum before the page scrolls. */
.stage {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(30, 60, 90, 0.25);
  flex: 1;
  min-height: 320px;
  /* Cap battlefield height relative to the left-column width so a near-square canvas does not crop the camera's sides. */
  max-height: calc((min(100vw - 20px, 1320px) - 352px) / 1.6);
}
#scene3d {
  width: 100%;
  height: 100%;
  background: #bfe3ff;
}
/* Canvas touch gestures drag heroes rather than scroll the page. */
#scene3d canvas { display: block; touch-action: none; }
/* Use a grabbing cursor while dragging. */
#scene3d.dragging, #scene3d.dragging canvas { cursor: grabbing; }

#bossBanner {
  position: absolute;
  top: 16%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(120, 10, 10, 0.88);
  color: #ffd93d;
  font-size: 26px;
  font-weight: 900;
  padding: 12px 34px;
  border-radius: 14px;
  border: 3px solid #ffd93d;
  z-index: 8;
  animation: bossin 0.4s cubic-bezier(0.2, 1.6, 0.4, 1);
  white-space: nowrap;
}
#bossBanner.mid {
  background: rgba(120, 60, 10, 0.88);
  border-color: #ffa040;
  color: #ffd9a0;
  font-size: 21px;
  padding: 9px 26px;
}
@keyframes bossin { from { transform: translateX(-50%) scale(0.3); opacity: 0; } }

/* Boss arrival is framed around the live 3D actor, not a separate stale image. */
.stage::before,
.stage::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  z-index: 7;
  height: 10%;
  background: rgba(9, 10, 22, .78);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}
.stage::before { top: 0; }
.stage::after { bottom: 0; }
.stage.boss-cutscene::before,
.stage.boss-cutscene::after { opacity: 1; }
#bossBanner.cutscene-title {
  top: auto;
  bottom: 5.2%;
  display: grid;
  min-width: min(72%, 480px);
  gap: 1px;
  border: 0;
  border-radius: 8px;
  padding: 7px 18px 8px;
  background: rgba(12, 12, 28, .92);
  color: #fff;
  text-align: left;
  box-shadow: 0 0 0 1px #f0cf7166;
}
#bossBanner.cutscene-title small { color: #f0cf71; font-size: 9px; letter-spacing: .2em; }
#bossBanner.cutscene-title b { font-size: 23px; line-height: 1; }
#bossBanner.cutscene-title span { color: #d6d8e6; font-size: 10px; }
#bossBanner.cutscene-title.mid b { font-size: 19px; }

/* Incoming enemy warning banner. */
#bossWarnBanner {
  position: absolute;
  top: 28%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 12, 12, 0.82);
  color: #ff9a3d;
  border: 2px dashed #ff9a3d;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 900;
  padding: 8px 22px;
  z-index: 8;
  white-space: nowrap;
  box-shadow: 0 0 0 2px rgba(255, 154, 61, 0.18);
}
#bossWarnBanner.great {
  color: #ff5252;
  border-color: #ff5252;
  border-style: solid;
  font-size: 21px;
}
#comboChip {
  position: absolute;
  top: 10px;
  right: 12px;
  background: rgba(30, 34, 48, 0.82);
  color: #ffd0a0;
  font-weight: 800;
  font-size: 14px;
  padding: 6px 14px;
  border-radius: 999px;
  z-index: 6;
  white-space: nowrap;
  border: 1.5px solid rgba(255, 157, 61, 0.6);
}
/* Emphasize active gold multipliers. */
#comboChip.boost {
  background: linear-gradient(180deg, #ff9d3d, #ff6a00);
  color: #fff;
  font-size: 15px;
  border-color: #ffd93d;
  box-shadow: 0 3px 12px rgba(255, 106, 0, 0.55);
}
#comboChip.pop { animation: combopop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes combopop { 0% { transform: scale(1.5); } 100% { transform: scale(1); } }

/* Summarize tactic, lane and result on the battlefield so players returning their gaze from the board can understand the effect. */
.tactic-impact {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 164px;
  padding: 6px 10px 6px 7px;
  border: 2px solid #ffcf83;
  border-radius: 13px;
  color: #fff;
  background: rgba(61, 32, 71, 0.84);
  box-shadow: 0 4px 14px rgba(21, 14, 38, 0.34), inset 0 0 16px rgba(255, 231, 165, 0.15);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px) scale(.9);
}
.tactic-impact.show { animation: tactic-impact-in .18s cubic-bezier(.18, 1.5, .4, 1) both, tactic-impact-out .25s ease-in forwards 1.4s; }
.tactic-impact-icon { display: grid; place-items: center; width: 33px; height: 33px; border-radius: 10px; font-size: 22px; background: linear-gradient(135deg, #ffae68, #d9574f); box-shadow: 0 0 13px #ffb15e; }
.tactic-impact-copy { display: grid; gap: 1px; line-height: 1.05; }
.tactic-impact-copy b { font-size: 14px; letter-spacing: -.3px; }
.tactic-impact-copy small { color: #ffe8c4; font-size: 10px; font-weight: 800; }
.tactic-impact[data-kind="tide"] { border-color: #9feaff; background: rgba(23, 57, 100, .84); }
.tactic-impact[data-kind="tide"] .tactic-impact-icon { background: linear-gradient(135deg, #bdf7ff, #4b91dc); box-shadow: 0 0 13px #70dfff; }
.tactic-impact[data-kind="bloom"] { border-color: #b8ffac; background: rgba(28, 83, 62, .84); }
.tactic-impact[data-kind="bloom"] .tactic-impact-icon { background: linear-gradient(135deg, #dbffc3, #54ad77); box-shadow: 0 0 13px #99ee90; }
.tactic-impact.preview { opacity: .82; }
.tactic-impact[data-match-size="5"] {
  min-width: 270px;
  border-width: 2px;
  background: linear-gradient(115deg, rgba(31, 21, 79, .96), rgba(114, 42, 102, .94));
  box-shadow: 0 0 0 2px #fff2b555, 0 0 32px #be76ffcc, inset 0 0 20px #fff2b522;
}
.tactic-impact[data-match-size="5"] .tactic-impact-icon {
  width: 48px;
  height: 48px;
  font-size: 32px;
}
.tactic-impact[data-match-size="5"] .tactic-impact-copy b {
  color: #fff2b5;
  font-size: 19px;
  letter-spacing: .8px;
  text-shadow: 0 0 12px #ffdf75;
}
.tactic-impact[data-match-size="5"] .tactic-impact-copy small { color: #fff; font-size: 12px; }
.tactic-impact[data-match-size="6"] {
  min-width: 290px;
  border: 2px solid #fff1a8;
  background: linear-gradient(115deg, rgba(35, 20, 84, .97), rgba(137, 54, 118, .95));
  box-shadow: 0 0 0 2px #ffffff66, 0 0 38px #d489ffcc, inset 0 0 24px #ffe9a833;
}
.tactic-impact[data-match-size="6"] .tactic-impact-icon { width: 52px; height: 52px; font-size: 35px; }
.tactic-impact[data-match-size="6"] .tactic-impact-copy b { color: #fff0a8; font-size: 20px; letter-spacing: 1px; text-shadow: 0 0 14px #ffd76a; }
.tactic-impact[data-match-size="6"] .tactic-impact-copy small { color: #fff; font-size: 12px; }
@keyframes tactic-impact-in { 0% { opacity: 0; transform: translateY(-12px) scale(.78); } 65% { opacity: 1; transform: translateY(1px) scale(1.07); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes tactic-impact-out { to { opacity: 0; transform: translateY(-7px) scale(.96); } }

#waveInfo {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 32, 50, 0.75);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 6px 16px;
  border-radius: 999px;
  z-index: 6;
}

#wavePreview {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid #cdd6e2;
  padding: 5px 12px;
  border-radius: 999px;
  z-index: 6;
  font-size: 13px;
}
#wavePreview .wlabel { font-weight: 800; color: #4a5a74; font-size: 12px; margin-right: 2px; }
#wavePreview .wchip {
  background: #f2f6fa;
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 700;
}
#wavePreview .wchip.boss {
  background: #ffe3e3;
  border: 1.5px solid #ff8a8a;
}
#wavePreview .wchip.midboss {
  background: #fff0e0;
  border: 1.5px solid #ffb073;
}

#bossBar {
  position: absolute;
  top: 44px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(62%, 440px);
  background: rgba(40, 10, 10, 0.8);
  border: 2px solid #ff6a6a;
  border-radius: 999px;
  padding: 5px 14px;
  z-index: 6;
  font-size: 13px;
  font-weight: 800;
  color: #ffd9d9;
}
#bossBar.mid {
  border-color: #ffa040;
  background: rgba(45, 26, 8, 0.8);
  color: #ffdcb0;
  width: min(52%, 360px);
}
#bossBar.enraged { border-color: #ff3030; box-shadow: 0 0 0 2px rgba(255, 48, 48, .2); }
#bossBarName { white-space: nowrap; }
#bossBar .bossbar-track {
  flex: 1;
  height: 12px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  overflow: hidden;
}
#bossBarFill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff5d5d, #c084fc);
  transition: width 0.2s;
}
#bossBar.mid #bossBarFill { background: linear-gradient(90deg, #ff8a3d, #ffc93d); }

.phase-countdown {
  position: absolute;
  top: 15%; left: 50%; transform: translateX(-50%);
  z-index: 9; display: grid; grid-template-columns: auto auto; align-items: center; gap: 0 9px;
  min-width: min(82%, 310px); padding: 10px 16px 9px; border: 2px solid #ffe08a; border-radius: 15px;
  background: rgba(31, 35, 73, .9); color: #fff7d5; box-shadow: 0 8px 24px rgba(20, 18, 55, .35);
  text-align: center; pointer-events: none;
}
.phase-countdown > span { font-size: 13px; font-weight: 900; }
.phase-countdown > b { min-width: 36px; color: #ffe36d; font-size: 29px; line-height: 1; text-shadow: 0 0 10px rgba(255, 220, 92, .42); }
.phase-countdown > small { grid-column: 1 / -1; margin-top: 3px; color: #d9dcff; font-size: 10px; font-weight: 700; }

.defense-victory {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px;
  background: rgba(9, 13, 34, .44); pointer-events: auto;
}
.defense-victory-card {
  width: min(420px, 100%); padding: 24px 26px; border: 2px solid #ffe18a; border-radius: 19px;
  background: linear-gradient(145deg, rgba(46, 35, 96, .98), rgba(23, 48, 88, .98));
  box-shadow: 0 18px 52px rgba(0, 0, 0, .44), inset 0 1px rgba(255,255,255,.25); text-align: center;
}
.defense-victory-card > span { color: #ffe27a; font-size: 13px; font-weight: 900; letter-spacing: .16em; }
.defense-victory-card h2 { margin: 5px 0 8px; color: #fff8d7; font-size: 25px; }
.defense-victory-card p { color: #d9e6ff; font-size: 13px; line-height: 1.55; }

.wave-btn {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  font-size: 20px;
  font-weight: 800;
  padding: 12px 28px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffd93d, #ffb302);
  color: #5b3d00;
  cursor: pointer;
  box-shadow: 0 4px 0 #c98a00, 0 8px 18px rgba(0, 0, 0, 0.25);
  font-family: inherit;
  z-index: 6;
}
.wave-btn:hover { filter: brightness(1.06); }
.wave-btn:active { transform: translateX(-50%) translateY(3px); box-shadow: 0 1px 0 #c98a00; }
.wave-btn.auto-next {
  outline: 2px solid rgba(255, 246, 191, .82);
  outline-offset: 3px;
}

#coachChip {
  position: absolute;
  bottom: 76px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.96);
  border: 2px solid #4da3ff;
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 13px;
  line-height: 1.6;
  z-index: 7;
  width: min(92%, 520px);
  box-shadow: 0 6px 18px rgba(30, 60, 90, 0.3);
  animation: coachin 0.5s ease-out;
}
@keyframes coachin { from { opacity: 0; transform: translateX(-50%) translateY(10px); } }

#toasts {
  position: absolute;
  top: 46px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  pointer-events: none;
  width: 90%;
  /* Keep important guidance above modal scrims at z-index 50. */
  z-index: 60;
}
.toast {
  background: rgba(20, 32, 50, 0.85);
  color: #fff;
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  animation: toast-in 0.25s ease-out, toast-out 0.4s ease-in forwards;
  animation-delay: 0s, 2.2s;
  max-width: 100%;
}
.toast.good { background: rgba(22, 130, 60, 0.92); }
.toast.bad  { background: rgba(190, 40, 40, 0.92); }
@keyframes toast-in  { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(-8px); } }

/* Collapse controls instructions behind a help toggle beneath the battlefield. */
.under-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.helpbtn {
  margin-left: auto;
  border: 2px solid #cdd6e2;
  background: #f2f6fa;
  border-radius: 999px;
  padding: 4px 14px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  color: #5a6a84;
}
.helpbtn.on { border-color: #2478e0; background: #e3f0ff; color: #1a5cb0; }
.helpbox {
  margin-top: 6px;
  background: #eef4fb;
  border: 1px solid #d5e2f2;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  line-height: 1.7;
  color: #35507a;
}
.helpbox.hidden { display: none; }
.helpbox p + p { margin-top: 3px; }
.helpbox b {
  background: #fff;
  border: 1px solid #b8c9e0;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 4px;
}
.difficulty {
  display: flex;
  gap: 6px;
  align-items: center;
}
.difficulty .dlabel { font-size: 13px; font-weight: 700; color: #4a5a74; }
.difficulty button {
  border: 2px solid #cdd6e2;
  background: #f2f6fa;
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  color: #5a6a84;
  font-family: inherit;
}
.difficulty button.on { border-color: #2478e0; background: #e3f0ff; color: #1a5cb0; }
.difficulty button:disabled { opacity: 0.55; cursor: not-allowed; }
.kbd {
  display: inline-block;
  background: #f2f6fa;
  border: 1px solid #cdd6e2;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 800;
  color: #5a6a84;
  margin-left: 3px;
}

/* Cards. */
.card {
  background: var(--card);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 3px 10px rgba(30, 60, 90, 0.12);
}
.card h2 { font-size: 15px; margin-bottom: 8px; }
.card h2 .sub { font-size: 11px; font-weight: 500; color: #7a879c; margin-left: 4px; }

.card.fixed { padding: 9px 10px; }
.statrow {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
}
.stat b { font-size: 17px; }
/* Compact legacy selector beneath the statistics row. */
.gradebar {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px dashed #e3e9f2;
}
.gradebar .glabel {
  font-size: 12px;
  font-weight: 800;
  color: #4a5a74;
  white-space: nowrap;
  cursor: help;
}

/* Right-panel tabs. */
.tabs { display: flex; gap: 6px; flex: 0 0 auto; }
.tabs button {
  flex: 1;
  position: relative;
  border: 2px solid #cdd6e2;
  border-bottom: none;
  background: #e9eff7;
  border-radius: 10px 10px 0 0;
  padding: 7px 0 8px;
  cursor: pointer;
  font-weight: 800;
  font-size: 13px;
  color: #5a6a84;
}
.tabs button.on {
  background: #fff;
  border-color: #2478e0;
  color: #1a5cb0;
  margin-bottom: -2px;
  padding-bottom: 10px;
}
.tabdot {
  position: absolute;
  top: 4px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff5d5d;
}
.tabdot.hidden { display: none; }
.pane.hidden { display: none; }
/* Square upper corners join the panel to the tab bar. */
.tabbody .pane { border-radius: 0 0 14px 14px; }
.minibtns {
  min-width: 0;
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.minibtns button {
  border: 1px solid #cdd6e2;
  background: #f2f6fa;
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  white-space: nowrap;
}
/* Muted sound buttons use subdued gray styling. */
.minibtns button.off {
  background: #e3e7ee;
  color: #98a3b4;
  border-color: #c3cbd8;
  text-decoration: line-through;
}
.minibtns #effectsBtn.calm {
  background: #e9edf4;
  color: #56657b;
  border-color: #bfc9d7;
}

/* Buttons. */
button { font-family: inherit; }
.big {
  width: 100%;
  padding: 11px;
  font-size: 16px;
  font-weight: 800;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: #fff;
}
.big.blue  { background: linear-gradient(180deg, #4da3ff, #2478e0); box-shadow: 0 3px 0 #1a5cb0; }
.big.amber { background: linear-gradient(180deg, #ffc24d, #ff9800); box-shadow: 0 3px 0 #c76a00; }
.big:active { transform: translateY(2px); box-shadow: none; }
.big:disabled { background: #c5cedb; box-shadow: none; cursor: not-allowed; }

/* Legacy selector styling. */
.grades { display: flex; gap: 5px; flex: 1; }
.grades button {
  flex: 1;
  padding: 7px 0;
  border-radius: 8px;
  border: 2px solid #cdd6e2;
  background: #f2f6fa;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  color: #5a6a84;
}
.grades button.on { border-color: #2478e0; background: #e3f0ff; color: #1a5cb0; }

/* Summon reveal card. */
.reveal {
  position: absolute;
  top: 34%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.97);
  border: 4px solid var(--t0);
  border-radius: 18px;
  padding: 14px 26px;
  text-align: center;
  z-index: 9;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.4);
}
.reveal .rv-em { font-size: 52px; line-height: 1.1; }
.reveal .rv-tier { font-size: 14px; font-weight: 900; }
.reveal .rv-name { font-size: 18px; font-weight: 800; }
.reveal.t0 { border-color: var(--t0); }
.reveal.t1 { border-color: var(--t1); }
.reveal.t2 { border-color: var(--t2); box-shadow: 0 0 30px rgba(168, 85, 247, 0.75); }
.reveal.t3 {
  border-color: var(--t3);
  box-shadow: 0 0 44px rgba(255, 217, 61, 0.9);
  animation: legendglow 0.8s ease-in-out infinite alternate;
}
@keyframes legendglow {
  from { box-shadow: 0 0 30px rgba(255, 217, 61, 0.7); }
  to   { box-shadow: 0 0 60px rgba(255, 217, 61, 1); }
}
.reveal.pop { animation: revealpop 0.45s cubic-bezier(0.2, 1.7, 0.4, 1); }
.reveal.t3.pop { animation: revealpop 0.45s cubic-bezier(0.2, 1.7, 0.4, 1), legendglow 0.8s ease-in-out 0.45s infinite alternate; }
@keyframes revealpop {
  0%   { transform: translate(-50%, -50%) scale(0.2) rotate(-12deg); opacity: 0; }
  60%  { transform: translate(-50%, -50%) scale(1.14) rotate(3deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1) rotate(0); }
}

/* Bench. */
.benchhint {
  background: #e8ffe3;
  border: 2px dashed #45b02e;
  color: #2a7a1a;
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  padding: 6px;
  margin-top: 8px;
}
.bench {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 8px;
  min-height: 40px;
}
.squad-intro { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; color: #4a456f; }
.squad-intro b { color: #5f469e; font-size: 15px; }
.squad-intro span { font-size: 11px; color: #6f7890; }
#benchCard .sellbar { display: none; }
.squad-card { position: relative; min-width: 0; text-align: left; cursor: pointer; font-family: inherit; }
.squad-card .tr { font-size: 10px; color: #65718d; white-space: nowrap; }
.squad-card .rg { margin-top: 3px; }
.squad-point { position: absolute; top: -6px; right: -4px; display: grid; place-items: center; min-width: 20px; height: 20px; border-radius: 999px; background: #ffca57; color: #5b3d00; border: 2px solid #fff; font-size: 11px; font-weight: 900; }
.hero-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.hero-card {
  position: relative; isolation: isolate; min-width: 0; min-height: 176px; overflow: hidden;
  display: grid; grid-template-columns: 62px minmax(0, 1fr); grid-template-areas: 'art copy' 'ability ability' 'stats stats' 'growth growth'; gap: 5px;
  padding: 8px; border: 1px solid color-mix(in srgb, var(--hero-card-accent) 58%, #ffffff); border-radius: 14px;
  background: linear-gradient(145deg, #ffffff 0%, color-mix(in srgb, var(--hero-card-accent) 12%, #fafcff) 100%);
  box-shadow: 0 4px 10px rgba(43, 54, 87, .10); color: #29324c; font-family: inherit; text-align: left; cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.hero-card::before { content: ''; position: absolute; z-index: -1; width: 120px; height: 120px; right: -47px; top: -56px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--hero-card-accent) 38%, transparent) 0 8%, transparent 9% 17%, color-mix(in srgb, var(--hero-card-accent) 17%, transparent) 18% 32%, transparent 33%); opacity: .88; }
.hero-card::after { content: ''; position: absolute; z-index: -1; inset: 0; opacity: .24; background-image: radial-gradient(circle at 18% 20%, var(--hero-card-accent) 0 1px, transparent 1.7px), radial-gradient(circle at 78% 74%, var(--hero-card-deep) 0 1px, transparent 1.8px); background-size: 29px 29px, 41px 41px; pointer-events: none; }
.hero-card:hover { transform: translateY(-2px); border-color: var(--hero-card-accent); box-shadow: 0 9px 18px color-mix(in srgb, var(--hero-card-deep) 21%, transparent); }
.hero-card:focus-visible { outline: 3px solid #f5bd5d; outline-offset: 2px; }
.hero-card.sel { border: 2px solid var(--hero-card-deep); padding: 7px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--hero-card-accent) 28%, transparent), 0 8px 18px color-mix(in srgb, var(--hero-card-deep) 20%, transparent); }
.hero-card.ready .hero-card-growth b { color: #8e5710; }
.hero-card-art { grid-area: art; position: relative; display: grid; place-items: center; width: 58px; height: 58px; overflow: hidden; border: 1px solid color-mix(in srgb, var(--hero-card-accent) 54%, #ffffff); border-radius: 19px; background: radial-gradient(circle at 35% 26%, #fff 0 6%, color-mix(in srgb, var(--hero-card-accent) 62%, #f5f0ff) 35%, var(--hero-card-deep) 100%); box-shadow: inset 0 1px rgba(255,255,255,.55), 0 4px 9px color-mix(in srgb, var(--hero-card-deep) 22%, transparent); }
.hero-card-constellation { position: absolute; top: -12px; right: -3px; color: #fff8bf; font-size: 39px; font-style: normal; opacity: .70; transform: rotate(-15deg); }
.hero-card-crest { position: relative; z-index: 1; color: #fffdf5; font-size: 29px; font-style: normal; filter: drop-shadow(0 2px 2px rgba(0,0,0,.25)); }
.hero-card-spark { position: absolute; color: #fff9cf; font-size: 13px; font-style: normal; }.hero-card-spark.spark-a { left: 8px; top: 7px; }.hero-card-spark.spark-b { right: 9px; bottom: 6px; font-size: 21px; }
.hero-card-copy { grid-area: copy; min-width: 0; align-self: center; }.hero-card-copy > * { display: block; }.hero-card-role { color: var(--hero-card-deep); font-size: 9px; font-weight: 900; letter-spacing: .04em; }.hero-card-name { overflow: hidden; color: #28304c; font-size: 16px; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }.hero-card-title { overflow: hidden; margin-top: 2px; color: #68728c; font-size: 9.5px; text-overflow: ellipsis; white-space: nowrap; }
.hero-card-ability { grid-area: ability; display: flex; align-items: center; gap: 5px; min-width: 0; padding: 4px 5px; border-radius: 8px; background: color-mix(in srgb, var(--hero-card-accent) 13%, #ffffff); color: #4b5570; }.hero-card-ability > i { display: grid; place-items: center; flex: 0 0 18px; width: 18px; height: 18px; border-radius: 6px; background: var(--hero-card-deep); color: #fff; font-size: 11px; font-style: normal; }.hero-card-ability span { display: block; min-width: 0; }.hero-card-ability small, .hero-card-ability b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.hero-card-ability small { color: var(--hero-card-deep); font-size: 8.5px; font-weight: 900; }.hero-card-ability b { font-size: 9.5px; }
.hero-card-stats { grid-area: stats; display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }.hero-card-stats > span { padding: 3px 2px; border-radius: 7px; background: rgba(255,255,255,.66); text-align: center; }.hero-card-stats small, .hero-card-stats b { display: block; }.hero-card-stats small { color: #7a8499; font-size: 8px; font-weight: 800; }.hero-card-stats b { color: #35405b; font-size: 11px; }
.hero-card-growth { grid-area: growth; display: block; }.hero-card-growth > span { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; }.hero-card-growth b { color: var(--hero-card-deep); font-size: 10px; }.hero-card-growth small { overflow: hidden; color: #778197; font-size: 8.5px; text-overflow: ellipsis; white-space: nowrap; }.hero-card-growth > i { display: block; height: 5px; margin-top: 3px; overflow: hidden; border-radius: 999px; background: rgba(75, 89, 122, .14); }.hero-card-growth > i > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--hero-card-accent), var(--hero-card-deep)); transition: width .2s ease; }
.growth-note { margin: 0 0 9px; color: #64708b; font-size: 12px; line-height: 1.4; }
.growth-hero { padding: 10px; border: 1px solid #d5d9ea; border-radius: 12px; background: linear-gradient(135deg, #fbfcff, #f4f0ff); margin-bottom: 8px; }
.growth-hero header { display: flex; justify-content: space-between; align-items: baseline; color: #343457; }
.growth-hero header small { color: #69748c; font-size: 11px; }
.growth-hero header strong { color: #8057c7; font-size: 14px; }
.growth-hero p { margin: 5px 0 7px; color: #66718a; font-size: 11px; }
.growth-xp { height: 6px; overflow: hidden; border-radius: 999px; background: #e2e7f3; }
.growth-xp i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #69b7f5, #a56eea); transition: width .2s ease; }
.growth-skills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.growth-skill { min-height: 52px; padding: 5px; border: 1px solid #d3d8e7; border-radius: 8px; background: #fff; color: #66718a; font-family: inherit; font-size: 10px; text-align: left; }
.growth-skill span, .growth-skill small { display: block; }
.growth-skill small { margin-top: 3px; line-height: 1.2; }
.growth-skill.ready { border-color: #c493ee; color: #4d357b; cursor: pointer; background: #fff9eb; box-shadow: 0 0 0 2px #f3ddff; }
.combine-row.feast { display: none; }

/* Constellation expedition map. */
.journey-modal {
  position: fixed; inset: 0; z-index: 45; overflow: auto; color: #f6f2ff;
  background:
    radial-gradient(circle at 22% 20%, rgba(115, 100, 225, .25), transparent 28%),
    radial-gradient(circle at 80% 76%, rgba(54, 182, 196, .19), transparent 34%),
    linear-gradient(145deg, #11142c 0%, #17234a 48%, #151631 100%);
}
.journey-modal::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; opacity: .42;
  background-image: radial-gradient(#fff 1px, transparent 1.4px), radial-gradient(#8bc8ff 1px, transparent 1.4px);
  background-position: 0 0, 29px 37px; background-size: 53px 53px, 79px 79px;
}
.journey-shell { position: relative; width: min(1100px, calc(100% - 34px)); min-height: 100%; margin: 0 auto; padding: 32px 0 28px; }
.journey-header { position: relative; z-index: 1; display: flex; justify-content: space-between; gap: 22px; align-items: flex-start; }
.journey-kicker { display: block; color: #9eacdc; font-size: 10px; letter-spacing: .14em; font-weight: 900; }
.journey-header h1 { margin: 5px 0 3px; font-size: clamp(27px, 4.5vw, 42px); letter-spacing: -.05em; color: #fff7df; text-shadow: 0 3px 16px rgba(0,0,0,.35); }
.journey-header p { margin: 0; color: #c7d2ef; font-size: 14px; }
.journey-resources { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; max-width: 330px; }
.journey-resources span, .journey-party { border: 1px solid rgba(203,216,255,.2); background: rgba(11,16,48,.55); border-radius: 999px; box-shadow: 0 8px 22px rgba(0,0,0,.18); }
.journey-resources span { padding: 8px 10px; color: #fff; font-weight: 900; font-size: 12px; white-space: nowrap; }
.journey-party-row { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 7px; margin: 22px 0 13px; }
.journey-party { display: inline-flex; gap: 5px; align-items: center; padding: 5px 9px 5px 5px; font-size: 12px; }
.journey-party i { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; background: #2c396f; font-style: normal; }
.journey-party b { font-size: 12px; }.journey-party small { color: #aeb9dc; }
.journey-annotation { position: relative; z-index: 1; display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 9px; margin: -3px 0 13px; padding: 8px 11px; border: 1px solid rgba(225,194,123,.3); border-left: 3px solid #d8b86c; border-radius: 10px; background: rgba(20,24,58,.68); color: #d5def5; }
.journey-annotation span { color: #ffe3a0; font-size: 10px; font-weight: 900; white-space: nowrap; }.journey-annotation p { margin: 0; font-size: 11px; line-height: 1.4; }.journey-annotation b { color: #bfc9e7; font-size: 10px; white-space: nowrap; }.journey-annotation small { color: #8998c3; font-size: 9px; white-space: nowrap; }
.journey-map-wrap { position: relative; height: clamp(350px, 48vw, 500px); overflow: hidden; border: 1px solid rgba(207,219,255,.25); border-radius: 25px; background: linear-gradient(135deg, rgba(24,36,81,.88), rgba(13,19,54,.93)); box-shadow: 0 20px 50px rgba(0,0,0,.32), inset 0 1px rgba(255,255,255,.12); }
.journey-map-wrap::before { content: ''; position: absolute; inset: 0; opacity: .62; background: linear-gradient(120deg, transparent 22%, rgba(138,118,220,.16) 22.4%, transparent 23%), linear-gradient(150deg, transparent 68%, rgba(80,193,200,.12) 68.3%, transparent 69%); }
.journey-moon { position: absolute; z-index: 0; top: 12%; right: 14%; width: clamp(48px, 7vw, 78px); aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 36% 32%, #fffbe3 0 8%, #e5dafc 42%, #9f9bd8 100%); box-shadow: 0 0 34px rgba(220,210,255,.42); opacity: .75; }
.journey-ridge { position: absolute; z-index: 0; left: -8%; width: 116%; pointer-events: none; }.ridge-far { bottom: -6%; height: 38%; opacity: .58; background: linear-gradient(160deg, transparent 0 20%, rgba(74,86,148,.46) 20.4% 42%, transparent 42.4% 48%, rgba(54,91,134,.46) 48.4% 67%, transparent 67.4%), linear-gradient(#25355f,#172654); clip-path: polygon(0 62%, 14% 37%, 28% 57%, 42% 16%, 56% 52%, 70% 24%, 87% 58%, 100% 36%, 100% 100%, 0 100%); }.ridge-near { bottom: -15%; height: 42%; opacity: .86; background: linear-gradient(180deg, #17274a, #0c1834); clip-path: polygon(0 58%, 12% 38%, 24% 58%, 40% 26%, 54% 60%, 66% 36%, 80% 56%, 92% 28%, 100% 48%, 100% 100%, 0 100%); }
.journey-haze { position: absolute; width: 42%; aspect-ratio: 1; border-radius: 50%; filter: blur(28px); opacity: .35; }.haze-a { background: #7656be; left: 10%; top: -22%; }.haze-b { background: #2b9ca8; right: -10%; bottom: -38%; }
.journey-lines { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; overflow: visible; }
.journey-path { fill: none; stroke: rgba(127,149,205,.28); stroke-width: .75; vector-effect: non-scaling-stroke; }.journey-path.seen { stroke: rgba(205,192,255,.65); }.journey-path.live { stroke: #ffe299; stroke-width: 1.3; filter: drop-shadow(0 0 4px #f1bd64); }
.journey-constellation { position: absolute; z-index: 2; inset: 0; }.journey-node { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%,-50%); width: 94px; padding: 0; border: 0; background: transparent; color: #8190b8; font-family: inherit; text-align: center; cursor: default; }.journey-node:disabled { opacity: 1; }
.journey-node-icon { display: grid; place-items: center; width: 42px; height: 42px; margin: auto; border: 1px solid rgba(172,191,238,.35); border-radius: 16px; background: rgba(12,18,52,.88); box-shadow: 0 8px 18px rgba(0,0,0,.3); font-size: 20px; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }.journey-node b, .journey-node small { display: block; margin-top: 4px; text-shadow: 0 2px 4px #080b22; }.journey-node b { color: inherit; font-size: 11px; }.journey-node small { font-size: 9px; opacity: .8; }
.journey-node.visited .journey-node-icon { border-color: var(--node); color: var(--node); }.journey-node.current .journey-node-icon { color: #fff7c8; border-color: #ffe48c; box-shadow: 0 0 0 4px rgba(255,219,126,.14), 0 8px 20px rgba(0,0,0,.36); }.journey-node.current b { color: #fff7d8; }.journey-node.choice { cursor: pointer; }.journey-node.choice:hover .journey-node-icon { transform: translateY(-3px) scale(1.07); border-color: #fff6c4; box-shadow: 0 0 0 4px rgba(255,229,133,.14), 0 12px 26px rgba(0,0,0,.38); }.journey-node.choice:focus-visible { outline: 3px solid #fff0a8; outline-offset: 4px; border-radius: 18px; }.journey-node.cleared .journey-node-icon::after { content: '✓'; position: absolute; margin: 27px 0 0 30px; display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: #73d7a0; color: #143a2a; font-size: 11px; font-weight: 900; }
.journey-map-caption { position: absolute; z-index: 3; left: 16px; bottom: 13px; color: #b8c6e8; font-size: 11px; }.journey-actions { position: relative; z-index: 1; margin-top: 14px; padding: 15px; border: 1px solid rgba(204,215,255,.22); border-radius: 18px; background: rgba(11,15,42,.72); box-shadow: 0 14px 30px rgba(0,0,0,.22); }
.journey-action-title { display: flex; justify-content: space-between; gap: 15px; align-items: baseline; margin: 0 3px 10px; }.journey-action-title b { font-size: 16px; color: #fff5d4; }.journey-action-title span { color: #b8c5e5; font-size: 12px; text-align: right; }.journey-offers { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; }
.journey-choice-card { display: flex; align-items: center; gap: 10px; min-height: 72px; padding: 10px; border: 1px solid rgba(184,202,250,.22); border-radius: 13px; background: linear-gradient(140deg, rgba(46,57,112,.7), rgba(22,29,67,.76)); color: #edf1ff; font-family: inherit; text-align: left; cursor: pointer; transition: transform .16s ease, border-color .16s ease, background .16s ease; }.journey-choice-card:hover:not(:disabled) { transform: translateY(-2px); border-color: #ecd18a; background: linear-gradient(140deg, rgba(69,78,143,.86), rgba(31,38,85,.9)); }.journey-choice-card > span { min-width: 29px; font-size: 24px; text-align: center; }.journey-choice-card div { min-width: 0; flex: 1; }.journey-choice-card b { display: block; font-size: 13px; }.journey-choice-card p { margin: 3px 0 0; color: #c2cdeb; font-size: 11px; line-height: 1.35; }.journey-choice-card em { color: #ffe29a; font-size: 10px; font-style: normal; font-weight: 900; text-align: right; }.journey-choice-card.recruit { border-color: rgba(202,163,255,.45); }.journey-choice-card.recruit:disabled { opacity: .52; cursor: default; }.journey-offer-icon { color: #fff4c8; }.journey-choice-card.win { cursor: default; border-color: rgba(123,224,162,.55); }.journey-quiet { margin: 0; color: #aebde0; font-size: 12px; }
.village-visit { position: relative; overflow: hidden; border-radius: 14px; }.village-scene { position: relative; min-height: 360px; overflow: hidden; border: 1px solid rgba(231,211,155,.34); border-radius: 13px; cursor: crosshair; background: linear-gradient(180deg, #9bd2df 0%, #e5b985 43%, #43643b 44%, #253f31 100%); box-shadow: inset 0 1px rgba(255,255,255,.22), inset 0 -45px 55px rgba(10,23,25,.32); }.village-sky { position: absolute; inset: 0 0 48%; background: radial-gradient(circle at 76% 25%, rgba(255,249,205,.95) 0 4%, transparent 4.4%), linear-gradient(115deg, rgba(231,249,255,.72), transparent 45%), linear-gradient(180deg, #5c78b2, #afcbd3 72%, transparent); }.village-sky i { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: rgba(255,253,205,.92); box-shadow: 0 0 14px #fff8bc; }.village-sky i:nth-child(1) { left: 14%; top: 18%; }.village-sky i:nth-child(2) { left: 42%; top: 32%; transform: scale(.55); }.village-sky i:nth-child(3) { left: 66%; top: 11%; transform: scale(.7); }.village-hill { position: absolute; border-radius: 50% 50% 0 0; }.village-hill-back { left: -12%; right: 34%; top: 34%; bottom: 32%; background: #54794e; box-shadow: 280px 8px 0 #637c55, 520px -13px 0 #405f4b; }.village-hill-front { left: -20%; right: -20%; top: 57%; bottom: -32%; background: radial-gradient(ellipse at 47% 0, #91a95c 0 6%, #5f8247 37%, #284631 75%); }.village-road { position: absolute; z-index: 2; left: 42%; top: 39%; width: 19%; height: 70%; transform: perspective(120px) rotateX(9deg); background: repeating-linear-gradient(90deg, rgba(126,90,58,.28) 0 8px, rgba(246,210,147,.16) 9px 15px), #c79768; clip-path: polygon(35% 0, 64% 0, 100% 100%, 0 100%); opacity: .9; }.village-trees { position: absolute; z-index: 3; color: #204b38; font-size: 78px; line-height: 1; filter: drop-shadow(0 8px 0 rgba(18,46,29,.36)); }.village-trees.tree-a { left: 4%; bottom: 17%; }.village-trees.tree-b { right: 5%; bottom: 12%; font-size: 94px; color: #2b573a; }.village-lantern { position: absolute; z-index: 5; color: #fff1a7; text-shadow: 0 0 11px #ffc45f; font-size: 17px; animation: villageLantern 2.4s ease-in-out infinite; }.village-lantern.lantern-a { left: 38%; top: 51%; }.village-lantern.lantern-b { right: 36%; top: 50%; animation-delay: -.9s; }.village-building, .village-person { position: absolute; z-index: 7; left: var(--x); top: var(--y); transform: translate(-50%, -50%); min-width: 96px; padding: 7px 8px; border: 0; border-radius: 12px; color: #fdf7df; font-family: inherit; text-align: center; cursor: default; opacity: .84; transition: transform .2s ease, filter .2s ease, opacity .2s ease; }.village-building { padding-top: 37px; background: linear-gradient(155deg, transparent 0 22%, #4c332e 22.5% 76%, transparent 76.5%), linear-gradient(180deg, transparent 0 24%, #bf6e4b 25% 28%, transparent 29%); text-shadow: 0 1px 2px #1a1720; }.village-building::before { content: ''; position: absolute; left: 21%; right: 21%; top: 5px; height: 38px; z-index: -1; background: linear-gradient(145deg, transparent 49%, #27394a 50%) 0 0/50% 100%, linear-gradient(35deg, transparent 49%, #27394a 50%) 100% 0/50% 100%; border-radius: 8px 8px 0 0; box-shadow: inset 0 -8px rgba(0,0,0,.16), 0 10px 0 rgba(26,40,30,.28); }.village-building.forge::after { content: '♨'; position: absolute; left: 50%; top: 21px; transform: translateX(-50%); color: #ffd179; font-size: 22px; text-shadow: 0 0 12px #ff822f; }.village-building.shrine::before { background: linear-gradient(90deg, transparent 0 24%, #d9e0ff 25% 44%, #59689a 45% 55%, #d9e0ff 56% 75%, transparent 76%); border-radius: 44% 44% 7px 7px; }.village-building.guild::before { background: linear-gradient(145deg, transparent 49%, #8b4d52 50%) 0 0/50% 100%, linear-gradient(35deg, transparent 49%, #8b4d52 50%) 100% 0/50% 100%; }.village-person { min-width: 74px; padding-top: 42px; background: none; }.village-person i { position: absolute; left: 50%; top: 0; transform: translateX(-50%); display: grid; place-items: center; width: 40px; height: 40px; border: 2px solid rgba(255,248,207,.86); border-radius: 50%; background: #715c8b; box-shadow: 0 6px 0 #463b52, 0 0 0 5px rgba(26,46,47,.28); font-style: normal; font-size: 23px; }.village-building i { position: absolute; left: 50%; top: 8px; transform: translateX(-50%); font-size: 22px; font-style: normal; }.village-building b, .village-person b { display: block; font-size: 11px; }.village-building small, .village-person small { display: block; margin-top: 2px; color: #ebdcae; font-size: 9px; white-space: nowrap; }.village-building.near, .village-person.near { cursor: pointer; opacity: 1; filter: drop-shadow(0 0 12px rgba(255,235,153,.78)); transform: translate(-50%, -50%) scale(1.08); }.village-avatar { position: absolute; z-index: 10; left: var(--x); top: var(--y); width: 31px; height: 40px; transform: translate(-50%, -68%); transition: left .22s ease, top .22s ease; border: 2px solid #f7f2cd; border-radius: 52% 52% 35% 35%; background: linear-gradient(135deg, #6f78d1, #463a87); box-shadow: 0 7px 0 rgba(22,45,32,.42), 0 0 0 4px rgba(252,238,160,.18); }.village-avatar span { display: grid; height: 100%; place-items: center; color: #fff3ac; text-shadow: 0 0 8px #fff; font-size: 17px; }.village-status { position: absolute; z-index: 12; left: 12px; right: 12px; bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; border: 1px solid rgba(255,244,192,.26); border-radius: 10px; background: rgba(19,31,39,.72); color: #e8efe0; pointer-events: none; }.village-status b { color: #fff1b0; font-size: 11px; white-space: nowrap; }.village-status span { font-size: 11px; text-align: right; }.village-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; color: #bccbe5; font-size: 11px; }.village-foot button { border: 1px solid rgba(229,211,153,.55); border-radius: 8px; padding: 6px 10px; background: rgba(77,65,122,.76); color: #fff4d6; font: inherit; font-weight: 800; cursor: pointer; }.village-dialog { position: absolute; z-index: 20; left: 50%; top: 52%; display: grid; grid-template-columns: auto 1fr; gap: 12px; width: min(680px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow: auto; transform: translate(-50%, -50%); padding: 18px; border: 1px solid rgba(255,229,157,.66); border-radius: 16px; background: linear-gradient(145deg, rgba(37,46,82,.97), rgba(23,28,55,.98)); box-shadow: 0 22px 48px rgba(0,0,0,.55), 0 0 0 999px rgba(4,9,24,.32); color: #eaf0ff; }.village-dialog-portrait { display: grid; place-items: center; align-self: start; width: 52px; height: 52px; border-radius: 17px; background: #6d5d9e; box-shadow: inset 0 1px rgba(255,255,255,.35); font-size: 30px; }.village-dialog h2 { margin: 1px 0 4px; color: #fff2c9; font-size: 19px; }.village-dialog p { margin: 0 0 10px; color: #cad5f1; font-size: 12px; line-height: 1.5; }.village-dialog-kicker { color: #ffdfa0 !important; font-size: 10px !important; font-weight: 900; letter-spacing: .08em; }.village-dialog-close { position: absolute; right: 8px; top: 7px; width: 26px; height: 26px; border: 0; border-radius: 50%; background: rgba(255,255,255,.1); color: #fff; font-size: 21px; cursor: pointer; }.village-dialog-action { min-height: 36px; padding: 8px 12px; border: 1px solid #f1ce7d; border-radius: 9px; background: linear-gradient(135deg, #8d5dac, #4d4a91); color: #fff9db; font: inherit; font-weight: 900; cursor: pointer; }.village-hero-build { margin-top: 11px; padding-top: 9px; border-top: 1px solid rgba(223,233,255,.15); }.village-hero-build header { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 5px; color: #fff0be; font-size: 12px; }.village-hero-build header small { color: #bbc9ec; }.village-skill { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 8px; margin-top: 5px; padding: 7px 8px; border: 1px solid rgba(181,199,245,.24); border-radius: 8px; background: rgba(16,24,51,.58); color: #cbd6ef; font: inherit; text-align: left; }.village-skill small { font-size: 10px; }.village-skill.ready { cursor: pointer; border-color: rgba(255,218,136,.7); color: #fff5d2; background: rgba(103,74,138,.56); }.village-skill:disabled { opacity: .55; }.village-empty { margin: 10px 0 0 !important; }.village-dialog.facility { top: 50%; }
@keyframes villageLantern { 50% { transform: scale(1.18); opacity: .65; } }
.journey-modal.village-mode { overflow: hidden; background: #263b48; }.journey-modal.village-mode::before { display: none; }.journey-shell.village-shell { width: 100%; min-height: 100%; padding: 0; }.village-screen { position: relative; width: 100vw; height: 100vh; min-height: 530px; overflow: hidden; background: #263b48; }.village-3d { position: absolute; inset: 0; cursor: crosshair; }.village-3d canvas { display: block; width: 100%; height: 100%; touch-action: none; }.village-top { position: absolute; z-index: 3; top: 0; left: 0; right: 0; padding: 22px clamp(18px, 4vw, 54px) 46px; pointer-events: none; background: linear-gradient(180deg, rgba(14,23,35,.76), rgba(14,23,35,.28), transparent); text-shadow: 0 3px 10px rgba(0,0,0,.58); }.village-top span { display: block; color: #c8e5e9; font-size: 10px; font-weight: 900; letter-spacing: .15em; }.village-top h1 { margin: 4px 0; color: #fff4cf; font-size: clamp(27px, 4.2vw, 46px); letter-spacing: -.05em; }.village-top p { margin: 0; color: #d9ebeb; font-size: 13px; }.village-bottom { position: absolute; z-index: 4; left: 50%; bottom: 19px; width: min(720px, calc(100% - 28px)); transform: translateX(-50%); padding: 13px; border: 1px solid rgba(255,234,177,.36); border-radius: 16px; background: linear-gradient(135deg, rgba(18,34,45,.9), rgba(28,39,72,.9)); box-shadow: 0 16px 38px rgba(0,0,0,.42), inset 0 1px rgba(255,255,255,.12); }.village-bottom p { margin: 0 0 10px; color: #e7f2ed; font-size: 12px; line-height: 1.4; }.village-controls { display: flex; align-items: center; gap: 8px; }.village-controls > button { min-height: 39px; border: 1px solid rgba(255,220,137,.7); border-radius: 10px; padding: 7px 12px; background: linear-gradient(135deg, #7357a3, #3e6692); color: #fff8dc; font: inherit; font-weight: 900; cursor: pointer; }.village-controls > button:disabled { border-color: rgba(211,222,230,.26); background: rgba(45,62,78,.7); color: #bdc9cf; cursor: default; }.village-map-exit { margin-left: auto !important; border-color: rgba(176,218,230,.55) !important; background: rgba(46,83,100,.9) !important; }.village-dpad { display: none; margin-left: auto; text-align: center; }.village-dpad > button, .village-dpad span { display: block; }.village-dpad span { white-space: nowrap; }.village-dpad button { width: 31px; height: 27px; margin: 1px; border: 1px solid rgba(211,232,240,.4); border-radius: 7px; background: rgba(45,74,94,.94); color: #fff7d2; font: inherit; cursor: pointer; }.journey-modal.village-mode .village-dialog { position: absolute; z-index: 8; top: 50%; }.journey-modal.village-mode .village-dialog::before { content: ''; position: fixed; inset: 0; z-index: -1; background: rgba(7,14,24,.34); }.journey-modal.village-mode .village-dialog.facility { top: 50%; }
.village-refuge-status { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }.village-top .village-refuge-status span { display: inline-block; padding: 4px 7px; border: 1px solid rgba(215,235,234,.25); border-radius: 999px; background: rgba(10,24,34,.62); color: #f4f6db; font-size: 9px; letter-spacing: 0; text-shadow: none; }
@media (max-width: 640px) { .journey-shell { width: min(100% - 20px, 1100px); padding-top: 18px; }.journey-header { display: block; }.journey-resources { justify-content: flex-start; margin-top: 12px; }.journey-annotation { grid-template-columns: 1fr auto; }.journey-annotation p { grid-column: 1 / -1; grid-row: 2; }.journey-annotation b { grid-column: 1; grid-row: 3; }.journey-annotation small { grid-column: 2; grid-row: 3; }.journey-map-wrap { height: 390px; border-radius: 19px; }.journey-node { width: 68px; }.journey-node b { font-size: 10px; }.journey-node small { font-size: 8px; }.journey-node-icon { width: 37px; height: 37px; border-radius: 13px; font-size: 17px; }.journey-action-title { display: block; }.journey-action-title span { display: block; margin-top: 5px; text-align: left; }.journey-map-caption { display: none; } }
@media (max-width: 640px) { .journey-shell.village-shell { width: 100%; padding: 0; }.village-screen { min-height: 100svh; }.village-top { padding: 16px 18px 42px; }.village-top p { max-width: 250px; font-size: 11px; }.village-bottom { bottom: 10px; width: calc(100% - 20px); padding: 10px; }.village-bottom p { font-size: 11px; }.village-controls > button { font-size: 11px; }.village-dpad { display: block; }.village-map-exit { margin-left: 0 !important; padding-inline: 8px !important; }.journey-modal.village-mode .village-dialog { width: calc(100% - 20px); padding: 15px; }.journey-modal.village-mode .village-dialog.facility { max-height: calc(100% - 18px); }.village-dialog-portrait { width: 43px; height: 43px; font-size: 24px; } }
.bench .empty-msg {
  grid-column: 1 / -1;
  color: #9aa7ba;
  font-size: 12px;
  text-align: center;
  padding: 8px 0;
}
.hcard {
  position: relative;               /* Anchor for the selected-for-sale checkmark. */
  border: 2.5px solid var(--t0);
  border-radius: 10px;
  background: #fafcff;
  padding: 5px 2px 3px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: transform 0.08s;
}
.hcard:hover { transform: translateY(-2px); }
.hcard .em { font-size: 22px; line-height: 1.1; position: relative; }
.hcard .nm { font-size: 10px; font-weight: 700; }
.hcard .tr { font-size: 9px; font-weight: 800; }
/* Range displayed on hero cards. */
.hcard .rg {
  font-size: 9.5px;
  font-weight: 800;
  border-radius: 4px;
  margin: 1px 3px;
  padding: 0 2px;
  color: #fff;
}
.hcard .rg.r1 { background: #e07a5f; }   /* Melee. */
.hcard .rg.r2 { background: #d9a13b; }   /* Medium range. */
.hcard .rg.r3 { background: #4f9e57; }   /* Long range. */
.hcard .rg.r4 { background: #3b82f6; }   /* Very long range. */
.hcard .bdgs {
  position: absolute;
  top: -2px;
  right: -6px;
  font-size: 9px;
  line-height: 1;
}
.hcard .bdg { display: block; }

/* Detailed tooltips. */
#tooltip {
  position: fixed;
  z-index: 100;
  width: 268px;
  background: rgba(20, 28, 44, 0.96);
  color: #e8eefb;
  border: 1.5px solid #4a5a7a;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 11.5px;
  line-height: 1.6;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
#tooltip b { color: #ffd93d; }
.tt-head {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 6px;
}
.tt-head .tt-emoji { font-size: 18px; }
.tt-head .tt-name { flex: 1; }
.tt-head .tt-tier {
  font-size: 9.5px;
  font-weight: 800;
  color: #fff;
  border-radius: 999px;
  padding: 1px 7px;
}
.tt-range { margin-bottom: 6px; }
.tt-rlabel {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  border-radius: 4px;
  padding: 0 6px;
  margin-right: 5px;
}
.tt-rlabel.r1 { background: #e07a5f; }
.tt-rlabel.r2 { background: #d9a13b; }
.tt-rlabel.r3 { background: #4f9e57; }
.tt-rlabel.r4 { background: #3b82f6; }
.tt-rnum { font-size: 11px; color: #b8c6de; }
.tt-rbar {
  height: 5px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  margin-top: 3px;
  overflow: hidden;
}
.tt-rfill { height: 100%; border-radius: 999px; }
.tt-rfill.r1 { background: #e07a5f; }
.tt-rfill.r2 { background: #d9a13b; }
.tt-rfill.r3 { background: #4f9e57; }
.tt-rfill.r4 { background: #3b82f6; }
.tt-rows { border-top: 1px solid rgba(255,255,255,0.12); padding-top: 5px; }
.tt-legend {
  margin-top: 5px;
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.5);
  border-radius: 7px;
  padding: 4px 7px;
  color: #ffd98a;
}
.tt-recipe {
  margin-top: 5px;
  background: rgba(168, 85, 247, 0.18);
  border: 1px solid rgba(168, 85, 247, 0.5);
  border-radius: 7px;
  padding: 4px 7px;
  color: #d8b4ff;
}
.tt-active {
  margin-top: 5px;
  padding: 5px 7px;
  border: 1px solid rgba(126, 168, 235, .58);
  border-radius: 7px;
  background: rgba(80, 130, 215, .16);
  color: #bed8ff;
}
.tt-active small { display: block; opacity: .78; }
.tt-desc { margin-top: 5px; color: #9fb0cc; font-style: italic; }
.tt-foot {
  margin-top: 5px;
  padding-top: 4px;
  border-top: 1px solid rgba(255,255,255,0.12);
  font-size: 10px;
  color: #8496b4;
}
/* Reuse the same markup in the hero panel. */
#hpInfo #tooltip, #hpInfo .tt-head { color: var(--ink); }
#hpInfo b { color: #23304a; }
#hpInfo .tt-rnum { color: #6a7a94; }
#hpInfo .tt-rows { border-color: #e3e9f2; }
#hpInfo .tt-rbar { background: #e3e9f2; }
#hpInfo .tt-legend { background: #fff7e0; border-color: #f2cf5b; color: #8a6400; }
#hpInfo .tt-recipe { background: #f3ebff; border-color: #c4a8f0; color: #5b2fb8; }
#hpInfo .tt-active { background: #eef4ff; border-color: #8eb2eb; color: #315b94; }
#hpInfo .tt-desc { color: #7a879c; }
#hpInfo .tt-foot { color: #93a0b4; border-color: #e3e9f2; }
.hcard .lv { color: #c98a00; }
.hcard.t0 { border-color: var(--t0); } .hcard.t0 .tr { color: var(--t0); }
.hcard.t1 { border-color: var(--t1); } .hcard.t1 .tr { color: var(--t1); }
.hcard.t2 { border-color: var(--t2); } .hcard.t2 .tr { color: var(--t2); }
.hcard.t3 { border-color: var(--t3); box-shadow: 0 0 8px rgba(245, 158, 11, 0.55); animation: legendshine 2s ease-in-out infinite; }
.hcard.t3 .tr { color: var(--t3); }
@keyframes legendshine { 0%, 100% { box-shadow: 0 0 6px rgba(245, 158, 11, 0.4); } 50% { box-shadow: 0 0 14px rgba(245, 158, 11, 0.85); } }
.hcard.sel {
  outline: 3px solid #22c55e;
  outline-offset: 1px;
  background: #eaffea;
}

/* Startup menu: resume or start over. */
.modal-card.start { text-align: center; max-width: 420px; }
.modal-card.start .big { width: 100%; margin-top: 10px; }
.continue-info { font-size: 14px; color: #4a5a74; line-height: 1.7; margin: 8px 0 4px; }
.continue-info b { color: #1c2b4a; }
.start-note { font-size: 11px; color: #93a0b4; margin-top: 12px; }

/* Bulk selling. */
.sellbar { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.sellbar button {
  border: 1.5px solid #d5ddea;
  border-radius: 8px;
  background: #f4f7fb;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
  color: #4a5a74;
  cursor: pointer;
  font-family: inherit;
}
.sellbar button:hover { background: #eaf0f8; }
#sellModeBtn.on { background: #ffe9e3; border-color: #e07a5f; color: #b3410f; }
.sellinfo { font-size: 12px; font-weight: 800; color: #7a6a3a; }
#sellGoBtn { background: linear-gradient(180deg, #ffb37a, #e07a3f); border-color: #d06a30; color: #fff; }
#sellGoBtn:hover:not(:disabled) { filter: brightness(1.06); background: linear-gradient(180deg, #ffb37a, #e07a3f); }
#sellGoBtn:disabled { background: #c5cedb; border-color: #c5cedb; cursor: not-allowed; }
/* Selected sale cards use an orange outline and checkmark. */
.hcard.sellsel {
  outline: 3px solid #e07a5f;
  outline-offset: 1px;
  background: #fff1ea;
}
.hcard .sellprice {
  font-size: 10px;
  font-weight: 900;
  color: #b3410f;
  background: #ffe9d6;
  border-radius: 4px;
  margin: 1px 3px;
  padding: 0 2px;
}
.hcard .sellcheck {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e0552f;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* Combination and castle-management rows. */
.combine-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 0;
  font-size: 13px;
  font-weight: 700;
}
.combine-row .cnt { color: #7a879c; font-weight: 600; font-size: 12px; }
.combine-row .cdesc { color: #93a0b4; font-weight: 500; font-size: 11px; flex: 1; }
.combine-row button {
  margin-left: auto;
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(180deg, #7bc96f, #43a047);
  white-space: nowrap;
}
.combine-row button:disabled { background: #c5cedb; cursor: not-allowed; }
.combine-sub {
  font-size: 12px;
  font-weight: 800;
  color: #4a5a74;
  margin: 8px 0 2px;
  padding-top: 6px;
  border-top: 1px dashed #e3e9f2;
}
.combine-sub:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.combine-sub .cnt { font-weight: 500; font-size: 11px; }
.combine-empty { font-size: 11px; color: #9aa7ba; padding: 4px 0; }
.combine-row.recipe { font-size: 12px; gap: 4px; }
.combine-row .rarrow { color: #9aa7ba; font-weight: 400; }
.combine-row /* Emphasize missing materials instead of making them the least visible elements. */
.ing {
  display: inline-flex;
  align-items: center;
  padding: 1px 4px;
  border-radius: 8px;
  border: 2px solid transparent;
}
.ing.have { border-color: #cfe0f5; background: #f2f8ff; }
.ing.lack {
  border: 2px dashed #f0a04a;
  background: #fff6ea;
  animation: ingpulse 1.6s ease-in-out infinite;
}
.ing .ingx { font-weight: 900; color: #e0761f; margin-left: 2px; }
@keyframes ingpulse {
  0%, 100% { border-color: #f0a04a; }
  50%      { border-color: #ffd9ae; }
}

/* Immediately available combinations appear at the top without scrolling. */
.combine-now {
  background: linear-gradient(180deg, #fffdf0, #fff8dc);
  border: 2px solid #ffd76a;
  border-radius: 12px;
  padding: 8px;
  margin-bottom: 10px;
}
.now-title { font-size: 13px; font-weight: 900; color: #8a6a12; margin-bottom: 6px; }
.resonance-card {
  margin: 0 0 10px;
  padding: 8px;
  border: 1px solid #c9b8ef;
  border-radius: 12px;
  background: linear-gradient(135deg, #f8f3ff, #eff8ff);
  color: #4e4670;
}
.resonance-title { display: flex; align-items: baseline; gap: 6px; }
.resonance-title b { color: #573a9d; font-size: 13px; }
.resonance-title span { color: #7c709d; font-size: 10px; font-weight: 700; }
.resonance-lanes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 6px; }
.resonance-lane { display: grid; gap: 1px; padding: 5px 4px; border: 1px solid #ddd4f3; border-radius: 8px; background: #fff; text-align: center; }
.resonance-lane b { color: #776a9f; font-size: 9px; }
.resonance-lane strong { color: #463184; font-size: 15px; line-height: 1; }
.resonance-lane small, .resonance-lane em { color: #9a91af; font-size: 8px; font-style: normal; font-weight: 800; }
.resonance-lane.active { border-color: #f0b95b; background: linear-gradient(180deg, #fff9db, #fff1ae); box-shadow: 0 0 10px #ffd76a88; }
.resonance-lane.active strong, .resonance-lane.active em { color: #a26511; }
.resonance-card p { margin: 6px 0 0; color: #6a6288; font-size: 10px; line-height: 1.35; }
.resonance-card p b { color: #553b9c; }
.res-badge { flex: none; border-radius: 5px; padding: 2px 4px; background: #ece8f4; color: #807698; font-size: 9px; font-weight: 900; white-space: nowrap; }
.res-badge.match { background: #fff0bb; color: #9d6513; box-shadow: 0 0 0 1px #efbc56 inset; }
.now-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin-bottom: 5px;
  padding: 7px 8px;
  border: 2px solid #ddd;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  text-align: left;
}
.now-btn:last-child { margin-bottom: 0; }
.now-btn:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0,0,0,0.12); }
.now-btn:active { transform: translateY(1px); box-shadow: none; }
.now-what { white-space: nowrap; }
.now-arrow { color: #9aa4b5; }
.now-res { font-weight: 900; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-cost { font-weight: 800; color: #7a6a3a; }

/* Direct actions from missing-material rows. */
.combine-row button.need { background: #fff2e0; border-color: #f0b071; color: #8a5a12; }

/* Distinguish insufficient gold from missing materials: show the coin shortfall and a disabled action rather than an apparently available green button. */
.gshort {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 10.5px;
  font-weight: 900;
  color: #9a5600;
  background: #fff3d6;
  border: 1.5px solid #f3c268;
  border-radius: 7px;
  padding: 2px 6px;
  white-space: nowrap;
}
.combine-row .mlv + .gshort { margin-left: 6px; }
.combine-row .gshort + button { margin-left: 6px; }
.combine-row button.lack,
.combine-row button:disabled {
  background: #dbe2ec;
  color: #8b95a5;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 1;
}
.combine-row button.lack::before { content: '🔒 '; }
/* Keep completed materials readable when only gold is missing; indicate the lock with the border. */
.combine-row.broke,
.combine-row.recipe.s-gold {
  background: #fbfbfd;
  border: 1.5px dashed #d7dfeb;
  border-radius: 8px;
  padding: 4px 6px;
}
/* Apply the same insufficient-gold state to summoning. */
.big.lack { background: #dbe2ec; color: #7b8698; box-shadow: none; cursor: not-allowed; }
.big.lack::before { content: '🔒 '; }
.combine-row.flash { animation: rowflash 1.4s ease-out; }
@keyframes rowflash {
  0%   { background: #fff3c4; box-shadow: 0 0 0 3px #ffd76a inset; }
  100% { background: transparent; box-shadow: none; }
}
.combine-row .ing.have { opacity: 1; filter: none; }
.combine-row .need { font-size: 10px; margin-left: auto; }
.combine-row .peek {
  cursor: help;
  border-bottom: 1.5px dotted #9aa7ba;
}
.combine-row .peek:hover { background: #fff7e0; border-radius: 4px; }
.tt-preview {
  background: #6d43e8;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  border-radius: 4px;
  padding: 1px 5px;
}
#tooltip.preview { border-color: #9d7bff; }
.combine-row.ready {
  background: #f4fff2;
  border-radius: 8px;
  padding: 5px 6px;
  animation: readyglow 1.6s ease-in-out infinite;
}
@keyframes readyglow {
  0%, 100% { box-shadow: 0 0 0 rgba(69, 176, 46, 0); }
  50% { box-shadow: 0 0 8px rgba(69, 176, 46, 0.45); }
}
.hcard.sp { background: #faf5ff; }
.hcard.sp .nm { color: #6d43e8; }
.ability.sp { background: #f3ebff; border-color: #c4a8f0; color: #5b2fb8; }

.movehint {
  background: #eaffea;
  border: 1.5px dashed #45b02e;
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 11.5px;
  font-weight: 600;
  color: #2a7a1a;
  line-height: 1.5;
  margin-bottom: 8px;
}

/* Hero panel. */
#hpInfo { font-size: 13px; line-height: 1.65; margin-bottom: 8px; }
#hpInfo .lv { color: #c98a00; font-weight: 800; }
#hpInfo .cdesc { color: #7a879c; }
.ability {
  margin-top: 4px;
  background: #fff7e0;
  border: 1.5px solid #f2cf5b;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  color: #8a6400;
  font-weight: 700;
}
.rowbtns { display: flex; gap: 6px; }
.rowbtns button {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
}
#recallBtn { background: #e3f0ff; color: #1a5cb0; }
#sellBtn { background: #ffe9e3; color: #c0392b; }
.rowbtns .hero-active-btn {
  flex: 2;
  background: linear-gradient(180deg, #556bd4, #3548a5);
  color: #fff;
  box-shadow: 0 3px 0 #25347f;
}
.rowbtns .hero-active-btn.ready { outline: 2px solid #ffd66b; outline-offset: 2px; }
.rowbtns .hero-active-btn:disabled { background: #d9deea; color: #7b8498; box-shadow: none; cursor: default; }
#overMetaBtn { background: #efe6ff; color: #5b2fb8; }
#shareBtn { background: #e3f0ff; color: #1a5cb0; }

/* Modals. */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 45, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.modal.hidden { display: none; }
.modal-card {
  background: #fff;
  border-radius: 18px;
  padding: 22px;
  width: 430px;
  max-width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  text-align: center;
  animation: modalin 0.25s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes modalin { from { transform: scale(0.85); opacity: 0; } }
.modal-card h2 { font-size: 20px; margin-bottom: 6px; }

.modal-card.settings { width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow-y: auto; text-align: left; }
.modal-card.settings h2 { text-align: center; }
.settings-lead, .settings-note, .settings-save-path { color: #596579; font-size: 12px; line-height: 1.45; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 8px; }
.settings-grid label { display: grid; gap: 5px; color: #39445a; font-size: 12px; font-weight: 900; }
.settings-grid select { width: 100%; min-height: 38px; border: 1px solid #c8d0df; border-radius: 9px; padding: 6px 9px; background: #f7f9fc; color: #273248; font: inherit; }
.settings-audio { justify-content: flex-start; margin: 12px 0; }
.settings-keys { margin: 12px 0; padding: 12px; border: 1px solid #d8deea; border-radius: 12px; background: #f7f9fd; }
.settings-section-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 9px; color: #303b52; }
.settings-section-head span { color: #68748a; font-size: 11px; }
.settings-key-rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.settings-key { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 34px; border: 1px solid #cbd3e2; border-radius: 8px; padding: 5px 8px; background: #fff; color: #334058; font: inherit; font-size: 11px; font-weight: 900; cursor: pointer; }
.settings-key kbd { min-width: 42px; border: 1px solid #aeb9cc; border-bottom-width: 2px; border-radius: 6px; padding: 3px 6px; background: #edf1f7; color: #263248; text-align: center; }
.settings-key.listening { border-color: #d08b23; background: #fff4d9; color: #754c09; }
.settings-key.listening kbd { border-color: #d08b23; background: #ffd879; }
.settings-reset { margin-top: 9px; border: 0; background: transparent; color: #536583; font: inherit; font-size: 11px; font-weight: 900; text-decoration: underline; cursor: pointer; }
.settings-save-path { padding: 8px 10px; border-radius: 8px; background: #eef2f8; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .settings-grid, .settings-key-rows { grid-template-columns: 1fr; }
  .settings-section-head { display: block; }
  .settings-section-head span { display: block; margin-top: 3px; }
}
.mgrade {
  display: inline-block;
  background: #e3f0ff;
  color: #1a5cb0;
  font-size: 12px;
  font-weight: 800;
  border-radius: 999px;
  padding: 3px 12px;
  margin-bottom: 12px;
}
.mproblem {
  /* Gaegu provides legible handwritten-style display text. */
  font-family: "Gaegu", "Jua", system-ui, sans-serif;
  font-size: 27px;
  font-weight: 800;
  line-height: 1.5;
  background: #f5f8fc;
  border-radius: 12px;
  padding: 18px 14px;
  margin-bottom: 14px;
  word-break: keep-all;
  white-space: pre-line;
}
/* Legacy unused fraction layout with numerator, denominator and a horizontal separator. */
.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 0.14em;
  line-height: 1.05;
  font-size: 0.82em;
}
.frac b, .frac i {
  font-style: normal;
  font-weight: inherit;
  padding: 0 0.18em;
}
.frac i { border-top: 2px solid currentColor; }

.mrow { display: flex; gap: 8px; margin-bottom: 10px; justify-content: center; }
.mrow input {
  flex: 1;
  font-family: "Gaegu", "Jua", system-ui, sans-serif;
  font-size: 25px;
  font-weight: 700;
  padding: 10px 12px;
  border: 2px solid #cdd6e2;
  border-radius: 10px;
  text-align: center;
}
.mrow input:focus { outline: none; border-color: #2478e0; }
.mrow .big { width: auto; padding: 10px 20px; }
.mfeedback { min-height: 26px; font-size: 15px; font-weight: 800; margin-bottom: 6px; }
.mfeedback.ok { color: #16a34a; }
.mfeedback.no { color: #dc2626; }

.mhint {
  background: #fff7e0;
  border: 1.5px solid #f2cf5b;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  color: #8a6400;
  margin-bottom: 8px;
  line-height: 1.5;
  animation: coachin 0.3s ease-out;
}
.hintbtn {
  border: 1.5px solid #f2cf5b;
  background: #fff7e0;
  color: #8a6400;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}
.hintbtn:disabled { opacity: 0.5; cursor: not-allowed; }
#mNext, #mClose {
  border: 1px solid #cdd6e2;
  background: #f2f6fa;
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: #4a5a74;
}
#mNext { background: #e3f0ff; border-color: #9cc4ee; color: #1a5cb0; }

.modal-card.over h2 { font-size: 24px; }
#overStats {
  background: #f5f8fc;
  border-radius: 12px;
  padding: 14px;
  margin: 12px 0;
  font-size: 14px;
  line-height: 1.9;
  text-align: left;
}
.over-shards {
  font-size: 17px;
  font-weight: 900;
  color: #6d43e8;
  margin-bottom: 8px;
  animation: combopop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.over-msg { font-size: 13px; color: #6a7a94; margin-bottom: 10px; }
.modal-card.over .rowbtns { margin-bottom: 10px; }

/* Star Blessings. */
.meta-desc { font-size: 13px; color: #5a6a84; margin-bottom: 12px; line-height: 1.6; }
.meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-bottom: 1px solid #eef2f7;
  text-align: left;
}
.meta-row .memoji { font-size: 24px; }
.meta-row .minfo { flex: 1; font-size: 13px; line-height: 1.5; }
.meta-row .minfo .cnt { color: #7a879c; font-size: 12px; }
.meta-row .minfo .cdesc { color: #93a0b4; font-size: 11px; }
.meta-row button {
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(180deg, #9d7bff, #6d43e8);
  white-space: nowrap;
}
.meta-row button:disabled { background: #c5cedb; cursor: not-allowed; }
#metaClose { margin-top: 12px; }

.hidden { display: none !important; }

/* Narrow screens. */
@media (max-width: 920px) {
  .wrap { flex-direction: column; }
  .right { width: 100%; }
}

/* Mythic tier 4. */
:root { --t4: #ff4d9d; }
.hcard.t4 {
  border-color: var(--t4);
  background: #fff0f8;
  box-shadow: 0 0 10px rgba(255, 77, 157, 0.6);
  animation: mythicshine 1.6s ease-in-out infinite;
}
.hcard.t4 .tr { color: var(--t4); }
@keyframes mythicshine {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 77, 157, 0.5); }
  50% { box-shadow: 0 0 20px rgba(255, 77, 157, 1); }
}
.reveal.t4 {
  border-color: var(--t4);
  box-shadow: 0 0 50px rgba(255, 77, 157, 0.95);
  animation: mythicglow 0.7s ease-in-out infinite alternate;
}
@keyframes mythicglow {
  from { box-shadow: 0 0 32px rgba(255, 77, 157, 0.7); }
  to   { box-shadow: 0 0 68px rgba(255, 77, 157, 1); }
}
.prob.t4 { background: var(--t4); }

/* Mythic combination section. */
.combine-sub.mythic { color: #c2185b; border-top-color: #ffc2dd; }
.combine-row.mythic { background: linear-gradient(90deg, #fff0f8, transparent); border-radius: 8px; }
.combine-row .found { color: #16a34a; font-weight: 900; }
.tt-mythic {
  margin-top: 5px;
  background: rgba(255, 77, 157, 0.18);
  border: 1px solid rgba(255, 77, 157, 0.6);
  border-radius: 7px;
  padding: 4px 7px;
  color: #ff9ecb;
}
#hpInfo .tt-mythic { background: #fff0f8; border-color: #ff9ecb; color: #c2185b; }

/* Combination rule guidance. */
.combine-rule {
  background: #eef4fb;
  border: 1px solid #d5e2f2;
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 11px;
  line-height: 1.65;
  color: #35507a;
  margin-bottom: 6px;
}
.combine-rule b { color: #1a5cb0; }
/* Material tier badges. */
.combine-row .ingt {
  display: inline-block;
  font-size: 8.5px;
  font-weight: 900;
  color: #fff;
  border-radius: 3px;
  padding: 0 3px;
  margin-left: 1px;
  vertical-align: super;
}

/* Legacy unused challenge difficulty and timer styling; not part of current progression. */

/* Legacy difficulty preview badge. */
.combine-row .mlv {
  font-size: 8.5px;
  font-weight: 900;
  color: #fff;
  border-radius: 5px;
  padding: 2px 5px;
  letter-spacing: -1px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: auto;
}
.combine-row .mlv + button { margin-left: 6px; }

/* Legacy challenge metadata row. */
.mmeta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.mdiff, .msteps, .mstreak {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  border-radius: 999px;
  padding: 3px 11px;
  letter-spacing: -0.5px;
}
.mgrade { margin-bottom: 0; }
.msteps { background: #6d43e8; }
.mstreak {
  background: linear-gradient(90deg, #ff8a3d, #ff4d6d);
  animation: streakpulse 1.1s ease-in-out infinite;
}
@keyframes streakpulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* Remaining-time bar. */
.mtimer {
  position: relative;
  height: 22px;
  border-radius: 999px;
  background: #e7edf5;
  overflow: hidden;
  margin-bottom: 12px;
}
#mTimerFill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #5ac47a, #2fa8d8);
  transition: background 0.3s;
}
#mTimerText {
  position: relative;
  display: block;
  line-height: 22px;
  font-size: 12px;
  font-weight: 900;
  color: #23405f;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}
.mtimer.warn #mTimerFill { background: linear-gradient(90deg, #ff7043, #e53935); }
.mtimer.warn {
  animation: timepanic 0.6s ease-in-out infinite;
}
.mtimer.warn #mTimerText { color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45); }
@keyframes timepanic {
  0%, 100% { box-shadow: 0 0 0 rgba(229, 57, 53, 0); }
  50% { box-shadow: 0 0 12px rgba(229, 57, 53, 0.75); }
}

/* Legacy unused worksheet grid with handwritten text and subtle ruled-paper styling. */
.mvert {
  margin: 0 auto 12px;
  padding: 10px 12px;
  background: #fffdf4;
  border: 2px dashed #e2d5a8;
  border-radius: 12px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}
.mvert.pop { animation: probpop 0.35s cubic-bezier(0.2, 1.5, 0.4, 1); }
.mv-title { font-size: 11px; color: #a08c50; margin-bottom: 6px; }
.mv-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), 30px);
  gap: 2px;
  justify-content: center;
}
.mv-c {
  height: 32px;
  line-height: 32px;
  text-align: center;
  font-family: "Gaegu", "Jua", system-ui, sans-serif;
  font-size: 23px;
  font-weight: 800;
  color: #2f3d55;
}
/* Outline empty cells only to avoid visual clutter. */
.mv-c.mv-blank, .mv-c.mv-carry {
  border: 1.5px dashed #d8cfae;
  border-radius: 6px;
  background: #fffef9;
}
.mv-c.mv-carry { height: 20px; border-style: dotted; background: transparent; }
.mv-sign { color: #c2703a; }
.mv-rule {
  grid-column: 1 / -1;
  height: 0;
  border-top: 2.5px solid #6b7688;
  margin: 3px 0;
}

/* Highlight the final remaining attempt. */
.mtries { background: #4a5a72; }
.mtries.last { background: #e0483a; animation: streakpulse 1.1s ease-in-out infinite; }
/* Color communicates that abandoning has a consequence. */
#mClose.giveup { background: #ffe9e6; color: #a02c1c; border-color: #f0b3aa; }

/* Reduce long legacy prompt text to keep inputs inside the viewport. */
.mproblem.long { font-size: 21px; line-height: 1.42; padding: 14px 12px; }
/* Allow internal scrolling on short screens rather than hiding inputs. */
#mathModal .modal-card { max-height: calc(100vh - 20px); overflow-y: auto; }

/* Local card-entry animation. */
.mproblem.pop { animation: probpop 0.32s cubic-bezier(0.2, 1.5, 0.4, 1); }
@keyframes probpop { from { transform: scale(0.9); opacity: 0.2; } }
/* Legacy difficulty badge entry cue replaces a more distracting selection animation. */
.mdiff.pop { animation: diffpop 0.5s cubic-bezier(0.2, 1.8, 0.4, 1); }
@keyframes diffpop {
  0% { transform: scale(0.5); opacity: 0; }
  55% { transform: scale(1.22); opacity: 1; }
  100% { transform: scale(1); }
}

/* Legacy challenge difficulty styling. */
.modal-card.lv4 { box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35), 0 0 0 3px #f59e0b; }
.modal-card.lv5 {
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), 0 0 0 3px #ff4d9d;
  animation: modalin 0.25s cubic-bezier(0.2, 1.4, 0.4, 1), mythicaura 1.8s ease-in-out infinite 0.25s;
}
@keyframes mythicaura {
  0%, 100% { box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), 0 0 0 3px #ff4d9d; }
  50% { box-shadow: 0 20px 70px rgba(255, 77, 157, 0.5), 0 0 0 5px #ff4d9d; }
}
.modal-card.lv5 .mproblem { background: #fff2f8; }
.modal-card.lv6 {
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 4px #ff2d55;
  animation: modalin 0.25s cubic-bezier(0.2, 1.4, 0.4, 1), mythicaura 1.1s ease-in-out infinite 0.25s;
}
.modal-card.lv6 .mproblem { background: #fff0f3; }

/* Stack columns and restore page scrolling when width or height is limited; preserve a 16:10 battlefield. */
@media (max-width: 1080px) {
  body { padding: 8px; }
  .wrap { flex-direction: column; height: auto; }
  /* Use display:contents to reorder column descendants without changing DOM structure. */
  .left, .right { display: contents; }
  .stage { flex: none; min-height: 0; max-height: none; }
  #scene3d { height: auto; aspect-ratio: 16 / 10; }
  .tabbody { overflow: visible; }

  /* On phones, keep bench and summoning directly below the field so selecting a card and a pad does not require scrolling between distant sections. */
  /* Placement-bar visibility is declared after its default hidden rule to avoid being overwritten. */
  .topbar        { order: 1; }
  .castlebar-wrap { order: 2; }
  .stage         { order: 3; }
  .combat-skill-dock { order: 4; }
  #placeBar      { order: 4; }
  #tacticCard    { order: 5; }
  #benchCard     { order: 6; }
  #statCard      { order: 7; }
  .tabs          { order: 8; }
  .tabbody       { order: 9; }
  .under-row     { order: 10; }
  #helpBox       { order: 11; }
}
/* On short laptops, retain two columns with a shallower battlefield. */
@media (min-width: 1081px) and (max-height: 660px) {
  .topbar { margin-bottom: 5px; }
  .topbar h1 { font-size: 20px; }
  .castlebar-wrap { margin-bottom: 5px; }
  .stage { min-height: 240px; }
  .under-row { margin-top: 5px; }
}
/* Very narrow screens use three bench columns and smaller text. */
@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; gap: 6px; }
  .topbar h1 { width: 100%; font-size: 20px; }
  .top-right { width: 100%; justify-content: flex-end; gap: 5px; }
  .weekly-badge { width: 100%; margin-left: 0; text-align: center; }
  .hero-card-grid { grid-template-columns: 1fr; }
  .hero-card { min-height: 156px; grid-template-columns: 56px minmax(0, 1fr); }
  .hero-card-art { width: 52px; height: 52px; border-radius: 17px; }
  .bench { grid-template-columns: repeat(3, 1fr); }
  .gradebar { flex-wrap: wrap; }
}


/* Interlude story. */
.modal-card.story {
  max-width: 460px;
  text-align: center;
  background: linear-gradient(180deg, #fffdf7, #fff6e6);
  border: 3px solid #e8d5a8;
}
.story-icon { font-size: 46px; line-height: 1; margin-bottom: 4px; }
.modal-card.story h2 { color: #6b5220; margin-bottom: 12px; }
.story-lines {
  text-align: left;
  background: #fffaf0;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
  font-size: 16px;
  line-height: 1.75;
  color: #3a2e18;
  word-break: keep-all;
}
.story-gap { height: 10px; }
.story-off {
  display: block;
  margin: 8px auto 0;
  background: none;
  border: none;
  color: #a89878;
  font-family: inherit;
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}

/* Legendary/mythic reveals at z-index 70 sit above ordinary modals and toasts. */
#revealModal {
  position: fixed;
  top: 14%;
  left: 50%;
  width: min(76vw, 340px);
  transform: translateX(-50%);
  z-index: 70;
}
.reveal-card {
  position: relative;
  width: 100%;
  padding: 18px 16px 15px;
  border-radius: 22px;
  text-align: center;
  background: radial-gradient(circle at 50% 34%, #ffffff 0%, #f6f2ff 55%, #e9e2fb 100%);
  border: 4px solid var(--tier, #f59e0b);
  box-shadow: 0 0 20px color-mix(in srgb, var(--tier, #f59e0b) 48%, transparent), 0 12px 28px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}
.reveal-card.pop { animation: revealpop 0.38s cubic-bezier(0.16, 1.4, 0.4, 1); }
@keyframes revealpop {
  0%   { transform: scale(0.55) rotate(-6deg); opacity: 0; }
  60%  { transform: scale(1.06) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
/* Procedural conic-gradient light rays behind the reveal. */
.reveal-rays {
  position: absolute;
  inset: -40%;
  background: conic-gradient(from 0deg,
    rgba(255,255,255,0) 0deg, rgba(255,255,255,0.24) 12deg, rgba(255,255,255,0) 26deg,
    rgba(255,255,255,0) 90deg, rgba(255,255,255,0.2) 102deg, rgba(255,255,255,0) 116deg,
    rgba(255,255,255,0) 180deg, rgba(255,255,255,0.22) 192deg, rgba(255,255,255,0) 206deg,
    rgba(255,255,255,0) 270deg, rgba(255,255,255,0.2) 282deg, rgba(255,255,255,0) 296deg);
  animation: rayspin 14s linear infinite;
  pointer-events: none;
}
@keyframes rayspin { to { transform: rotate(360deg); } }
.reveal-tier {
  position: relative;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 3px;
  margin-bottom: 4px;
}
.reveal-art {
  position: relative;
  height: 132px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 104px;
  line-height: 1;
}
.reveal-art img {
  height: 100%;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.3));
  animation: revealfloat 3s ease-in-out infinite;
}
@keyframes revealfloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-7px); }
}
.reveal-name {
  position: relative;
  font-size: 27px;
  font-weight: 900;
  color: #26304a;
  margin-top: 2px;
}
.reveal-desc {
  position: relative;
  font-size: 14px;
  color: #4b5670;
  margin-top: 6px;
  line-height: 1.5;
  word-break: keep-all;
  min-height: 20px;
}
.reveal-hint { position: relative; margin-top: 12px; font-size: 12px; color: #8d94a8; }
.reveal-card.short .reveal-art { height: 130px; font-size: 76px; }
.reveal-card.short .reveal-hint { display: none; }


/* AI spectator mode. */
#demoBtn.on { background: #ffe0e0; border-color: #ff8a8a; color: #a33; }
#demoBar {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(88%, 720px);
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(20, 32, 50, 0.88);
  color: #fff;
  z-index: 9;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  max-width: 92%;
  border: 1px solid rgba(159, 197, 255, .36);
  transition: border-color .18s, background-color .18s;
}
#demoBar.hidden { display: none; }
#demoBar[data-tone="guide"] { border-color: rgba(139, 205, 255, .75); background: rgba(18, 38, 64, .92); }
#demoBar[data-tone="sigil"] { border-color: rgba(255, 229, 133, .9); background: rgba(55, 30, 78, .94); }
#demoBar[data-tone="hero"] { border-color: rgba(255, 186, 105, .85); background: rgba(52, 35, 56, .93); }
#demoBar[data-tone="boss"] { border-color: rgba(255, 137, 122, .88); background: rgba(62, 28, 42, .94); }
.demo-bot { flex: none; font-size: 20px; filter: drop-shadow(0 1px 3px #0008); }
.demo-copy { min-width: 0; display: grid; flex: 1; gap: 2px; }
#demoCaption { overflow: hidden; font-size: 13px; font-weight: 900; line-height: 1.25; word-break: keep-all; }
#demoDetail { color: #c8ddff; font-size: 10px; font-weight: 700; line-height: 1.25; word-break: keep-all; }
#demoBar[data-tone="sigil"] #demoDetail { color: #ffe9ac; }
#demoBar[data-tone="hero"] #demoDetail { color: #ffd6af; }
#demoBar[data-tone="boss"] #demoDetail { color: #ffc4ba; }
#demoCaption.pop { animation: demopop 0.35s cubic-bezier(0.2, 1.5, 0.4, 1); }
@keyframes demopop {
  0%   { transform: translateY(5px); opacity: 0.3; }
  100% { transform: translateY(0); opacity: 1; }
}
#demoExit {
  flex: none;
  padding: 4px 10px;
  border-radius: 999px;
  border: none;
  background: #ff7b7b;
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
/* A restrained border treatment identifies automated control. */
body.demo-on #scene3d { box-shadow: inset 0 0 0 3px rgba(255, 123, 123, 0.55); }

/* Legacy fast-result card badge. */
.hcard .bdg.spark { color: #ffb300; text-shadow: 0 0 6px rgba(255, 179, 0, 0.6); }

/* Wave previews explain that mythic pressure raises both enemy strength and rewards. */
.wchip.myth { background: linear-gradient(180deg, #ff8ac4, #d5399a); color: #fff; font-weight: 800; }

/* Legacy unused hint state. */
.hintbtn.free {
  background: #e8ffe3;
  border-color: #45b02e;
  color: #2a7a1a;
  animation: streakpulse 1.2s ease-in-out infinite;
}
/* Legacy decimal cells use a narrower width than digit cells. */
.mv-c.mv-dot { color: #2f3d55; }

/* Legacy champion HUD chip and constellation skill-tree modal. */
#champChip {
  position: absolute;
  left: 10px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: rgba(22, 28, 46, 0.82);
  border: 2px solid rgba(255, 226, 122, 0.55);
  border-radius: 14px;
  color: #fff;
  z-index: 5;
  backdrop-filter: blur(3px);
}
#champChip.ko { border-color: rgba(170, 180, 212, 0.5); filter: saturate(0.4); }
#champFace {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: radial-gradient(circle at 40% 30%, #3b4a8f, #141a33);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  overflow: hidden;
  flex: none;
}
#champFace img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.35) translateY(6%); }
.champ-mid { display: flex; flex-direction: column; gap: 3px; min-width: 96px; }
.champ-name { font-size: 12px; line-height: 1; display: flex; align-items: center; gap: 5px; }
.champ-lv {
  background: linear-gradient(180deg, #ffe27a, #f5b93d);
  color: #4a3505;
  font-weight: 800;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
}
.champ-lv.pop { animation: combopop 0.4s cubic-bezier(0.2, 1.6, 0.4, 1); }
.champ-ko { font-size: 11px; color: #ffb0b0; font-weight: 800; }
.champ-hp, .champ-xp {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}
.champ-xp { height: 4px; }
#champHpFill { height: 100%; width: 100%; background: linear-gradient(90deg, #6ee08a, #b6f09a); transition: width 0.15s; }
#champHpFill.mid { background: linear-gradient(90deg, #ffc93d, #ffe08a); }
#champHpFill.low { background: linear-gradient(90deg, #ff5d5d, #ff9a7a); }
#champXpFill { height: 100%; width: 0; background: linear-gradient(90deg, #9fb6ff, #d8b4ff); transition: width 0.25s; }
.champ-btns { display: flex; gap: 6px; }
.champ-btns button {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-family: inherit;
  cursor: pointer;
  overflow: hidden;
  padding: 0;
}
.champ-btns button:not(:disabled):hover { border-color: #ffe27a; background: rgba(255, 226, 122, 0.14); }
.champ-btns button:disabled { opacity: 0.55; cursor: default; }
.champ-btns .bicon { position: relative; font-size: 19px; z-index: 2; }
.champ-btns .bkey {
  position: absolute;
  right: 2px;
  bottom: 1px;
  font-size: 9px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.75);
  z-index: 3;
}
/* Cooldown and charge gauges fill from below. */
.cdfill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 0%;
  background: rgba(120, 150, 255, 0.4);
  z-index: 1;
  transition: height 0.12s linear;
}
.cdfill.ult { background: linear-gradient(180deg, rgba(216, 180, 255, 0.55), rgba(130, 90, 220, 0.55)); }
#ultBtn.full {
  border-color: #d8b4ff;
  box-shadow: 0 0 12px rgba(216, 180, 255, 0.8);
  animation: streakpulse 1.1s ease-in-out infinite;
}
#spellBtn.ready { border-color: #ffe27a; }
.spbadge {
  position: absolute;
  top: -1px;
  right: -1px;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #ff5d8a;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
  padding: 0 3px;
}
#skillBtn.has-sp { border-color: #ff9ec4; animation: streakpulse 1.2s ease-in-out infinite; }

/* Constellation skill-tree modal. */
.modal-card.skill { max-width: 620px; }
.skill-desc { font-size: 13px; color: #4a5670; margin-bottom: 10px; }
#skillCols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.skill-branch {
  background: linear-gradient(180deg, #f4f7ff, #e9eefc);
  border: 2px solid #ccd6ee;
  border-radius: 12px;
  padding: 8px;
}
.skill-branch h3 { font-size: 14px; margin-bottom: 6px; text-align: center; color: #2c3352; }
.skill-node {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 2px solid #c8d2ea;
  background: #fff;
  border-radius: 10px;
  padding: 6px 7px;
  margin-bottom: 6px;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.1s;
}
.skill-node:not(:disabled):hover { border-color: #7f9bf0; transform: translateY(-1px); }
.skill-node:disabled { cursor: default; opacity: 0.9; }
.skill-node.maxed { border-color: #f5b93d; background: #fff8e0; }
.skill-node.locked { opacity: 0.55; background: #eef0f6; }
.skill-node.can { border-color: #ff9ec4; box-shadow: 0 0 8px rgba(255, 158, 196, 0.45); }
.skill-node .semoji { font-size: 20px; flex: none; }
.skill-node .sinfo { flex: 1; min-width: 0; }
.skill-node .sname { font-size: 13px; font-weight: 800; color: #2c3352; line-height: 1.15; }
.skill-node .sper { font-size: 11px; color: #5a6a8a; }
.skill-node .spips { font-size: 10px; letter-spacing: 1px; color: #f5a93d; }
.skill-node .slock { font-size: 11px; color: #8a93ad; }

/* Stack constellations and compact the chip on narrow screens. */
@media (max-width: 720px) {
  .tactic-impact { top: 8px; right: 8px; min-width: 142px; padding: 5px 8px 5px 6px; }
  .tactic-impact-icon { width: 29px; height: 29px; font-size: 19px; }
  .tactic-impact-copy b { font-size: 12px; }
  #skillCols { grid-template-columns: 1fr; }
  #champChip { gap: 6px; padding: 5px 6px; bottom: 8px; left: 8px; }
  #champFace { width: 36px; height: 36px; font-size: 22px; }
  .champ-mid { min-width: 76px; }
  .champ-btns button { width: 38px; height: 38px; }
  .champ-btns .bkey { display: none; }
}

/* Champion wardrobe: name, hair, clothes, weapon and starlight. */
#champFace {
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  transition: transform 0.12s;
}
#champFace:hover { transform: scale(1.08); box-shadow: 0 0 10px rgba(255, 226, 122, 0.7); }

.modal-card.closet { max-width: 540px; }
.closet-top { display: flex; gap: 14px; align-items: center; margin-bottom: 10px; }
#closetPreview {
  width: 132px;
  height: 132px;
  flex: none;
  border-radius: 16px;
  background: radial-gradient(circle at 40% 30%, #3b4a8f, #141a33);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 3px solid #ffe27a;
}
#closetPreview img { width: 100%; height: 100%; object-fit: cover; }
#closetPreview .closet-emoji { font-size: 56px; }
.closet-namebox { flex: 1; }
.closet-namebox label { font-size: 13px; font-weight: 800; color: #4a5670; }
.closet-namebox input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 18px;
  border: 2px solid #c8d2ea;
  border-radius: 10px;
}
.closet-namebox input:focus { outline: none; border-color: #7f9bf0; }
.closet-note { font-size: 12px; color: #7a86a0; margin-top: 6px; line-height: 1.5; }
.closet-axis { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.claxis { flex: none; width: 74px; font-size: 13px; font-weight: 800; color: #2c3352; padding-top: 6px; }
.clopts { display: flex; flex-wrap: wrap; gap: 6px; }
.clopt {
  display: flex;
  align-items: center;
  gap: 5px;
  border: 2px solid #c8d2ea;
  background: #fff;
  border-radius: 999px;
  padding: 5px 11px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.1s;
}
.clopt:hover { transform: translateY(-1px); border-color: #7f9bf0; }
.clopt.on {
  border-color: #f5a93d;
  background: #fff4d8;
  font-weight: 800;
  box-shadow: 0 0 8px rgba(245, 169, 61, 0.4);
}
.clswatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
  flex: none;
}
@media (max-width: 560px) {
  .closet-top { flex-direction: column; }
  .claxis { width: 62px; }
}

/* Move overlays away from small mobile pads during placement, using reduced emphasis rather than sudden disappearance. */
/* Declare transitions on the base state so both entering and leaving placement animate consistently. */
#waveBtn, #champChip, #wavePreview, #coachChip { transition: opacity 0.16s ease; }
.stage.placing #waveBtn,
.stage.placing #champChip,
.stage.placing #wavePreview,
.stage.placing #coachChip {
  opacity: 0.16;
  pointer-events: none;
}
.stage.placing #waveBtn { transform: translateX(-50%) scale(0.9); }

/* Show placement guidance below the battlefield only on narrow/touch layouts. Desktop already shows the bench alongside it; adding a bar would resize the canvas. */
.placebar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  padding: 5px 10px;
  border-radius: 12px;
  font-size: 14px;
  /* Subtle idle guidance becomes green during placement. */
  background: #f2f4f8;
  border: 2px solid #dbe2ec;
  box-shadow: 0 3px 0 #cdd6e2;
  color: #6b7688;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}
.placebar.on {
  background: linear-gradient(180deg, #eafbef, #d6f5e0);
  border-color: #6fd08c;
  box-shadow: 0 3px 0 #4fae6c;
  color: #14532d;
}
#placeBarText { font-weight: 700; }
/* Reserve cancel-button space but show it only during placement. */
.placebar:not(.on) #placeBarCancel { visibility: hidden; }
#placeBarCancel {
  flex-shrink: 0;
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  background: #fff;
  border: 2px solid #a7d8b6;
  color: #14532d;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}
#placeBarCancel:active { transform: translateY(1px); }

/* Show guidance on stacked or touch layouts after the default hidden rule. */
@media (max-width: 1080px), (pointer: coarse) {
  .placebar { display: flex; }
  /* Hide redundant bench hints on mobile to prevent layout shifts and irrelevant keyboard instructions. */
  #benchHint { display: none !important; }
}

/* Enlarge interactive targets for touch. */
@media (pointer: coarse) {
  .placebar { font-size: 15px; padding: 6px 10px; }
  #placeBarCancel { padding: 8px 15px; font-size: 15px; }
  /* Increase separation around champion spell buttons to reduce accidental taps near pads. */
  #champChip { left: 6px; bottom: 6px; }
}

/* Codex and records. */
#bookBtn {
  position: relative;
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(180deg, #5aa7e8, #2f6fc8);
  box-shadow: 0 2px 0 #1e4e96;
  font-family: inherit;
}
#bookBtn:active { transform: translateY(2px); box-shadow: none; }

.modal-card.book { width: 560px; text-align: left; }
.modal-card.book h2 { text-align: center; }
.book-tabs { display: flex; gap: 6px; margin: 12px 0 10px; }
.book-tabs button {
  flex: 1;
  border: 1px solid #cdd6e2;
  background: #f2f6fa;
  border-radius: 10px;
  padding: 7px 4px;
  font-family: inherit;
  font-weight: 800;
  font-size: 13px;
  color: #5b6a84;
  cursor: pointer;
}
.book-tabs button.on { background: #2f6fc8; border-color: #2f6fc8; color: #fff; }
.book-body {
  max-height: min(58vh, 520px);
  overflow-y: auto;
  overscroll-behavior: contain;
  margin-bottom: 12px;
  padding-right: 4px;
}
.book-progress {
  font-size: 13.5px;
  background: #f0f5fb;
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 8px;
}
.book-progress .cnt { color: #7a86a0; font-size: 12px; margin-left: 6px; }
.book-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid #eef2f8;
  font-size: 14px;
}
.book-row.unknown { color: #a5aec2; }
.book-row.unknown .bkemoji { filter: grayscale(1); opacity: 0.6; }
.bkemoji { font-size: 22px; width: 30px; text-align: center; flex-shrink: 0; }
.bkname { font-weight: 800; min-width: 86px; }
.bktag {
  font-size: 10px;
  font-weight: 800;
  border-radius: 6px;
  padding: 1px 6px;
  margin-left: 5px;
  vertical-align: 2px;
  color: #fff;
}
.bktag.sp { background: #a855f7; }
.bktag.mythic { background: #ff4d9d; }
.bktag.mid { background: #ff9a3d; }
.bktag.boss { background: #e14b4b; }
.bkcells { margin-left: auto; display: flex; gap: 4px; }
.bkcell {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: #dfe5ef;
}
.bkcell:not(.on) { color: #a5aec2; }
.bkkills { margin-left: auto; font-size: 13px; color: #5b6a84; font-weight: 700; }

/* Achievement rows. */
.book-row.ach { align-items: flex-start; }
.book-row.ach .bkemoji { margin-top: 2px; }
.book-row.ach:not(.done) { opacity: 0.72; }
.book-row.ach.done { background: #f2fbf3; border-radius: 10px; }
.bkach { flex: 1; min-width: 0; }
.bkach .bkname { min-width: 0; }
.bkdesc { font-size: 12px; color: #7a86a0; }
.bkdone { color: #2c9e4b; font-size: 12px; margin-left: 4px; }
.bkreward {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 800;
  color: #b8860b;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.bkunlock { font-size: 11px; color: #8a5fd6; font-weight: 700; }

/* Legacy record styling. */
.tactic-summary { display: flex; gap: 8px; margin-bottom: 10px; }
.msbox {
  flex: 1;
  background: #f0f5fb;
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
}
.msbox b { display: block; font-size: 22px; color: #2f6fc8; }
.msbox span { font-size: 11.5px; color: #7a86a0; }
.mathrow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-bottom: 1px solid #eef2f8;
  font-size: 13px;
}
.mrgrade { flex-shrink: 0; font-weight: 800; color: #7a86a0; font-size: 11.5px; width: 40px; }
.mrname { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.mrbar {
  flex-shrink: 0;
  width: 110px;
  height: 9px;
  border-radius: 999px;
  background: #e7ecf4;
  overflow: hidden;
}
.mrbar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #7fd45e, #3fae57); }
.mrnum { flex-shrink: 0; font-size: 11.5px; color: #7a86a0; width: 86px; text-align: right; }

/* Thirtieth-dawn victory. */
.modal-card.victory {
  width: 470px;
  background: linear-gradient(180deg, #fff9e8, #ffffff 55%);
  border: 2px solid #ffd76e;
}
.victory-sun { font-size: 46px; animation: vicsun 2.4s ease-in-out infinite; }
@keyframes vicsun { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .victory-sun { animation: none; } }
.modal-card.victory h2 { font-size: 24px; color: #b8860b; }
.victory-stats {
  background: #fdf6e4;
  border-radius: 12px;
  padding: 12px 14px;
  margin: 12px 0;
  font-size: 14px;
  line-height: 1.9;
  text-align: left;
}
.victory-msg { font-size: 13px; color: #7a86a0; margin: 8px 0 12px; }
.victory-note { font-size: 12px; color: #a08a4e; margin: 6px 0 10px; }

/* Loop indicator in the HUD. */
.loopchip {
  margin-left: 6px;
  font-size: 11.5px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #ffb64e, #e8892f);
  border-radius: 999px;
  padding: 2px 8px;
  vertical-align: 2px;
}
.loopchip.hidden { display: none; }

/* Constellation Defense tactics board in the right-hand interaction area. */
#tacticCard {
  width: 100%;
  flex: 0 0 auto;
}
.tactic-card { position: relative; overflow: hidden; padding: 8px 9px 9px; background: linear-gradient(145deg, #f7f4ff, #eff6ff); border: 1px solid #c9c5e9; }
.tactic-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tactic-head h2 { margin: 0; font-size: 15px; color: #403279; }
.tactic-head span { display: block; margin-top: 1px; color: #7a7899; font-size: 9.5px; }
.tactic-actions { display: flex; align-items: center; gap: 5px; flex: none; }
.tactic-spectate { padding: 5px 7px; border: 1px solid #b8a8e8; border-radius: 8px; background: #fff; color: #574182; font-family: inherit; font-size: 10px; font-weight: 900; cursor: pointer; white-space: nowrap; box-shadow: 0 1px 2px #8979c333; }
.tactic-spectate:hover { background: #eee8ff; transform: translateY(-1px); }
.tactic-spectate.on { border-color: #ff8a8a; background: #ffe0e0; color: #a33; }
.tactic-spectate span { display: inline; margin: 0 0 0 2px; padding: 1px 3px; border-radius: 3px; background: #e8e2fb; color: #6c5b9c; font-size: 8px; }
.tactic-spectate.on span { background: #ffd0d0; color: #a33; }
.tactic-lanes { display: flex; gap: 3px; color: #7652b8; font-size: 15px; }
.tactic-lanes b { display: grid; place-items: center; width: 23px; height: 23px; border-radius: 8px; background: #e5d9ff; }
.combat-hero-bar { display: none; align-items: center; gap: 8px; min-height: 42px; margin-top: 7px; padding: 5px 6px 5px 9px; border: 1px solid #b9b1dc; border-radius: 10px; background: #fff; box-shadow: inset 3px 0 #7252b8; }
.combat-hero-copy { display: grid; min-width: 0; flex: 1; }
.combat-hero-copy b, .combat-hero-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combat-hero-copy b { color: #403279; font-size: 12px; }
.combat-hero-copy small { color: #797895; font-size: 9.5px; }
.combat-hero-bar > button { flex: none; min-width: 83px; border: 1px solid #aaa3c8; border-radius: 8px; padding: 6px 8px; background: #e8e7ef; color: #7b7890; font-size: 11px; font-weight: 900; cursor: default; }
.combat-hero-bar > button.ready { border-color: #cc7e22; background: linear-gradient(180deg, #ffd66b, #f0a737); color: #4d3200; box-shadow: 0 2px 0 #b87219; cursor: pointer; }
.combat-hero-bar.is-empty { box-shadow: inset 3px 0 #b8b6c5; }
.combat-blueprint-bar { display: flex; align-items: center; gap: 8px; min-height: 42px; margin-top: 6px; padding: 5px 6px 5px 9px; border: 1px solid #88c9ad; border-radius: 10px; background: #f3fff9; box-shadow: inset 3px 0 #2d9f73; }
.combat-blueprint-copy { display: grid; min-width: 0; flex: 1; }
.combat-blueprint-copy b, .combat-blueprint-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combat-blueprint-copy b { color: #1d694f; font-size: 12px; }
.combat-blueprint-copy small { color: #5d7c70; font-size: 9.5px; }
.combat-blueprint-bar > button { flex: none; min-width: 83px; border: 1px solid #9eafa7; border-radius: 8px; padding: 6px 8px; background: #e4ece8; color: #718078; font-size: 11px; font-weight: 900; cursor: default; }
.combat-blueprint-bar > button.ready { border-color: #248d67; background: linear-gradient(180deg, #8af0c1, #43bd8c); color: #103f30; box-shadow: 0 2px 0 #197454; cursor: pointer; }
.combat-constellation-bar { display: flex; align-items: center; gap: 6px; min-height: 34px; margin-top: 5px; padding: 3px 4px 3px 8px; border: 1px solid #bca5ec; border-radius: 9px; background: #faf6ff; box-shadow: inset 3px 0 #8057cc; }
.combat-constellation-copy { display: grid; min-width: 0; flex: 1; }
.combat-constellation-copy b, .combat-constellation-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combat-constellation-copy b { color: #57358e; font-size: 12px; }
.combat-constellation-copy small { color: #7b6a98; font-size: 9.5px; }
.combat-constellation-bar > button { flex: none; min-width: 91px; border: 1px solid #b6acc9; border-radius: 8px; padding: 6px 8px; background: #ebe8f1; color: #817a8c; font-size: 11px; font-weight: 900; cursor: default; }
.combat-constellation-bar > button.ready { border-color: #7550b6; background: linear-gradient(180deg, #e4c5ff, #b37bea); color: #38205f; box-shadow: 0 2px 0 #7045af; cursor: pointer; }
.tactic-routes { display: grid; grid-template-columns: repeat(3, 1fr); margin: 6px 0 4px; text-align: center; color: #77739a; font-size: 10px; font-weight: 800; }
.tactic-routes span { position: relative; z-index: 3; border-radius: 7px; transition: color .15s, background .15s, box-shadow .15s, transform .15s; }
.lane-pressure { gap: 4px; }
.lane-pressure > span { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 1px 5px; padding: 3px 5px; border: 1px solid #d4d1e6; background: #f8f8fc; }
.lane-pressure > span > b { color: #57536f; font-size: 9.5px; text-align: left; }
.lane-pressure > span > em { color: #7d7993; font-size: 8.5px; font-style: normal; text-align: right; white-space: nowrap; }
.lane-pressure > span > i { grid-column: 1 / -1; display: block; height: 4px; overflow: hidden; border-radius: 99px; background: #e2e2eb; }
.lane-pressure > span > i > i { display: block; width: 0; height: 100%; border-radius: inherit; background: #85b88b; transition: width .18s linear; }
.lane-pressure > span.watch > i > i { background: #d3a848; }
.lane-pressure > span.pressed { border-color: #de9a55; background: #fff5e8; }
.lane-pressure > span.pressed > i > i { background: #e07a3f; }
.lane-pressure > span.critical { border-color: #df655c; background: #fff0ef; }
.lane-pressure > span.critical > b, .lane-pressure > span.critical > em { color: #9b2f31; }
.lane-pressure > span.critical > i > i { background: #d94c52; }
.tactic-routes span.active { color: #fff; transform: translateY(-1px) scale(1.06); text-shadow: 0 1px 2px #161530; animation: tacticroute .28s ease-out both; }
.tactic-routes span.active.flare { background: #d66656; box-shadow: 0 0 13px #f4a159; }
.tactic-routes span.active.tide { background: #4e84c5; box-shadow: 0 0 13px #8de6ff; }
.tactic-routes span.active.bloom { background: #4c9b72; box-shadow: 0 0 13px #aef58f; }
.tactic-board { position: relative; z-index: 2; display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; width: min(100%, 286px); margin-inline: auto; padding: 5px; border-radius: 11px; background: linear-gradient(135deg, #2a2255, #151938); box-shadow: inset 0 2px 6px #07071d77; touch-action: none; user-select: none; overscroll-behavior: contain; }
.tactic-board.casting { outline: 2px solid var(--tactic-glow, #d8b4ff); outline-offset: 1px; }
.tactic-star { position: relative; z-index: 2; min-width: 0; aspect-ratio: 1; border: 1px solid #ffffff55; border-radius: 8px; cursor: pointer; font-size: clamp(15px, 2.1vw, 23px); line-height: 1; transition: transform .13s, filter .13s, outline .13s; background: #4d4185; }
.tactic-star:hover { transform: translateY(-2px); filter: brightness(1.15); }
.tactic-star.picked { outline: 3px solid #ffe985; transform: scale(.9); z-index: 1; }
.tactic-star.flare { background: radial-gradient(circle at 40% 33%, #ffe4a3, #ee8b5e 46%, #9e4767); }
.tactic-star.tide { background: radial-gradient(circle at 40% 33%, #d7f8ff, #78bce8 46%, #4f6eb6); }
.tactic-star.bloom { background: radial-gradient(circle at 40% 33%, #e6ffd0, #8bd582 46%, #518f7c); }
.guided-opening .tactic-star.guided-from,
.guided-opening .tactic-star.guided-to {
  z-index: 5;
  outline: 3px solid #fff3a6;
  box-shadow: 0 0 0 4px #ffd55a55;
}
.guided-opening .tactic-star.guided-from::after {
  content: '→';
  position: absolute;
  left: 72%;
  top: 50%;
  z-index: 7;
  color: #fff8c7;
  font-size: 24px;
  text-shadow: 0 2px 5px #342453;
  transform: translateY(-50%);
  pointer-events: none;
}
.tactic-star.matched { z-index: 4; border-color: #fff; animation: tacticmatch .22s cubic-bezier(.18, 1.55, .42, 1) both; }
.tactic-star.matched.flare { box-shadow: 0 0 0 2px #ffe4a3, 0 0 20px 7px #f48559; }
.tactic-star.matched.tide { box-shadow: 0 0 0 2px #e7fbff, 0 0 20px 7px #6bd9ff; }
.tactic-star.matched.bloom { box-shadow: 0 0 0 2px #edffcf, 0 0 20px 7px #89e98c; }
.tactic-star.matched.jackpot { animation-duration: .28s; }
.tactic-beam { position: absolute; z-index: 5; height: 4px; border-radius: 99px; opacity: 0; pointer-events: none; transform-origin: left center; transform: rotate(var(--beam-angle)) scaleX(0); }
.tactic-beam.run { animation: tacticbeam .23s cubic-bezier(.1, .8, .3, 1) both; }
.tactic-beam.flare { background: linear-gradient(90deg, #fff4b0, #ff824f); box-shadow: 0 0 6px #fff2a6, 0 0 16px #ff7650; }
.tactic-beam.tide { background: linear-gradient(90deg, #ecffff, #64cfff); box-shadow: 0 0 6px #e5ffff, 0 0 16px #5abcf9; }
.tactic-beam.bloom { background: linear-gradient(90deg, #efffcf, #76d98e); box-shadow: 0 0 6px #efffcf, 0 0 16px #6ddf89; }
.tactic-beam::after { content: ''; position: absolute; right: -4px; top: 50%; width: 10px; height: 10px; border-radius: 50%; background: #fff; transform: translateY(-50%); box-shadow: 0 0 10px 4px currentColor; }
.tactic-key { display: flex; justify-content: space-around; margin-top: 5px; color: #615e85; font-size: 9px; font-weight: 700; }
.tactic-sigil-hint { margin-top: 3px; color: #65438f; text-align: center; font-size: 8.5px; font-weight: 850; letter-spacing: -.1px; }
.tactic-status { margin-top: 4px; min-height: 17px; border-radius: 7px; padding: 3px 6px; background: #e7e8f8; color: #59567a; text-align: center; font-size: 9.5px; font-weight: 700; }

/* Five separate edge buttons caused long eye travel.  One consistent strip
 * below the battlefield keeps every hero active within the same thumb path. */
.combat-skill-dock {
  display: grid;
  grid-template-columns: repeat(var(--skill-count, 5), minmax(0, 1fr));
  gap: 5px;
  flex: 0 0 auto;
  margin-top: 6px;
  padding: 5px;
  border: 1px solid #b9b1dc;
  border-radius: 12px;
  background: linear-gradient(135deg, #f8f5ff, #edf5ff);
  box-shadow: 0 3px 10px #34456b22;
}
.combat-skill-dock button {
  min-width: 0;
  min-height: 42px;
  border: 1px solid #bbb4d2;
  border-radius: 9px;
  padding: 4px 3px;
  background: #eceaf1;
  color: #777386;
  font-family: inherit;
  line-height: 1.05;
}
.combat-skill-dock button b,
.combat-skill-dock button small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combat-skill-dock button b { font-size: 10.5px; }
.combat-skill-dock button small { margin-top: 3px; font-size: 8.5px; }
.combat-skill-dock button.ready {
  border-color: #c77d22;
  background: linear-gradient(180deg, #ffe17e, #efad43);
  color: #513600;
  box-shadow: 0 2px 0 #ac6c1c;
  cursor: pointer;
}
@media (max-width: 720px) {
  #demoBar { bottom: 8px; width: 94%; max-width: 94%; gap: 6px; padding: 7px 8px; align-items: flex-start; }
  .demo-bot { font-size: 17px; }
  #demoCaption { font-size: 11.5px; }
  #demoDetail { font-size: 9px; }
  #demoExit { padding: 4px 6px; font-size: 10px; }
}
body:not(.combat-focus) .combat-skill-dock { display: none; }
body.judge-opening .tactic-status { background: #302a61; color: #fff4b5; font-size: 13px; box-shadow: 0 0 18px #8e72ff66; }
body.judge-mode #coachChip,
body.judge-mode #diffRow { display: none !important; }
.tactic-card[data-match-size="4"] .tactic-status { background: #fff0bf; color: #81591e; }
.tactic-card[data-match-size="5"] .tactic-status { background: #ffdce8; color: #8c3159; box-shadow: 0 0 14px #ff8ebd88; }
.tactic-card[data-match-size="6"] .tactic-status { background: #fff0b8; color: #6d397f; box-shadow: 0 0 17px #bd76edaa; }
.tactic-card[data-match-size="6"] .tactic-board { outline-width: 3px; box-shadow: inset 0 2px 6px #07071d77, 0 0 17px #c77df099; }
@keyframes tacticmatch { 0% { transform: scale(.76); filter: brightness(1); } 58% { transform: scale(1.25); filter: brightness(1.7); } 100% { transform: scale(1.08); filter: brightness(1.35); } }
@keyframes tacticroute { 0% { filter: brightness(.8); } 55% { filter: brightness(1.45); } 100% { filter: brightness(1); } }
@keyframes tacticbeam { 0% { opacity: 0; transform: rotate(var(--beam-angle)) scaleX(0); } 22% { opacity: 1; } 76% { opacity: 1; transform: rotate(var(--beam-angle)) scaleX(1); } 100% { opacity: 0; transform: rotate(var(--beam-angle)) scaleX(1.08); } }
@media (max-width: 720px) {
  #tacticCard { width: min(100%, 390px); justify-self: center; margin-inline: auto; }
  .tactic-board { width: min(100%, 360px); }
  .tactic-star { font-size: 23px; }
  .tactic-head { align-items: flex-start; }
  .tactic-spectate { padding: 4px 5px; font-size: 9px; }
  .tactic-lanes { display: none; }
  .combat-hero-copy small { max-width: 190px; }
  .combat-blueprint-copy small { max-width: 190px; }
  .combat-constellation-copy small { max-width: 190px; }
}

/* During a live defense, management recedes and the fixed party becomes a
 * compact selector. Preparation and towns restore every growth/control panel. */
body.combat-focus #bookBtn,
body.combat-focus #metaBtn,
body.combat-focus .right > .tabs,
body.combat-focus .right > .tabbody,
body.combat-focus .under-row,
body.combat-focus #helpBox { display: none !important; }
body.combat-focus .hero-card-grid { gap: 5px; }
body.combat-focus .hero-card { min-height: 69px; grid-template-columns: 46px minmax(0, 1fr); grid-template-areas: 'art copy'; align-items: center; padding: 6px; }
body.combat-focus .hero-card.sel { padding: 5px; }
body.combat-focus .hero-card-art { width: 43px; height: 43px; border-radius: 14px; }
body.combat-focus .hero-card-crest { font-size: 23px; }
body.combat-focus .hero-card-ability,
body.combat-focus .hero-card-stats,
body.combat-focus .hero-card-growth { display: none; }
body.combat-focus .squad-intro { margin-bottom: 4px; }
body.combat-focus .squad-intro span { display: none; }
body.combat-focus #benchCard { padding: 7px 8px; }
body.combat-focus #benchCard .bench { margin-top: 4px; }

@media (max-width: 560px) {
  .combat-skill-dock { gap: 3px; padding: 4px; }
  .combat-skill-dock button { min-height: 45px; padding-inline: 2px; }
  .combat-skill-dock button b { font-size: 9px; }
  body.combat-focus .hero-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.combat-focus .hero-card-name { font-size: 13px; }
  body.combat-focus .hero-card-role { font-size: 8px; }
  body.combat-focus .hero-card-title { display: none; }
}

/* Wardrobe locks. */
.clopt.locked {
  opacity: 0.55;
  cursor: not-allowed;
  background: #eef1f6;
  color: #8a94ac;
}

/* Restrained effects are the default and respect the operating system's reduced-motion preference. */
.reduced-effects #bossWarnBanner,
.reduced-effects #bossBanner,
.reduced-effects #comboChip.pop,
.reduced-effects .combine-row.ready,
.reduced-effects .hcard.t3,
.reduced-effects .hcard.t4,
.reduced-effects .reveal.t4,
.reduced-effects .tactic-board.casting,
.reduced-effects .tactic-routes span.active,
.reduced-effects .guided-opening .tactic-star.guided-from,
.reduced-effects .guided-opening .tactic-star.guided-to {
  animation: none !important;
}
.reduced-effects .tactic-star.matched { animation-duration: .12s; }
.reduced-effects .tactic-beam.run { animation-duration: .13s; }
.reduced-effects .defense-victory { transition: none; }

@media (prefers-reduced-motion: reduce) {
  #bossWarnBanner,
  #bossBanner,
  #comboChip.pop,
  .combine-row.ready,
  .hcard.t3,
  .hcard.t4,
  .reveal.t4,
  .tactic-board.casting,
  .tactic-routes span.active,
  .guided-opening .tactic-star.guided-from,
  .guided-opening .tactic-star.guided-to {
    animation: none !important;
  }
  .tactic-star.matched { animation-duration: .12s; }
  .tactic-beam.run { animation-duration: .13s; }
  .defense-victory { transition: none; }
}
@font-face { font-family: "Jua"; src: url("../assets/fonts/Jua-Regular.ttf") format("truetype"); font-display: swap; font-weight: 400; }
@font-face { font-family: "Gaegu"; src: url("../assets/fonts/Gaegu-Bold.ttf") format("truetype"); font-display: swap; font-weight: 700; }
