:root {
  --profession-class: #59d6ff;
  --profession-spec: #bd79ff;
  --profession-gold: #f2cf78;
  --profession-ink: rgba(4, 11, 24, .96);
}

.profession-draw-dialog .profession-draw-box {
  width: min(1080px, calc(100vw - 28px));
}

.profession-draw-head > span,
.profession-hand-kicker {
  color: var(--profession-gold);
  letter-spacing: .2em;
  text-transform: uppercase;
}

.profession-draw-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(12px, 1.8vw, 22px);
}

.profession-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-width: 0;
  min-height: 250px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--profession-tone, var(--profession-class)) 54%, #fff 12%);
  border-radius: 18px;
  color: #edf7ff;
  text-align: left;
  background:
    radial-gradient(circle at 78% 8%, color-mix(in srgb, var(--profession-tone, var(--profession-class)) 25%, transparent), transparent 34%),
    linear-gradient(155deg, rgba(20, 38, 65, .97), var(--profession-ink));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 14px 34px rgba(0, 0, 0, .28);
  isolation: isolate;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.profession-card[data-source="spec"] {
  --profession-tone: var(--profession-spec);
}

.profession-card[data-source="class"] {
  --profession-tone: var(--profession-class);
}

.profession-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(120deg, transparent 9%, rgba(255, 255, 255, .2) 48%, transparent 72%);
  transition: opacity 140ms ease;
}

.profession-card:hover:not(:disabled),
.profession-card:focus-visible:not(:disabled) {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--profession-tone, var(--profession-class)) 72%, #fff 28%);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--profession-tone, var(--profession-class)) 35%, transparent), 0 18px 42px rgba(0, 0, 0, .38);
}

.profession-card:hover:not(:disabled):not([data-choice-pending="true"])::after {
  opacity: 1;
}

.profession-card:disabled {
  cursor: not-allowed;
  filter: saturate(.58) contrast(.82);
}

.profession-card[data-disabled-reason="职业牌请求处理中"] {
  cursor: progress;
}

.profession-card[data-choice-pending="true"] {
  border-color: var(--profession-gold);
  box-shadow: 0 0 0 2px rgba(242, 207, 120, .32), 0 14px 34px rgba(0, 0, 0, .3);
}

.profession-card[data-choice-pending="true"]::after {
  opacity: 0;
}

.profession-card-source,
.profession-card-cost,
.profession-card-school {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 25px;
  padding: 4px 9px;
  border: 1px solid color-mix(in srgb, var(--profession-tone, var(--profession-class)) 50%, transparent);
  border-radius: 999px;
  color: color-mix(in srgb, var(--profession-tone, var(--profession-class)) 75%, #fff 25%);
  background: rgba(2, 8, 18, .62);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.profession-card-cost {
  position: absolute;
  top: 14px;
  right: 14px;
  color: #fff1b7;
  border-color: rgba(242, 207, 120, .48);
}

.profession-card strong {
  display: block;
  margin: 20px 0 10px;
  color: #fff;
  font-size: clamp(22px, 2vw, 30px);
  line-height: 1.12;
}

.profession-card p {
  margin: 0;
  color: rgba(229, 240, 255, .86);
  font-size: 15px;
  line-height: 1.62;
}

.profession-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 18px;
}

.profession-replace-panel {
  margin-top: 18px;
  padding: 15px;
  border: 1px solid rgba(242, 207, 120, .4);
  border-radius: 16px;
  background: rgba(6, 13, 27, .88);
}

.profession-replace-panel[hidden],
.profession-hand-drawer[hidden] {
  display: none !important;
}

.profession-replace-copy {
  margin: 0 0 12px;
  color: #fff0be;
  text-align: center;
}

.profession-replace-cards,
.profession-hand-cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-block: 6px 14px;
  overscroll-behavior-inline: contain;
  scroll-padding-block: 6px 14px;
  scrollbar-width: thin;
}

.profession-replace-cards .profession-card,
.profession-hand-cards .profession-card {
  min-height: 210px;
  padding: 14px;
}

.profession-replace-cards .profession-card strong,
.profession-hand-cards .profession-card strong {
  margin-top: 16px;
  font-size: 19px;
}

.profession-replace-back {
  display: block;
  min-height: 38px;
  margin: 12px auto 0;
}

.profession-hand-action b {
  margin-left: 6px;
  color: #bfefff;
}

/* The single hand control belongs to the local character, outside the libraries. */
.profession-hand-anchor {
  position: fixed;
  left: var(--profession-hand-left, 6px);
  top: var(--profession-hand-top, -100px);
  z-index: 101;
  width: var(--profession-hand-width, 180px);
  height: 44px;
}

.profession-hand-anchor[hidden] {
  display: none;
}

.profession-hand-anchor > .profession-hand-open {
  display: grid;
  grid-template-columns: 13px auto;
  align-items: center;
  justify-content: center;
  gap: 1px 9px;
  width: 100%;
  min-width: 0;
  height: 44px;
  min-height: 44px;
  margin: 0;
  padding: 7px 12px;
  border: 1px solid var(--lfd-ui-border-strong, var(--lfd-ui-border));
  border-radius: var(--lfd-ui-radius-control, 10px);
  color: var(--lfd-ui-text);
  background: var(--lfd-ui-panel);
  box-shadow: var(--lfd-ui-shadow-panel);
  font-size: 13px;
  line-height: 1.2;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--lfd-ui-motion), border-color var(--lfd-ui-motion);
}

.profession-hand-open::before {
  all: unset;
  content: "";
  display: block;
  grid-column: 1;
  grid-row: 1 / span 2;
  flex: 0 0 13px;
  height: 18px;
  border: 1px solid currentColor;
  border-radius: 3px;
  box-shadow: -3px -2px 0 -1px var(--lfd-ui-panel), -4px -3px 0 -1px currentColor;
  color: var(--lfd-ui-text-muted);
}

.profession-hand-open::after {
  content: none;
}

.profession-hand-anchor > .profession-hand-open > span {
  grid-column: 2;
  grid-row: 1;
}

.profession-hand-open[data-void-state]:not([data-void-state=""])::after {
  all: unset;
  content: attr(data-void-state);
  grid-column: 2;
  grid-row: 2;
  color: var(--lfd-ui-text-muted);
  font-size: 10px;
  line-height: 1.2;
}

.profession-hand-anchor > .profession-hand-open:hover:not(:disabled) {
  background: var(--lfd-ui-panel-hover);
  border-color: var(--lfd-ui-border-strong);
}

.profession-hand-anchor > .profession-hand-open:focus-visible {
  outline: 2px solid var(--lfd-ui-border-strong);
  outline-offset: 3px;
  box-shadow: var(--lfd-ui-focus);
}

.profession-hand-anchor > .profession-hand-open:disabled {
  cursor: not-allowed;
  filter: saturate(.55) contrast(.8);
}

#battle[data-profession-hand-layout] .self-seat .team-hand-count,
#youHandCount[hidden] {
  display: none;
}

@media (max-width: 720px), (orientation: landscape) and (max-height: 520px) and (max-width: 960px) {
  /* Override inherited geometry tokens at their owning surface, without changing seats. */
  #appRoot.team-battle-app #battle.battle.team-mode[data-profession-hand-layout="team"],
  #appRoot.identity-battle-app #battle.battle.identity-battle[data-profession-hand-layout="identity"] {
    --mtb-board-bottom: calc(var(--mtb-action-bottom) + var(--mtb-action-h) + 54px);
  }

  #appRoot.duel-battle-app:not(.team-battle-app):not(.identity-battle-app)
  #battle.battle:not(.team-mode):not(.identity-battle)[data-profession-hand-layout="duel"] > .fighters {
    --duel-mobile-stage-bottom: calc(var(--mobile-battle-action-bottom, var(--duel-mobile-action-bottom)) + var(--mobile-action-button-h) + 62px);
    --mobile-battle-stage-bottom: calc(var(--mobile-battle-action-bottom, var(--duel-mobile-action-bottom)) + var(--mobile-action-button-h) + 62px);
  }
}

/* V1.334 landscape and focus safety locks live in the final UI contract. */

.profession-hand-public,
.team-hand-count {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid rgba(105, 203, 255, .36);
  border-radius: 999px;
  color: #c8f1ff;
  background: rgba(4, 17, 34, .68);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.profession-hand-drawer {
  position: fixed;
  inset: 0;
  z-index: 1260;
  display: grid;
  place-items: end center;
  padding: 18px;
  background: rgba(0, 5, 14, .54);
  backdrop-filter: blur(8px);
}

.profession-hand-panel {
  width: min(1160px, 100%);
  max-height: min(72dvh, 760px);
  padding: clamp(16px, 2vw, 24px);
  overflow: auto;
  border: 1px solid rgba(105, 203, 255, .38);
  border-radius: 22px 22px 14px 14px;
  color: #eef8ff;
  background: linear-gradient(155deg, rgba(13, 30, 53, .985), rgba(3, 9, 21, .99));
  box-shadow: 0 -22px 70px rgba(0, 0, 0, .52), inset 0 1px 0 rgba(255, 255, 255, .1);
}

.profession-hand-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.profession-hand-title {
  display: grid;
  gap: 4px;
}

.profession-hand-title strong {
  font-size: clamp(22px, 3vw, 34px);
}

.profession-hand-head button {
  min-width: 82px;
  min-height: 42px;
}

.profession-hand-empty {
  margin: 10px 0;
  padding: 30px 18px;
  border: 1px dashed rgba(141, 211, 255, .32);
  border-radius: 15px;
  color: rgba(220, 237, 255, .72);
  text-align: center;
}

.profession-hand-hint {
  margin: 14px 0 0;
  color: rgba(207, 226, 247, .72);
  font-size: 13px;
  text-align: center;
}

.profession-target-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(189, 121, 255, .4);
  border-radius: 16px;
  background: rgba(14, 9, 31, .82);
}

.profession-target-panel[hidden] {
  display: none !important;
}

.profession-target-panel > p {
  margin: 0 0 12px;
  color: #ead8ff;
  font-weight: 900;
  text-align: center;
}

.profession-targets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 9px;
}

.profession-target-option {
  min-height: 44px;
  border: 1px solid rgba(189, 121, 255, .5);
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, rgba(65, 35, 103, .92), rgba(10, 24, 48, .94));
  font-weight: 900;
}

.profession-target-option:hover:not(:disabled),
.profession-target-option:focus-visible:not(:disabled) {
  border-color: #e9ccff;
  box-shadow: 0 0 20px rgba(189, 121, 255, .32);
}

#professionTargetBack {
  display: block;
  min-height: 38px;
  margin: 12px auto 0;
}

@media (max-width: 900px) {
  .profession-draw-options {
    grid-template-columns: 1fr;
    max-height: 64dvh;
    overflow-y: auto;
    padding-block: 6px 10px;
    scroll-padding-block: 6px 10px;
  }

  .profession-draw-options .profession-card {
    min-height: 188px;
  }

  .profession-replace-cards,
  .profession-hand-cards {
    grid-template-columns: repeat(5, minmax(156px, 74vw));
    scroll-snap-type: x mandatory;
  }

  .profession-replace-cards .profession-card,
  .profession-hand-cards .profession-card {
    scroll-snap-align: center;
  }

  html body:not(.maintenance-mode):has(
    #appRoot.app.battle-app.duel-battle-app:not(.team-battle-app):not(.identity-battle-app)
    #battle.battle:not([hidden]):not(.team-mode):not(.identity-battle)
  ) > .profession-hand-drawer {
    padding: 0;
  }

  html body:not(.maintenance-mode):has(
    #appRoot.app.battle-app.duel-battle-app:not(.team-battle-app):not(.identity-battle-app)
    #battle.battle:not([hidden]):not(.team-mode):not(.identity-battle)
  ) > .profession-hand-drawer > .profession-hand-panel {
    max-height: 60dvh;
    border-radius: 20px 20px 0 0;
  }

  html body:not(.maintenance-mode):has(
    #appRoot.app.team-battle-app:not(.identity-battle-app)
    #battle.battle.team-mode:not(.identity-battle):not([hidden])
  ) > .profession-hand-drawer,
  html body:not(.maintenance-mode):has(
    #appRoot.app.identity-battle-app #battle.battle.identity-battle:not([hidden])
  ) > .profession-hand-drawer {
    padding: 8px;
  }

  html body:not(.maintenance-mode):has(
    #appRoot.app.team-battle-app:not(.identity-battle-app)
    #battle.battle.team-mode:not(.identity-battle):not([hidden])
  ) > .profession-hand-drawer > .profession-hand-panel,
  html body:not(.maintenance-mode):has(
    #appRoot.app.identity-battle-app #battle.battle.identity-battle:not([hidden])
  ) > .profession-hand-drawer > .profession-hand-panel {
    max-height: 56dvh;
  }
}

@media (max-width: 430px) {
  .profession-draw-dialog .profession-draw-box {
    width: calc(100vw - 14px);
  }

  .profession-card {
    border-radius: 14px;
  }

  html body:not(.maintenance-mode):has(
    #appRoot.app.battle-app.duel-battle-app:not(.team-battle-app):not(.identity-battle-app)
    #battle.battle:not([hidden]):not(.team-mode):not(.identity-battle)
  ) > .profession-hand-drawer {
    padding: 0;
  }

  html body:not(.maintenance-mode):has(
    #appRoot.app.battle-app.duel-battle-app:not(.team-battle-app):not(.identity-battle-app)
    #battle.battle:not([hidden]):not(.team-mode):not(.identity-battle)
  ) > .profession-hand-drawer > .profession-hand-panel {
    padding: 14px 12px max(14px, env(safe-area-inset-bottom));
  }
}

body[data-vfx-quality="low"] .profession-hand-drawer {
  background: rgba(0, 5, 14, .82);
  backdrop-filter: none;
}

@media (prefers-reduced-motion: reduce) {
  .profession-hand-drawer {
    background: rgba(0, 5, 14, .76);
    backdrop-filter: none;
  }

  .profession-card {
    transition: none;
  }

  .profession-card::after {
    transition: none;
  }

  .profession-card:hover:not(:disabled),
  .profession-card:focus-visible:not(:disabled) {
    transform: none;
  }
}

@media (forced-colors: active) {
  .profession-card,
  .profession-hand-panel,
  .profession-replace-panel {
    border: 2px solid CanvasText;
    color: CanvasText;
    background: Canvas;
    forced-color-adjust: none;
  }

  .profession-card:hover:not(:disabled),
  .profession-card:focus-visible:not(:disabled) {
    outline: 3px solid Highlight;
    outline-offset: 2px;
  }
}
