/* 데모 페이지 — 로비 · 장비 장착 · 대전 */
html,
body {
  margin: 0;
  height: 100%;
  background: #050403;
  color: var(--tc-text);
  font-family: var(--tc-font-body);
  overflow: hidden;
}
button {
  font: inherit;
}
/* 무대: index.html 의 fit() 이 정한 논리 크기로 배치한 뒤 창에 맞게 확대·축소한다.
   안쪽에서는 vw·vh 대신 무대 기준인 cqw·cqh, @media 대신 @container app 을 쓴다. */
#app {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--app-w, 100vw);
  height: var(--app-h, 100vh);
  transform: scale(var(--app-scale, 1));
  transform-origin: 0 0;
  overflow: hidden;
  container: app / size;
}
.screen {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
  background: center / cover no-repeat #050403;
}
.screen.on {
  display: block;
}
.screen > .tc-embers,
.screen > .tc-vignette {
  z-index: 1;
}
.ico {
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  background: currentColor;
  -webkit-mask: var(--src) center / contain no-repeat;
  mask: var(--src) center / contain no-repeat;
  vertical-align: -0.2em;
  flex: none;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  padding: 0.35em 0.8em;
  border: 1px solid var(--tc-ink-600);
  border-radius: 999px;
  background: rgba(11, 10, 9, 0.65);
  font-size: 0.85rem;
  color: var(--tc-text-muted);
}
.iconbtn {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--tc-bronze-700);
  background: rgba(11, 10, 9, 0.65);
  color: var(--tc-bronze-300);
  font-size: 1.1rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, transform 0.15s;
}
.iconbtn:hover {
  border-color: var(--tc-bronze-300);
  color: var(--tc-bronze-200);
}
.iconbtn:active {
  transform: scale(0.94);
}
.tc-btn {
  cursor: pointer;
  transition: filter 0.15s, transform 0.12s;
}
.tc-btn:hover {
  filter: brightness(1.12);
}
.tc-btn:active {
  transform: translateY(1px) scale(0.99);
}
.tc-btn[disabled] {
  filter: grayscale(0.7) brightness(0.7);
  cursor: default;
}
/* 아이콘이 붙은 버튼: 오른쪽에 아이콘만큼 빈 칸을 둬서 글자가 버튼 한가운데 오게 한다 */
.tc-btn:has(> .ico:first-child)::after {
  content: "";
  flex: none;
  width: 1.15em;
}

/* ================= 로비 ================= */
#lobby {
  background-image: url(../assets/backgrounds/lobby-base.jpg);
}
#lobby .shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse 46% 52% at 50% 56%, rgba(5, 4, 3, 0.62), rgba(5, 4, 3, 0.3) 70%, rgba(5, 4, 3, 0.55));
}
#lobby .logo {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 5cqh;
  width: min(440px, 30cqw);
  translate: -50% 0;
  filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.7));
}
.menu {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 57%;
  translate: -50% -50%;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.05rem;
}
.menu li {
  position: relative;
  translate: var(--dx) 0;
  font: 400 2.05rem/1.2 var(--tc-font-serif);
  letter-spacing: 0.14em;
  color: #c8c0b0;
  text-shadow: 0 2px 6px #000, 0 0 2px #000;
  cursor: pointer;
  white-space: nowrap;
  transition: scale 0.2s;
}
.menu li.on {
  scale: 1.06;
  animation: tca-ignite 0.45s ease-out forwards;
}
.menu li::after {
  content: "";
  position: absolute;
  left: -6%;
  right: -6%;
  bottom: -0.18em;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(243, 165, 72, 0.85), transparent);
  transform: scaleX(0);
  opacity: 0;
}
.menu li.on::after {
  animation: tca-underline 0.35s 0.05s cubic-bezier(0.3, 0.8, 0.3, 1) forwards;
}
.menu .note {
  display: none;
  position: absolute;
  left: 100%;
  top: 50%;
  translate: 0 -50%;
  margin-left: 1.1em;
  white-space: nowrap;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  color: rgba(243, 200, 140, 0.75);
  text-shadow: 0 1px 4px #000;
}
.menu li.on .note {
  display: block;
}
#lobby .foot {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 3.2cqh;
  display: flex;
  justify-content: center;
  gap: 2.4em;
  font-family: var(--tc-font-serif);
  font-size: 0.9rem;
  letter-spacing: 0.12em;
  color: rgba(200, 192, 176, 0.55);
  text-shadow: 0 1px 3px #000;
}
#lobby .foot .conn {
  color: rgba(127, 191, 166, 0.75);
}
#lobby .foot .conn.off {
  color: rgba(200, 192, 176, 0.55);
}

/* 매칭 대기 */
.matching {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at center, rgba(5, 4, 3, 0.7), rgba(5, 4, 3, 0.92));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.menu,
#lobby .foot {
  transition: opacity 0.3s, filter 0.3s;
}
#lobby.waiting .menu,
#lobby.waiting .foot,
#lobby.listing .menu {
  opacity: 0;
  filter: blur(4px);
}
.matching.on {
  opacity: 1;
  pointer-events: auto;
}
.matching .box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  font-family: var(--tc-font-serif);
  font-size: 1.5rem;
  letter-spacing: 0.18em;
  color: var(--tc-bone-200);
  text-shadow: 0 2px 6px #000;
}
.matching .ring {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(163, 34, 27, 0) 0deg, rgba(163, 34, 27, 0.2) 60deg, #a3221b 300deg, #d04a35 340deg, rgba(163, 34, 27, 0) 360deg);
  -webkit-mask: radial-gradient(closest-side, transparent 72%, #000 74%, #000 96%, transparent 98%);
  mask: radial-gradient(closest-side, transparent 72%, #000 74%, #000 96%, transparent 98%);
  animation: spin 1.1s linear infinite;
  filter: drop-shadow(0 0 8px rgba(208, 74, 53, 0.6));
}
.matching .sub {
  font-size: 0.95rem;
  letter-spacing: 0.1em;
  color: var(--tc-text-muted);
  text-align: center;
  word-break: keep-all;
  padding: 0 20px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 내 방: 상대를 기다리는 동안 로비 오른쪽 위에 띄운다. 메뉴는 그대로 쓸 수 있다 */
.room-chip {
  position: absolute;
  z-index: 30;
  top: 3.2cqh;
  right: 2.4cqw;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(600px, 46cqw);
  padding: 8px 10px 8px 16px;
  border: 1px solid rgba(122, 86, 39, 0.6);
  border-radius: 12px;
  background: rgba(11, 10, 9, 0.8);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  font-family: var(--tc-font-serif);
  color: var(--tc-bone-200);
}
.room-chip[hidden],
.room-chip .tc-btn[hidden],
.lo-room[hidden] {
  display: none;
}
.room-chip .ring,
.lo-room .ring {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(163, 34, 27, 0) 0deg, rgba(163, 34, 27, 0.2) 60deg, #a3221b 300deg, #d04a35 340deg, rgba(163, 34, 27, 0) 360deg);
  -webkit-mask: radial-gradient(closest-side, transparent 66%, #000 70%, #000 94%, transparent 98%);
  mask: radial-gradient(closest-side, transparent 66%, #000 70%, #000 94%, transparent 98%);
  animation: spin 1.1s linear infinite;
}
/* 잠깐 띄우는 알림 (방이 닫혔다 등) 에는 고리가 없다 */
.room-chip.note .ring,
.lo-room.note .ring {
  display: none;
}
.rc-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rc-text b {
  font-weight: 400;
  letter-spacing: 0.08em;
}
.rc-text span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
  color: var(--tc-text-muted);
}
.rc-text span:empty {
  display: none;
}
.room-chip .tc-btn {
  flex: none;
  min-height: 46px;
  border-width: 14px;
  border-image-width: 14px;
  font-size: 0.92rem;
}
/* 장비 장착 화면 제목 옆 */
.lo-room {
  max-width: 34cqw;
  margin-top: 6px;
  font-family: var(--tc-font-serif);
  white-space: nowrap;
}
.lo-room .ring {
  width: 16px;
  height: 16px;
}
.lo-room #lo-room-t {
  overflow: hidden;
  text-overflow: ellipsis;
}
.lo-room.hot {
  border-color: var(--tc-bronze-500);
  color: #ffd08a;
}

/* 대화 상자 (규칙·환경설정) */
.modal {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  background: rgba(5, 4, 3, 0.6);
}
.modal.on {
  display: grid;
}
.modal .tc-parchment,
.modal .tc-panel {
  width: min(620px, 80cqw);
  max-height: 76cqh;
  overflow: auto;
}
.modal h3 {
  margin: 0 0 12px;
  font: 400 1.5rem/1.1 var(--tc-font-display);
}
.modal ul {
  margin: 0;
  padding-left: 1.2em;
  line-height: 1.85;
}
.modal .close {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}
/* 진영 선택 */
.sides {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.side-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px 14px;
  border: 1px solid rgba(122, 86, 39, 0.45);
  border-radius: 8px;
  background: rgba(10, 9, 8, 0.45);
  color: var(--tc-text-muted);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.side-btn img {
  width: 72px;
  height: 72px;
}
.side-btn b {
  font: 400 1.15rem/1.1 var(--tc-font-display);
  color: var(--tc-bone-100);
}
.side-btn small {
  font-size: 0.8rem;
}
.side-btn:hover,
.side-btn:focus-visible {
  outline: none;
  border-color: var(--tc-bronze-500);
  background: rgba(185, 138, 69, 0.14);
  transform: translateY(-2px);
}
/* 온라인 대전 진영 선택: 내가 고른 것, 상대가 이미 고른 것 */
.side-btn.mine {
  border-color: var(--tc-ember-400);
  background: rgba(240, 138, 58, 0.16);
  box-shadow: 0 0 18px rgba(240, 138, 58, 0.3);
}
.side-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
  border-color: rgba(122, 86, 39, 0.45);
  background: rgba(10, 9, 8, 0.45);
}
/* 한 판 더: 결과 화면(z-index 80) 위에 뜬다 */
#m-pick {
  z-index: 95;
}
.pick-lead {
  margin: 0 0 14px;
  color: var(--tc-text-muted);
}
.pick-state {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  font-size: 0.95rem;
  color: var(--tc-bone-200);
}
#pick-opp.done,
#pick-me.done {
  color: var(--tc-ember-400);
}
@container app (max-width: 560px) {
  .sides {
    grid-template-columns: 1fr;
  }
  .side-btn {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
  }
  .side-btn img {
    width: 48px;
    height: 48px;
  }
}
.setting {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid rgba(122, 86, 39, 0.35);
}
.toggle {
  position: relative;
  width: 60px;
  height: 30px;
  border-radius: 15px;
  border: 0;
  background: var(--tc-ink-600);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: background 0.2s;
}
.toggle::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--tc-bone-100);
  transition: transform 0.25s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.toggle.on {
  background: var(--tc-bronze-500);
}
.toggle.on::after {
  transform: translateX(30px);
}
/* 환경설정의 닉네임 버튼: 지금 닉네임을 보여 주고, 누르면 바꾼다 */
.setting .set-name {
  flex: none;
  min-height: 44px;
  max-width: 50%;
  border-width: 12px;
  border-image-width: 12px;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ================= 온라인 대전 ================= */
/* 비밀번호와 닉네임 상자는 목록이나 환경설정 위에 겹쳐 뜬다 */
#m-pass,
#m-name {
  z-index: 60;
}
#m-online .tc-panel {
  width: min(760px, 86cqw);
}
.ol-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
}
.ol-head .tc-panel__title {
  flex: 1;
  margin: 0;
}
.ol-meta {
  display: flex;
  gap: 14px;
  font-size: 0.9rem;
  color: var(--tc-text-muted);
  white-space: nowrap;
}
.ol-meta #ol-me {
  color: var(--tc-bone-200);
}
.ol-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: min(340px, 42cqh);
  margin: 14px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.ol-room {
  display: grid;
  grid-template-columns: 1.3em minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  flex: none;
  padding: 12px 14px;
  border: 1px solid rgba(122, 86, 39, 0.45);
  border-radius: 8px;
  background: rgba(10, 9, 8, 0.45);
  color: var(--tc-bone-100);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.ol-room:hover,
.ol-room:focus-visible {
  outline: none;
  border-color: var(--tc-bronze-500);
  background: rgba(185, 138, 69, 0.14);
}
.ol-lock {
  color: var(--tc-ember-400);
}
.ol-name {
  display: flex;
  align-items: baseline;
  gap: 0.7em;
  min-width: 0;
  font-size: 1.05rem;
}
.ol-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 방 이름을 붙인 방은 방장 닉네임을 옆에 작게 쓴다 */
.ol-host {
  flex: none;
  font-size: 0.82rem;
  color: var(--tc-text-faint);
}
/* 내가 만들어 둔 방 */
.ol-room.mine {
  cursor: default;
  border-color: var(--tc-bronze-500);
}
.ol-room.mine .ol-age {
  color: var(--tc-ember-400);
}
.ol-age {
  font-size: 0.82rem;
  color: var(--tc-text-faint);
}
.ol-go {
  font-family: var(--tc-font-display);
  color: var(--tc-bronze-300);
}
.ol-empty {
  margin: auto;
  max-width: 30em;
  text-align: center;
  line-height: 1.7;
  color: var(--tc-text-muted);
}
.ol-create,
.ol-code {
  display: flex;
  gap: 10px;
  align-items: center;
}
.ol-create .ol-input[hidden] {
  display: none;
}
.ol-code {
  margin: 0 auto auto;
  width: min(360px, 100%);
}
.ol-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  font: inherit;
  color: var(--tc-bone-100);
  background: rgba(5, 4, 3, 0.6);
  border: 1px solid rgba(122, 86, 39, 0.6);
  border-radius: 6px;
  outline: none;
}
.ol-input:focus {
  border-color: var(--tc-bronze-300);
}
.ol-input::placeholder {
  color: var(--tc-text-faint);
}
.ol-err {
  min-height: 1.3em;
  margin: 8px 0 0;
  font-size: 0.9rem;
  color: var(--tc-danger);
}

/* ================= 보드 ================= */
.db-board {
  position: relative;
  aspect-ratio: 1;
  background: center / 100% 100% no-repeat;
  filter: drop-shadow(0 24px 40px rgba(0, 0, 0, 0.7));
  user-select: none;
}
.db-grid {
  position: absolute;
  inset: 5.357%;
}
.db-cell,
.db-piece,
.db-top-ov {
  position: absolute;
  width: 12.5%;
  height: 12.5%;
}
.db-cell {
  cursor: default;
}
.db-cell.can {
  cursor: pointer;
}
.db-cell img,
.db-top-ov img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.db-pcs,
.db-top {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.db-piece {
  z-index: 2;
}
.db-piece > img {
  position: absolute;
  inset: 5%;
  width: 90%;
  height: 90%;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.45));
}
.db-piece .b {
  position: absolute;
  z-index: 3;
  width: 30%;
  height: 30%;
  font-size: clamp(0.65rem, 1cqw, 0.95rem);
}
.db-piece .b-atk {
  left: 0;
  bottom: 0;
}
/* 킹의 공격력 100 처럼 세 자리 숫자는 배지 안에 들어가게 줄인다 */
.db-piece .b-wide {
  font-size: clamp(0.5rem, 0.75cqw, 0.72rem);
  letter-spacing: -0.04em;
}
.db-piece .b-hp {
  right: 0;
  bottom: 0;
}
.db-piece .b-greed {
  right: 0;
  top: 0;
  width: 24%;
  height: 24%;
}
.db-piece .b-unknown {
  left: 0;
  bottom: 0;
}
.db-piece.reveal .b {
  animation: flip-in 0.5s both;
}
@keyframes flip-in {
  from {
    transform: rotateY(90deg);
  }
  to {
    transform: rotateY(0);
  }
}
.db-fx {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}
.db-ov-in {
  animation: ov-in 0.22s ease-out both;
}
@keyframes ov-in {
  from {
    opacity: 0;
    transform: scale(0.7);
  }
}

/* ================= 장비 장착 ================= */
#loadout {
  background-image: url(../assets/backgrounds/loadout-base.jpg);
}
.lo-head {
  position: absolute;
  z-index: 3;
  top: 22px;
  left: 32px;
  right: 32px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.lo-head img {
  height: 64px;
}
.lo-head h1 {
  margin: 0;
  font: 400 1.9rem/1 var(--tc-font-display);
  letter-spacing: 0.06em;
  text-shadow: 0 3px 0 #000;
}
.lo-head .sub {
  font-family: var(--tc-font-serif);
  color: var(--tc-text-muted);
}
.lo-head .spacer {
  flex: 1;
}
/* 백·흑 탭 + 같은 자리에 장착 */
.lo-side {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 8px 6px 6px;
  border: 1px solid var(--tc-ink-600);
  border-radius: 999px;
  background: rgba(11, 10, 9, 0.65);
}
.seg {
  display: flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--tc-ink-800);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}
.seg__btn {
  min-width: 64px;
  padding: 0.4em 1em;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--tc-text-faint);
  font: 400 1rem/1 var(--tc-font-display);
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.seg__btn:hover {
  color: var(--tc-text);
}
.seg__btn.on {
  background: var(--tc-ink-600);
  box-shadow: 0 0 0 1px currentColor inset;
}
.seg__btn--w.on {
  color: var(--tc-side-white);
}
.seg__btn--b.on {
  color: var(--tc-side-black);
}
.lo-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--tc-text-muted);
}
.lo-body {
  position: absolute;
  z-index: 3;
  top: 112px;
  bottom: 28px;
  left: 32px;
  right: 32px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 36px;
  align-items: center;
}
#lo-board {
  height: min(860px, calc(100cqh - 150px));
}
.lo-right {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 700px;
}
.supply {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.card {
  position: relative;
  container-type: inline-size;
  transition: filter 0.3s;
}
.card img {
  width: 100%;
  display: block;
}
/* 카드 그림(240 × 336) 아래쪽의 숫자 칸(x 80~160, y 292~316)에 맞춘다. 글자 크기는 카드 폭을 따른다 */
.card__count {
  position: absolute;
  left: 33.333%;
  top: 86.905%;
  width: 33.333%;
  height: 7.143%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3em;
  font: 400 7cqw/1 var(--tc-font-display);
  color: var(--tc-bone-100);
  white-space: nowrap;
}
.card__count b {
  color: var(--tc-bronze-200);
  font-weight: 400;
  font-size: 8.5cqw;
}
.card.empty {
  filter: grayscale(0.85) brightness(0.55);
}
.sel {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 18px;
  align-items: center;
}
.sel img {
  width: 96px;
}
.sel h3 {
  margin: 0 0 4px;
  font: 400 1.4rem/1.1 var(--tc-font-display);
}
.sel p {
  margin: 0;
  color: var(--tc-text-muted);
  font-size: 0.9rem;
}
.stat {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid rgba(122, 86, 39, 0.35);
}
.stat .tc-badge {
  width: 30px;
  height: 30px;
}
.stat .val {
  display: flex;
  align-items: center;
  gap: 10px;
}
.stat .num {
  display: inline-block;
  width: 48px;
  text-align: center;
  font: 400 1.6rem/1 var(--tc-font-display);
}
.pips {
  display: inline-flex;
  gap: 3px;
  margin-left: 8px;
  vertical-align: middle;
}
.pips i {
  width: 10px;
  height: 14px;
  border-radius: 2px;
  background: var(--tc-ink-600);
  transition: background 0.2s;
}
.pips i.on {
  background: currentColor;
}
.stat.atk {
  color: var(--tc-stat-atk);
}
.stat.hp {
  color: var(--tc-stat-hp);
}
.stat .name {
  color: var(--tc-text);
}
/* 연습 모드: 확정한 진영 탭에 표시 */
.seg__btn.done::after {
  content: " ✓";
}
.lo-link[hidden] {
  display: none;
}
/* 연습 모드: 저장된 배치 불러오기 */
.lo-load {
  display: flex;
  align-items: center;
  gap: 10px;
}
.lo-load[hidden] {
  display: none;
}
.lo-load > span {
  margin-right: auto;
  font-family: var(--tc-font-serif);
  color: var(--tc-text-muted);
}
.lo-load .tc-btn {
  min-height: 44px;
  padding-inline: 1.2em;
  font-size: 0.95rem;
}
.lo-actions {
  display: flex;
  gap: 14px;
}
.lo-actions .tc-btn {
  flex: 1;
  min-height: 66px;
  font-size: 1.3rem;
}
.lo-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--tc-text-faint);
  display: flex;
  gap: 8px;
  align-items: center;
}
.seal {
  position: absolute;
  z-index: 70;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  display: grid;
  place-items: center;
  width: 190px;
  height: 190px;
  border: 6px solid #f3e6d0;
  outline: 10px solid #a3221b;
  background: #a3221b;
  color: #f3e6d0;
  font: 400 3rem/1.05 var(--tc-font-serif);
  text-align: center;
  letter-spacing: 0.1em;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

/* ================= 대전 ================= */
#game {
  background-image: url(../assets/backgrounds/arena-base.jpg);
}
.stage {
  position: absolute;
  z-index: 3;
  inset: 24px 32px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  /* 행 높이를 무대 높이로 고정 — 전투 기록이 길어져도 행이 늘어나 체스판을 밀지 않게 */
  grid-template-rows: minmax(0, 1fr);
  gap: 32px;
  align-items: center;
}
.board-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
/* 높이와 함께 폭도 본다: 4:3 화면에서도 좌우 패널 자리(약 340씩)를 남긴다 */
#g-board {
  height: min(880px, calc(100cqh - 130px), calc(100cqw - 820px));
}
.turn {
  height: 64px;
  margin-bottom: -6px;
}
.col {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  min-height: 0;
}
.col.right > :not(.log) {
  flex: none;
}
.col.left {
  justify-content: space-between;
}
.plate {
  position: relative;
  width: 100%;
  max-width: 440px;
  aspect-ratio: 560 / 112;
  background: center / contain no-repeat;
  transition: opacity 0.4s;
}
.plate--white {
  background-image: url(../assets/ui/nameplate-white.svg);
}
.plate--black {
  background-image: url(../assets/ui/nameplate-black.svg);
}
.plate__text {
  position: absolute;
  left: 24%;
  top: 50%;
  translate: 0 -50%;
}
.plate__name {
  font: 400 1.35rem/1.1 var(--tc-font-display);
}
.plate__meta {
  font-size: 0.8rem;
  color: var(--tc-text-muted);
  margin-top: 3px;
}
.plate .tc-timer {
  position: absolute;
  right: 9%;
  top: 50%;
  translate: 0 -50%;
  width: 64px;
  height: 64px;
  font-size: 1.15rem;
}
.player.idle .plate {
  opacity: 0.65;
}
.player.idle .tc-timer__progress {
  stroke: var(--tc-steel-500);
}
.player {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.captured {
  display: flex;
  gap: 2px;
  padding-left: 8px;
  min-height: 34px;
}
.captured img {
  width: 34px;
}
.greed-panel {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 16px;
  align-items: center;
}
.greed-panel img {
  width: 84px;
  height: 84px;
}
.greed-panel h3 {
  margin: 0 0 4px;
  font: 400 1.2rem/1.1 var(--tc-font-display);
  color: var(--tc-ember-200);
}
.greed-panel p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--tc-text-muted);
}
.extra {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.extra i {
  width: 26px;
  height: 8px;
  border-radius: 4px;
  background: var(--tc-ink-600);
  transition: background 0.3s, box-shadow 0.3s;
}
.extra i.on {
  background: var(--tc-ember-400);
  box-shadow: var(--tc-glow-ember);
}
.log {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.log h3,
.memo h3 {
  margin: 0 0 8px;
  font: 400 1.15rem/1 var(--tc-font-display);
}
.log ol {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.98rem;
  line-height: 1.85;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: #9a7a4e transparent;
}
.log ol::-webkit-scrollbar {
  width: 8px;
}
.log ol::-webkit-scrollbar-track {
  background: transparent;
}
.log ol::-webkit-scrollbar-thumb {
  background: #9a7a4e;
  border-radius: 4px;
}
.log ol::-webkit-scrollbar-thumb:hover {
  background: #7b5a35;
}
.log li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  animation: log-in 0.35s ease-out both;
}
@keyframes log-in {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
}
.log li .n {
  width: 34px;
  color: #7b5a35;
  flex: none;
}
.log li .k {
  color: #8a1d14;
}
.log li .d {
  color: #9a5a14;
}
.log li .c {
  color: #b4423a;
  font-weight: 700;
}
.log li .g {
  margin-left: auto;
  font-size: 0.8rem;
  color: #7b5a35;
  white-space: nowrap;
}
.memo .who {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 40px;
  margin-bottom: 10px;
  color: var(--tc-text-muted);
  font-size: 0.9rem;
}
.memo .who img {
  width: 40px;
}
.memo .who .mine {
  margin-left: auto;
  color: var(--tc-text-faint);
  font-size: 0.8rem;
}
.memo textarea:disabled {
  opacity: 0.5;
}
/* 메모를 보고 있는 상대 기물 */
.db-piece.memo-sel > img {
  filter: drop-shadow(0 0 4px var(--tc-bronze-300)) drop-shadow(0 0 10px var(--tc-bronze-500));
}
/* 메모가 있는 상대 기물 */
.db-piece .memo-mark {
  position: absolute;
  z-index: 3;
  left: 2%;
  top: 2%;
  display: grid;
  place-items: center;
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: var(--tc-ink-900);
  border: 1px solid var(--tc-bronze-500);
  color: var(--tc-bone-100);
  font-size: clamp(0.55rem, 0.8cqw, 0.8rem);
}
.db-piece .memo-mark .ico {
  vertical-align: 0;
}
.captured img.memo-able {
  cursor: pointer;
  border-radius: 4px;
}
.captured img.noted {
  box-shadow: inset 0 -3px 0 var(--tc-bronze-500);
}
.captured img.memo-sel {
  background: rgba(255, 255, 255, 0.08);
  outline: 1px solid var(--tc-bronze-300);
}
.memo textarea {
  width: 100%;
  box-sizing: border-box;
  height: 76px;
  resize: none;
  background: var(--tc-ink-950);
  color: var(--tc-bone-100);
  border: 1px solid var(--tc-bronze-700);
  border-radius: 4px;
  padding: 10px;
  font: inherit;
  font-size: 0.92rem;
}
.actions {
  display: flex;
  gap: 12px;
}
.actions .tc-btn {
  flex: 1;
  white-space: nowrap;
}
/* 기록과 메모 탭은 세로 화면에서만 쓴다 */
.info-tabs {
  display: none;
}
.hint {
  position: absolute;
  left: 50%;
  bottom: -4px;
  translate: -50% 100%;
  font-family: var(--tc-font-serif);
  font-size: 0.9rem;
  color: var(--tc-crimson-400);
  text-shadow: 0 1px 3px #000;
  opacity: 0;
  transition: opacity 0.25s;
  white-space: nowrap;
  pointer-events: none;
}
.hint.on {
  opacity: 1;
}

/* 승격 선택 (판 위에 띄운다) */
.promo {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  background: rgba(5, 4, 3, 0.45);
}
.promo.on {
  display: grid;
}
.promo .tc-panel {
  width: min(460px, 92%);
  text-align: center;
}
.promo p {
  margin: 0 0 14px;
  font-size: 0.88rem;
  color: var(--tc-text-muted);
}
.promo__row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.promo__row .side-btn img {
  width: 64px;
  height: 64px;
}
.log li .p {
  color: #7a5627;
  font-weight: 700;
}

/* 결과 */
.result {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: radial-gradient(ellipse at center, rgba(11, 10, 9, 0.45), rgba(11, 10, 9, 0.85));
}
.result.on {
  display: flex;
}
.result .holder {
  width: min(1000px, 80cqw);
  min-height: 250px;
  display: grid;
  place-items: center;
  position: relative;
}
.result .reason {
  font-family: var(--tc-font-serif);
  color: var(--tc-bone-200);
  font-size: 1.8rem;
  text-shadow: 0 2px 6px #000;
}
.result .reveal {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--tc-text-muted);
  font-size: 0.9rem;
}
.result .row {
  display: flex;
  gap: 16px;
}
.result .row .tc-btn {
  min-width: 200px;
  font-size: 1.25rem;
  min-height: 66px;
}
/* 정보 보기: 결과 창을 내린 동안 차례 배너 자리에 '결과 보기' 를 띄운다 */
.peek-back {
  position: absolute;
  z-index: 85;
  top: 14px;
  left: 50%;
  translate: -50% 0;
  display: none;
  min-width: 200px;
}
#game.peeking .peek-back {
  display: inline-flex;
  animation: fade-up 0.3s ease-out both;
}
#game.peeking .turn {
  visibility: hidden;
}
.memo .who {
  flex-wrap: wrap;
}
.memo .who .stats {
  flex-basis: 100%;
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--tc-bone-200);
}
.fade-up {
  animation: fade-up 0.5s ease-out both;
}
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

/* 연출 시연 판 */
.director {
  position: absolute;
  z-index: 90;
  left: 32px;
  bottom: 140px;
  width: 248px;
  padding: 12px;
  border: 1px solid var(--tc-bronze-700);
  border-radius: 8px;
  background: rgba(11, 10, 9, 0.88);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  font-size: 0.85rem;
  transition: transform 0.3s, opacity 0.3s;
}
/* 접힌 상태: 머리만 남긴다 (높이를 자르면 아래 패딩으로 버튼이 비쳐 보인다) */
.director.min .grid,
.director.min .tip {
  display: none;
}
.director.min header {
  margin: 0;
}
.director header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font: 400 1rem/1 var(--tc-font-display);
  color: var(--tc-bronze-200);
  cursor: pointer;
}
.director .grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.director button {
  padding: 7px 6px;
  border: 1px solid var(--tc-ink-600);
  border-radius: 5px;
  background: var(--tc-ink-800);
  color: var(--tc-bone-200);
  cursor: pointer;
  font-size: 0.82rem;
}
.director button:hover {
  border-color: var(--tc-bronze-500);
  color: var(--tc-bronze-200);
}
.director button.wide {
  grid-column: span 2;
  background: var(--tc-crimson-800);
  border-color: var(--tc-crimson-600);
}
.director button:disabled {
  opacity: 0.4;
  cursor: default;
}
.director .tip {
  margin: 10px 0 0;
  color: var(--tc-text-faint);
  line-height: 1.5;
}

/* 낮은 화면 (노트북 등) */
@container app (max-height: 920px) {
  .lo-head img {
    height: 48px;
  }
  .lo-head h1 {
    font-size: 1.5rem;
  }
  .lo-body {
    top: 88px;
    bottom: 18px;
    gap: 28px;
  }
  #lo-board {
    height: min(860px, calc(100cqh - 110px));
  }
  .lo-right {
    gap: 10px;
    max-width: 620px;
  }
  .lo-right .tc-panel {
    border-width: 18px;
    border-image-width: 18px;
  }
  .lo-right .tc-panel__title {
    margin-bottom: 6px;
  }
  .lo-note {
    display: none;
  }
  .supply {
    grid-template-columns: repeat(3, minmax(0, calc((100cqh - 600px) / 1.4)));
    justify-content: center;
    gap: 10px;
  }
  .sel {
    grid-template-columns: 64px 1fr;
    gap: 12px;
  }
  .sel img {
    width: 64px;
  }
  .sel h3 {
    font-size: 1.15rem;
  }
  .stat {
    padding: 5px 0;
  }
  .stat .iconbtn {
    width: 34px;
    height: 34px;
  }
  .stat .num {
    font-size: 1.3rem;
  }
  .lo-actions .tc-btn {
    min-height: 52px;
    font-size: 1.1rem;
  }
  #g-board {
    height: min(880px, calc(100cqh - 100px), calc(100cqw - 820px));
  }
  .turn {
    height: 48px;
  }
  .greed-panel {
    grid-template-columns: 64px 1fr;
  }
  .greed-panel img {
    width: 64px;
    height: 64px;
  }
  .memo textarea {
    height: 52px;
  }
}

/* ================= 낮은 가로 화면 (폰 가로) =================
   index.html 의 fit() 이 기준 높이를 520~660 으로 낮춘 경우. 글자를 덜 줄이는 대신 여백과 장식을 조인다. */
@container app (orientation: landscape) and (max-height: 660px) {
  /* ---- 로비 ---- */
  #lobby .logo {
    top: 4cqh;
    width: min(440px, 30cqw, 50cqh);
  }
  .menu {
    top: 63%;
    gap: 0.7rem;
  }
  .menu li {
    font-size: 1.6rem;
  }

  /* ---- 장비 장착 ---- */
  .lo-head {
    top: 10px;
    left: 20px;
    right: 20px;
    gap: 14px;
  }
  .lo-head img {
    height: 36px;
  }
  .lo-head h1 {
    font-size: 1.3rem;
  }
  .lo-head .sub {
    font-size: 0.8rem;
  }
  .lo-body {
    top: 62px;
    bottom: 10px;
    left: 20px;
    right: 20px;
    gap: 22px;
  }
  #lo-board {
    height: min(calc(100cqh - 72px), calc(100cqw - 560px));
  }
  /* 오른쪽 패널이 판 높이를 넘으면 그 안에서만 스크롤한다 */
  .lo-right {
    max-height: calc(100cqh - 72px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    gap: 8px;
  }
  .lo-right .tc-panel {
    border-width: 14px;
    border-image-width: 14px;
  }
  .lo-right .tc-panel__title {
    margin-bottom: 4px;
    font-size: 0.9rem;
  }
  .supply {
    grid-template-columns: repeat(3, minmax(0, 80px));
  }
  .sel {
    grid-template-columns: 44px 1fr;
  }
  .sel img {
    width: 44px;
  }
  .sel p {
    display: none;
  }
  .stat {
    padding: 2px 0;
  }
  .lo-actions .tc-btn {
    min-height: 48px;
    font-size: 1rem;
  }

  /* ---- 대전 ---- */
  .stage {
    inset: 10px 20px;
    gap: 20px;
  }
  .col {
    gap: 10px;
  }
  .turn {
    height: 36px;
    margin-bottom: -4px;
  }
  /* 높이와 함께 폭도 본다: 좌우 패널 자리(약 300씩)를 남긴다 */
  #g-board {
    height: min(880px, calc(100cqh - 64px), calc(100cqw - 680px));
  }
  .plate {
    max-width: 340px;
  }
  .plate__name {
    font-size: 1.15rem;
  }
  .plate .tc-timer {
    width: 52px;
    height: 52px;
    font-size: 1rem;
  }
  .player {
    gap: 6px;
  }
  .captured {
    min-height: 26px;
  }
  .captured img {
    width: 26px;
  }
  .greed-panel {
    grid-template-columns: 52px 1fr;
    gap: 10px;
    border-width: 14px;
    border-image-width: 14px;
  }
  .greed-panel img {
    width: 52px;
    height: 52px;
  }
  .greed-panel h3 {
    font-size: 1rem;
  }
  .greed-panel p {
    font-size: 0.78rem;
  }
  .log {
    border-width: 16px;
    border-image-width: 16px;
  }
  .memo {
    border-width: 14px;
    border-image-width: 14px;
  }
  .log h3,
  .memo h3 {
    margin-bottom: 4px;
    font-size: 1rem;
  }
  .log ol {
    font-size: 0.88rem;
    line-height: 1.6;
  }
  .memo .who {
    min-height: 30px;
    margin-bottom: 6px;
    font-size: 0.8rem;
  }
  .memo .who img {
    width: 30px;
  }
  .memo textarea {
    height: 44px;
    padding: 6px 8px;
  }
  .actions .tc-btn {
    min-height: 44px;
    border-width: 12px;
    border-image-width: 12px;
    font-size: 1rem;
  }
  .result {
    gap: 14px;
  }
  .result .holder {
    min-height: 150px;
    width: min(760px, 70cqw);
  }
  .result .row .tc-btn {
    min-width: 170px;
    min-height: 52px;
    font-size: 1.05rem;
  }
  .modal .tc-parchment,
  .modal .tc-panel {
    max-height: 90cqh;
  }
}

@keyframes sheet-up {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
}

/* ================= 세로 화면 (폰 세로) =================
   index.html 의 fit() 이 폭 440 기준으로 맞춘다. 체스판을 폭에 꽉 채우고 나머지는 위아래로 쌓는다.
     대전       (가운데) 상대 이름표 / 체스판 / 내 이름표와 주사위, (아래) 탭, 규칙, 항복.
                탭을 누르면 기록 또는 메모가 버튼 줄 위로 올라오고 다시 누르면 내려간다
     장비 장착  제목 / 진영 탭 / 체스판 / 선택한 기물 / 남은 장비 / 저장 (화면 아래에 붙어 있다)
   이 구간은 파일 끝에 두어 위의 max-height 규칙보다 나중에 적용되게 한다. */
@container app (orientation: portrait) {
  /* ---- 공통 ---- */
  .modal .tc-parchment,
  .modal .tc-panel {
    width: 92cqw;
    max-height: 86cqh;
    box-sizing: border-box;
  }
  .modal .tc-panel {
    border-width: 16px;
    border-image-width: 16px;
  }
  .modal .tc-parchment {
    border-width: 18px;
    border-image-width: 18px;
    font-size: 0.92rem;
  }
  .modal ul {
    line-height: 1.65;
  }
  .setting {
    gap: 10px;
    font-size: 0.92rem;
  }
  .toggle {
    flex: none;
  }

  /* ---- 로비 ---- */
  #lobby .logo {
    top: 6cqh;
    width: min(380px, 80cqw);
  }
  /* 위를 기준으로 둔다: 고른 항목의 설명이 펼쳐질 때 아래쪽만 밀려난다 */
  .menu {
    top: 37cqh;
    translate: -50% 0;
    gap: 0.95rem;
  }
  .menu li {
    translate: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 1.7rem;
  }
  .menu li::after {
    top: 1.22em;
    bottom: auto;
  }
  .menu .note {
    position: static;
    translate: none;
    margin: 8px 0 2px;
    width: 84cqw;
    white-space: normal;
    text-align: center;
    font-size: 0.82rem;
    letter-spacing: 0.02em;
    line-height: 1.4;
  }
  #lobby .foot {
    flex-wrap: wrap;
    gap: 0.3em 1.4em;
    padding: 0 16px;
    font-size: 0.8rem;
  }

  /* ---- 온라인 대전 ---- */
  #m-online .tc-panel {
    width: 92cqw;
  }
  .ol-head {
    flex-wrap: wrap;
    gap: 4px 12px;
  }
  .ol-list {
    height: 46cqh;
  }
  .ol-room {
    grid-template-columns: 1.2em minmax(0, 1fr) auto;
    gap: 10px;
    padding: 12px;
  }
  .ol-go {
    display: none;
  }
  .ol-create {
    flex-direction: column;
    align-items: stretch;
  }
  /* 내 방: 메뉴 아래, 화면 아래쪽 안내 위 */
  .room-chip {
    top: auto;
    left: 16px;
    right: 16px;
    bottom: 9cqh;
    max-width: none;
    gap: 10px;
    padding: 8px 8px 8px 12px;
  }
  .room-chip .ring {
    width: 28px;
    height: 28px;
  }
  .room-chip .tc-btn {
    padding: 0 6px;
    font-size: 0.85rem;
  }
  .lo-room {
    max-width: 100%;
    box-sizing: border-box;
  }

  /* ---- 장비 장착 ---- */
  .lo-head {
    top: 10px;
    left: 12px;
    right: 12px;
    flex-wrap: wrap;
    gap: 8px 12px;
  }
  .lo-head img {
    height: 40px;
  }
  .lo-head h1 {
    font-size: 1.35rem;
  }
  .lo-head .sub {
    font-size: 0.78rem;
  }
  .lo-head .spacer {
    display: none;
  }
  .lo-head > div:nth-child(2) {
    flex: 1;
    min-width: 0;
  }
  /* 진영 탭은 둘째 줄을 통째로 쓴다 */
  .lo-side {
    order: 5;
    flex-basis: 100%;
    box-sizing: border-box;
    justify-content: space-between;
  }
  .seg__btn {
    min-width: 72px;
    padding: 0.55em 1.1em;
  }
  .lo-body {
    top: 118px;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
  }
  #lo-board {
    flex: none;
    height: auto;
    width: 100%;
  }
  .lo-right {
    max-width: none;
    gap: 10px;
  }
  /* 판에서 고른 기물의 능력치를 판 바로 아래에서 고친다 */
  #lo-sel {
    order: -1;
  }
  .lo-right .tc-panel {
    border-width: 14px;
    border-image-width: 14px;
  }
  .lo-right .tc-panel__title {
    margin-bottom: 6px;
    font-size: 0.9rem;
  }
  .supply {
    grid-template-columns: repeat(3, minmax(0, 104px));
    justify-content: center;
    gap: 12px;
  }
  .sel {
    grid-template-columns: 48px 1fr;
    gap: 10px;
  }
  .sel img {
    width: 48px;
  }
  .sel h3 {
    font-size: 1.1rem;
  }
  .sel p {
    font-size: 0.78rem;
  }
  .stat {
    grid-template-columns: 26px 1fr auto;
    gap: 8px;
    padding: 6px 0;
  }
  .stat .tc-badge {
    width: 26px;
    height: 26px;
  }
  .stat .iconbtn {
    width: 44px;
    height: 44px;
  }
  .stat .num {
    width: 34px;
    font-size: 1.35rem;
  }
  .pips {
    gap: 2px;
    margin-left: 6px;
  }
  .pips i {
    width: 7px;
    height: 12px;
  }
  .lo-load {
    flex-wrap: wrap;
  }
  .lo-load > span {
    flex-basis: 100%;
  }
  .lo-load .tc-btn {
    flex: 1;
  }
  /* 저장과 초기화는 스크롤해도 화면 아래에 붙어 있다 */
  .lo-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    gap: 10px;
    margin: 0 -12px;
    padding: 10px 12px 12px;
    background: linear-gradient(rgba(5, 4, 3, 0), rgba(5, 4, 3, 0.9) 35%);
  }
  .lo-actions .tc-btn {
    min-height: 54px;
    font-size: 1.1rem;
  }
  .lo-note {
    display: flex;
    order: 9;
    padding-bottom: 12px;
    font-size: 0.78rem;
    line-height: 1.45;
  }

  /* ---- 대전 ---- */
  /* 왼쪽과 오른쪽 열을 풀어서 안의 패널을 무대 격자에 바로 올린다.
     상대 이름표, 체스판, 내 이름표를 한 묶음으로 위아래 빈 줄(1fr) 사이에 두어 화면 세로 가운데,
     손가락이 닿기 쉬운 자리에 오게 한다. 기록과 메모는 격자 밖에 띄우는 패널이다 */
  .stage {
    inset: 10px 12px;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: minmax(0, 1fr) auto auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      ".     ."
      "opp   opp"
      "board board"
      "me    greed"
      ".     ."
      "act   act";
    gap: 8px;
    align-items: stretch;
  }
  .col {
    display: contents;
  }
  #p-opp {
    grid-area: opp;
  }
  #p-me {
    grid-area: me;
  }
  .greed-panel {
    grid-area: greed;
  }
  .board-wrap {
    grid-area: board;
    gap: 0;
  }
  .actions {
    grid-area: act;
  }

  /* 이름표: 옆에 잡은 기물을 겹쳐 놓는다 */
  .player {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }
  #p-me .captured {
    order: 1;
  }
  .plate {
    flex: none;
    width: 250px;
    max-width: 64%;
  }
  .plate__name {
    font-size: 1.05rem;
  }
  .plate__meta {
    margin-top: 1px;
    font-size: 0.7rem;
    white-space: nowrap;
  }
  .plate .tc-timer {
    right: 8%;
    width: 40px;
    height: 40px;
    font-size: 0.8rem;
  }
  .captured {
    flex: 1;
    min-width: 0;
    min-height: 0;
    flex-wrap: wrap;
    align-content: center;
    gap: 0;
    padding-left: 0;
  }
  .captured img {
    width: 24px;
  }
  .captured img + img {
    margin-left: -7px;
  }

  /* 운명의 주사위: 주사위와 추가 턴 칸만 남긴다 (결과는 배너와 전투 기록에 나온다) */
  .greed-panel {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    border-width: 10px;
    border-image-width: 10px;
  }
  .greed-panel img {
    width: 40px;
    height: 40px;
  }
  .greed-panel h3,
  .greed-panel p {
    display: none;
  }
  .extra {
    flex-direction: column;
    gap: 4px;
    margin: 0;
  }
  .extra i {
    width: 8px;
    height: 16px;
  }

  /* 체스판: 폭을 채우되 이름표 둘과 아래 버튼 줄 자리(약 250)는 남긴다 */
  .turn {
    position: relative;
    z-index: 1;
    height: 34px;
    margin-bottom: -6px;
  }
  #g-board {
    height: auto;
    width: min(calc(100cqw - 24px), calc(100cqh - 250px));
  }
  /* 판 아래 내 이름표를 가리지 않게 판 위에 띄운다 */
  .hint {
    z-index: 5;
    bottom: 10%;
    translate: -50% 0;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(5, 4, 3, 0.85);
  }
  .promo .tc-panel {
    border-width: 16px;
    border-image-width: 16px;
  }
  .promo__row {
    gap: 6px;
  }
  .promo__row .side-btn {
    padding: 10px 4px;
  }
  .promo__row .side-btn img {
    width: 52px;
    height: 52px;
  }

  /* 기록과 메모: 아래 탭을 누르면 버튼 줄 바로 위로 올라오는 패널. 한 번에 하나만 보이고 제목은 탭이 대신한다 */
  .log,
  .memo {
    position: absolute;
    z-index: 30;
    left: 0;
    right: 0;
    bottom: 56px;
    box-sizing: border-box;
    min-height: 0;
    filter: drop-shadow(0 -8px 24px rgba(0, 0, 0, 0.65));
    animation: sheet-up 0.24s cubic-bezier(0.2, 0.8, 0.3, 1) both;
  }
  .log {
    height: min(34cqh, 330px);
  }
  /* 메모는 내용 높이만 차지해 체스판을 덜 가린다 */
  .memo {
    height: auto;
  }
  #game:not(.info-open) .log,
  #game:not(.info-open) .memo,
  #game:not(.info-memo) .memo,
  #game.info-memo .log {
    display: none;
  }
  .log h3,
  .memo h3 {
    display: none;
  }
  .log {
    border-width: 16px;
    border-image-width: 16px;
  }
  .log ol {
    font-size: 0.9rem;
    line-height: 1.65;
  }
  .memo {
    display: flex;
    flex-direction: column;
    border-width: 12px;
    border-image-width: 12px;
  }
  .memo .who {
    flex: none;
    gap: 6px;
    min-height: 26px;
    margin-bottom: 4px;
    font-size: 0.78rem;
  }
  .memo .who img {
    width: 26px;
  }
  .memo textarea {
    flex: none;
    height: 54px;
    padding: 6px 8px;
    font-size: 0.95rem;
  }

  /* 탭, 규칙, 항복을 한 줄에 */
  .actions {
    align-items: center;
    gap: 8px;
  }
  .info-tabs {
    display: flex;
    flex: 1;
  }
  .info-tabs .seg__btn {
    flex: 1;
    min-width: 0;
    padding: 0.7em 0.4em;
  }
  .info-tabs .seg__btn.on {
    color: var(--tc-bronze-200);
  }
  /* 닫혀 있는 동안 새 기록이 쌓였다 */
  .info-tabs .seg__btn.new::after {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-left: 6px;
    border-radius: 50%;
    background: var(--tc-ember-400);
    box-shadow: var(--tc-glow-ember);
    vertical-align: 0.15em;
  }
  .actions .tc-btn {
    flex: none;
    min-height: 46px;
    padding: 0 6px;
    border-width: 12px;
    border-image-width: 12px;
    font-size: 0.95rem;
  }

  /* 결과 */
  .result {
    gap: 16px;
    padding: 0 16px;
    text-align: center;
  }
  .result .holder {
    width: 94cqw;
    min-height: 140px;
  }
  .result .reason {
    font-size: 1.4rem;
  }
  .result .reveal {
    font-size: 0.8rem;
  }
  .result .row {
    flex-direction: column;
    width: min(300px, 80cqw);
    gap: 10px;
  }
  .result .row .tc-btn {
    min-width: 0;
    min-height: 54px;
    font-size: 1.1rem;
  }

  /* 연출 시연 판: 오른쪽 위에 접어 둔다 */
  .director {
    left: auto;
    right: 6px;
    top: 6px;
    bottom: auto;
    width: 230px;
  }
  .director.min {
    width: auto;
    padding: 8px 10px;
  }
  .director.min header {
    gap: 10px;
  }
}
