:root {
  --bg: #0e1117;
  --panel: #161b22;
  --line: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --accent2: #a371f7;
  --danger: #f85149;
  --heal: #3fb950;
  --card: #21262d;
  --card-border: #3d444d;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  font-family: "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", Meiryo, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background: radial-gradient(1200px 800px at 20% 0%, #1f2937 0%, var(--bg) 55%);
  color: var(--text);
}

html.scg-duel-view,
body.scg-duel-view {
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
}

html.scg-card-zoom-open,
body.scg-card-zoom-open {
  overflow: hidden;
  overscroll-behavior: none;
}

body.scg-duel-view .shell {
  flex: 1;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

body.scg-card-zoom-open .shell {
  overflow: hidden;
}

.shell {
  max-width: min(1320px, 100%);
  width: 100%;
  margin: 0 auto;
  padding: 0.65rem clamp(0.5rem, 2.8vw, 1.85rem) 0.5rem;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.topbar {
  text-align: center;
  margin-bottom: 0.85rem;
}

body.scg-duel-view .topbar {
  margin-bottom: 0.5rem;
}

.logo {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.tagline {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

#screen-game.screen.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  max-height: calc(100dvh - 4.25rem);
  overflow: hidden;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.25rem 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

.panel.hero {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 420px;
  margin: 2rem auto;
}

h2 {
  margin: 0.5rem 0 1rem;
  font-size: 1.35rem;
}

h3 {
  margin: 1rem 0 0.5rem;
  font-size: 1rem;
  color: var(--muted);
  font-weight: 600;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.join-row {
  display: flex;
  gap: 0.5rem;
}

.input {
  flex: 1;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0d1117;
  color: var(--text);
  font-size: 1rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.btn {
  cursor: pointer;
  border: 1px solid var(--line);
  background: #21262d;
  color: var(--text);
  border-radius: 10px;
  padding: 0.65rem 1rem;
  font-size: 1rem;
  transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s;
}

.btn:hover {
  border-color: var(--accent);
}

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

.btn.primary {
  background: linear-gradient(135deg, #1f6feb, #8957e5);
  border-color: transparent;
  font-weight: 600;
}

.btn.ghost {
  background: transparent;
}

.btn.xl {
  padding: 0.9rem 1rem;
  font-size: 1.05rem;
}

.btn.back {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.room-code-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.75rem;
  margin: 0 0 1rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0d1117;
}

.room-code-label {
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.room-code-value {
  font-size: 1.12rem;
  letter-spacing: 0.22em;
  color: var(--accent);
}

.room-code-copy {
  font-size: 0.8rem;
  padding: 0.26rem 0.7rem;
  margin-left: auto;
}

.mono {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  letter-spacing: 0.18em;
}

.lobby-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.lobby-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--muted);
}

.lobby-list li strong {
  color: var(--text);
}

.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-top: 1rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  background: #21262d;
  border: 1px solid var(--line);
  padding: 0.65rem 1rem;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 50;
  max-width: min(520px, 92vw);
}

.toast[hidden] {
  display: none !important;
}

/* カード共通 */
.card-face {
  position: relative;
  width: 140px;
  min-height: 190px;
  border-radius: 8px;
  background: linear-gradient(160deg, #2a3038, #1a1f26);
  border: 1px solid var(--card-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card-face.wide {
  width: 160px;
  min-height: 210px;
}

.card-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.card-panel {
  border-radius: 0;
  border: 1px solid rgba(61, 68, 77, 0.95);
  background: rgba(13, 17, 23, 0.55);
}

.card-panel--head {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.28rem 0.38rem;
  flex-shrink: 0;
}

.card-title {
  font-size: 0.78rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.02em;
  line-height: 1.25;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-cost {
  position: static;
  flex-shrink: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #f0c674;
  text-shadow: 0 0 10px rgba(240, 198, 116, 0.3);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.card-panel--body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: block;
  padding: 0.48rem 0.4rem 0.35rem;
  font-size: 0.88rem;
  line-height: 1.55;
  letter-spacing: 0.01em;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.card-body > span {
  display: inline;
  vertical-align: baseline;
  line-height: inherit;
}

.card-face.wide .card-inner {
  gap: 0.32rem;
}

.card-face.wide .card-panel--head {
  padding: 0.3rem 0.42rem;
}

.card-face.wide .card-title {
  font-size: 0.86rem;
}

.card-face.wide .card-cost {
  font-size: 1.12rem;
}

.card-face.wide .card-body {
  font-size: 0.9rem;
  padding: 0.52rem 0.42rem 0.38rem;
}

.seg-muted {
  color: #c9d1d9;
}

.seg-damage {
  color: #ff7b72;
  font-weight: 800;
  text-shadow: 0 0 14px rgba(248, 81, 73, 0.35);
}

.seg-heal {
  color: #56d364;
  font-weight: 800;
  text-shadow: 0 0 14px rgba(63, 185, 80, 0.35);
}

.seg-draw {
  color: #79c0ff;
  font-weight: 800;
}

.seg-discard {
  color: #ffa657;
  font-weight: 800;
}

.seg-condition {
  color: #d2a8ff;
  font-weight: 800;
}

.seg-cap {
  color: #f0883e;
  font-weight: 800;
}

/* デッキ構築 */
.deck-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.deck-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 0.75rem;
  margin: 0.25rem 0 0.35rem;
}

.deck-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.deck-toolbar select,
.select-input {
  min-width: 10rem;
  padding: 0.5rem 0.6rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0d1117;
  color: var(--text);
  font-size: 0.95rem;
}

.deck-toolbar .deck-name {
  min-width: 11rem;
  letter-spacing: normal;
  text-transform: none;
}

.lobby-deck-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.75rem 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.deck-meta {
  margin: 0;
  color: var(--muted);
}

.deck-status.ok {
  color: var(--heal);
}

.deck-status.bad {
  color: var(--danger);
}

.deck-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-height: 2.5rem;
  padding: 0.5rem;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #0d1117;
}

.deck-chip {
  font-size: 0.78rem;
  padding: 0.25rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  cursor: pointer;
  color: var(--text);
  background: #161b22;
}

.deck-chip:hover {
  border-color: var(--danger);
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.65rem;
}

.catalog-grid .card-face {
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s;
}

.catalog-grid .card-face:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.deck-footer {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

/* 対戦（1画面・手札折り返し・カード寸法統一） */
#screen-game {
  --duel-card-w: 108px;
  --duel-card-h: 142px;
}

#screen-game.duel-zoom-lg {
  --duel-card-w: 128px;
  --duel-card-h: 168px;
}

@media (min-width: 641px) {
  #screen-game.duel-zoom-lg {
    --duel-card-w: 136px;
    --duel-card-h: 178px;
  }
}

#screen-game.duel-zoom-lg .card-face:not(.wide) .card-title {
  font-size: 0.7rem;
}

#screen-game.duel-zoom-lg .card-face:not(.wide) .card-cost {
  font-size: 0.88rem;
}

#screen-game.duel-zoom-lg .card-face:not(.wide) .card-body {
  font-size: 0.64rem;
  padding: 0.42rem 0.24rem 0.28rem;
}

#screen-game.duel-zoom-lg .card-face:not(.wide) .card-panel--head {
  padding: 0.2rem 0.28rem;
}

#screen-game .card-face:not(.wide) {
  width: var(--duel-card-w);
  min-height: var(--duel-card-h);
  max-height: var(--duel-card-h);
  padding: 0.2rem;
  flex: 0 0 auto;
}

#screen-game .card-face:not(.wide) .card-inner {
  gap: 0.15rem;
}

#screen-game .card-face:not(.wide) .card-panel--head {
  padding: 0.16rem 0.24rem;
  gap: 0.18rem;
}

#screen-game .card-face:not(.wide) .card-title {
  font-size: 0.62rem;
}

#screen-game .card-face:not(.wide) .card-cost {
  font-size: 0.78rem;
}

#screen-game .card-face:not(.wide) .card-body {
  font-size: 0.58rem;
  line-height: 1.48;
  padding: 0.38rem 0.22rem 0.24rem;
}

.duel-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  max-width: 100%;
  width: 100%;
  margin: 0 auto;
}

.duel-opp-field,
.duel-self-field {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(22, 27, 34, 0.96);
  padding: 0.45rem 0.55rem 0.5rem;
}

.duel-opp-field {
  border-color: rgba(248, 81, 73, 0.42);
  box-shadow: inset 0 0 0 1px rgba(248, 81, 73, 0.07);
  flex: 0 0 auto;
}

.duel-self-field {
  border-color: rgba(88, 166, 255, 0.42);
  box-shadow: inset 0 0 0 1px rgba(88, 166, 255, 0.08);
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.duel-self-main {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.5rem;
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 0.35rem;
}

.duel-field-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.duel-field-head--opp {
  align-items: center;
}

.duel-attack-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.12rem;
  min-width: 6.5rem;
}

.duel-attack-block--self {
  align-items: flex-start;
}

.duel-attack-label {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.duel-attack-num {
  font-size: clamp(1.55rem, 4.2vw, 2.35rem);
  line-height: 1;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 22px rgba(255, 184, 108, 0.38);
}

.duel-id-block {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem 0.75rem;
}

.duel-player-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.duel-hp-line {
  font-size: 0.95rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.duel-hp-num {
  color: var(--text);
  font-weight: 700;
}

.duel-hp-max {
  color: var(--muted);
  font-weight: 500;
}

.duel-zone-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.duel-field-split {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.5rem;
  min-height: 0;
  margin-top: 0.35rem;
}

.duel-field-split--opp {
  flex: 0 1 auto;
}

.duel-pile-column {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 0 0 auto;
  width: clamp(4.5rem, 13vw, 5.75rem);
}

.duel-pile-column .pile {
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
  padding: 0.36rem 0.38rem;
}

.duel-pile-column .pile-name {
  margin-bottom: 0.1rem;
  font-size: 0.64rem;
}

.duel-pile-column .pile-num {
  font-size: 1.12rem;
}

.duel-play-column {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.duel-field-split--opp .duel-play-column {
  min-width: 0;
  min-height: 0;
}

.duel-play-column > .duel-hand-lane {
  margin-top: 0;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

.pile {
  flex: 1 1 5.5rem;
  min-width: 5.1rem;
  padding: 0.5rem 0.55rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0d1117;
  text-align: center;
}

.pile-name {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.22rem;
}

.pile-num {
  display: block;
  font-size: 1.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.15;
}

.pile--deck {
  border-color: rgba(88, 166, 255, 0.38);
}

.pile--discard {
  border-color: rgba(255, 166, 87, 0.42);
}

.pile--hand {
  border-color: rgba(210, 168, 255, 0.38);
}

.pile--meta {
  border-color: rgba(139, 148, 158, 0.45);
}

.duel-hand-mat {
  flex: 1 1 auto;
  min-width: 0;
  align-self: flex-start;
  width: 100%;
  display: flex;
  flex-direction: column;
  padding: 0.4rem 0.45rem 0.45rem;
  border-radius: 12px;
  border: 1px solid rgba(88, 166, 255, 0.38);
  background: linear-gradient(
    180deg,
    rgba(20, 26, 36, 0.98) 0%,
    rgba(8, 12, 18, 0.99) 100%
  );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 6px 24px rgba(0, 0, 0, 0.35);
}

.duel-hand-mat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex: 0 0 auto;
  margin-bottom: 0.38rem;
}

.duel-hand-mat-player {
  font-size: 0.88rem;
  font-weight: 700;
  color: #79c0ff;
  letter-spacing: 0.05em;
}

.duel-hand-mat .duel-hand-lane-label {
  margin-bottom: 0;
  font-size: 0.72rem;
}

.duel-hand-lane {
  margin-top: 0.35rem;
}

.duel-hand-lane-label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.32rem;
  letter-spacing: 0.05em;
}

.duel-hand-strip {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: flex-end;
  gap: 0.28rem;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 0.35rem 0.22rem 0.08rem;
  min-height: calc(var(--duel-card-h) + 1.05rem);
  max-height: calc(var(--duel-card-h) + 1.05rem);
  overflow-x: auto;
  overflow-y: hidden;
}

.duel-hand-mat .duel-hand-self {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: flex-end;
  gap: 0.32rem;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 0.35rem 0.22rem 0.08rem;
  min-height: calc(var(--duel-card-h) + 1.05rem);
  max-height: calc(var(--duel-card-h) + 1.05rem);
  overflow-x: auto;
  overflow-y: hidden;
  flex: 0 0 auto;
}

.duel-hand-scroll {
  scrollbar-width: thin;
  scrollbar-color: rgba(88, 166, 255, 0.55) rgba(13, 17, 23, 0.98);
  touch-action: pan-x pinch-zoom;
}

.duel-hand-scroll--opp {
  scrollbar-color: rgba(248, 113, 102, 0.55) rgba(13, 17, 23, 0.98);
}

.duel-hand-scroll::-webkit-scrollbar {
  height: 11px;
}

.duel-hand-scroll::-webkit-scrollbar-track {
  margin: 0 6px;
  border-radius: 999px;
  background: linear-gradient(180deg, #141920, #0a0d12);
  box-shadow: inset 0 0 0 1px rgba(48, 54, 61, 0.55);
}

.duel-hand-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  border: 2px solid #0d1117;
  background: linear-gradient(90deg, #3d7bdc, #8b5cf6);
}

.duel-hand-scroll--opp::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, #e5534b, #d29922);
}

.duel-hand-scroll::-webkit-scrollbar-thumb:hover {
  filter: brightness(1.14);
}

.duel-hand-strip .card-face {
  cursor: default;
}

.duel-hand-self .card-face {
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s;
}

.duel-hand-self .card-face:hover:not(.disabled) {
  transform: translateY(-6px);
}

.duel-hand-self .card-face.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.duel-hand-self .card-face.disabled:hover {
  transform: none;
}

.duel-center {
  flex: 0 1 auto;
  min-height: 0;
  max-height: min(26vh, 11rem);
}

.duel-log-panel {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0d1117;
  overflow: hidden;
}

.duel-log-head {
  padding: 0.38rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: rgba(22, 27, 34, 0.88);
}

#screen-game .battle-log {
  max-height: min(22vh, 9rem);
  margin: 0;
  border: none;
  border-radius: 0;
  font-size: 0.78rem;
  overflow-y: auto;
  line-height: 1.38;
  padding: 0.38rem 0.5rem;
  background: #0d1117;
}

.battle-log .log-row {
  padding: 0.15rem 0;
  border-bottom: 1px solid rgba(48, 54, 61, 0.45);
}

.battle-log .log-row:last-child {
  border-bottom: none;
}

.battle-log .log-row.flash {
  animation: logFlash 0.55s ease-out;
}

.battle-log .log-sys {
  color: var(--muted);
}

.battle-log .log-you {
  color: #79c0ff;
}

.battle-log .log-opp {
  color: #ff9c94;
}

.battle-log .log-clash {
  color: #d2a8ff;
  font-weight: 700;
}

.battle-log .log-neg {
  color: #ffa657;
}

@keyframes logFlash {
  from {
    background: rgba(88, 166, 255, 0.22);
  }
  to {
    background: transparent;
  }
}

.duel-field-foot {
  margin-top: 0.45rem;
  padding: 0.45rem 0.45rem 0.5rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 0 0 auto;
  background: rgba(8, 12, 18, 0.65);
  border-radius: 0 0 12px 12px;
}

.duel-foot-left {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  flex: 1 1 auto;
}

.duel-foot-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.32rem 0.4rem;
}

.duel-round-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.42rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(139, 148, 158, 0.18);
  color: var(--text);
  border: 1px solid rgba(139, 148, 158, 0.35);
}

.duel-round-badge span {
  font-variant-numeric: tabular-nums;
}

.duel-stat-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.22rem;
  padding: 0.12rem 0.4rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0d1117;
  font-size: 0.78rem;
}

.duel-stat-chip--atk {
  border-color: rgba(255, 184, 108, 0.38);
}

.duel-stat-chip-label {
  font-size: 0.64rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.duel-stat-chip-num {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.duel-stat-chip--atk .attack-stock {
  font-size: 1.2rem;
  line-height: 1;
}

.duel-stat-chip .duel-hp-max {
  font-size: 0.78em;
  font-weight: 500;
  color: var(--muted);
}

.duel-stat-chip .duel-cost-nums {
  margin-left: 0;
}

#cost-bar.wait {
  opacity: 0.52;
}

.duel-foot-right {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: stretch;
}

@media (min-width: 720px) {
  .duel-field-foot {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem 1rem;
  }

  .duel-foot-left {
    flex: 1 1 auto;
  }

  .duel-foot-right {
    flex: 0 0 auto;
    align-items: flex-end;
    min-width: min(20rem, 38%);
  }

  .duel-foot-right .duel-help-details {
    text-align: right;
  }

  #screen-game .duel-foot-right .game-actions {
    justify-content: flex-end;
  }
}

.duel-cost-line {
  font-size: 0.94rem;
  font-weight: 600;
}

.duel-cost-line.wait {
  opacity: 0.52;
}

.duel-cost-nums {
  font-variant-numeric: tabular-nums;
  margin-left: 0.35rem;
}

.duel-help-details {
  font-size: 0.72rem;
  color: var(--muted);
  max-width: 22rem;
}

.duel-help-details summary {
  cursor: pointer;
  user-select: none;
  color: var(--accent);
  list-style: none;
}

.duel-help-details summary::-webkit-details-marker {
  display: none;
}

.duel-help-details[open] summary {
  margin-bottom: 0.3rem;
}

.duel-help-details p {
  margin: 0;
  line-height: 1.45;
}

.duel-help-details kbd {
  display: inline-block;
  padding: 0.05rem 0.32rem;
  margin: 0 0.05rem;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: #0d1117;
  font-size: 0.66rem;
  font-family: ui-monospace, monospace;
}

.lock-badge {
  padding: 0.1rem 0.42rem;
  border-radius: 6px;
  font-size: 0.72rem;
  background: rgba(163, 113, 247, 0.22);
  color: #d2a8ff;
}

.attack-stock {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: #ffb86c;
}

.attack-stock.pulse {
  animation: atkPulse 0.45s ease-out;
}

@keyframes atkPulse {
  35% {
    transform: scale(1.08);
    color: #fff;
  }
}

#screen-game .turn-banner {
  margin: 0;
  font-size: 0.92rem;
  color: var(--accent);
}

#screen-game .turn-banner.wait {
  color: var(--muted);
}

#screen-game .game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
  margin-top: 0.15rem;
}

#screen-game .duel-foot-right .game-actions {
  margin-top: 0;
}

.card-zoom-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.75rem, 3vw, 2rem);
  background: rgba(0, 0, 0, 0.78);
  box-sizing: border-box;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y pan-x;
}

.card-zoom-backdrop[hidden] {
  display: none !important;
}

.card-zoom-surface {
  position: relative;
  z-index: 1;
  width: auto;
  max-width: none;
  max-height: none;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  pointer-events: auto;
}

.card-zoom-mount {
  display: flex;
  justify-content: center;
  align-items: center;
  width: auto;
  min-width: 0;
  max-width: none;
  max-height: none;
  overflow: visible;
  padding: 0;
}

.card-zoom-mount .card-face.wide {
  transform: scale(2);
  transform-origin: center center;
  flex-shrink: 0;
  will-change: transform;
}

@media (min-width: 960px) {
  .duel-field {
    display: grid;
    grid-template-columns: 1fr minmax(248px, 32%);
    grid-template-rows: auto 1fr;
    column-gap: clamp(0.5rem, 1.5vw, 1.25rem);
    row-gap: 0.4rem;
    align-items: stretch;
    min-height: 0;
    max-height: 100%;
  }

  .duel-opp-field {
    grid-column: 1;
    grid-row: 1;
  }

  .duel-self-field {
    grid-column: 1;
    grid-row: 2;
    min-height: 0;
  }

  .duel-self-main {
    flex: 1 1 auto;
    min-height: 0;
  }

  .duel-center {
    grid-column: 2;
    grid-row: 1 / 3;
    min-height: 0;
    max-height: none;
  }

  .duel-log-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  #screen-game .battle-log {
    flex: 1 1 auto;
    max-height: none;
    min-height: 0;
  }
}

@media (max-width: 640px) {
  .catalog-grid .card-face:not(.wide),
  .deck-panel .card-face:not(.wide) {
    width: 128px;
    min-height: 180px;
  }

  #screen-game {
    --duel-card-w: 82px;
    --duel-card-h: 106px;
  }

  #screen-game.duel-zoom-lg {
    --duel-card-w: 102px;
    --duel-card-h: 132px;
  }

  #screen-game .card-face:not(.wide) .card-title {
    font-size: 0.52rem;
  }

  #screen-game .card-face:not(.wide) .card-body {
    font-size: 0.52rem;
    line-height: 1.45;
    padding: 0.32rem 0.18rem 0.2rem;
  }

  #screen-game .card-face:not(.wide) .card-cost {
    font-size: 0.72rem;
  }

  .duel-attack-num {
    font-size: clamp(1.35rem, 6vw, 1.95rem);
  }
}
