@font-face {
  font-family: "Pretendard Variable";
  font-style: normal;
  font-weight: 45 920;
  font-display: swap;
  src: url("./fonts/pretendard/PretendardVariable.woff2") format("woff2-variations");
}

/* ======================================================================
   디자인 토큰 정본 시트 — 이 블록이 유일한 `:root`다. (규약: docs/DESIGN_TOKENS.md)
   - 팔레트·시맨틱 토큰을 여기서만 정의한다. 다크 테마는 :root[data-theme="dark"]
     에서 "프리미티브 토큰 재정의"로만 구현한다(셀렉터별 오버라이드 금지).
   - 마작 등 게임 스킨은 --mj-* 네임스페이스만 사용하고 이 토큰을 재정의하지 않는다.
   ====================================================================== */
:root {
  color-scheme: light;

  /* 프리미티브 팔레트 (다크에서 재정의되는 대상) */
  --ink: #17202b;
  --muted: #687484;
  --line: #d9e0ea;
  --panel: #ffffff;
  --bg: #eef2f6;
  --soft: #f7f9fc;
  --blue: #246cba;
  --green: #24875b;
  --red: #b64646;
  --amber: #b97919;
  --teal: #247c8d;
  --shadow: 0 18px 34px rgba(22, 34, 49, 0.11);

  /* 시맨틱 별칭 — 신규·이관 코드는 프리미티브 대신 이쪽을 쓴다.
     프리미티브를 참조하므로 다크 테마가 자동 반영된다. */
  --text: var(--ink);
  --text-muted: var(--muted);
  --surface: var(--panel);
  --surface-soft: var(--soft);
  --surface-page: var(--bg);
  --accent: var(--blue);
  /* Readable text/icon color to place ON an --accent-filled surface. White
     works while --accent is a dark blue (light + atelier); the dark theme
     flips --blue to a light #78aff8 and redefines this to a dark ink so accent
     buttons/badges stay legible. */
  --on-accent: #ffffff;
  --positive: var(--green);
  --danger: var(--red);
  --warning: var(--amber);
  --info: var(--teal);
  --positive-text: #1f6a48;
  --warning-text: #8a5a10;
  --danger-text: #8f3733;
  --info-text: #1d626f;
  --word-display-bg: #101722;
  --word-display-text: #f3f6fa;

  /* 간격·모서리 (구 "Palette Arcade context shell" 블록에서 이동) */
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;
  --space-5: 24px;
  --space-6: 32px;
  --radius-sm: 7px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --context-width: 320px;
  --desktop-play-height: calc(100vh - 104px);
  --desktop-play-height: calc(100dvh - 104px);

  /* 타이포 */
  --font-body: "Pretendard Variable", Pretendard, "Segoe UI", "Noto Sans KR", Arial, sans-serif;
  --font-display: "Noto Serif JP", "Yu Mincho", "MS Mincho", serif;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 15px;
  --text-lg: 18px;
  --text-xl: 24px;
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color:
    color-mix(in srgb, var(--text-muted) 62%, var(--surface))
    color-mix(in srgb, var(--surface-page) 84%, var(--line));
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track,
*::-webkit-scrollbar-corner {
  background: color-mix(in srgb, var(--surface-page) 84%, var(--line));
}

*::-webkit-scrollbar-thumb {
  min-width: 36px;
  min-height: 36px;
  border: 2px solid color-mix(in srgb, var(--surface-page) 84%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-muted) 62%, var(--surface));
}

*::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--accent) 58%, var(--text-muted));
}

*::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--surface-page);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: var(--surface-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(145deg, var(--blue), var(--teal));
  font-weight: 800;
  box-shadow: inset -4px -5px 0 rgba(0, 0, 0, 0.12);
}

.brand h1,
.stage-header h2,
.log-panel h3,
.leader-panel h3 {
  margin: 0;
}

.brand h1 {
  font-size: 22px;
  line-height: 1.1;
}

.brand p,
.meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.field-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
}

.auth-status {
  min-height: 34px;
  margin: -8px 0 0;
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.oauth-button {
  display: grid;
  min-height: 42px;
  place-items: center;
  border-radius: 8px;
  padding: 0 12px;
  background: #2d3745;
  color: #fff;
  font-weight: 750;
  text-align: center;
  text-decoration: none;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--ink);
}

.icon-button,
.primary-button,
.ghost-button,
.danger-button,
.choice-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 750;
}

.icon-button,
.primary-button {
  color: var(--on-accent);
  background: var(--blue);
}

.danger-button {
  color: #fff;
  background: var(--red);
}

.ghost-button,
.choice-button {
  color: var(--ink);
  background: var(--line);
}

.profile-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.profile-panel > div {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
}

.profile-panel strong {
  display: block;
  margin-top: 4px;
  font-size: 26px;
}

.game-list {
  display: grid;
  gap: 8px;
}

.game-tab {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 10px;
  min-height: 62px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  background: var(--panel);
}

.game-tab::before {
  content: "";
  align-self: stretch;
  border-radius: 99px;
  background: #a7b0bd;
}

.game-tab.active {
  border-color: rgba(37, 92, 153, 0.55);
  box-shadow: 0 0 0 3px rgba(37, 92, 153, 0.12);
}

.game-tab.active::before {
  background: var(--blue);
}

.game-tab.is-admin-hidden {
  opacity: 0.58;
}

.game-hidden-badge {
  display: inline-flex;
  width: fit-content;
  margin-top: 5px;
  border-radius: 999px;
  padding: 2px 7px;
  background: var(--soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.game-tab strong,
.game-tab span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-tab span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.stage {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
}

.stage-header {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.stage-header h2 {
  font-size: 28px;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.surface {
  min-height: 430px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.room-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
}

.room-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.room-summary strong {
  display: block;
  margin-top: 3px;
  font-size: 18px;
}

.room-badges,
.room-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.word-dictionary-license {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.word-dictionary-license a {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

.word-dictionary-license a:hover {
  text-decoration: underline;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 8px;
  padding: 0 10px;
  background: var(--line);
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
}

.status-pill.idle {
  background: color-mix(in srgb, var(--positive) 11%, var(--surface));
  color: var(--positive-text);
}

.status-pill.running {
  background: #fff2dd;
  color: #86520f;
}

.room-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(260px, auto);
  gap: 10px;
  align-items: stretch;
}

.compact-room-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(260px, auto);
}

.room-list {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel);
}

.room-list > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 7px;
}

.room-user {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  min-width: 92px;
  max-width: 132px;
  border-radius: 12px;
  border: 2px solid transparent;
  padding: 7px 10px 9px;
  background: var(--soft);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

/* 카드 내부: 위에서부터 칭호 → 닉네임 → 프로필 사진(중심). */
.room-user-titlebar {
  min-height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
}

.room-user-titlebar .title-badge.inline {
  margin-left: 0;
  max-width: 100%;
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: break-word;
  line-height: 1.25;
}

.room-user-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.room-user-avatar {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  overflow: hidden;
  flex: none;
  background: linear-gradient(135deg, #93a8c2, #5f7893);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.room-user-initial {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f6f9fc;
  font-size: 19px;
  font-weight: 800;
}

.room-user-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.room-user.auto-join {
  background:
    linear-gradient(var(--soft), var(--soft)) padding-box,
    conic-gradient(from var(--auto-angle), #2fbf78, #2fbf78 24%, transparent 32%, transparent 100%) border-box;
  color: var(--positive-text);
  animation: autoJoinSweep 1.4s linear infinite;
}

.room-user.ready {
  background:
    linear-gradient(var(--soft), var(--soft)) padding-box,
    conic-gradient(from var(--ready-angle), #42a5f5, #42a5f5 24%, transparent 32%, transparent 100%) border-box;
  color: var(--accent);
  animation: readySweep 1.4s linear infinite;
}

.room-user.me {
  border-color: rgba(36, 135, 91, 0.3);
  background: #dff5e8;
  color: #176b46;
}

.room-user.me.ready {
  background:
    linear-gradient(#dff5e8, #dff5e8) padding-box,
    conic-gradient(from var(--ready-angle), #268bf2, #268bf2 28%, transparent 36%, transparent 100%) border-box;
  color: #176b46;
  animation: readySweep 1.4s linear infinite;
}

.room-user-state {
  max-width: 100%;
  border-radius: 999px;
  padding: 2px 7px;
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
  color: var(--accent);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.25;
}

.room-user.me .room-user-state {
  background: #bde9d0;
  color: #125d3c;
}

/* ── 명패 프레임(G12) ─────────────────────────────────────────
   ready/자동참여 상태가 border+background 스윕을 쓰므로, 프레임은
   background/border를 건드리지 않고 box-shadow와 ::before/::after
   레이어로만 표현해 상태 표시와 공존한다. */
.room-user.nameplate-gilt,
.room-user.nameplate-pearl,
.room-user.nameplate-inkline {
  overflow: hidden;
}

.room-user.nameplate-gilt {
  box-shadow:
    0 0 0 2px #d9b24a,
    0 0 0 4px rgba(217, 178, 74, 0.35),
    0 2px 8px rgba(120, 90, 20, 0.25);
}

.room-user.nameplate-gilt::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 8px;
  border: 1px solid rgba(217, 178, 74, 0.75);
  pointer-events: none;
}

.room-user.nameplate-gilt::after {
  content: "";
  position: absolute;
  top: -60%;
  bottom: -60%;
  left: -30%;
  width: 34%;
  background: linear-gradient(100deg, transparent, rgba(255, 240, 190, 0.5), transparent);
  transform: rotate(18deg) translateX(-40px);
  animation: nameplate-sheen 3.6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes nameplate-sheen {
  0%, 55% { transform: rotate(18deg) translateX(-70px); }
  80%, 100% { transform: rotate(18deg) translateX(190px); }
}

.room-user.nameplate-pearl {
  box-shadow:
    0 0 0 2px rgba(240, 244, 250, 0.95),
    0 0 12px rgba(186, 168, 226, 0.35),
    0 2px 12px rgba(150, 160, 210, 0.4);
}

/* 무지개 링: 검수 피드백(얇아서 색이 안 보임)으로 4px + 채도 올린 팔레트. */
.room-user.nameplate-pearl::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 10px;
  padding: 4px;
  background: conic-gradient(
    from 210deg,
    #9cc6ee, #d2a4e2, #9adcbd, #ecd694, #a2b0ee, #eaa4c6, #9cc6ee
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

/* 카드 안쪽에도 은은한 자개빛 박막(薄膜) 틴트를 깔아 존재감을 보강한다. */
.room-user.nameplate-pearl::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    130deg,
    rgba(156, 198, 238, 0.18),
    rgba(210, 164, 226, 0.14) 38%,
    rgba(154, 220, 189, 0.16) 68%,
    rgba(236, 214, 148, 0.14)
  );
  pointer-events: none;
}

.room-user.nameplate-inkline {
  box-shadow:
    0 0 0 2px #33333c,
    0 3px 9px rgba(30, 30, 40, 0.3);
}

.room-user.nameplate-inkline::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 12px 5px 11px 4px;
  border: 1px solid rgba(45, 45, 55, 0.55);
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .room-user.nameplate-gilt::after {
    animation: none;
    opacity: 0;
  }
}

.room-user.disconnected {
  border-style: dashed;
  filter: saturate(0.45);
  opacity: 0.72;
}

.room-user.disconnected .room-user-state {
  background: color-mix(in srgb, var(--muted) 14%, var(--panel));
  color: var(--muted);
}

@property --auto-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

@property --ready-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

@keyframes autoJoinSweep {
  from {
    --auto-angle: 0deg;
  }
  to {
    --auto-angle: 360deg;
  }
}

@keyframes readySweep {
  from {
    --ready-angle: 0deg;
  }
  to {
    --ready-angle: 360deg;
  }
}

.room-actions {
  align-content: center;
  justify-content: flex-end;
}

.stop-vote-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-top: 10px;
  border: 1px solid rgba(184, 75, 71, 0.35);
  border-radius: 8px;
  padding: 12px;
  background: #fff4f3;
}

.stop-vote-box p {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr);
  gap: 16px;
}

.log-panel,
.leader-panel {
  min-height: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
}

.log-panel h3,
.leader-panel h3 {
  margin-bottom: 12px;
  font-size: 16px;
}

.log,
.leaderboard {
  display: grid;
  gap: 8px;
}

.log-entry,
.leader-row {
  min-height: 34px;
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--soft);
  color: var(--text);
  font-size: 14px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.game-card {
  display: grid;
  gap: 16px;
}

.game-card h3 {
  margin: 0;
  font-size: 20px;
}

.muted {
  color: var(--muted);
}

.is-hidden {
  display: none !important;
}

.result-line {
  min-height: 40px;
  padding: 10px 12px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--positive) 8%, var(--surface));
  color: var(--positive-text);
}

.result-line[data-tone="success"] {
  background: color-mix(in srgb, var(--positive) 12%, var(--surface));
  color: var(--positive-text);
}

.result-line[data-tone="warn"] {
  background: color-mix(in srgb, var(--warning) 14%, var(--surface));
  color: var(--warning-text);
}

.result-line[data-tone="danger"] {
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  color: var(--danger-text);
}

.result-line[data-tone="info"] {
  background: color-mix(in srgb, var(--info) 12%, var(--surface));
  color: var(--info-text);
}

.color-grid {
  --grid-size: 5;
  display: grid;
  grid-template-columns: repeat(var(--grid-size), minmax(0, 1fr));
  gap: 4px;
  width: min(100%, 520px);
  aspect-ratio: 1;
  padding: 8px;
  border-radius: 8px;
  background: #1e2733;
}

.color-cell {
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  border-radius: 5px;
  color: #fff;
  font-weight: 800;
  font-size: clamp(0.7rem, calc(3rem / var(--grid-size)), 1.05rem);
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.72), 0 0 1px rgba(0, 0, 0, 0.9);
  box-shadow: inset -2px -3px 0 rgba(0, 0, 0, 0.18);
}

.color-symbol-badge {
  display: inline-grid;
  min-width: 1.5em;
  place-items: center;
  border-radius: 999px;
  padding: 0.08em 0.35em;
  background: var(--soft);
  color: var(--text);
  font-weight: 900;
}

.choice-row,
.answer-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.play-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.play-action-row button {
  min-width: 128px;
}

.answer-row input {
  max-width: 360px;
}

.setting-note {
  display: grid;
  gap: 8px;
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.setting-note p {
  margin: 0;
}

.mask-board {
  display: grid;
  gap: 10px;
  max-width: min(100%, 880px);
}

.music-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
}

.music-status strong {
  color: var(--blue);
}

.mask {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #101722;
  color: #f3f6fa;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 24px;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.battle-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.45fr);
  gap: 16px;
  align-items: start;
}

.battle-candidates {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.section-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.candidate-grid {
  display: grid;
  grid-template-columns: 56px minmax(92px, 1fr) minmax(76px, 0.8fr) minmax(76px, 0.8fr) minmax(64px, 0.7fr);
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
}

.candidate-head {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.candidate-grid.winner {
  border-color: rgba(31, 95, 66, 0.45);
  background: #e9f6ef;
}

.pitch-keyboard,
.pitch-keyboard-empty {
  display: grid;
  gap: 14px;
  max-width: 760px;
}

.pitch-keyboard-empty {
  min-height: 120px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--soft);
}

.octave-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: stretch;
  gap: 10px;
}

.octave-label {
  display: grid;
  min-height: 112px;
  place-items: center;
  border-radius: 8px;
  background: #1c2735;
  color: #fff;
  font-weight: 800;
}

.piano-octave {
  position: relative;
  min-height: 112px;
}

.white-keys {
  display: grid;
  grid-template-columns: repeat(7, minmax(38px, 1fr));
  height: 112px;
}

.piano-key {
  position: relative;
  border: 1px solid #c9d0da;
  font-weight: 800;
}

.white-key {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 10px;
  border-radius: 0 0 7px 7px;
  background: linear-gradient(180deg, #ffffff, #edf1f6);
  color: #1d2733;
  box-shadow: inset 0 -8px 0 rgba(25, 35, 55, 0.08);
}

.black-keys {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.black-key {
  position: absolute;
  top: 0;
  left: calc((100% / 7) * var(--key-left));
  z-index: 2;
  width: min(9%, 48px);
  height: 68px;
  transform: translateX(-50%);
  border-radius: 0 0 6px 6px;
  border-color: #111820;
  background: linear-gradient(180deg, #263343, #05080c);
  color: #fff;
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.24), inset 0 -8px 0 rgba(255, 255, 255, 0.06);
  pointer-events: auto;
}

.black-key span {
  display: block;
  transform: translateY(12px);
  font-size: 12px;
}

.gamble-grid,
.gamble-panels {
  display: grid;
  gap: 18px;
}

.gamble-panels {
  grid-template-columns: repeat(2, minmax(300px, 1fr));
  align-items: stretch;
}

.gamble-mode-card {
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
}

.gamble-mode-card .panel-head {
  margin-bottom: 0;
}

.gamble-mode-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.95fr) minmax(220px, 1.05fr);
  gap: 16px;
  align-items: stretch;
}

.gamble-controls {
  display: grid;
  align-content: start;
  gap: 12px;
}

.gamble-controls .choice-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.gamble-controls .choice-row .ghost-button {
  grid-column: 1 / -1;
}

.gamble-grid {
  grid-template-columns: minmax(260px, 0.8fr) minmax(320px, 1.2fr);
}

.dice-scene {
  display: grid;
  min-height: 250px;
  place-items: center;
  border-radius: 8px;
  background: radial-gradient(circle at 35% 25%, #f9fbff, #cfd9e7 68%, #b5c0cf);
  perspective: 800px;
}

.die {
  display: grid;
  width: 112px;
  height: 112px;
  place-items: center;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(145deg, #2a6fb3, #173b66);
  box-shadow: 16px 22px 24px rgba(20, 35, 55, 0.28), inset -12px -16px 0 rgba(0, 0, 0, 0.18);
  font-size: 46px;
  font-weight: 900;
  transform: rotateX(18deg) rotateY(-25deg) rotateZ(6deg);
  transition: transform 360ms ease;
}

.die.roll {
  transform: rotateX(380deg) rotateY(310deg) rotateZ(16deg);
}

.yacht-card {
  gap: 14px;
}

.yacht-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1.12fr) minmax(420px, 0.88fr);
  gap: 16px;
  align-items: start;
}

.yacht-play {
  display: grid;
  gap: 12px;
}

.yacht-play .play-action-row {
  justify-content: center;
}

.yacht-play #rollYacht {
  min-width: 180px;
}

.yacht-dice-tray {
  width: 100%;
  min-height: 0;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  background: transparent;
}

.yacht-board {
  position: relative;
  width: 100%;
  min-height: 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid rgba(29, 49, 47, 0.28);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0) 25%),
    radial-gradient(circle at 30% 16%, rgba(255, 255, 255, 0.14), transparent 30%),
    linear-gradient(145deg, #285248, #17383a 58%, #102b33);
  box-shadow:
    inset 0 0 0 13px rgba(102, 76, 53, 0.62),
    inset 0 16px 26px rgba(255, 255, 255, 0.08),
    inset 0 -20px 28px rgba(4, 12, 19, 0.28),
    0 16px 28px rgba(29, 42, 58, 0.14);
  transform-style: preserve-3d;
}

.yacht-board::before {
  content: "";
  position: absolute;
  inset: 9px;
  z-index: 3;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.17),
    inset 0 -5px 0 rgba(0, 0, 0, 0.18);
  pointer-events: none;
}

.yacht-board::after {
  content: "";
  position: absolute;
  right: 24px;
  bottom: 12px;
  left: 24px;
  z-index: 1;
  height: 10px;
  border-radius: 50%;
  background: rgba(0, 8, 18, 0.22);
  filter: blur(5px);
  pointer-events: none;
}

.yacht-board-3d {
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 26%),
    linear-gradient(145deg, #2e594f, #153b3f 52%, #0e2730);
}

.yacht-3d-canvas {
  position: absolute;
  inset: 10px;
  z-index: 2;
  display: block;
  width: calc(100% - 20px);
  height: calc(100% - 20px);
  border-radius: 8px;
  background:
    radial-gradient(circle at 34% 18%, rgba(255, 255, 255, 0.13), transparent 28%),
    linear-gradient(145deg, #153f3c, #0f3038);
  touch-action: manipulation;
}

.yacht-board-3d.can-hold .yacht-3d-canvas {
  cursor: pointer;
}

.yacht-3d-status {
  position: absolute;
  right: 24px;
  bottom: 22px;
  left: 24px;
  z-index: 5;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  pointer-events: none;
}

.yacht-die-controls {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.yacht-board-lane {
  position: absolute;
  right: 24px;
  left: 24px;
  z-index: 1;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 6px 14px rgba(0, 0, 0, 0.2);
}

.yacht-board-lane span {
  position: absolute;
  top: 8px;
  left: 12px;
  color: rgba(241, 250, 247, 0.76);
  font-size: 11px;
  font-weight: 900;
}

.yacht-save-lane {
  top: 24px;
  height: 74px;
  background:
    linear-gradient(90deg, rgba(111, 163, 135, 0.24), rgba(255, 255, 255, 0.04)),
    rgba(255, 255, 255, 0.05);
}

.yacht-roll-lane {
  top: 112px;
  bottom: 24px;
}

.yacht-dice-row {
  position: absolute;
  right: 34px;
  bottom: 38px;
  left: 34px;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(5, minmax(50px, 1fr));
  gap: 12px;
  align-items: end;
  min-height: 92px;
}

.yacht-die {
  position: relative;
  display: grid;
  min-width: 0;
  height: 86px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  perspective: 520px;
  transform: translateY(0);
  transition: transform 200ms ease, filter 200ms ease;
  cursor: pointer;
}

.yacht-die::after {
  content: "";
  position: absolute;
  bottom: 10px;
  left: 18%;
  width: 64%;
  height: 13px;
  border-radius: 50%;
  background: rgba(3, 8, 16, 0.25);
  filter: blur(5px);
  transform: rotateX(62deg);
  transition: opacity 200ms ease, transform 200ms ease;
}

.yacht-die.held {
  transform: translateY(-91px);
}

.yacht-die.held::after {
  opacity: 0.18;
}

.yacht-die-body {
  --die-rest: rotateX(58deg) rotateZ(-38deg);
  position: relative;
  display: grid;
  width: min(72px, 100%);
  aspect-ratio: 1;
  place-items: center;
  transform: var(--die-rest);
  transform-style: preserve-3d;
  transition: transform 180ms ease, filter 180ms ease;
  filter: drop-shadow(12px 16px 6px rgba(2, 9, 18, 0.24));
}

.yacht-die-body::before,
.yacht-die-body::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: #d7dde7;
  transform-origin: center;
}

.yacht-die-body::before {
  transform: translate3d(10px, 10px, -16px);
  filter: brightness(0.82);
}

.yacht-die-body::after {
  transform: translate3d(19px, 19px, -28px);
  background: rgba(30, 42, 58, 0.18);
  filter: blur(2px);
}

.yacht-die-face {
  position: relative;
  z-index: 2;
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
  border: 1px solid #c5ccd8;
  border-radius: 8px;
  background: linear-gradient(145deg, #ffffff, #edf1f5);
  color: #5b6572;
  font-weight: 900;
  box-shadow:
    inset -6px -7px 0 rgba(30, 42, 58, 0.08),
    inset 5px 5px 0 rgba(255, 255, 255, 0.55);
}

.yacht-die.held .yacht-die-face {
  border-color: rgba(35, 136, 95, 0.7);
  background: linear-gradient(145deg, #f7fff8, #d9f0e3);
  box-shadow:
    0 0 0 2px rgba(80, 192, 140, 0.16),
    inset -6px -7px 0 rgba(30, 82, 58, 0.08),
    inset 5px 5px 0 rgba(255, 255, 255, 0.6);
}

.yacht-die:disabled {
  opacity: 1;
  cursor: default;
}

.yacht-die.roll .yacht-die-body {
  animation: yachtRoll 760ms cubic-bezier(0.16, 0.84, 0.32, 1);
}

.pip {
  display: block;
  width: 42%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #1d2733;
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.15);
}

.value-1 .pip-1 {
  grid-area: 2 / 2;
}

.value-2 .pip-1 {
  grid-area: 1 / 1;
}

.value-2 .pip-2 {
  grid-area: 3 / 3;
}

.value-3 .pip-1 {
  grid-area: 1 / 1;
}

.value-3 .pip-2 {
  grid-area: 2 / 2;
}

.value-3 .pip-3 {
  grid-area: 3 / 3;
}

.value-4 .pip-1 {
  grid-area: 1 / 1;
}

.value-4 .pip-2 {
  grid-area: 1 / 3;
}

.value-4 .pip-3 {
  grid-area: 3 / 1;
}

.value-4 .pip-4 {
  grid-area: 3 / 3;
}

.value-5 .pip-1 {
  grid-area: 1 / 1;
}

.value-5 .pip-2 {
  grid-area: 1 / 3;
}

.value-5 .pip-3 {
  grid-area: 2 / 2;
}

.value-5 .pip-4 {
  grid-area: 3 / 1;
}

.value-5 .pip-5 {
  grid-area: 3 / 3;
}

.value-6 .pip-1 {
  grid-area: 1 / 1;
}

.value-6 .pip-2 {
  grid-area: 1 / 3;
}

.value-6 .pip-3 {
  grid-area: 2 / 1;
}

.value-6 .pip-4 {
  grid-area: 2 / 3;
}

.value-6 .pip-5 {
  grid-area: 3 / 1;
}

.value-6 .pip-6 {
  grid-area: 3 / 3;
}

@keyframes yachtRoll {
  0% {
    transform: var(--die-rest) translate3d(0, 0, 0);
  }
  24% {
    transform: rotateX(var(--roll-x, 620deg)) rotateY(var(--roll-y, 480deg)) rotateZ(var(--roll-z, 60deg)) translate3d(var(--roll-slide, 8px), var(--roll-hop, -24px), 26px);
  }
  58% {
    transform: rotateX(var(--roll-y, 480deg)) rotateY(var(--roll-x, 620deg)) rotateZ(var(--roll-z2, -60deg)) translate3d(var(--roll-slide2, -5px), 6px, 8px);
  }
  82% {
    transform: rotateX(92deg) rotateY(34deg) rotateZ(-18deg) translate3d(0, -4px, 4px);
  }
  100% {
    transform: var(--die-rest) translate3d(0, 0, 0);
  }
}

.yacht-log-panel {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.yacht-log-panel .log {
  max-height: 176px;
  overflow: auto;
}

.indian-card {
  gap: 14px;
}

.indian-table {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(39, 83, 89, 0.18);
  border-radius: 8px;
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(239, 247, 242, 0.9), rgba(235, 241, 249, 0.92)),
    #f4f7f5;
}

.indian-status-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.indian-status-row strong {
  min-width: 54px;
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--text);
  color: var(--surface);
  text-align: center;
}

.indian-player-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.indian-duel-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.9fr) minmax(280px, 0.92fr) minmax(180px, 0.9fr);
  gap: 12px;
  align-items: stretch;
}

.indian-center-panel {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.indian-player-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  border: 1px solid rgba(37, 92, 153, 0.18);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
  box-shadow: 0 10px 22px rgba(27, 42, 58, 0.08);
}

.indian-player-card.empty-seat {
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.indian-player-card.mine {
  border-color: rgba(31, 95, 66, 0.34);
  background: #fbfffc;
}

.indian-player-card.left {
  opacity: 0.58;
}

.indian-player-head {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.indian-player-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.indian-player-head span {
  display: flex;
  flex-shrink: 0;
  gap: 4px;
}

.indian-player-head em {
  border-radius: 999px;
  padding: 3px 7px;
  background: #e7eef7;
  color: var(--blue);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.indian-number {
  display: grid;
  min-height: 112px;
  place-items: center;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 255, 255, 0.3), transparent 40%),
    linear-gradient(145deg, #223142, #121a24);
  color: #fff;
  font-size: 54px;
  font-weight: 900;
}

.indian-action-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
}

.indian-rolling-label {
  display: grid;
  min-height: 40px;
  place-items: center;
  border-radius: 8px;
  background: var(--text);
  color: var(--surface);
  font-size: 13px;
  font-weight: 900;
}

.indian-action-buttons:empty {
  display: none;
}

.indian-d20-stage {
  position: relative;
  min-height: 300px;
  overflow: hidden;
  border: 1px solid rgba(37, 92, 153, 0.16);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.86), transparent 38%),
    linear-gradient(145deg, #eef4f8, #dde7ee);
}

.indian-d20-stage.rolling .indian-d20-values {
  opacity: 0.22;
  filter: blur(1px);
}

.indian-d20-canvas {
  display: block;
  width: 100%;
  height: 300px;
}

.indian-d20-status {
  position: absolute;
  inset: 10px 10px auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.indian-d20-values {
  position: absolute;
  right: 10px;
  bottom: 10px;
  left: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  pointer-events: none;
}

.indian-d20-values span {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 8px;
  background: rgba(23, 33, 46, 0.82);
  color: #fff;
  font-size: 24px;
  font-weight: 950;
  box-shadow: 0 8px 18px rgba(26, 42, 56, 0.18);
}

.indian-d20-values span.hidden {
  background: rgba(232, 237, 242, 0.9);
  color: #5c6b78;
}

.indian-d20-values em {
  color: currentColor;
  font-size: 10px;
  font-style: normal;
  opacity: 0.72;
}

.indian-number.hidden {
  background: linear-gradient(145deg, #e8edf2, #d8e1e8);
  color: #5c6b78;
  font-size: 18px;
}

.indian-token-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.indian-token-row span {
  border-radius: 8px;
  padding: 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
}

.indian-token-row strong {
  color: var(--ink);
  font-size: 18px;
}

.drawing-card {
  gap: 14px;
}

.drawing-status-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.drawing-status-strip span {
  display: grid;
  gap: 3px;
  min-width: 0;
  border: 1px solid rgba(39, 83, 89, 0.14);
  border-radius: 8px;
  padding: 9px 10px;
  background: #f5f8f6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.drawing-status-strip strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawing-word-pill {
  background: #fff8e8 !important;
}

.drawing-word-setup {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 5;
  display: grid;
  width: min(420px, calc(100% - 32px));
  gap: 10px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(37, 92, 153, 0.2);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 18px 42px rgba(24, 43, 62, 0.2);
}

.drawing-word-setup-title {
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.drawing-word-setup-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(96px, auto);
  gap: 8px;
}

.drawing-word-setup[hidden] {
  display: none;
}

.drawing-play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 0.34fr);
  gap: 12px;
  align-items: stretch;
  min-height: 0;
}

.drawing-board-column {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  max-width: none;
  min-width: 0;
  margin: 0 auto;
}

.drawing-board-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-auto-rows: min-content;
  gap: 8px;
  align-content: start;
  align-items: stretch;
  border: 1px solid rgba(39, 83, 89, 0.14);
  border-radius: 8px;
  padding: 8px;
  background: #f8faf7;
}

.drawing-board-wrap {
  position: relative;
  border: 1px solid rgba(37, 92, 153, 0.16);
  border-radius: 8px;
  padding: 10px;
  background:
    linear-gradient(90deg, rgba(36, 48, 68, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(36, 48, 68, 0.04) 1px, transparent 1px),
    #eef3ef;
  background-size: 28px 28px;
}

.drawing-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  border: 1px solid rgba(36, 48, 68, 0.14);
  border-radius: 8px;
  background: #fbfcf9;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72);
  cursor: crosshair;
  touch-action: none;
}

/* 격자 질감은 캔버스 비트맵 안에서 그린다(app.js drawPaperTexture) —
   CSS 배경은 획 채우기에 덮여 보이지 않으므로 배경색만 맞춰 둔다. */
.drawing-board-wrap[data-drawing-paper="grid"] .drawing-canvas {
  background-color: #f7fbff;
}

.drawing-board-wrap[data-drawing-brush="soft"] .drawing-canvas {
  box-shadow:
    inset 0 0 0 1px rgba(36, 108, 186, 0.08),
    0 10px 24px rgba(36, 108, 186, 0.08);
}

.drawing-canvas.is-eraser {
  cursor: cell;
}

.drawing-answer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(96px, auto);
  gap: 8px;
  grid-auto-rows: min-content;
  align-content: start;
  align-self: start;
}

.drawing-chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-self: stretch;
  height: 100%;
  max-height: none;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(39, 83, 89, 0.14);
  border-radius: 8px;
  padding: 10px;
  background: #f8faf7;
}

.drawing-chat-list {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 2px;
}

.drawing-chat-message,
.drawing-chat-empty {
  border: 1px solid rgba(39, 83, 89, 0.12);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.drawing-chat-message {
  display: grid;
  flex: 0 0 auto;
  gap: 3px;
}

.drawing-chat-message strong {
  min-width: 0;
  overflow: hidden;
  color: #647280;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawing-chat-message span {
  overflow-wrap: anywhere;
}

.drawing-chat-message.system {
  border-color: rgba(31, 106, 72, 0.18);
  background: color-mix(in srgb, var(--positive) 14%, var(--surface));
  color: var(--positive-text);
  font-weight: 900;
}

.drawing-chat-empty {
  color: var(--muted);
}

.drawing-player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.drawing-player {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(39, 83, 89, 0.14);
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--surface);
}

.drawing-player strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawing-player span,
.drawing-player em {
  border-radius: 999px;
  padding: 3px 7px;
  background: #e8edf2;
  color: #4d5d6b;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.drawing-player.drawer span {
  background: #ffe9bd;
  color: #865a10;
}

.drawing-player.guessed span {
  background: color-mix(in srgb, var(--positive) 14%, var(--surface));
  color: var(--positive-text);
}

.drawing-guess-panel {
  display: grid;
  gap: 8px;
}

.drawing-guess-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.drawing-guess,
.drawing-guess-empty {
  display: grid;
  min-height: 36px;
  align-items: center;
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--soft);
  color: var(--text);
  font-size: 13px;
}

.drawing-guess {
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr);
  gap: 8px;
}

.drawing-guess strong,
.drawing-guess span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawing-guess.correct {
  background: color-mix(in srgb, var(--positive) 14%, var(--surface));
  color: var(--positive-text);
  font-weight: 900;
}

.drawing-guess-empty {
  color: var(--muted);
}

.drawing-tools {
  display: grid;
  gap: 12px;
}

.drawing-color-field input {
  width: 100%;
  min-height: 38px;
  padding: 2px;
}

.drawing-size-field {
  display: grid;
  gap: 5px;
}

/* 게임 중 브러시 칸 — 그리는 사람에게만, 보유 브러시 2종 이상일 때 노출 */
.drawing-brush-field {
  display: grid;
  gap: 5px;
}

.drawing-brush-field[hidden] {
  display: none;
}

.drawing-brush-field select {
  min-height: 34px;
  border: 1px solid rgba(39, 83, 89, 0.2);
  border-radius: 6px;
  padding: 4px 8px;
  background: var(--surface);
}

.drawing-board-toolbar:has(.drawing-brush-field:not([hidden])) {
  grid-template-columns: minmax(0, 1fr);
}

.drawing-tool-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.drawing-tool-toggle.active {
  border-color: rgba(31, 95, 66, 0.34);
  background: color-mix(in srgb, var(--positive) 14%, var(--surface));
  color: var(--positive-text);
}

.mahjong-card {
  gap: 14px;
}

.mahjong-status-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.mahjong-status-strip > span {
  min-height: 44px;
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.mahjong-status-strip strong {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mahjong-dora-cell strong {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.mahjong-table-3d {
  position: relative;
  width: 100%;
  height: min(68vh, 680px);
  min-height: 520px;
  overflow: hidden;
  background: #193f38;
}

.mahjong-3d-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
}

/* Feature 1: fullscreen toggle for the mahjong main panel. */
.mahjong-fullscreen-button {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 6;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(214, 183, 108, 0.38);
  border-radius: 10px;
  background: rgba(8, 28, 25, 0.6);
  color: #f7f2df;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.mahjong-fullscreen-button:hover {
  background: rgba(12, 40, 35, 0.85);
  border-color: rgba(214, 183, 108, 0.6);
  transform: scale(1.04);
}

.mahjong-fullscreen-button.is-active {
  background: var(--mj-brass, #d1a95b);
  color: #182a22;
  border-color: rgba(255, 225, 160, 0.7);
}

/* 텐파이 오름패 표시 패널 on/off — 우측 하단의 작은 버튼. */
.mahjong-wait-toggle-button {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 6;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(214, 183, 108, 0.38);
  border-radius: 9px;
  background: rgba(8, 28, 25, 0.6);
  color: #f7f2df;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    opacity 160ms ease,
    transform 160ms ease;
}

.mahjong-wait-toggle-button[hidden] {
  display: none;
}

.mahjong-wait-toggle-button:hover {
  background: rgba(12, 40, 35, 0.85);
  border-color: rgba(214, 183, 108, 0.6);
  transform: scale(1.04);
}

.mahjong-wait-toggle-button.is-off {
  opacity: 0.55;
  color: #cdbf9a;
  border-style: dashed;
  text-decoration: line-through;
}

/* Only the 3D table panel goes fullscreen, filling the whole screen. */
.mahjong-table-3d:fullscreen {
  width: 100%;
  height: 100%;
  max-height: none;
  border-width: 0;
  border-radius: 0;
}

.mahjong-3d-canvas:focus-visible {
  outline: 3px solid rgba(255, 209, 102, 0.88);
  outline-offset: -4px;
}

.mahjong-3d-seats {
  position: absolute;
  inset: 0;
  container-type: inline-size;
  pointer-events: none;
}

.mahjong-actions-overlay {
  position: absolute;
  right: 16px;
  bottom: calc(24% + var(--mahjong-bottom-safe-offset, 0px));
  left: 14px;
  z-index: 5;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  pointer-events: none;
}

.mahjong-actions-overlay > * {
  pointer-events: auto;
}

/* 한 줄 배치: 시간 칩은 항상 우측 고정, 이벤트(후로/스킵 등) 버튼은 같은 높이 왼쪽(#2). */
.mahjong-actions-overlay .mahjong-decision-stack {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  gap: 10px;
  max-width: min(72%, 620px);
}

/* 시간 칩: 내용 너비로만 차지하는 컴팩트 표시(기존 460px 그리드 해제). 클릭은 통과. */
.mahjong-actions-overlay .mahjong-decision-banner.mahjong-decision-clockchip {
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  width: auto;
  max-width: none;
  min-height: 0;
  grid-template-columns: none;
  flex: 0 0 auto;
  padding: 6px 14px;
  gap: 8px;
}

.mahjong-decision-clockchip .mahjong-decision-clock {
  width: auto;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* 오름패 팝업: 가운데 최상단(타가 버림패·중앙 패널을 가리지 않도록), 내용 너비만큼만(#4). */
.mahjong-wait-overlay {
  position: absolute;
  top: 8px;
  bottom: auto;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  width: auto;
  max-width: min(72%, 460px);
  pointer-events: none;
}

/* 5종까지는 그만큼만 늘어나고, 6종 이상이면 폭을 고정해 자동 스크롤로 순회한다(#4). */
.mahjong-wait-overlay .mahjong-wait-list {
  max-width: 168px;
  scroll-behavior: auto;
}

.mahjong-wait-overlay:empty {
  display: none;
}

/* 한 줄: [라벨 │ (패+남은수) (패+남은수) ...] */
.mahjong-wait-overlay .mahjong-wait-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 12px;
  border: 1px solid rgba(235, 207, 137, 0.4);
  background: linear-gradient(145deg, rgba(25, 60, 51, 0.96), rgba(7, 27, 24, 0.97));
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(8px);
}

.mahjong-wait-overlay .mahjong-wait-info.is-furiten {
  border-color: rgba(224, 96, 96, 0.7);
  background: linear-gradient(145deg, rgba(120, 32, 32, 0.96), rgba(70, 14, 14, 0.97));
}

.mahjong-wait-overlay .mahjong-wait-label {
  flex: 0 0 auto;
  font-weight: 800;
  font-size: 14px;
  color: #f6e7bd;
  padding-right: 10px;
  border-right: 1px solid rgba(235, 207, 137, 0.3);
}

.mahjong-wait-overlay .mahjong-wait-info.is-furiten .mahjong-wait-label {
  color: #ffd9d9;
  border-right-color: rgba(255, 200, 200, 0.4);
}

.mahjong-wait-overlay .mahjong-wait-list {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

/* 오름패 한 칸: 패(70% 크기) 위, "잔여 N장"은 그 아래로 — 공간 절약(#4). */
.mahjong-wait-overlay .mahjong-wait-tile {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 2px 3px;
  background: transparent;
}

.mahjong-wait-overlay .mahjong-wait-tile .mahjong-wait-face {
  width: 20px;
  height: 29px;
  border-radius: 3px;
}

.mahjong-wait-overlay .mahjong-wait-count {
  font-size: 10px;
  text-align: center;
}

.mahjong-wait-overlay .mahjong-wait-tile small {
  font-size: 9px;
}

.mahjong-table-3d.is-animating .mahjong-actions-overlay {
  opacity: 0.56;
}

.mahjong-table-3d.is-animating .mahjong-actions-overlay > * {
  pointer-events: none;
}

.mahjong-3d-automation-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 6;
  display: flex;
  gap: 7px;
  align-items: center;
  border: 1px solid rgba(151, 226, 195, 0.34);
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(10, 29, 27, 0.82);
  color: #dff8ed;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.02em;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition:
    opacity 140ms ease,
    transform 160ms ease;
}

.mahjong-3d-automation-badge::before {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #72d5ba;
  box-shadow: 0 0 0 4px rgba(114, 213, 186, 0.14);
  content: "";
  animation: mahjong-auto-pulse 900ms ease-in-out infinite alternate;
}

.mahjong-3d-automation-badge.visible {
  opacity: 1;
  transform: translateY(0);
}

.mahjong-3d-touch-hint,
.mahjong-3d-recovery-badge {
  position: absolute;
  left: 50%;
  z-index: 8;
  border: 1px solid rgba(255, 232, 169, 0.48);
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(10, 28, 27, 0.9);
  color: #fff1bf;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  font-size: 12px;
  font-weight: 850;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition:
    opacity 140ms ease,
    transform 160ms ease;
}

.mahjong-3d-touch-hint {
  bottom: calc(58px + env(safe-area-inset-bottom, 0px));
  width: max-content;
  max-width: calc(100% - 24px);
}

.mahjong-3d-recovery-badge {
  top: 50%;
  transform: translate(-50%, -42%);
}

.mahjong-3d-touch-hint.visible,
.mahjong-3d-recovery-badge.visible {
  opacity: 1;
}

.mahjong-3d-touch-hint.visible {
  transform: translate(-50%, 0);
}

.mahjong-3d-recovery-badge.visible {
  transform: translate(-50%, -50%);
}

.mahjong-3d-diagnostics {
  position: absolute;
  top: 48px;
  right: 10px;
  z-index: 9;
  border: 1px solid rgba(151, 226, 195, 0.26);
  border-radius: 8px;
  padding: 6px 8px;
  background: rgba(6, 20, 20, 0.82);
  color: #ccefe2;
  font: 700 10px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre;
  pointer-events: none;
}

.mahjong-table-3d.is-context-lost .mahjong-3d-canvas {
  opacity: 0.58;
}

@keyframes mahjong-auto-pulse {
  from {
    opacity: 0.5;
    transform: scale(0.82);
  }

  to {
    opacity: 1;
    transform: scale(1.08);
  }
}

.mahjong-3d-event-label {
  position: absolute;
  top: 48%;
  left: 50%;
  z-index: 6;
  min-width: 90px;
  border: 1px solid rgba(255, 232, 169, 0.7);
  border-radius: 10px;
  padding: 8px 18px;
  background: rgba(20, 30, 31, 0.84);
  color: #fff1bf;
  box-shadow:
    0 10px 26px rgba(0, 0, 0, 0.28),
    inset 0 0 18px rgba(255, 213, 102, 0.08);
  font-family: "Yu Mincho", "MS Mincho", serif;
  font-size: clamp(22px, 3vw, 40px);
  font-weight: 900;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.82);
  transition:
    opacity 100ms ease,
    transform 160ms ease;
}

.mahjong-3d-event-label.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.mahjong-3d-result-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 7;
  display: grid;
  width: min(82%, 620px);
  max-height: 62%;
  gap: 8px;
  overflow: auto;
  border: 1px solid rgba(255, 231, 167, 0.58);
  border-radius: 14px;
  padding: 14px;
  background:
    linear-gradient(145deg, rgba(28, 43, 43, 0.96), rgba(12, 24, 27, 0.96));
  color: #f8f4e8;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.4),
    inset 0 0 28px rgba(255, 218, 112, 0.05);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -46%) scale(0.94);
  transition:
    opacity 180ms ease,
    transform 220ms ease;
}

.mahjong-3d-result-panel.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.mahjong-3d-final-card {
  display: grid;
  gap: 8px;
}

.mahjong-3d-ftitle {
  margin-bottom: 2px;
  color: #ffe49a;
  font-family: "Yu Mincho", "MS Mincho", serif;
  font-size: clamp(20px, 2.6vw, 30px);
  letter-spacing: 0.08em;
  text-align: center;
}

.mahjong-3d-frow {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border: 1px solid rgba(244, 209, 121, 0.2);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
}

.mahjong-3d-frow.rank-1 {
  border-color: rgba(244, 209, 121, 0.6);
  background: rgba(232, 190, 90, 0.14);
}

.mahjong-3d-frank {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #f3d47f;
  font-family: "Yu Mincho", "MS Mincho", serif;
  font-weight: 700;
}

.mahjong-3d-frow.rank-1 .mahjong-3d-frank {
  background: radial-gradient(circle at 35% 28%, #fff1b9, #c5963f 72%);
  color: #4f3418;
}

.mahjong-3d-fmid {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.mahjong-3d-fname {
  overflow: hidden;
  color: #f4efe4;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mahjong-3d-fdetail {
  color: rgba(233, 224, 200, 0.62);
  font-size: 12px;
}

.mahjong-3d-fscore {
  display: flex;
  align-items: baseline;
  gap: 10px;
  justify-self: end;
}

.mahjong-3d-fpts {
  color: #f4efe4;
  font-size: 16px;
  font-weight: 600;
}

.mahjong-3d-fsettle {
  font-weight: 600;
}

.mahjong-3d-fsettle.is-pos {
  color: #8fe3b0;
}

.mahjong-3d-fsettle.is-neg {
  color: #ff9a88;
}

.mahjong-3d-freward {
  display: flex;
  gap: 8px;
  justify-self: end;
}

.mahjong-3d-fcoin,
.mahjong-3d-fexp {
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(31, 106, 72, 0.28);
  color: #bff0d4;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.mahjong-table-3d.is-portrait .mahjong-3d-frow {
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
}

.mahjong-table-3d.is-portrait .mahjong-3d-freward {
  grid-column: 2 / -1;
  justify-self: start;
}

.mahjong-3d-result-title {
  color: #ffe49a;
  font-family: "Yu Mincho", "MS Mincho", serif;
  font-size: clamp(23px, 3vw, 38px);
  letter-spacing: 0.08em;
  text-align: center;
}

.mahjong-3d-result-row {
  display: grid;
  grid-template-columns: minmax(100px, 0.7fr) minmax(0, 2fr) auto;
  gap: 10px;
  align-items: center;
  border-radius: 9px;
  padding: 9px 11px;
  background: rgba(255, 255, 255, 0.07);
}

.mahjong-3d-result-row b,
.mahjong-3d-result-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mahjong-3d-result-row span {
  color: #ccd9d5;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.45;
  white-space: pre-line;
}

.mahjong-3d-result-row em {
  color: #78e4af;
  font-size: 18px;
  font-style: normal;
  font-weight: 950;
}

.mahjong-actions-overlay .mahjong-action-grid,
.mahjong-actions-overlay .mahjong-combination-panel {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 8px;
  background: rgba(13, 29, 28, 0.86);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
  color: #f7faf9;
  backdrop-filter: blur(8px);
}

.mahjong-actions-overlay .mahjong-action-grid.is-reaction-grid {
  max-width: min(100%, 560px);
}

.mahjong-actions-overlay .mahjong-action-grid.is-reaction-grid .mahjong-command {
  min-width: 104px;
}

.mahjong-3d-seat {
  position: absolute;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  max-width: min(42%, 280px);
  gap: 6px;
  align-items: center;
  border-left: 3px solid rgba(255, 255, 255, 0.28);
  padding: 5px 8px;
  background: rgba(16, 31, 31, 0.72);
  color: #f7faf9;
  font-size: 12px;
}

.mahjong-3d-seat.current {
  border-left-color: #ffd166;
}

.mahjong-3d-seat span {
  color: #b9d5cd;
  font-weight: 900;
}

.mahjong-3d-seat strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mahjong-3d-seat em {
  color: #ffffff;
  font-style: normal;
  font-weight: 900;
}

.mahjong-3d-seat.mortal-bot {
  border-left-color: #63d2aa;
}

.mahjong-3d-seat .mahjong-3d-mortal-badge {
  border-radius: 999px;
  padding: 1px 5px;
  background: rgba(99, 210, 170, 0.2);
  color: #a8f3d8;
  font-size: 10px;
  letter-spacing: 0.08em;
}

.mahjong-3d-seat i {
  color: #ffd166;
  font-style: normal;
  font-weight: 900;
}

/* 화료 직후 작탁 연출(세리머니) — 테이블 전체 오버레이.
   transform/opacity만 애니메이션(레이아웃 불변), 결과 정보를 가리지 않는 투명도 상한. */
.mahjong-win-ceremony {
  position: absolute;
  inset: 0;
  z-index: 31;
  overflow: hidden;
  border: 0;
  padding: 0;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.mahjong-win-ceremony.visible {
  opacity: 1;
}

/* ── 빛 번짐 (classic, 기본) ── */
.mj-cere-bloom {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(72%, 560px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 236, 170, 0.55), rgba(255, 226, 122, 0.22) 42%, transparent 66%);
  transform: translate(-50%, -50%) scale(0.2);
  opacity: 0;
}

.mahjong-win-ceremony.visible .mj-cere-bloom {
  animation: mj-cere-bloom 950ms ease-out forwards;
}

.mahjong-win-ceremony.visible .mj-cere-bloom-late {
  animation-delay: 170ms;
}

@keyframes mj-cere-bloom {
  0% { transform: translate(-50%, -50%) scale(0.18); opacity: 0; }
  22% { opacity: 0.85; }
  100% { transform: translate(-50%, -50%) scale(2.3); opacity: 0; }
}

/* ── 작탁 폭죽 (confetti) ── */
.mj-cere-burst {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 90px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.9), rgba(255, 209, 102, 0.4) 45%, transparent 70%);
  transform: translate(-50%, -50%) scale(0.3);
  opacity: 0;
}

.mahjong-win-ceremony.visible .mj-cere-burst {
  animation: mj-cere-burst 460ms ease-out forwards;
}

@keyframes mj-cere-burst {
  0% { transform: translate(-50%, -50%) scale(0.25); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2.1); opacity: 0; }
}

.mj-cere-confetti {
  position: absolute;
  left: 50%;
  top: 46%;
  width: var(--size, 8px);
  height: var(--size, 8px);
  border-radius: 2px;
  background: var(--c, #ffd166);
  opacity: 0;
  transform: translate(-50%, -50%);
}

.mj-cere-ribbon {
  width: calc(var(--size, 8px) * 0.55);
  height: calc(var(--size, 8px) * 1.9);
  border-radius: 999px;
}

.mahjong-win-ceremony.visible .mj-cere-confetti {
  animation: mj-cere-confetti 1700ms linear var(--delay, 0ms) forwards;
}

/* 포물선 낙하(검수 피드백: 공중 정지 후 급낙하 어색) — 상승은 감속, 낙하는 중력 가속. */
@keyframes mj-cere-confetti {
  0% {
    transform: translate(-50%, -50%) scale(0.4) rotate(0deg);
    opacity: 0;
    animation-timing-function: cubic-bezier(0.16, 0.72, 0.34, 1);
  }
  8% { opacity: 1; }
  34% {
    transform: translate(calc(-50% + var(--tx) * 0.92), calc(-50% + var(--ty))) scale(1) rotate(calc(var(--rot) * 0.45));
    animation-timing-function: cubic-bezier(0.42, 0, 0.88, 0.55);
  }
  58% {
    transform: translate(calc(-50% + var(--tx) * 1.06), calc(-50% + var(--ty) + var(--fall) * 0.3)) scale(0.98) rotate(calc(var(--rot) * 0.72));
    opacity: 0.96;
    animation-timing-function: cubic-bezier(0.34, 0.14, 0.72, 0.6);
  }
  82% {
    transform: translate(calc(-50% + var(--tx) * 1.14), calc(-50% + var(--ty) + var(--fall) * 0.74)) scale(0.94) rotate(calc(var(--rot) * 0.9));
    opacity: 0.78;
  }
  100% {
    transform: translate(calc(-50% + var(--tx) * 1.18), calc(-50% + var(--ty) + var(--fall))) scale(0.9) rotate(var(--rot));
    opacity: 0;
  }
}

/* ── 등불 세리머니 (lantern) ── */
.mj-cere-veil {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 62%, rgba(255, 171, 89, 0.2), rgba(80, 42, 12, 0.12) 58%, transparent 82%);
  opacity: 0;
}

.mahjong-win-ceremony.visible .mj-cere-veil {
  animation: mj-cere-veil 2200ms ease-in-out forwards;
}

@keyframes mj-cere-veil {
  0% { opacity: 0; }
  22% { opacity: 1; }
  78% { opacity: 1; }
  100% { opacity: 0; }
}

.mj-cere-lantern {
  position: absolute;
  left: var(--lx, 50%);
  bottom: -48px;
  width: 26px;
  height: 36px;
  border-radius: 9px 9px 11px 11px;
  background: radial-gradient(circle at 50% 42%, rgba(255, 244, 214, 0.95), rgba(255, 186, 92, 0.92) 58%, rgba(214, 108, 34, 0.9));
  box-shadow: 0 0 22px 6px rgba(255, 171, 89, 0.4);
  opacity: 0;
}

.mj-cere-lantern::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -5px;
  width: 12px;
  height: 4px;
  border-radius: 2px;
  background: rgba(122, 62, 20, 0.9);
  transform: translateX(-50%);
}

.mj-cere-lantern::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 3px;
  height: 7px;
  border-radius: 2px;
  background: rgba(255, 214, 128, 0.85);
  transform: translateX(-50%);
}

.mahjong-win-ceremony.visible .mj-cere-lantern {
  animation: mj-cere-lantern 2100ms ease-out var(--delay, 0ms) forwards;
}

@keyframes mj-cere-lantern {
  0% { transform: translate(0, 0); opacity: 0; }
  12% { opacity: 1; }
  45% { transform: translate(var(--sway, 12px), calc(var(--rise, 340px) * -0.5)); }
  82% { opacity: 0.92; }
  100% { transform: translate(calc(var(--sway, 12px) * -0.6), calc(var(--rise, 340px) * -1)); opacity: 0; }
}

.mj-cere-word {
  position: absolute;
  left: 50%;
  top: 44%;
  color: rgba(255, 230, 180, 0.92);
  font-size: 44px;
  font-weight: 900;
  text-shadow: 0 0 26px rgba(255, 171, 89, 0.55);
  transform: translate(-50%, -50%) scale(0.86);
  opacity: 0;
}

.mahjong-win-ceremony.visible .mj-cere-word {
  animation: mj-cere-word 2000ms ease-out 260ms forwards;
}

@keyframes mj-cere-word {
  0% { transform: translate(-50%, -50%) scale(0.86); opacity: 0; }
  18% { opacity: 0.95; transform: translate(-50%, -50%) scale(1); }
  70% { opacity: 0.9; }
  100% { transform: translate(-50%, -56%) scale(1.04); opacity: 0; }
}

/* ── 벚꽃 세리머니 (sakura) ── */
.mj-cere-sakura-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, rgba(255, 199, 214, 0.22), transparent 62%);
  opacity: 0;
}

.mahjong-win-ceremony.visible .mj-cere-sakura-glow {
  animation: mj-cere-veil 2000ms ease-in-out forwards;
}

.mj-cere-petal {
  position: absolute;
  left: var(--px, 50%);
  top: -22px;
  width: var(--size, 10px);
  height: calc(var(--size, 10px) * 0.82);
  border-radius: 62% 38% 55% 45%;
  background: linear-gradient(135deg, #ffd7e2, #f8a8c0 62%, #f18bab);
  box-shadow: inset 0 0 3px rgba(255, 255, 255, 0.5);
  opacity: 0;
}

.mahjong-win-ceremony.visible .mj-cere-petal {
  animation: mj-cere-petal 1900ms cubic-bezier(0.3, 0.2, 0.6, 0.9) var(--delay, 0ms) forwards;
}

@keyframes mj-cere-petal {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  10% { opacity: 0.95; }
  55% { transform: translate(calc(var(--drift) * 0.7), calc(var(--fall) * 0.55)) rotate(calc(var(--spin) * 0.55)); opacity: 0.95; }
  100% { transform: translate(var(--drift), var(--fall)) rotate(var(--spin)); opacity: 0; }
}

/* ── 먹 붓글씨 세리머니 (ink) ── */
.mj-cere-ink-wrap {
  position: absolute;
  left: 50%;
  top: 46%;
  width: min(52%, 320px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  /* 어두운 스킨(미래도시 등)에서도 먹획이 보이도록 얇은 흰 할로를 두른다.
     밝은 배경에서는 흰색이 묻혀 티가 나지 않는다. */
  filter:
    drop-shadow(0 0 1.5px rgba(255, 255, 255, 0.9))
    drop-shadow(0 0 7px rgba(255, 255, 255, 0.32));
}

.mj-cere-ink {
  width: 100%;
  height: 100%;
}

.mj-cere-ink-stroke {
  fill: none;
  stroke: rgba(28, 26, 23, 0.88);
  stroke-width: 11;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

/* 和 자 8획을 획순대로 긋는다 — 순서는 마크업 인라인 --delay가 정한다. */
.mahjong-win-ceremony.visible .mj-cere-ink-stroke {
  animation: mj-cere-ink-draw 340ms cubic-bezier(0.5, 0, 0.3, 1) var(--delay, 0ms) forwards;
}

@keyframes mj-cere-ink-draw {
  0% { stroke-dashoffset: 1; opacity: 0.4; }
  12% { opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 1; }
}

.mj-cere-ink-splat {
  position: absolute;
  left: 74%;
  top: 22%;
  width: 16px;
  height: 16px;
  border-radius: 58% 42% 50% 50%;
  background: rgba(28, 26, 23, 0.62);
  transform: scale(0);
}

.mj-cere-ink-splat-2 {
  left: 22%;
  top: 70%;
  width: 10px;
  height: 10px;
}

.mahjong-win-ceremony.visible .mj-cere-ink-splat {
  animation: mj-cere-ink-splat 420ms ease-out 560ms forwards;
}

.mahjong-win-ceremony.visible .mj-cere-ink-splat-2 {
  animation-delay: 980ms;
}

@keyframes mj-cere-ink-splat {
  0% { transform: scale(0); opacity: 0; }
  55% { transform: scale(1.24); opacity: 0.85; }
  100% { transform: scale(1); opacity: 0.7; }
}

/* ── 뇌우 세리머니 (storm) — 광과민 배려: 섬광 2회, 휘도 상한 0.26 ── */
.mj-cere-storm-veil {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(18, 24, 38, 0.55), rgba(24, 30, 46, 0.3) 62%, transparent);
  opacity: 0;
}

.mahjong-win-ceremony.visible .mj-cere-storm-veil {
  animation: mj-cere-veil 1900ms ease-in-out forwards;
}

.mj-cere-flash {
  position: absolute;
  inset: 0;
  background: rgba(226, 233, 248, 1);
  opacity: 0;
}

.mahjong-win-ceremony.visible .mj-cere-flash {
  animation: mj-cere-flash 1900ms linear forwards;
}

@keyframes mj-cere-flash {
  0%, 8% { opacity: 0; }
  12% { opacity: 0.26; }
  18% { opacity: 0.04; }
  30% { opacity: 0.22; }
  42%, 100% { opacity: 0; }
}

.mj-cere-bolt {
  position: absolute;
  left: 50%;
  top: 8%;
  width: 84px;
  height: 134px;
  transform: translateX(-50%);
  fill: rgba(255, 241, 180, 0.92);
  filter: drop-shadow(0 0 12px rgba(255, 231, 150, 0.55));
  opacity: 0;
}

.mahjong-win-ceremony.visible .mj-cere-bolt {
  animation: mj-cere-bolt 1900ms linear forwards;
}

@keyframes mj-cere-bolt {
  0%, 9% { opacity: 0; }
  12% { opacity: 0.95; }
  20% { opacity: 0.1; }
  30% { opacity: 0.8; }
  44%, 100% { opacity: 0; }
}

.mj-cere-rain {
  position: absolute;
  left: var(--rx, 50%);
  top: -28px;
  width: 2px;
  height: 22px;
  border-radius: 999px;
  background: linear-gradient(180deg, transparent, rgba(168, 194, 230, 0.7));
  opacity: 0;
}

.mahjong-win-ceremony.visible .mj-cere-rain {
  animation: mj-cere-rain 700ms linear var(--delay, 0ms) 2;
}

@keyframes mj-cere-rain {
  0% { transform: translateY(0); opacity: 0; }
  14% { opacity: 0.8; }
  100% { transform: translateY(120vh); opacity: 0.2; }
}

/* 모션 최소화: 정적 1프레임 폴백(애니메이션 없이 잠깐 보였다 사라짐) */
.mahjong-win-ceremony.is-reduced * {
  animation: none !important;
}

.mahjong-win-ceremony.is-reduced .mj-cere-bloom,
.mahjong-win-ceremony.is-reduced .mj-cere-burst {
  opacity: 0.4;
  transform: translate(-50%, -50%) scale(1);
}

.mahjong-win-ceremony.is-reduced .mj-cere-confetti {
  opacity: 0.75;
  transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty)));
}

.mahjong-win-ceremony.is-reduced .mj-cere-veil {
  opacity: 0.8;
}

.mahjong-win-ceremony.is-reduced .mj-cere-lantern {
  opacity: 0.9;
  transform: translate(var(--sway, 12px), calc(var(--rise, 340px) * -0.45));
}

.mahjong-win-ceremony.is-reduced .mj-cere-word {
  opacity: 0.9;
}

.mahjong-win-ceremony.is-reduced .mj-cere-petal {
  opacity: 0.8;
  transform: translate(var(--drift), calc(var(--fall) * 0.4)) rotate(calc(var(--spin) * 0.3));
}

.mahjong-win-ceremony.is-reduced .mj-cere-sakura-glow,
.mahjong-win-ceremony.is-reduced .mj-cere-storm-veil {
  opacity: 0.7;
}

.mahjong-win-ceremony.is-reduced .mj-cere-ink-stroke {
  stroke-dashoffset: 0;
  opacity: 1;
}

.mahjong-win-ceremony.is-reduced .mj-cere-ink-splat {
  transform: scale(1);
  opacity: 0.7;
}

/* 모션 최소화 시 섬광은 아예 표시하지 않는다(광과민 배려). */
.mahjong-win-ceremony.is-reduced .mj-cere-flash {
  opacity: 0;
}

.mahjong-win-ceremony.is-reduced .mj-cere-bolt {
  opacity: 0.55;
}

.mahjong-win-ceremony.is-reduced .mj-cere-rain {
  opacity: 0.4;
  transform: translateY(40vh);
}

/* 프로필 칩 배치 — 작혼·일번가와 동일: 자가=좌하단, 대면=상단우측, 좌/우가=각 변 상단. */
.mahjong-3d-seat.seat-bottom {
  bottom: 10px;
  left: 10px;
  transform: none;
}

.mahjong-3d-seat.seat-top {
  top: 8px;
  right: 20%;
  left: auto;
  transform: none;
}

.mahjong-3d-seat.seat-right {
  top: 20%;
  right: 8px;
  transform: none;
}

.mahjong-3d-seat.seat-left {
  top: 20%;
  left: 8px;
  transform: none;
}

.mahjong-table-3d.is-portrait .mahjong-3d-seat.seat-top {
  top: 18%;
}

.mahjong-table-3d.is-portrait .mahjong-3d-seat.seat-bottom {
  top: 76%;
  bottom: auto;
}

@media (min-width: 601px) {
  .mahjong-table-3d:not(.is-portrait):has(.mti-power-summary:not(:empty)) .mahjong-3d-seat.seat-left {
    top: calc(35% + 24px);
  }

  .mahjong-table-3d:not(.is-portrait):has(.mti-power-summary:not(:empty)) .mahjong-table-info {
    box-sizing: border-box;
    max-height: 35%;
    overflow-y: auto;
    overscroll-behavior: contain;
    pointer-events: auto;
  }
}

.mahjong-table-3d.is-portrait .mahjong-actions-overlay {
  bottom: calc(16% + var(--mahjong-bottom-safe-offset, 0px) + env(safe-area-inset-bottom, 0px));
}

/* 세로 작탁에서는 반응 패널을 가로 시간칩 행으로 두지 않는다. 넓은 반응
   버튼이 좌측으로 넘치면 작탁 바깥에 놓여 클릭할 수 없어진다. */
.mahjong-table-3d.is-portrait .mahjong-actions-overlay .mahjong-decision-stack {
  display: grid;
  flex-direction: initial;
  max-width: 100%;
}

.mahjong-table-3d.is-portrait .mahjong-wait-overlay {
  top: 8px;
  bottom: auto;
  left: 8px;
  width: min(58%, 330px);
  max-height: 22%;
}

.mahjong-table-3d.is-portrait .mahjong-3d-automation-badge {
  top: 8px;
  right: 8px;
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mahjong-table-3d.is-portrait .mahjong-3d-result-panel {
  width: min(90%, 430px);
  max-height: 48%;
}

.mahjong-table-3d.is-portrait .mahjong-3d-result-row {
  grid-template-columns: minmax(82px, 0.8fr) minmax(0, 1.5fr) auto;
  gap: 6px;
  padding: 7px 8px;
}

.mahjong-table-3d[data-viewport-profile="phone-portrait"] .mahjong-3d-seat.seat-left,
.mahjong-table-3d[data-viewport-profile="phone-portrait"] .mahjong-3d-seat.seat-right {
  top: 39%;
}

.mahjong-table-3d[data-viewport-profile="phone-portrait"] .mahjong-3d-seat.seat-top {
  top: 13%;
}

.mahjong-table-3d[data-viewport-profile="phone-portrait"] .mahjong-3d-seat.seat-bottom {
  top: 79%;
}

.mahjong-table-3d[data-viewport-profile="phone-portrait"] .mahjong-3d-touch-hint {
  bottom: calc(18% + 54px + env(safe-area-inset-bottom, 0px));
}

.mahjong-table-3d[data-viewport-profile="ultrawide"] .mahjong-actions-overlay {
  right: 10%;
  left: 10%;
}

.mahjong-table-3d[data-viewport-profile="tablet"] .mahjong-actions-overlay {
  right: 8%;
  left: 8%;
  bottom: calc(18% + var(--mahjong-bottom-safe-offset, 0px) + env(safe-area-inset-bottom, 0px));
}

.mahjong-table-3d[data-viewport-profile="tablet"] .mahjong-actions-overlay .mahjong-decision-stack {
  max-width: min(78%, 680px);
}

.mahjong-table-3d[data-viewport-profile="compact-landscape"] .mahjong-3d-seat.seat-top {
  top: 4px;
}

.mahjong-table-3d[data-viewport-profile="compact-landscape"] .mahjong-3d-seat.seat-bottom {
  bottom: 4px;
}

.mahjong-table-3d[data-viewport-profile="compact-landscape"] .mahjong-actions-overlay {
  bottom: calc(48px + var(--mahjong-bottom-safe-offset, 0px) + env(safe-area-inset-bottom, 0px));
}

.mahjong-table-3d[data-viewport-profile="compact-landscape"] .mahjong-wait-overlay {
  bottom: 100px;
  width: min(48%, 390px);
  max-height: 26%;
}

/* Mahjong visual identity: lacquered wood, jade felt and brass instrumentation. */
.mahjong-surface {
  --mj-night: #071917;
  --mj-ink: #0d2521;
  --mj-jade: #1d6b5a;
  --mj-jade-bright: #42b895;
  --mj-brass: #d8b76c;
  --mj-brass-light: #f7df9b;
  --mj-ivory: #f5efdf;
  --mj-vermillion: #b93a36;
  --mj-wood: #4b2e22;
}

.mahjong-effect-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.55rem 0;
}

.mahjong-effect-strip[hidden] {
  display: none;
}

.mahjong-effect-badge {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  color: var(--muted);
  background: rgba(15, 23, 42, 0.55);
  font-size: 0.78rem;
}

.mahjong-effect-badge.mine {
  border-color: rgba(192, 132, 252, 0.7);
  color: #e9d5ff;
  box-shadow: 0 0 18px rgba(147, 51, 234, 0.18);
}

@keyframes mahjong-power-jammed-beat {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  28% { transform: scale(0.9); filter: brightness(0.55) saturate(0.2); }
  55% { transform: scale(1.08); filter: brightness(1.35) saturate(0.5); }
}

.mahjong-effect-badge.is-power-jammed {
  animation: mahjong-power-jammed-beat 720ms ease-out 1;
  border-color: rgba(239, 68, 68, 0.85);
}

.mahjong-effect-badge.is-reduced {
  border-color: rgba(239, 68, 68, 0.85);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25);
  filter: saturate(0.25) brightness(0.8);
}

.mahjong-surface .game-main-panel {
  background:
    radial-gradient(circle at 50% 0%, rgba(59, 139, 113, 0.12), transparent 32rem),
    linear-gradient(145deg, #f7f5ed, #edf3ef 58%, #e4ece8);
}

.mahjong-surface .settings-section {
  border-color: rgba(68, 89, 76, 0.18);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(239, 245, 240, 0.96));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 8px 22px rgba(37, 65, 54, 0.06);
}

.mahjong-surface .settings-section .section-title {
  color: #21493f;
  letter-spacing: 0.04em;
}

.mahjong-sound-setting {
  display: grid;
  gap: 6px;
}

.mahjong-mortal-setting {
  border: 1px solid rgba(91, 124, 113, 0.28);
  border-radius: 10px;
  padding: 10px;
  background: rgba(228, 241, 235, 0.68);
}

.mahjong-mortal-setting span {
  display: grid;
  gap: 2px;
}

.mahjong-mortal-setting small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.mahjong-sound-control {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) 42px 34px 34px;
  gap: 7px;
  align-items: center;
}

.mahjong-sound-control input[type="range"] {
  min-width: 0;
  accent-color: var(--mj-jade);
}

.mahjong-sound-control output {
  color: #385c50;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  text-align: right;
}

.mahjong-sound-button {
  display: grid;
  width: 34px;
  min-width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(52, 91, 77, 0.2);
  border-radius: 50%;
  padding: 0;
  background:
    radial-gradient(circle at 35% 25%, #fff, #e2ebe5 72%);
  color: #245345;
  box-shadow:
    inset 0 1px 0 #fff,
    0 4px 10px rgba(29, 70, 55, 0.12);
  font-size: 13px;
  font-weight: 950;
}

.mahjong-sound-button[aria-pressed="false"] {
  color: #8b514c;
  filter: saturate(0.55);
}

.mahjong-sound-button:hover,
.mahjong-sound-button:focus-visible {
  border-color: rgba(183, 139, 55, 0.58);
  color: #8a6122;
  transform: translateY(-1px);
}

.mahjong-card {
  position: relative;
  isolation: isolate;
  border: 1px solid rgba(64, 83, 72, 0.18);
  border-radius: 18px;
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(238, 243, 238, 0.92)),
    #f3f5ef;
  box-shadow:
    0 24px 60px rgba(30, 56, 47, 0.13),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

/* 테마 섬(theme island): 마작 대기 카드는 항상 밝은 종이 질감이므로, 셸의
   다크 테마가 안쪽 토큰 사용 요소(result-line, muted 등)를 뒤집지 않도록
   프리미티브 토큰을 라이트 값으로 고정한다. 3D 모드는 자체 색을 쓰므로 제외.
   (규약: docs/DESIGN_TOKENS.md — 스킨은 --mj-*만 만지지만, 테마 불변 게임
   매체가 셸 토큰을 "스코프 안에서 고정"하는 것은 허용 패턴이다.) */
.mahjong-card:not(.mahjong-3d-active) {
  --ink: #17202b;
  --muted: #687484;
  --line: #d9e0ea;
  --panel: #ffffff;
  --bg: #eef2f6;
  --soft: #f7f9fc;
  --blue: #246cba;
  --green: #24875b;
  --red: #b64646;
  --amber: #b97919;
  --teal: #247c8d;
  --positive-text: #1f6a48;
  --warning-text: #8a5a10;
  --danger-text: #8f3733;
  --info-text: #1d626f;
  /* 시맨틱 별칭은 :root에서 이미 (다크) 프리미티브로 확정된 "계산값"이 상속되므로,
     프리미티브 고정만으로는 안 바뀐다. 섬 스코프에서 재선언해 재해석시킨다. */
  --text: var(--ink);
  --text-muted: var(--muted);
  --surface: var(--panel);
  --surface-soft: var(--soft);
  --surface-page: var(--bg);
  --accent: var(--blue);
  --on-accent: #ffffff;
  --positive: var(--green);
  --danger: var(--red);
  --warning: var(--amber);
  --info: var(--teal);
  color: var(--ink);
}

.mahjong-card::before {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: -1;
  width: min(72%, 620px);
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--mj-brass), transparent);
  content: "";
  transform: translateX(-50%);
}

.mahjong-status-strip {
  gap: 7px;
  border: 1px solid rgba(214, 183, 108, 0.32);
  border-radius: 14px;
  padding: 7px;
  background:
    linear-gradient(180deg, rgba(20, 50, 43, 0.98), rgba(8, 28, 25, 0.98));
  box-shadow:
    0 10px 24px rgba(8, 31, 26, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.mahjong-status-strip > .mahjong-status-cell {
  position: relative;
  display: grid;
  min-height: 56px;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 0 7px;
  align-content: center;
  align-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 7px 9px;
  background:
    radial-gradient(circle at 18% 0%, rgba(91, 202, 165, 0.12), transparent 55%),
    rgba(255, 255, 255, 0.035);
  color: #a8c9be;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mahjong-status-cell::after {
  position: absolute;
  right: -14px;
  bottom: -20px;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(216, 183, 108, 0.09);
  border-radius: 50%;
  content: "";
}

.mahjong-status-cell > i {
  display: grid;
  width: 28px;
  height: 28px;
  grid-row: 1 / span 2;
  place-items: center;
  border: 1px solid rgba(239, 211, 139, 0.45);
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, #f8e6ae, #b58b41 72%);
  color: #332317;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.22),
    inset 0 1px 1px rgba(255, 255, 255, 0.55);
  font-family: "Yu Mincho", "MS Mincho", serif;
  font-size: 14px;
  font-style: normal;
  font-weight: 900;
}

.mahjong-status-strip .mahjong-status-cell strong {
  display: block;
  grid-column: 2;
  margin: 1px 0 0;
  color: #f7f2df;
  font-size: 14px;
  letter-spacing: 0;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
  text-transform: none;
}

.mahjong-status-cell.status-dora {
  border-color: rgba(240, 199, 100, 0.24);
  background:
    radial-gradient(circle at 12% 10%, rgba(240, 199, 100, 0.16), transparent 58%),
    rgba(255, 255, 255, 0.04);
}

.mahjong-card > .result-line {
  min-height: 38px;
  border: 1px solid rgba(77, 106, 93, 0.16);
  border-radius: 999px;
  padding: 9px 16px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  /* The background is a theme token that flips dark, but the text and bevel were
     hardcoded light-paper values, so this pre-game panel went invisible in dark
     mode when the card wasn't in its light island state (3D-active). */
  color: var(--text);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--text) 14%, transparent);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

/* 관전자 컨트롤: 시점 좌석 선택 + 전체 손패 토글. */
.mahjong-spectator-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(214, 183, 108, 0.32);
  border-radius: 10px;
  background: rgba(20, 50, 43, 0.06);
}

.mahjong-spectator-bar[hidden] {
  display: none;
}

.mahjong-spectator-overlay {
  position: absolute;
  right: 16px;
  bottom: calc(24% + var(--mahjong-bottom-safe-offset, 0px));
  z-index: 5;
  max-width: calc(100% - 32px);
  margin-bottom: 0;
  background: rgba(7, 25, 23, 0.94);
  --color-text-secondary: #e8dec3;
}

.mahjong-spectator-bar .msb-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-secondary, #3c5c52);
}

.mahjong-spectator-bar .msb-seats {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

.mahjong-spectator-bar .msb-seat {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 4px 9px;
  border: 1px solid rgba(77, 106, 93, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: #3c5c52;
  font-size: 12px;
  cursor: pointer;
}

.mahjong-spectator-bar .msb-seat span {
  font-weight: 800;
}

.mahjong-spectator-bar .msb-seat.active {
  border-color: #2f9a57;
  background: #2f9a57;
  color: #fff;
}

.mahjong-spectator-bar .msb-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-secondary, #3c5c52);
  cursor: pointer;
  white-space: nowrap;
}

.mahjong-spectator-bar .msb-toggle input {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  accent-color: #2f9a57;
}

/* 3D 테이블 좌측 상단의 압축 정보 오버레이(도라 · 점봉 · 능력). */
.mahjong-table-info {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: min(420px, 52%);
  padding: 6px 10px;
  border: 1px solid rgba(214, 183, 108, 0.34);
  border-radius: 10px;
  background: rgba(8, 28, 25, 0.6);
  color: #e8f0ea;
  font-size: 11px;
  line-height: 1.2;
  pointer-events: none;
}

.mahjong-table-info:empty {
  display: none;
}

.mahjong-table-info .mti-dora {
  display: flex;
  align-items: center;
  gap: 5px;
}

.mahjong-table-info .mti-dora-label {
  color: #d8b76c;
  font-size: 10px;
  letter-spacing: 0.04em;
}

.mahjong-table-info .mti-dora-tiles {
  display: inline-flex;
  gap: 3px;
}

.mahjong-table-info .mti-tile {
  display: inline-block;
  width: 21px;
  height: 30px;
  border-radius: 3px;
  overflow: hidden;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.mahjong-table-info .mti-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.mahjong-table-info .mti-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  color: #a8c9be;
  font-size: 10px;
  letter-spacing: 0.03em;
}

.mahjong-table-info .mti-stick-count {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #e8f0ea;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.mahjong-table-info .mti-stick {
  display: block;
  flex: 0 0 auto;
  width: 42px;
  height: 12px;
}

.mahjong-table-info .mti-empty {
  color: #8aa39a;
}

.mti-power-summary {
  display: grid;
  gap: 4px;
  margin-top: 4px;
  padding-top: 5px;
  border-top: 1px solid rgba(216, 183, 108, 0.24);
}

.mti-wall-peek {
  display: grid;
  gap: 4px;
  margin-top: 6px;
  padding: 6px 7px;
  border: 1px solid rgba(247, 223, 155, 0.38);
  border-radius: 6px;
  background: rgba(12, 35, 32, 0.72);
  box-shadow: 0 0 16px rgba(216, 183, 108, 0.13);
}

.mti-wall-peek-label {
  color: #f7df9b;
  font-size: 10px;
  font-weight: 900;
}

.mti-wall-peek-tiles {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.mti-wall-peek-empty {
  color: #d8e4db;
  font-size: 11px;
  font-weight: 800;
}

.mahjong-power-info-row {
  display: grid;
  gap: 5px;
}

.mahjong-power-info-row b {
  color: #f7df9b;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
}

.mahjong-power-info-row span {
  color: #f7fbf4;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.48;
}

.mahjong-power-info-row.compact b {
  font-size: 11px;
}

.mahjong-power-info-row.compact span {
  font-size: 11px;
}

.mahjong-power-notice {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 16;
  display: grid;
  width: min(620px, calc(100% - 32px));
  max-height: min(72%, 460px);
  gap: 12px;
  padding: 22px 24px;
  border: 1px solid rgba(247, 223, 155, 0.78);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 0%, rgba(247, 223, 155, 0.2), transparent 62%),
    rgba(3, 17, 16, 0.95);
  color: #f7f2df;
  box-shadow:
    0 0 0 1px rgba(5, 18, 16, 0.78),
    0 28px 70px rgba(0, 0, 0, 0.52);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.mahjong-power-notice[hidden] {
  display: none;
}

.mahjong-power-activation-copy { font-size: 14px; line-height: 1.65; text-align: left; word-break: keep-all; overflow-wrap: anywhere; }
.mahjong-power-activation-copy p { margin: 0; }
.mahjong-power-activation-copy p + p { margin-top: 12px; padding-top: 12px; border-top: 1px solid #f4ddac30; }
.mahjong-power-activation-entry + .mahjong-power-activation-entry { margin-top: 16px; padding-top: 16px; border-top: 1px solid #f4ddac50; }
.mahjong-card:has(.mahjong-fallback-table[data-power-notice-phase="before_result"]) #mahjongResult { visibility: hidden; }
.mahjong-card:has(#mahjongPowerNotice:not([hidden])) .mahjong-3d-result-panel,
.mahjong-lab-stage:has(#mahjongPowerNotice:not([hidden])) .mahjong-3d-result-panel { visibility: hidden; }
[data-table-flipped="flying"] .mahjong-3d-result-panel { visibility: hidden; }
.mahjong-power-activation-copy p > span { display: block; color: #d8bb80; font-size: 11px; letter-spacing: .06em; margin-bottom: 4px; }
.mahjong-power-notice:has(.mahjong-power-activation-copy) { width: min(490px, calc(100% - 32px)); overflow-y: auto; pointer-events: auto; }
.mahjong-fallback-table { position: relative; }
.mahjong-reactions { position: absolute; z-index: 24; right: 10px; top: 45%; }
.mahjong-reactions[hidden], .mahjong-reaction-menu[hidden] { display: none; }
.mahjong-reaction-toggle { display: grid; justify-items: center; gap: 1px; width: 48px; min-height: 48px; padding: 6px 2px; border: 1px solid #e5c58e80; border-radius: 14px; background: #132e2cee; color: #f9e7c1; box-shadow: 0 5px 16px #0003; cursor: pointer; }
.mahjong-reaction-toggle > span { font-size: 20px; line-height: 1; }
.mahjong-reaction-toggle small { font-size: 10px; }
.mahjong-reaction-toggle:hover, .mahjong-reaction-toggle[aria-expanded="true"] { background: #34524b; border-color: #f4d7a1; }
.mahjong-reaction-menu { position: absolute; top: 50%; right: 58px; transform: translateY(-50%); width: min(290px, calc(100vw - 108px)); padding: 16px; border: 1px solid #d8c39d70; border-radius: 16px; background: #102724f7; color: #f5e9d1; box-shadow: 0 12px 36px #0005; display: grid; gap: 14px; text-align: left; }
.mahjong-reaction-menu > strong { font-size: 14px; }
.mahjong-reaction-menu section > span { display: block; margin-bottom: 7px; font-size: 12px; color: #dfc28b; }
.mahjong-reaction-menu section > div { display: flex; flex-wrap: wrap; gap: 6px; }
.mahjong-reaction-menu button { flex: 1 0 42px; min-height: 36px; padding: 6px 8px; border: 1px solid #e9d4ad40; border-radius: 8px; background: #ffffff0c; color: inherit; cursor: pointer; font-size: 12px; }
.mahjong-reaction-menu button:hover { background: #efd09a26; border-color: #e9d4ad; }
.mahjong-reaction-menu button:disabled { opacity: .45; cursor: default; }
.mahjong-reaction-menu > small { font-size: 10px; color: #b4c7bf; line-height: 1.5; word-break: keep-all; }
.mahjong-reaction-status { position: absolute; right: 0; top: 56px; width: 170px; font-size: 11px; line-height: 1.5; color: #ffe5ac; text-align: right; pointer-events: none; }
.mahjong-reaction-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 20; }
.mahjong-reaction-token { position: absolute; display: block; transform: translate(-50%, -50%); filter: drop-shadow(0 5px 5px #0006); }
.mahjong-reaction-token.is-score_sticks { width: 62px; height: 11px; background: #4d5558; border: 1px solid #fff8e9; border-radius: 4px; color: #fff; }
.mahjong-reaction-token.is-score_sticks[data-value="1000"] { background: #3f77ba; }
.mahjong-reaction-token.is-score_sticks[data-value="5000"] { background: #e0a637; color: #382304; }
.mahjong-reaction-token.is-score_sticks[data-value="10000"] { background: #d94c55; }
.mahjong-reaction-token.is-score_sticks i { display: block; font: 700 8px/9px sans-serif; font-style: normal; text-align: center; }
.mahjong-reaction-token.is-tile { width: 32px; }
.mahjong-reactions button:focus-visible { outline: 2px solid #f7d795; outline-offset: 3px; }
@media (max-width: 600px) {
  .mahjong-reactions { right: 6px; }
  .mahjong-reaction-menu { right: 54px; padding: 12px; width: min(290px, calc(100vw - 128px)); }
  .mahjong-power-activation-copy { font-size: 12px; }
}

/* Two-stage targeted-power picker (ability → target). */
.mahjong-power-target-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 8px;
}

.mahjong-power-target-panel .mahjong-combination-head {
  margin-bottom: 8px;
}

/* "You can't discard this turn" notice for a discard-controlled target. */
.mahjong-controlled-notice {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid rgba(247, 223, 155, 0.5);
  border-radius: 10px;
  background: rgba(8, 28, 25, 0.82);
  color: #f7f2df;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

/* peek_dora result popup, sitting just above the player's hand. */
.mahjong-peek-dora-popup {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 12;
  transform: translateX(-50%);
  pointer-events: none;
}

.mahjong-peek-dora-popup:empty {
  display: none;
}

.mahjong-peek-dora-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 14px;
  border: 1px solid rgba(247, 223, 155, 0.7);
  border-radius: 999px;
  background: linear-gradient(145deg, rgba(25, 60, 51, 0.97), rgba(7, 27, 24, 0.97));
  color: #f7f2df;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.34);
  pointer-events: auto;
}

.mahjong-peek-dora-name {
  font-size: 13px;
  font-weight: 800;
}

.mahjong-peek-dora-meta {
  color: #cfe9dd;
  font-size: 12px;
}

.mahjong-peek-dora-count {
  color: #ffd166;
  font-size: 18px;
  font-weight: 900;
}

.mahjong-peek-dora-close {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-left: 2px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #f7f2df;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.mahjong-peek-dora-close:hover {
  background: rgba(255, 255, 255, 0.26);
}

.mahjong-power-notice[data-tone="opponent"] {
  width: min(420px, calc(100% - 36px));
  text-align: center;
}

.mahjong-power-notice-title {
  color: #f7df9b;
  font-size: 21px;
  font-weight: 900;
  line-height: 1.15;
}

@media (max-width: 600px) {
  .mahjong-table-info {
    top: 6px;
    left: 6px;
    max-width: calc(100% - 12px);
    padding: 5px 8px;
    font-size: 10px;
  }
  .mahjong-table-info .mti-tile {
    width: 18px;
    height: 25px;
  }
  .mahjong-power-notice {
    width: calc(100% - 24px);
    padding: 16px 17px;
  }
  .mahjong-power-notice-title {
    font-size: 18px;
  }
}

.mahjong-table-3d {
  isolation: isolate;
  border: 8px solid var(--mj-wood);
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 45%, #286f5e, #123d34 72%, #08251f);
  box-shadow:
    0 28px 60px rgba(23, 42, 34, 0.28),
    0 0 0 1px #2e1c15,
    0 0 0 4px rgba(209, 169, 91, 0.28),
    inset 0 0 0 2px rgba(255, 225, 160, 0.15);
}

.mahjong-table-3d::before,
.mahjong-table-3d::after {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  content: "";
}

.mahjong-table-3d::before {
  border: 1px solid rgba(255, 230, 174, 0.16);
  border-radius: 13px;
  box-shadow:
    inset 0 0 48px rgba(0, 0, 0, 0.18),
    inset 0 0 0 6px rgba(255, 255, 255, 0.018);
}

.mahjong-table-3d::after {
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.05), transparent 22%),
    radial-gradient(circle at 50% 50%, transparent 62%, rgba(2, 14, 12, 0.22));
}

.mahjong-3d-canvas {
  position: relative;
  z-index: 1;
}

.mahjong-3d-seats,
.mahjong-actions-overlay,
.mahjong-wait-overlay {
  z-index: 4;
}

.mahjong-actions-overlay .mahjong-action-grid,
.mahjong-actions-overlay .mahjong-combination-panel {
  position: relative;
  border: 1px solid rgba(231, 203, 135, 0.3);
  border-radius: 16px;
  padding: 9px;
  background:
    linear-gradient(145deg, rgba(20, 47, 41, 0.94), rgba(7, 25, 23, 0.96));
  box-shadow:
    0 16px 36px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.mahjong-decision-stack {
  display: grid;
  width: min(100%, 720px);
  gap: 8px;
  justify-items: center;
}

.mahjong-decision-banner {
  --decision-progress: 1;
  position: relative;
  display: grid;
  width: min(100%, 460px);
  min-height: 54px;
  grid-template-columns: 38px minmax(0, 1fr) 58px;
  gap: 9px;
  align-items: center;
  overflow: hidden;
  border: 1px solid rgba(235, 207, 137, 0.42);
  border-radius: 15px;
  padding: 7px 8px;
  background:
    linear-gradient(145deg, rgba(25, 60, 51, 0.97), rgba(7, 27, 24, 0.98));
  color: #f6f2e5;
  box-shadow:
    0 14px 34px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
}

.mahjong-decision-banner::before {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background:
    linear-gradient(
      90deg,
      var(--mj-brass-light) calc(var(--decision-progress) * 100%),
      rgba(255, 255, 255, 0.08) 0
    );
  content: "";
  transition: background 100ms linear;
}

.mahjong-decision-banner.is-urgent {
  border-color: rgba(244, 116, 99, 0.72);
  background:
    radial-gradient(circle at 12% 0%, rgba(219, 80, 61, 0.24), transparent 52%),
    linear-gradient(145deg, rgba(66, 43, 35, 0.98), rgba(35, 21, 20, 0.98));
  box-shadow:
    0 0 0 3px rgba(214, 71, 57, 0.13),
    0 14px 34px rgba(0, 0, 0, 0.32);
}

.mahjong-decision-crest {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(242, 216, 151, 0.48);
  border-radius: 50%;
  background: rgba(3, 27, 23, 0.55);
  color: var(--mj-brass-light);
  font-family: "Yu Mincho", "MS Mincho", serif;
  font-size: 19px;
  font-weight: 900;
}

.mahjong-decision-copy {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.mahjong-decision-copy strong,
.mahjong-decision-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mahjong-decision-copy strong {
  font-size: 13px;
  font-weight: 950;
}

.mahjong-decision-copy small {
  color: #a9cbbf;
  font-size: 10px;
  font-weight: 750;
}

.mahjong-decision-clock {
  display: grid;
  min-height: 38px;
  place-items: center;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  color: #f6d889;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  font-weight: 950;
}

.mahjong-decision-banner.is-urgent .mahjong-decision-clock {
  color: #ff9a88;
  text-shadow: 0 0 14px rgba(255, 92, 70, 0.32);
}

.mahjong-action-grid {
  gap: 7px;
}

.mahjong-command,
.mahjong-riichi-toggle {
  position: relative;
  display: grid;
  min-width: 118px;
  min-height: 58px;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 7px 12px 7px 8px;
  background:
    linear-gradient(155deg, rgba(59, 105, 91, 0.98), rgba(23, 62, 54, 0.98));
  color: #f7f5e9;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.13),
    inset 0 -7px 16px rgba(0, 0, 0, 0.08),
    0 6px 14px rgba(0, 0, 0, 0.18);
  text-align: left;
  transition:
    border-color 140ms ease,
    filter 140ms ease,
    transform 140ms ease;
}

.mahjong-command::after,
.mahjong-riichi-toggle::after {
  position: absolute;
  top: -28px;
  right: -20px;
  width: 70px;
  height: 70px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 50%;
  content: "";
}

.mahjong-command:hover,
.mahjong-command:focus-visible,
.mahjong-riichi-toggle:hover,
.mahjong-riichi-toggle:focus-within {
  border-color: rgba(248, 221, 151, 0.7);
  filter: brightness(1.08);
  transform: translateY(-2px);
}

.mahjong-command:active {
  transform: translateY(1px);
}

.mahjong-command:disabled,
.mahjong-riichi-toggle:has(input:disabled) {
  filter: grayscale(0.45);
  opacity: 0.48;
  transform: none;
}

.mahjong-command-sigil {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(250, 225, 164, 0.42);
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 25%, rgba(255, 255, 255, 0.28), transparent 32%),
    rgba(4, 27, 23, 0.48);
  color: var(--mj-brass-light);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.08);
  font-family: "Yu Mincho", "MS Mincho", serif;
  font-size: 19px;
  font-weight: 900;
}

.mahjong-command-copy {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.mahjong-command-copy b {
  overflow: hidden;
  color: inherit;
  font-size: 13px;
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mahjong-command-copy small {
  color: rgba(232, 242, 237, 0.62);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.mahjong-command-ron,
.mahjong-command-tsumo {
  border-color: rgba(255, 211, 115, 0.48);
  background:
    linear-gradient(150deg, #b6463d, #6f211f 68%, #481514);
  box-shadow:
    inset 0 1px 0 rgba(255, 238, 187, 0.23),
    0 7px 18px rgba(83, 20, 19, 0.34);
}

.mahjong-command-ron .mahjong-command-sigil,
.mahjong-command-tsumo .mahjong-command-sigil {
  background: radial-gradient(circle at 35% 28%, #fff2bd, #d0a34b 70%);
  color: #5a1c19;
}

.mahjong-command-chi,
.mahjong-command-pon {
  background: linear-gradient(150deg, #2b826c, #174d42 72%);
}

.mahjong-command-kan,
.mahjong-command-open-kan,
.mahjong-command-closed-kan,
.mahjong-command-added-kan {
  background: linear-gradient(150deg, #425c83, #243650 70%);
}

.mahjong-command-north {
  background: linear-gradient(150deg, #677a88, #374955 72%);
}

.mahjong-command-power {
  border-color: rgba(213, 177, 255, 0.48);
  background:
    radial-gradient(circle at 18% 0%, rgba(238, 214, 255, 0.2), transparent 48%),
    linear-gradient(150deg, #74548d, #3f2c58 72%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 7px 18px rgba(49, 26, 72, 0.32);
}

.mahjong-command-power .mahjong-command-sigil {
  border-color: rgba(229, 203, 255, 0.56);
  color: #f1ddff;
}

.mahjong-command-pass,
.mahjong-command-abortive-draw {
  border-color: rgba(255, 255, 255, 0.1);
  background: linear-gradient(150deg, #4a5657, #293536 72%);
  color: #d9e0dd;
}

.mahjong-command-next-hand {
  background: linear-gradient(150deg, #9a7637, #60461e 72%);
}

.mahjong-command.is-selected,
.mahjong-reaction-type.is-selected {
  border-color: var(--mj-brass-light);
  box-shadow:
    0 0 0 3px rgba(240, 199, 100, 0.2),
    0 9px 22px rgba(0, 0, 0, 0.28);
}

.mahjong-command-riichi,
.mahjong-riichi-toggle {
  cursor: pointer;
  background: linear-gradient(150deg, #a64a3d, #64251f 72%);
}

.mahjong-riichi-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.mahjong-riichi-toggle:has(input:checked) {
  border-color: var(--mj-brass-light);
  background: linear-gradient(150deg, #ce5b42, #7e281f 72%);
  box-shadow:
    0 0 0 3px rgba(240, 199, 100, 0.2),
    0 8px 20px rgba(87, 24, 18, 0.36);
}

.mahjong-combination-panel {
  counter-reset: mahjong-combination;
}

.mahjong-combination-head {
  color: #f4ead2;
}

.mahjong-combination-head strong::before {
  margin-right: 6px;
  color: var(--mj-brass-light);
  content: "◇";
}

.mahjong-combination-option {
  position: relative;
  counter-increment: mahjong-combination;
  border-color: rgba(222, 194, 126, 0.36);
  border-radius: 11px;
  background:
    linear-gradient(180deg, #fffdf5, #eae0ca);
  box-shadow:
    inset 0 1px 0 #fff,
    0 5px 12px rgba(0, 0, 0, 0.18);
}

.mahjong-combination-option::before {
  position: absolute;
  top: -6px;
  left: -6px;
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 1px solid #e4c981;
  border-radius: 50%;
  background: #163e35;
  color: #ffe8a8;
  content: counter(mahjong-combination);
  font-size: 10px;
  font-weight: 900;
}

.mahjong-power-choice-panel {
  display: grid;
  gap: 10px;
}

/* Choice candidates use the table's central popup, outside the narrow action row. */
.mahjong-actions-overlay:has(.mahjong-power-choice-panel) {
  z-index: 12;
  overflow: visible;
}

.mahjong-actions-overlay .mahjong-power-choice-panel {
  position: absolute;
  left: 50%;
  bottom: 0;
  box-sizing: border-box;
  width: min(520px, 100%);
  max-height: min(320px, calc(100dvh - 180px));
  overflow: auto;
  overscroll-behavior: contain;
  transform: translateX(-50%);
}

.mahjong-power-choice-rows {
  display: grid;
  gap: 10px;
}

.mahjong-power-choice-row {
  display: grid;
  gap: 6px;
}

.mahjong-power-choice-title {
  color: #f6e4b1;
  font-size: 12px;
  font-weight: 900;
}

.mahjong-power-tile-list,
.mahjong-power-hidden-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mahjong-power-tile-list.is-large {
  gap: 9px;
  justify-content: flex-start;
}

.mahjong-power-tile-list.is-large .mahjong-power-tile-choice {
  min-width: 50px;
  min-height: 68px;
}

.mahjong-power-tile-list.is-large .riichi-tile {
  width: 44px;
  height: 62px;
}

.mahjong-power-hidden-list.is-large {
  gap: 8px;
}

.mahjong-power-hidden-list.is-large .mahjong-power-hidden-choice {
  width: 48px;
  min-height: 66px;
  padding: 5px 4px;
}

.mahjong-power-hidden-list.is-large .riichi-tile {
  width: 34px;
  height: 48px;
}

.mahjong-round-wind-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(54px, 1fr));
  gap: 8px;
}

.mahjong-power-tile-choice,
.mahjong-power-hidden-choice {
  position: relative;
  display: grid;
  min-width: 38px;
  min-height: 48px;
  place-items: center;
  border: 1px solid rgba(222, 194, 126, 0.4);
  border-radius: 8px;
  background: linear-gradient(180deg, #fffdf5, #e6dcc8);
  color: #173d34;
  cursor: pointer;
  overflow: hidden;
}

.mahjong-power-hidden-choice {
  width: 38px;
  background:
    linear-gradient(135deg, rgba(34, 81, 70, 0.96), rgba(13, 40, 35, 0.96));
  color: #ffe8a8;
  font-weight: 900;
}

.mahjong-power-tile-choice.is-selected,
.mahjong-power-hidden-choice.is-selected {
  border-color: var(--mj-brass-light);
  box-shadow:
    0 0 0 3px rgba(240, 199, 100, 0.34),
    0 10px 22px rgba(24, 16, 5, 0.22);
}

.mahjong-power-tile-choice.is-selected::after,
.mahjong-power-hidden-choice.is-selected::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.28);
  color: #fff8d7;
  font-size: 24px;
  font-weight: 900;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.72);
  pointer-events: none;
}

/* A joker tile cannot be exchanged: darken it and overlay a large X. */
.mahjong-hand-exchange-steal.is-blocked {
  position: relative;
  filter: grayscale(0.5) brightness(0.5);
  cursor: not-allowed;
}
.mahjong-hand-exchange-steal.is-blocked .mahjong-exchange-blocked {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 900;
  color: #ff5a5a;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

.mahjong-power-hand-prompt {
  border: 1px solid rgba(222, 194, 126, 0.22);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(6, 28, 25, 0.54);
  color: rgba(247, 242, 223, 0.72);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.35;
}

.mahjong-power-hand-prompt.is-active {
  border-color: rgba(240, 199, 100, 0.58);
  background: rgba(240, 199, 100, 0.14);
  color: #fff6d7;
}

.mahjong-round-wind-choice {
  display: grid;
  gap: 5px;
  place-items: center;
  border: 1px solid rgba(222, 194, 126, 0.4);
  border-radius: 8px;
  padding: 8px 6px;
  background: linear-gradient(150deg, #1d5a4e, #0c2c27 72%);
  color: #f6e4b1;
  cursor: pointer;
}

.mahjong-round-wind-choice b {
  font-size: 12px;
}

.mahjong-power-confirm {
  justify-self: end;
}

.mahjong-power-confirm-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mahjong-power-confirm-row .mahjong-power-confirm {
  justify-self: stretch;
}

.mahjong-power-tile-popup {
  width: min(560px, 100%);
}

.mahjong-curse-tile-panel .mahjong-power-choice-row {
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
}

.mahjong-power-tile-placeholder {
  display: inline-block;
  width: 38px;
  height: 48px;
}

.mahjong-peek-hands-list {
  display: grid;
  gap: 6px;
  min-width: min(76vw, 440px);
}

.mahjong-peek-hands-row {
  display: grid;
  grid-template-columns: minmax(72px, 0.32fr) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.mahjong-peek-hands-row strong {
  overflow: hidden;
  color: #f6e4b1;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mahjong-peek-hands-row span {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.mahjong-next-hand-control {
  border-color: rgba(229, 198, 123, 0.34);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(21, 48, 42, 0.95), rgba(8, 27, 24, 0.97));
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.28);
}

.mahjong-wait-info,
.mahjong-wait-hint {
  border: 1px solid rgba(228, 197, 121, 0.34);
  border-radius: 13px;
  background:
    linear-gradient(145deg, rgba(23, 54, 47, 0.96), rgba(8, 29, 26, 0.97));
  color: #edf4ef;
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.mahjong-wait-heading strong {
  color: #f6e4b1;
  letter-spacing: 0.02em;
}

.mahjong-wait-heading strong::before {
  margin-right: 6px;
  color: #69d4b0;
  content: "聴";
  font-family: "Yu Mincho", "MS Mincho", serif;
}

.mahjong-wait-tile,
.mahjong-card.mahjong-3d-active .mahjong-wait-tile {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.08);
  color: #f3f6f3;
}

.mahjong-wait-count {
  color: #aee8d4;
}

.mahjong-3d-seat {
  isolation: isolate;
  min-height: 42px;
  border: 1px solid rgba(235, 208, 143, 0.24);
  border-left: 0;
  border-radius: 12px;
  padding: 6px 10px 6px 7px;
  background:
    linear-gradient(145deg, rgba(21, 47, 42, 0.91), rgba(7, 25, 23, 0.91));
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(8px);
}

.mahjong-3d-seat.current {
  position: absolute;
  border-color: rgba(255, 215, 120, 0.72);
  box-shadow:
    0 0 0 3px rgba(255, 209, 102, 0.13),
    0 9px 24px rgba(0, 0, 0, 0.3);
}

.mahjong-3d-seat.current::after {
  position: absolute;
  inset: -5px;
  z-index: -1;
  border: 1px solid rgba(255, 216, 120, 0.52);
  border-radius: 15px;
  content: "";
  animation: mahjong-seat-turn 1.4s ease-in-out infinite;
}

.mahjong-power-statuses {
  display: grid;
  gap: 3px;
  justify-items: start;
  min-width: 0;
}

.mahjong-power-status {
  max-width: 100%;
  border: 1px solid;
  border-radius: 5px;
  padding: 3px 6px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
  white-space: normal;
}

.mahjong-power-status.is-buff {
  border-color: rgba(169, 97, 41, 0.45);
  background: #262b22;
  color: #ffbb73;
}

.mahjong-power-status.is-debuff {
  border-color: rgba(64, 117, 168, 0.45);
  background: #142a2d;
  color: #9dcfff;
}

.mahjong-power-status.has-target {
  display: flex;
  align-items: baseline;
  pointer-events: auto;
}

.mahjong-power-target {
  flex: 0 1 auto;
  min-width: 1.5em;
  max-width: 5em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: inherit;
}

.mahjong-power-description {
  flex: 0 0 auto;
  max-width: calc(100% - 1.5em);
  font: inherit;
  white-space: pre-wrap;
}

.mahjong-3d-seat > .mahjong-power-statuses {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  width: max-content;
  max-width: min(240px, 38vw);
}

.mahjong-3d-seat.seat-right > .mahjong-power-statuses {
  right: 0;
  left: auto;
  justify-items: end;
}

.mahjong-3d-seat.seat-top > .mahjong-power-statuses {
  top: 0;
  left: calc(100% + 6px);
  max-width: min(240px, calc(20cqw - 58px));
}

.mahjong-table-3d.is-portrait .mahjong-3d-seat.seat-top:has(.mahjong-power-statuses) {
  right: 42%;
  max-width: calc(58% - 16px);
}

.mahjong-table-3d.is-portrait .mahjong-3d-seat.seat-top > .mahjong-power-statuses {
  max-width: calc(42cqw - 14px);
}

.mahjong-3d-seat.seat-bottom > .mahjong-power-statuses {
  top: auto;
  bottom: calc(100% + 5px);
}

/* Short landscape windows need room for the nickname and its stacked effects. */
@media (max-height: 520px) {
  .mahjong-table-3d[data-viewport-profile="compact-landscape"] .mahjong-3d-seat.seat-top:has(.mahjong-power-statuses) {
    right: 30%;
  }

  .mahjong-table-3d[data-viewport-profile="compact-landscape"] .mahjong-3d-seat.seat-top > .mahjong-power-statuses {
    max-width: min(240px, calc(30cqw - 58px));
  }

  .game-layout.mahjong-surface .mahjong-card.mahjong-3d-active:has(.mahjong-power-statuses) {
    overflow-y: auto;
  }

  .game-layout.mahjong-surface .mahjong-card.mahjong-3d-active:has(.mahjong-power-statuses) .mahjong-table-3d {
    min-height: 320px;
  }

  .mahjong-table-3d:fullscreen[data-viewport-profile="compact-landscape"] .mahjong-combination-panel {
    max-height: calc(100dvh - 64px - var(--mahjong-bottom-safe-offset, 0px) - env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

.mahjong-command-feedback {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 10;
  display: grid;
  min-width: min(82%, 270px);
  grid-template-columns: 42px minmax(0, 1fr) 22px;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(246, 217, 145, 0.58);
  border-radius: 16px;
  padding: 10px 12px;
  background:
    radial-gradient(circle at 18% 0%, rgba(231, 190, 90, 0.16), transparent 52%),
    rgba(7, 29, 25, 0.96);
  color: #f8f2e3;
  box-shadow:
    0 22px 54px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -44%) scale(0.94);
  transition:
    opacity 130ms ease,
    transform 170ms ease;
}

.mahjong-command-feedback.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.mahjong-command-feedback-sigil {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(247, 218, 144, 0.5);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #f9e8ad, #b98a3e 72%);
  color: #3b291a;
  font-family: "Yu Mincho", "MS Mincho", serif;
  font-size: 20px;
  font-weight: 900;
}

.mahjong-command-feedback > span:not(.mahjong-command-feedback-sigil) {
  display: grid;
  gap: 2px;
}

.mahjong-command-feedback strong {
  font-size: 14px;
  font-weight: 950;
}

.mahjong-command-feedback small {
  color: #b1ccc2;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.mahjong-command-feedback i {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #f1d27d;
  border-radius: 50%;
  animation: mahjong-command-spin 700ms linear infinite;
}

.mahjong-table-3d.is-command-pending .mahjong-3d-canvas {
  filter: saturate(0.86) brightness(0.88);
}

.mahjong-3d-seat span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid rgba(237, 209, 141, 0.46);
  border-radius: 50%;
  background: rgba(4, 22, 20, 0.52);
  color: #f0d99d;
  font-family: "Yu Mincho", "MS Mincho", serif;
}

.mahjong-3d-seat strong {
  color: #f4f3e8;
}

.mahjong-3d-seat em {
  color: #a9e7d0;
  font-variant-numeric: tabular-nums;
}

.mahjong-3d-seat i {
  border-radius: 999px;
  padding: 2px 5px;
  background: rgba(208, 157, 55, 0.17);
}

.mahjong-3d-event-label {
  border: 1px solid rgba(255, 224, 143, 0.82);
  border-radius: 50% 50% 46% 46% / 16% 16% 20% 20%;
  padding: 12px 28px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 222, 137, 0.13), transparent 56%),
    rgba(13, 34, 31, 0.94);
  box-shadow:
    0 16px 38px rgba(0, 0, 0, 0.38),
    inset 0 0 0 3px rgba(255, 255, 255, 0.025);
  letter-spacing: 0.08em;
}

.mahjong-3d-result-panel {
  border-color: rgba(244, 209, 121, 0.68);
  border-radius: 18px;
  padding: 18px;
  background:
    radial-gradient(circle at 50% -18%, rgba(232, 190, 90, 0.19), transparent 48%),
    linear-gradient(145deg, rgba(24, 55, 48, 0.985), rgba(5, 23, 21, 0.99));
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.52),
    inset 0 0 0 3px rgba(255, 255, 255, 0.025),
    inset 0 1px 0 rgba(255, 240, 196, 0.12);
}

.mahjong-3d-result-panel::before {
  display: block;
  width: 54px;
  height: 4px;
  margin: -5px auto 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #efd58c, transparent);
  content: "";
}

.mahjong-3d-result-row {
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 11px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.035));
}

.mahjong-3d-result-panel.visible .mahjong-3d-result-row {
  animation: mahjong-result-row-in 280ms cubic-bezier(0.18, 0.82, 0.3, 1) both;
  animation-delay: calc(var(--result-index, 0) * 65ms);
}

.mahjong-3d-result-row em {
  color: #f3d47f;
  text-shadow: 0 0 14px rgba(243, 212, 127, 0.16);
}

.mahjong-3d-result-row em.is-negative {
  color: #ff9a91;
}

@keyframes mahjong-seat-turn {
  0%,
  100% {
    opacity: 0.38;
    transform: scale(0.985);
  }

  50% {
    opacity: 0.92;
    transform: scale(1.025);
  }
}

@keyframes mahjong-command-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes mahjong-result-row-in {
  from {
    opacity: 0;
    transform: translateY(7px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.mahjong-card.mahjong-3d-active .mahjong-hand-panel {
  display: none;
}

.mahjong-surface .mahjong-tabletop {
  border: 7px solid var(--mj-wood);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 42%, rgba(52, 132, 108, 0.96), rgba(18, 66, 56, 0.98));
  box-shadow:
    0 18px 42px rgba(25, 46, 38, 0.22),
    0 0 0 2px rgba(213, 177, 99, 0.24);
}

.mahjong-surface .mahjong-player {
  border-color: rgba(219, 190, 124, 0.28);
  background:
    linear-gradient(145deg, rgba(255, 253, 244, 0.96), rgba(231, 237, 226, 0.94));
  box-shadow:
    0 8px 22px rgba(6, 34, 28, 0.16),
    inset 0 1px 0 #fff;
}

.mahjong-surface .mahjong-player.current {
  border-color: rgba(238, 196, 91, 0.76);
  box-shadow:
    0 0 0 3px rgba(239, 200, 103, 0.2),
    0 10px 26px rgba(7, 34, 28, 0.2);
}

.mahjong-surface .mahjong-final-panel,
.mahjong-surface .mahjong-replay-panel,
.mahjong-surface .mahjong-hand-panel {
  border-color: rgba(83, 108, 94, 0.2);
  border-radius: 13px;
  background:
    linear-gradient(145deg, rgba(255, 255, 252, 0.96), rgba(235, 241, 234, 0.96));
  box-shadow:
    inset 0 1px 0 #fff,
    0 10px 26px rgba(32, 61, 50, 0.08);
}

.mahjong-table-3d.is-unavailable {
  display: none;
}

.mahjong-tabletop {
  min-height: 420px;
  border: 1px solid rgba(35, 82, 70, 0.18);
  border-radius: 8px;
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.55), rgba(224, 236, 232, 0.72)),
    #eaf1ee;
}

.mahjong-player-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 12px;
}

.mahjong-player {
  display: grid;
  min-width: 0;
  gap: 9px;
  border: 1px solid rgba(24, 32, 42, 0.12);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.46);
}

.mahjong-player.current {
  border-color: rgba(37, 92, 153, 0.45);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.55),
    0 0 0 3px rgba(37, 92, 153, 0.1);
}

.mahjong-player.me {
  background: #fbfffc;
}

.mahjong-player.winner {
  border-color: rgba(35, 136, 95, 0.52);
  background: #effaf3;
}

.mahjong-player-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.mahjong-player-head span,
.mahjong-player-head strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mahjong-player-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.mahjong-player-head strong {
  font-size: 18px;
}

.mahjong-player-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 24px;
}

.mahjong-player-badges span,
.mahjong-side-note {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 8px;
  padding: 0 8px;
  background: var(--line);
  color: #334155;
  font-size: 12px;
  font-weight: 850;
}

.mahjong-player.mortal-bot {
  border-color: rgba(60, 136, 113, 0.42);
}

.mahjong-player-badges .mahjong-mortal-badge {
  background: #d8f3e7;
  color: #17634e;
  letter-spacing: 0.08em;
}

.mahjong-closed-count,
.mahjong-discard-row,
.mahjong-meld-row,
.mahjong-hand {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 4px;
}

.mahjong-hand.is-hand-exchange-pick {
  border: 1px solid rgba(240, 199, 100, 0.54);
  border-radius: 8px;
  padding: 7px;
  background: rgba(255, 246, 210, 0.18);
  box-shadow:
    inset 0 0 0 1px rgba(255, 246, 210, 0.14),
    0 0 0 3px rgba(240, 199, 100, 0.12);
}

.mahjong-closed-count {
  min-height: 28px;
}

.mahjong-discard-row {
  min-height: 72px;
  align-content: flex-start;
  border-radius: 8px;
  padding: 7px;
  background: rgba(235, 240, 246, 0.72);
}

.mahjong-meld-row {
  min-height: 30px;
  align-items: center;
}

.mahjong-meld {
  display: inline-flex;
  gap: 2px;
  align-items: center;
  border-radius: 8px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.76);
}

.mahjong-reaction-target {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 8px;
  border: 1px solid rgba(190, 145, 36, 0.3);
  border-radius: 8px;
  padding: 5px 8px;
  background: rgba(255, 248, 222, 0.92);
  color: #514022;
  font-size: 12px;
  font-weight: 900;
}

.mahjong-reaction-target-label {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mahjong-final-panel {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 10px;
  border: 1px solid rgba(213, 177, 99, 0.34);
  border-radius: 16px;
  padding: 14px;
  background:
    radial-gradient(circle at 85% -20%, rgba(218, 178, 86, 0.13), transparent 42%),
    linear-gradient(145deg, rgba(253, 252, 245, 0.98), rgba(232, 241, 234, 0.98));
  box-shadow:
    0 16px 38px rgba(29, 59, 48, 0.1),
    inset 0 1px 0 #fff;
}

.mahjong-final-panel::after {
  position: absolute;
  top: -48px;
  right: -36px;
  width: 130px;
  height: 130px;
  border: 1px solid rgba(183, 139, 55, 0.1);
  border-radius: 50%;
  content: "";
}

.mahjong-final-list {
  display: grid;
  gap: 7px;
}

.mahjong-final-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(150px, 1.1fr) minmax(86px, auto) minmax(106px, auto) minmax(180px, 1.3fr);
  gap: 10px;
  align-items: center;
  min-height: 42px;
  border: 1px solid rgba(54, 98, 80, 0.08);
  border-radius: 11px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.mahjong-final-row.rank-1 {
  border-color: rgba(196, 151, 55, 0.35);
  background:
    linear-gradient(90deg, rgba(243, 216, 145, 0.3), rgba(255, 255, 255, 0.7));
  box-shadow:
    inset 3px 0 0 #c99737,
    inset 0 1px 0 #fff;
}

.mahjong-final-row span,
.mahjong-final-row strong,
.mahjong-final-row em,
.mahjong-final-row small {
  min-width: 0;
}

.mahjong-final-row span {
  display: flex;
  gap: 8px;
  align-items: center;
  overflow: hidden;
  color: var(--ink);
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mahjong-final-row span i {
  display: grid;
  width: 27px;
  height: 27px;
  flex: 0 0 27px;
  place-items: center;
  border: 1px solid rgba(63, 105, 88, 0.2);
  border-radius: 50%;
  background: rgba(30, 91, 72, 0.08);
  color: #315f50;
  font-family: "Yu Mincho", "MS Mincho", serif;
  font-size: 12px;
  font-style: normal;
}

.mahjong-final-row.rank-1 span i {
  border-color: rgba(211, 169, 75, 0.55);
  background: radial-gradient(circle at 35% 28%, #fff1b9, #c5963f 72%);
  color: #4f3418;
}

.mahjong-final-row strong {
  justify-self: end;
  font-size: 17px;
}

.mahjong-final-row em {
  justify-self: end;
  color: var(--positive);
  font-style: normal;
  font-weight: 900;
}

.mahjong-final-row small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mahjong-final-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.mahjong-replay-panel {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(38, 95, 80, 0.22);
  border-radius: 10px;
  padding: 12px;
  background: linear-gradient(135deg, rgba(239, 248, 244, 0.96), rgba(249, 247, 238, 0.96));
}

.mahjong-url-replay-controls {
  position: sticky;
  bottom: 10px;
  z-index: 30;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  border: 1px solid rgba(38, 95, 80, 0.28);
  border-radius: 12px;
  padding: 10px;
  background: rgba(248, 250, 245, 0.96);
  box-shadow: 0 8px 24px rgba(28, 48, 40, 0.16);
  backdrop-filter: blur(10px);
}

.mahjong-url-replay-controls input[type="range"] {
  min-width: 180px;
  flex: 1 1 260px;
}

.mahjong-replay-list,
.mahjong-replay-controls,
.mahjong-replay-heading {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.mahjong-replay-list .mahjong-replay-open {
  display: inline-flex;
  gap: 7px;
  align-items: baseline;
}

.mahjong-replay-list small,
.mahjong-replay-heading small,
.mahjong-replay-integrity {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.mahjong-replay-heading {
  justify-content: space-between;
}

.mahjong-replay-heading > div:not(.mahjong-replay-heading-actions) {
  display: grid;
  gap: 3px;
}

.mahjong-replay-heading-actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.mahjong-log-download {
  border-color: rgba(49, 114, 96, 0.34);
  background: rgba(65, 151, 115, 0.08);
}

.mahjong-replay-controls input[type="range"] {
  flex: 1 1 220px;
  min-width: 140px;
}

.mahjong-replay-controls select {
  min-width: 130px;
}

.mahjong-replay-integrity {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  justify-self: start;
  border: 1px solid rgba(64, 145, 111, 0.2);
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(65, 151, 115, 0.08);
  color: #39755f;
  overflow-wrap: anywhere;
}

.mahjong-replay-integrity strong {
  color: #24875f;
}

.mahjong-hand-panel {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(24, 32, 42, 0.12);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.mahjong-card.mahjong-3d-active .mahjong-hand-title,
.mahjong-card.mahjong-3d-active .mahjong-hand {
  display: none;
}

.mahjong-card.mahjong-3d-active .mahjong-hand-panel {
  min-height: 64px;
  align-content: center;
}

.mahjong-wait-container:empty {
  display: none;
}

.mahjong-wait-info {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(35, 136, 95, 0.24);
  border-radius: 9px;
  padding: 9px 11px;
  background:
    linear-gradient(135deg, rgba(231, 249, 241, 0.96), rgba(245, 250, 255, 0.96));
}

.mahjong-card.mahjong-3d-active .mahjong-wait-info,
.mahjong-card.mahjong-3d-active .mahjong-wait-hint {
  border-color: rgba(151, 226, 195, 0.26);
  background: rgba(11, 32, 29, 0.9);
  color: #f5faf8;
}

.mahjong-wait-info.is-furiten {
  border-color: rgba(197, 47, 55, 0.36);
  background:
    linear-gradient(135deg, rgba(255, 238, 238, 0.96), rgba(253, 247, 241, 0.96));
}

.mahjong-card.mahjong-3d-active .mahjong-wait-info.is-furiten {
  border-color: rgba(255, 120, 126, 0.42);
  background: rgba(53, 24, 27, 0.92);
}

.mahjong-wait-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.mahjong-wait-warning {
  border-radius: 999px;
  padding: 3px 8px;
  background: #c52f37;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

.mahjong-wait-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mahjong-wait-tile {
  display: grid;
  grid-template-columns: auto minmax(48px, auto);
  gap: 1px 6px;
  align-items: center;
  border-radius: 7px;
  padding: 4px 7px 4px 4px;
  background: rgba(255, 255, 255, 0.72);
}

.mahjong-card.mahjong-3d-active .mahjong-wait-tile {
  background: rgba(255, 255, 255, 0.1);
}

.mahjong-wait-tile .mahjong-wait-face {
  grid-row: 1 / span 2;
  width: 29px;
  height: 41px;
  border-radius: 4px;
}

/* TilePainter 이미지로 그린 안내용 패: 패 도안이 이미지에 포함되므로 별도 배경/테두리 없이 채운다. */
.mahjong-wait-face-img {
  display: inline-block;
  overflow: hidden;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.mahjong-wait-face-img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  border-radius: inherit;
}

.mahjong-wait-count {
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.mahjong-wait-tile small {
  color: #b02b33;
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}

.mahjong-card.mahjong-3d-active .mahjong-wait-tile small {
  color: #ff9ca2;
}

.mahjong-wait-tile.is-exhausted {
  opacity: 0.56;
}

.mahjong-wait-tile.is-furiten .riichi-tile {
  border-color: rgba(197, 47, 55, 0.62);
}

.mahjong-wait-hint {
  border: 1px dashed rgba(35, 92, 153, 0.24);
  border-radius: 8px;
  padding: 8px 10px;
  color: #657184;
  font-size: 12px;
  font-weight: 750;
}

.mahjong-hand {
  min-height: 70px;
  align-items: flex-end;
}

.mahjong-actions {
  min-height: 42px;
}

.mahjong-action-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.mahjong-next-hand-control {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(13, 29, 28, 0.86);
  color: #e7f3ef;
  font-size: 12px;
  font-weight: 750;
}

.mahjong-action-grid button {
  min-width: 92px;
}

.mahjong-combination-panel {
  display: grid;
  gap: 9px;
  border-top: 1px solid rgba(24, 32, 42, 0.1);
  padding-top: 10px;
}

.mahjong-combination-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.mahjong-combination-head strong {
  font-size: 13px;
}

.mahjong-combination-head button {
  min-height: 34px;
  padding: 0 10px;
}

.mahjong-combination-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mahjong-combination-option {
  display: flex;
  min-width: 0;
  min-height: 68px;
  gap: 3px;
  align-items: center;
  border: 1px solid rgba(35, 92, 153, 0.22);
  border-radius: 8px;
  padding: 7px 9px;
  background: #f5f8fc;
  cursor: pointer;
}

.mahjong-combination-option:hover {
  border-color: rgba(35, 92, 153, 0.48);
  background: #edf4fb;
}

.mahjong-combination-option:focus-visible {
  border-color: rgba(255, 209, 102, 0.82);
}


.mahjong-kan-choice-label {
  display: inline-flex;
  align-items: center;
  align-self: stretch;
  margin-right: 5px;
  border-right: 1px solid rgba(35, 92, 153, 0.18);
  padding-right: 8px;
  color: #27313a;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.mahjong-kan-combination-panel .mahjong-combination-option {
  gap: 4px;
}

.riichi-tile.reaction-called {
  border-color: rgba(197, 47, 55, 0.58);
  box-shadow:
    inset -2px -4px 0 rgba(91, 75, 48, 0.12),
    0 0 0 2px rgba(197, 47, 55, 0.12);
}

.riichi-tile.latest-discard {
  border-color: rgba(217, 149, 17, 0.88);
  box-shadow:
    inset -2px -4px 0 rgba(91, 75, 48, 0.12),
    0 0 0 2px rgba(217, 149, 17, 0.2),
    0 7px 16px rgba(146, 92, 12, 0.22);
}

.riichi-tile.latest-discard::before {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 3;
  border-radius: 999px;
  padding: 1px 3px;
  background: rgba(146, 64, 14, 0.92);
  color: #fff7ed;
  font-size: 7px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  content: "LAST";
  pointer-events: none;
}

.mahjong-riichi-toggle {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  gap: 8px;
  border-radius: 8px;
  padding: 0 12px;
  background: var(--line);
  font-weight: 850;
}

.mahjong-riichi-toggle input {
  width: 18px;
  min-height: 18px;
}

.mahjong-quality-toggle {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.4;
}

.mahjong-quality-toggle input {
  width: 18px;
  min-width: 18px;
  height: 18px;
  margin-top: 1px;
}

#mahjongMortalAdvancedAxes {
  --mortal-hard: oklch(0.61 0.27 27);
  --mortal-easy: oklch(0.68 0.25 145);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

#mahjongMortalAdvancedAxes[hidden] {
  display: none;
}

#mahjongMortalAdvancedAxes > label {
  display: inline-flex;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  border-radius: 8px;
  padding: 7px 9px;
  background: color-mix(in srgb, var(--accent) 6%, var(--panel));
}

#mahjongMortalAdvancedAxes > label input[type="range"] {
  display: none;
}

.mahjong-mortal-matrix-wrap {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: 17px minmax(0, 1fr);
  grid-template-rows: minmax(176px, 22vh) auto;
  gap: 6px 7px;
}

.mahjong-mortal-matrix {
  position: relative;
  display: grid;
  grid-column: 2;
  grid-row: 1;
  grid-template-columns: repeat(5, minmax(42px, 1fr));
  grid-template-rows: repeat(5, minmax(34px, 1fr));
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 82%, var(--text));
  border-radius: 5px;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

.mahjong-mortal-cell {
  --cell-color: color-mix(in oklch, var(--mortal-easy) var(--difficulty-ratio), var(--mortal-hard));
  display: grid;
  grid-column: var(--matrix-column);
  grid-row: var(--matrix-row);
  min-width: 0;
  border-right: 1px solid color-mix(in srgb, var(--panel) 62%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--panel) 62%, transparent);
  place-items: center;
  background: color-mix(in srgb, var(--cell-color) 32%, var(--panel));
  color: color-mix(in srgb, var(--text) 72%, transparent);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
}

.mahjong-mortal-cell small {
  display: block;
  margin-top: 3px;
  font-size: 9px;
  font-weight: 750;
}

.mahjong-mortal-selection {
  --selection-x: 0px;
  --selection-y: 0px;
  --selection-width: 20%;
  --selection-height: 100%;
  --selection-color: color-mix(in oklch, var(--mortal-easy) var(--difficulty-ratio), var(--mortal-hard));
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  width: calc(var(--selection-width) - 6px);
  height: calc(var(--selection-height) - 6px);
  border: 2px solid color-mix(in srgb, white 78%, var(--selection-color));
  border-radius: 11px;
  padding: 0;
  background: var(--selection-color);
  box-shadow: 0 4px 13px color-mix(in srgb, var(--selection-color) 48%, transparent), inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  transform: translate(calc(var(--selection-x) + 3px), calc(var(--selection-y) + 3px));
  transition: transform 150ms cubic-bezier(.2, .8, .2, 1), width 150ms ease, height 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
  pointer-events: none;
}

.mahjong-mortal-selection:focus-visible {
  outline: 3px solid var(--text);
  outline-offset: -1px;
}

.mahjong-mortal-matrix.is-disabled {
  cursor: not-allowed;
  filter: grayscale(.45);
  opacity: .58;
}

.mahjong-mortal-y-label,
.mahjong-mortal-x-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.mahjong-mortal-y-label {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.mahjong-mortal-x-label {
  grid-column: 2;
  grid-row: 2;
  justify-self: center;
}

@media (prefers-reduced-motion: reduce) {
  .mahjong-mortal-selection {
    transition: none;
  }
}

.riichi-tile {
  position: relative;
  display: inline-grid;
  width: 38px;
  height: 54px;
  overflow: hidden;
  place-items: center;
  border: 1px solid rgba(24, 32, 42, 0.18);
  border-radius: 6px;
  padding: 0;
  background:
    linear-gradient(180deg, #ffffff 0%, #fbfaf3 62%, #e7dfcc 100%);
  color: #1f2937;
  box-shadow:
    inset -2px -4px 0 rgba(91, 75, 48, 0.12),
    0 3px 7px rgba(23, 32, 43, 0.12);
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.mahjong-tile-face-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  border-radius: inherit;
  pointer-events: none;
}

.riichi-tile.masked-tile {
  border-color: rgba(92, 78, 48, 0.62);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.45) 0 18%, transparent 18% 31%, rgba(255, 255, 255, 0.28) 31% 44%, transparent 44% 100%),
    linear-gradient(180deg, #d8d2c2 0%, #a99f8a 100%);
  color: #453923;
  box-shadow:
    inset -2px -4px 0 rgba(62, 46, 24, 0.18),
    0 3px 8px rgba(34, 28, 18, 0.16);
}

.mahjong-masked-face {
  display: grid;
  width: 72%;
  height: 72%;
  place-items: center;
  border: 1px solid rgba(69, 57, 35, 0.3);
  border-radius: 999px;
  background: rgba(255, 248, 220, 0.58);
  font-size: 20px;
  font-weight: 900;
}

button.riichi-tile {
  cursor: pointer;
}

button.riichi-tile:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.riichi-tile.selectable {
  border-color: rgba(35, 136, 95, 0.55);
  box-shadow:
    inset -2px -4px 0 rgba(91, 75, 48, 0.12),
    0 0 0 3px rgba(35, 136, 95, 0.13);
}

.riichi-tile.exchange-target {
  border-color: rgba(240, 199, 100, 0.86);
  box-shadow:
    inset -2px -4px 0 rgba(91, 75, 48, 0.12),
    0 0 0 3px rgba(240, 199, 100, 0.24),
    0 8px 16px rgba(92, 66, 14, 0.2);
  transform: translateY(-3px);
}

.riichi-tile.dora-locked-tile:not(.joker-tile),
.riichi-tile.discard-restricted:not(.joker-tile) {
  filter: brightness(0.84);
  opacity: 1;
}

.riichi-tile.joker-tile {
  border-color: rgba(181, 196, 216, 0.65);
  box-shadow:
    inset -2px -4px 0 rgba(91, 75, 48, 0.12),
    0 0 9px rgba(203, 223, 255, 0.5);
}

.riichi-tile.joker-tile:not(.reverse-joker-tile):not(.masked-tile) .mahjong-tile-face-img {
  animation: mahjong-joker-shimmer 8s linear infinite;
}

.riichi-tile.reverse-joker-tile {
  border-color: #929b96;
  box-shadow: inset -2px -4px 0 rgba(43, 51, 47, 0.18), 0 3px 6px rgba(0, 0, 0, 0.15);
}

.mahjong-special-blank {
  width: 100%; height: 100%; border-radius: inherit;
  background: linear-gradient(135deg, #fffaf3, #e4e8fb);
}

.reverse-joker-tile .mahjong-special-blank {
  background: linear-gradient(135deg, #d6d6cf, #909894);
}

@keyframes mahjong-joker-shimmer {
  0% { filter: hue-rotate(0deg) saturate(1.3) brightness(1.04); }
  50% { filter: hue-rotate(180deg) saturate(1.3) brightness(1.12); }
  100% { filter: hue-rotate(360deg) saturate(1.3) brightness(1.04); }
}

@media (prefers-reduced-motion: reduce) {
  .riichi-tile.joker-tile .mahjong-tile-face-img { animation: none; }
}

.riichi-tile.drawn {
  margin-left: 8px;
}

.mahjong-man-face {
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-rows: 1fr auto;
  place-items: center;
  padding: 4px 2px 3px;
  font-family: "Yu Mincho", "MS Mincho", serif;
}

.mahjong-man-face b {
  color: #171b20;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.mahjong-man-face i {
  color: #c5272d;
  font-size: 13px;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
}

.mahjong-man-face.red b {
  color: #c5272d;
}

.mahjong-pin-face {
  display: grid;
  width: 78%;
  height: 78%;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
}

.mahjong-pin-dot {
  display: block;
  width: 8px;
  height: 8px;
  border: 2px solid currentColor;
  border-radius: 50%;
  background:
    radial-gradient(circle, currentColor 0 25%, transparent 28% 46%, currentColor 49% 61%, transparent 64%);
}

.mahjong-pin-dot.blue {
  color: #1f5491;
}

.mahjong-pin-dot.red {
  color: #c52f37;
}

.mahjong-sou-face {
  display: grid;
  width: 76%;
  height: 82%;
  grid-template-columns: repeat(3, 1fr);
  place-items: center;
  align-content: center;
  gap: 1px;
}

.mahjong-sou-stick {
  position: relative;
  display: block;
  width: 5px;
  height: 14px;
  border-radius: 3px;
  background: currentColor;
  color: #247047;
  box-shadow: inset 0 -5px 0 rgba(255, 255, 255, 0.28);
}

.mahjong-sou-stick::after {
  content: "";
  position: absolute;
  top: 5px;
  left: -2px;
  width: 9px;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(-18deg);
}

.mahjong-sou-stick.red {
  color: #c52f37;
}

.mahjong-sou-one {
  position: relative;
  display: block;
  width: 28px;
  height: 39px;
}

.mahjong-sou-one i {
  position: absolute;
  bottom: 5px;
  left: 11px;
  width: 6px;
  height: 25px;
  border-radius: 80% 20% 70% 30%;
  background: #247047;
  transform-origin: bottom center;
}

.mahjong-sou-one i:nth-child(1) {
  transform: rotate(-38deg);
}

.mahjong-sou-one i:nth-child(2) {
  background: #1e5c91;
}

.mahjong-sou-one i:nth-child(3) {
  transform: rotate(38deg);
}

.mahjong-sou-one b {
  position: absolute;
  top: 9px;
  left: 9px;
  width: 11px;
  height: 11px;
  border: 3px solid #c52f37;
  border-radius: 50%;
}

.mahjong-honor-face {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  font-family: "Yu Mincho", "MS Mincho", serif;
  font-size: 24px;
  font-weight: 800;
}

.mahjong-honor-face.black {
  color: #171b20;
}

.mahjong-honor-face.green {
  color: #25834f;
}

.mahjong-honor-face.red {
  color: #c5272d;
}

.mahjong-honor-face.white::after {
  content: "";
  width: 22px;
  height: 31px;
  border: 2px solid #5d83a5;
  border-radius: 2px;
  box-shadow: inset 0 0 0 2px rgba(93, 131, 165, 0.1);
}

.riichi-tile.back {
  border-color: rgba(20, 33, 48, 0.18);
  background:
    linear-gradient(145deg, #2d6f77, #174a55),
    #1d5b66;
  color: rgba(255, 255, 255, 0.22);
  box-shadow:
    inset -3px -5px 0 rgba(0, 0, 0, 0.16),
    0 3px 7px rgba(23, 32, 43, 0.1);
}

.mahjong-tile-back-mark {
  width: 70%;
  height: 72%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 3px;
  background:
    repeating-linear-gradient(45deg, transparent 0 4px, rgba(255, 255, 255, 0.08) 4px 5px),
    repeating-linear-gradient(-45deg, transparent 0 4px, rgba(255, 255, 255, 0.06) 4px 5px);
}

.riichi-tile.called {
  transform: rotate(90deg);
}

.riichi-tile.called-away {
  opacity: 0.45;
}

.riichi-tile.riichi-discard::after {
  content: "";
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #cf3e3a;
}

.yut-card {
  gap: 14px;
}

.yut-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.yut-play {
  display: grid;
  gap: 12px;
}

.yut-status-strip {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  align-items: center;
  gap: 8px;
}

.yut-status-strip .music-status,
.yut-status-strip .result-line,
.yut-status-strip .play-action-row,
.yut-status-strip .yut-moves {
  min-height: 40px;
  padding: 8px 10px;
}

.yut-tabletop {
  display: block;
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(82, 72, 55, 0.18);
  border-radius: 8px;
  padding: 12px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.52), rgba(233, 241, 238, 0.72)),
    #edf3ef;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.yut-board-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "board";
  gap: 0;
  align-items: stretch;
  min-width: 0;
  min-height: 0;
}

.yut-stick-tray {
  position: relative;
  display: grid;
  min-height: 132px;
  grid-template-columns: repeat(4, minmax(34px, 1fr));
  align-items: center;
  gap: 8px;
  overflow: hidden;
  border: 1px solid rgba(82, 72, 55, 0.18);
  border-radius: 8px;
  padding: 18px 14px;
  background:
    linear-gradient(145deg, rgba(73, 106, 91, 0.18), rgba(42, 77, 92, 0.2)),
    #f7f5ef;
}

.yut-throw-3d {
  position: relative;
  display: grid;
  aspect-ratio: auto;
  min-height: 0;
  gap: 8px;
  align-content: center;
}

.yut-throw-dock {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: grid;
  width: min(34%, 310px);
  min-width: 0;
  min-height: 0;
  align-content: end;
  padding: 12px;
  pointer-events: auto;
}

.yut-finish-target {
  position: absolute;
  right: 2.5%;
  top: 50%;
  z-index: 9;
  min-width: 68px;
  min-height: 40px;
  border: 2px solid #f4b942;
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(24, 35, 42, 0.9);
  color: #ffd76a;
  font-weight: 950;
  box-shadow: 0 0 0 5px rgba(255, 200, 87, 0.18), 0 0 24px rgba(255, 200, 87, 0.5);
  cursor: pointer;
  transform: translateY(-50%);
  animation: yutFinishPulse 760ms ease-in-out infinite alternate;
}

.yut-finish-chooser {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  z-index: 12;
  display: grid;
  gap: 8px;
  border: 1px solid color-mix(in srgb, var(--warning) 48%, var(--line));
  border-radius: 12px;
  padding: 12px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.yut-finish-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@keyframes yutFinishPulse {
  from { filter: brightness(0.94); transform: translateY(-50%) scale(0.97); }
  to { filter: brightness(1.12); transform: translateY(-50%) scale(1.04); }
}

@media (prefers-reduced-motion: reduce) {
  .yut-finish-target {
    animation: none;
  }
}

.yut-panel-clock {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  min-width: 48px;
  border-radius: 999px;
  padding: 5px 11px;
  background: rgba(23, 33, 46, 0.9);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  text-align: center;
  box-shadow: 0 8px 18px rgba(16, 25, 34, 0.18);
}

.yut-throw-dock.can-throw .yut-throw-label {
  cursor: pointer;
  outline: 3px solid rgba(66, 211, 140, 0.34);
}

.yut-throw-label {
  justify-self: center;
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--text);
  color: var(--surface);
  font-size: 13px;
}

.yut-throw-history {
  display: grid;
  gap: 5px;
  justify-items: center;
  min-height: 42px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.yut-throw-history span {
  max-width: 100%;
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(15, 25, 31, 0.78);
  color: rgba(245, 249, 247, 0.84);
}

.yut-throw-history strong {
  color: #fff0ba;
}

.yut-stick-tray strong {
  position: absolute;
  right: 12px;
  bottom: 10px;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--text);
  color: var(--surface);
  font-size: 13px;
}

.yut-stick {
  position: relative;
  height: 102px;
  border-radius: 999px 999px 18px 18px;
  background: linear-gradient(90deg, #d6b27a, #f5d99c 42%, #9f7548);
  box-shadow:
    0 12px 20px rgba(52, 42, 31, 0.18),
    inset -8px 0 10px rgba(80, 49, 24, 0.18),
    inset 8px 0 10px rgba(255, 255, 255, 0.28);
  transform: translateY(var(--offset, 0)) rotate(var(--angle, 0deg));
  transition: transform 420ms cubic-bezier(0.18, 0.82, 0.28, 1);
  animation: yutStickDrop 820ms cubic-bezier(0.16, 0.84, 0.22, 1) both;
  animation-delay: var(--delay, 0ms);
}

.yut-stick.back {
  background: linear-gradient(90deg, #5e4430, #8c6844 44%, #3a281c);
}

.yut-throw-dock[data-yut-stick="obsidian"] .yut-stick {
  background: linear-gradient(90deg, #302931, #191519 44%, #080708);
  box-shadow:
    0 12px 20px rgba(15, 18, 24, 0.24),
    inset -8px 0 10px rgba(0, 0, 0, 0.26),
    inset 8px 0 10px rgba(216, 160, 68, 0.12);
}

.yut-throw-dock[data-yut-stick="obsidian"] .yut-stick.back {
  background: linear-gradient(90deg, #1c181d, #302931 44%, #090708);
}

.yut-throw-dock[data-yut-stick="dancheong"] .yut-stick {
  background: linear-gradient(90deg, #1b5a45, #2f8f6d 44%, #14402f);
  box-shadow:
    0 12px 20px rgba(15, 24, 20, 0.24),
    inset -8px 0 10px rgba(10, 30, 22, 0.3),
    inset 8px 0 10px rgba(138, 47, 43, 0.2);
}

.yut-throw-dock[data-yut-stick="dancheong"] .yut-stick.back {
  background: linear-gradient(90deg, #6e2823, #8a2f2b 44%, #4c1a17);
}

.yut-stick.marked::after {
  content: "";
  position: absolute;
  right: 50%;
  bottom: 12px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #ba2f38;
  transform: translateX(50%);
}

.yut-throw-dock[data-yut-stick="obsidian"] .yut-stick.marked::after {
  background: #d8a044;
}

.yut-throw-dock[data-yut-stick="dancheong"] .yut-stick.marked::after {
  background: #2f5fae;
}

.yut-stick.fallen {
  opacity: 0.45;
  transform: translateY(34px) rotate(78deg);
  animation: none;
}

.yut-stick.placeholder {
  opacity: 0.32;
  animation: none;
}

@keyframes yutStickDrop {
  0% {
    opacity: 0.25;
    transform: translate3d(0, var(--start-y, -86px), 0) rotate(calc(var(--angle, 0deg) + var(--spin, 380deg)));
  }
  62% {
    opacity: 1;
    transform: translate3d(0, 12px, 0) rotate(calc(var(--angle, 0deg) - 26deg));
  }
  82% {
    transform: translate3d(0, -5px, 0) rotate(calc(var(--angle, 0deg) + 8deg));
  }
  100% {
    opacity: 1;
    transform: translateY(var(--offset, 0)) rotate(var(--angle, 0deg));
  }
}

.yut-board-wrap {
  grid-area: board;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  overflow: hidden;
}

.yut-board-perspective {
  position: relative;
  width: auto;
  height: 100%;
  max-width: min(100%, 1100px);
  max-height: 100%;
  min-width: 0;
  margin: 0 auto;
  aspect-ratio: 16 / 10;
  perspective: 1200px;
  perspective-origin: 50% 18%;
}

.yut-board {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  transform: none;
  transform-origin: 50% 62%;
  transform-style: preserve-3d;
  border-radius: 8px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.yut-board-hud {
  position: absolute;
  top: 10px;
  left: 38%;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  max-width: calc(100% - 28px);
  border: 1px solid rgba(31, 43, 54, 0.12);
  border-radius: 999px;
  padding: 7px 10px 7px 12px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 24px rgba(15, 24, 32, 0.13);
  color: #1f2b36;
  font-size: 12px;
  font-weight: 900;
  pointer-events: none;
  transform: translateX(-50%);
}

.yut-board-turn {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.yut-board-clock {
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(23, 33, 46, 0.92);
  color: #fff;
  font-size: 12px;
  line-height: 1;
}

.yut-turn-cube {
  --piece-size: 18px;
  --piece-depth: 12px;
  flex: 0 0 auto;
  transform: rotateX(58deg) rotateZ(-28deg);
}

.yut-board-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

.yut-board.three-ready .yut-track-svg,
.yut-board.three-ready .yut-node {
  opacity: 0;
}

.yut-board.three-ready .yut-node {
  pointer-events: none;
}

.yut-track-svg {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: visible;
  pointer-events: none;
  transform: translateZ(8px);
}

.yut-track-svg marker path {
  fill: var(--positive);
}

.yut-track-line {
  fill: none;
  stroke: #237fca;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.05;
}

.yut-candidate-line {
  fill: none;
  marker-end: url(#yutArrowHead);
  stroke: var(--positive);
  stroke-dasharray: 3 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
  animation: yutPathPulse 760ms ease-in-out infinite alternate;
}

.yut-board-wrap[data-yut-board="midnight"] .yut-board {
  background:
    radial-gradient(circle at 50% 50%, rgba(120, 220, 232, 0.1), transparent 55%),
    #172033;
}

.yut-board-wrap[data-yut-board="midnight"] .yut-track-line,
.yut-board-wrap[data-yut-board="midnight"] .yut-candidate-line {
  stroke: rgba(120, 220, 232, 0.78);
}

.yut-board-wrap[data-yut-board="midnight"] .yut-node {
  border-color: rgba(120, 220, 232, 0.5);
  background: rgba(23, 32, 51, 0.92);
  color: #d8fbff;
}

.yut-board-wrap[data-yut-board="hanji"] .yut-board {
  background:
    radial-gradient(circle at 32% 24%, rgba(164, 142, 106, 0.12), transparent 46%),
    radial-gradient(circle at 70% 72%, rgba(164, 142, 106, 0.1), transparent 42%),
    #f6f1e3;
}

.yut-board-wrap[data-yut-board="hanji"] .yut-track-line,
.yut-board-wrap[data-yut-board="hanji"] .yut-candidate-line {
  stroke: rgba(92, 74, 51, 0.82);
}

.yut-board-wrap[data-yut-board="hanji"] .yut-node {
  border-color: rgba(138, 107, 74, 0.5);
  background: rgba(227, 215, 187, 0.94);
  color: #4c3b26;
}

.yut-node {
  position: absolute;
  left: var(--x);
  top: var(--y);
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 999px;
  border: 0;
  background: #9dccf0;
  color: var(--muted);
  cursor: default;
  transform: translate(-50%, -50%) translateZ(12px);
  z-index: 3;
  box-shadow:
    0 4px 0 #64a6dc,
    0 8px 12px rgba(30, 42, 48, 0.12);
}

.yut-node.key-node {
  width: 58px;
  height: 58px;
  background: #ff646b;
  color: #fff;
  font-weight: 900;
  box-shadow:
    0 5px 0 #cf4950,
    0 10px 16px rgba(183, 67, 75, 0.22);
}

/* M20 = 정통 윷놀이의 시작이자 도착(참먹이) 코너 — 한 칸으로 통일 표시. */
.yut-node.home-node {
  background: #f5bd48;
  color: #3f2b00;
  box-shadow: 0 5px 0 #c88722, 0 10px 18px rgba(200, 135, 34, 0.28);
}

.yut-node.destination-node {
  border-color: rgba(35, 136, 95, 0.78);
  cursor: pointer;
  outline: 4px solid rgba(35, 136, 95, 0.18);
}

.yut-node.path-node {
  background: #b9e5ca;
}

.yut-node.path-active {
  transform: translate(-50%, -50%) translateZ(30px) scale(1.08);
}

.yut-node span {
  display: none;
  font-size: 10px;
  font-weight: 800;
}

.yut-node-pieces {
  position: absolute;
  inset: 0;
  display: block;
  transform-style: preserve-3d;
  pointer-events: none;
}

.yut-piece {
  --piece-size: 25px;
  --piece-depth: 16px;
  display: block;
  position: relative;
  width: var(--piece-size);
  height: var(--piece-size);
  border: 0;
  padding: 0;
  cursor: default;
  background: transparent;
  color: transparent;
  transform: translateZ(8px);
  transform-style: preserve-3d;
}

.piece-face {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 4px;
  pointer-events: none;
}

.piece-top {
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.32), transparent 34%),
    linear-gradient(145deg, var(--piece-color, #246cba), color-mix(in srgb, var(--piece-color, #246cba) 72%, #000));
  box-shadow:
    0 9px 10px rgba(15, 24, 32, 0.24);
  transform: translateZ(var(--piece-depth));
}

.piece-front {
  top: 100%;
  left: 0;
  width: var(--piece-size);
  height: var(--piece-depth);
  background: color-mix(in srgb, var(--piece-color, #246cba) 66%, #000);
  transform: rotateX(-90deg);
  transform-origin: top;
}

.piece-right {
  top: 0;
  left: 100%;
  width: var(--piece-depth);
  height: var(--piece-size);
  background: color-mix(in srgb, var(--piece-color, #246cba) 54%, #000);
  transform: rotateY(90deg);
  transform-origin: left top;
}

.piece-left {
  top: 0;
  right: 100%;
  width: var(--piece-depth);
  height: var(--piece-size);
  background: color-mix(in srgb, var(--piece-color, #246cba) 62%, #000);
  transform: rotateY(-90deg);
  transform-origin: right top;
}

.yut-node-pieces .yut-piece {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, calc(-50% - var(--stack-y, 0px))) translateZ(var(--stack-z, 6px));
  pointer-events: none;
}

.yut-piece.p0,
.yut-player.p0 {
  --piece-color: #246cba;
}

.yut-piece.p1,
.yut-player.p1 {
  --piece-color: #be3c4a;
}

.yut-piece.p2,
.yut-player.p2 {
  --piece-color: #2f8a5d;
}

.yut-piece.p3,
.yut-player.p3 {
  --piece-color: #8a5ab8;
}

.yut-piece.team0,
.yut-player.team0 {
  --piece-color: #246cba;
}

.yut-piece.team1,
.yut-player.team1 {
  --piece-color: #be3c4a;
}

.yut-board-wrap[data-yut-piece="flower"] .yut-piece,
.yut-reserve-wrap[data-yut-piece="flower"] .yut-piece {
  box-shadow:
    inset 0 -10px rgba(0, 0, 0, 0.16),
    inset 0 0 0 3px rgba(255, 255, 255, 0.18),
    0 0 0 2px rgba(232, 107, 154, 0.22);
}

.yut-board-wrap[data-yut-piece="flower"] .yut-piece .piece-top,
.yut-reserve-wrap[data-yut-piece="flower"] .yut-piece .piece-top {
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.52) 0 18%, transparent 19%),
    var(--piece-color);
}

.yut-board-wrap[data-yut-piece="pearl"] .yut-piece,
.yut-reserve-wrap[data-yut-piece="pearl"] .yut-piece {
  box-shadow:
    inset 0 -10px rgba(0, 0, 0, 0.14),
    inset 0 0 0 3px rgba(255, 255, 255, 0.3),
    0 0 0 2px rgba(143, 184, 216, 0.32);
}

.yut-board-wrap[data-yut-piece="pearl"] .yut-piece .piece-top,
.yut-reserve-wrap[data-yut-piece="pearl"] .yut-piece .piece-top {
  background:
    linear-gradient(118deg, rgba(233, 240, 246, 0.55) 8%, rgba(197, 226, 244, 0.4) 34%, rgba(236, 214, 238, 0.38) 58%, rgba(206, 240, 224, 0.4) 82%),
    var(--piece-color);
}

.yut-piece.selected {
  outline: 4px solid rgba(16, 112, 71, 0.96);
  outline-offset: 4px;
  box-shadow:
    0 0 0 7px rgba(24, 184, 117, 0.26),
    0 8px 16px rgba(15, 24, 32, 0.32);
}

.yut-piece.selected .piece-top {
  box-shadow:
    0 0 0 5px rgba(16, 112, 71, 0.72),
    0 10px 14px rgba(15, 24, 32, 0.28);
}

.yut-piece.ghost {
  opacity: 0.92;
  animation: yutPieceHop 190ms ease-out both;
}

.yut-reserve-wrap {
  grid-area: reserve;
  min-width: 0;
  align-self: stretch;
}

.yut-reserve {
  display: grid;
  height: 100%;
  align-content: center;
  gap: 8px;
}

.yut-reserve-player {
  display: grid;
  gap: 7px;
  border-left: 4px solid var(--piece-color, #246cba);
  border-radius: 8px;
  padding: 8px 6px 8px 9px;
  background: rgba(255, 255, 255, 0.42);
}

.yut-reserve-player strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.yut-reserve-pieces {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
}

.reserve-piece {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--piece-color, #246cba);
  cursor: pointer;
  opacity: 0.82;
  transform: none;
}

.reserve-piece .piece-face {
  display: none;
}

.yut-finish-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.yut-special-targets {
  display: grid;
  gap: 6px;
}

.yut-player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.yut-player {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(37, 92, 153, 0.16);
  border-left: 5px solid var(--piece-color, #246cba);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface);
}

.yut-player-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.yut-player-head span {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.yut-player-head em {
  border-radius: 999px;
  padding: 2px 7px;
  background: #e7eef7;
  color: var(--blue);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.yut-piece-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.yut-piece-summary span,
.yut-player p {
  border-radius: 8px;
  padding: 7px 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
}

.yut-piece-summary strong {
  color: var(--ink);
}

.yut-player p {
  margin: 0;
}

.yut-moves {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.yut-moves .yut-move {
  flex: 1 1 180px;
}

@keyframes yutPathPulse {
  from {
    opacity: 0.55;
  }
  to {
    opacity: 1;
  }
}

@keyframes yutPieceHop {
  0% {
    transform: translateZ(8px) scale(0.92);
  }
  100% {
    transform: translateZ(28px) scale(1.08);
  }
}

.yacht-scoreboard {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.yacht-score-head,
.yacht-score-row {
  display: grid;
  grid-template-columns: minmax(130px, 1.1fr) repeat(4, minmax(72px, 1fr));
  gap: 6px;
  align-items: center;
}

.yacht-score-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.yacht-score-row > span,
.yacht-score-row > strong,
.score-pick {
  display: grid;
  min-height: 34px;
  place-items: center;
  border-radius: 8px;
  padding: 5px 7px;
  background: var(--soft);
  font-size: 13px;
}

.yacht-score-row > span:first-child {
  justify-content: start;
  font-weight: 800;
}

.score-pick {
  border: 1px solid rgba(37, 92, 153, 0.3);
  color: var(--on-accent);
  background: var(--blue);
  font-weight: 800;
}

.score-preview {
  /* Preview highlight was a hardcoded light-blue island that stayed bright in
     dark mode; track the accent tint against the theme surface instead. */
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--surface)) !important;
  font-weight: 900;
}

.pending-score {
  color: var(--muted);
  font-weight: 800;
}

.current-cell {
  outline: 2px solid rgba(66, 165, 245, 0.35);
}

.total-row > span,
.total-row > strong {
  /* Was a hardcoded light fill; in dark mode the inherited (light) text landed
     on it and the total vanished. Keep the tinted emphasis but theme-aware. */
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-soft));
  font-weight: 900;
}

.slot-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
}

.mahjong-tile {
  display: flex;
  width: 58px;
  height: 88px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  place-items: center;
  border-radius: 8px;
  border: 1px solid #d4d7cf;
  background: linear-gradient(145deg, #fffdf5, #e6e0d1);
  box-shadow: 7px 10px 14px rgba(20, 35, 55, 0.16), inset -5px -7px 0 rgba(118, 112, 92, 0.12);
  font-family: "Noto Serif CJK KR", "Batang", "PMingLiU", serif;
  font-weight: 900;
}

.tile-number {
  color: #111820;
  font-size: 30px;
  line-height: 1;
}

.tile-man {
  color: #b62828;
  font-size: 26px;
  line-height: 1;
}

.tile-hatsu {
  color: #168044;
  font-size: 44px;
  line-height: 1;
}

.tile-unknown {
  color: var(--muted);
  font-family: inherit;
  font-size: 28px;
}

.word-status {
  display: grid;
  gap: 8px;
  max-width: 640px;
}

.word-player-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.word-player {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.word-player.current {
  border-color: rgba(37, 92, 153, 0.55);
  background: #eaf2fc;
  color: var(--blue);
}

.word-player.winner {
  border-color: rgba(31, 95, 66, 0.45);
  background: color-mix(in srgb, var(--positive) 10%, var(--surface));
  color: var(--positive-text);
}

.word-player.loser {
  border-color: rgba(170, 82, 82, 0.42);
  background: #faecec;
  color: #7e2d2d;
}

.current-word {
  display: inline-flex;
  align-items: center;
  min-height: 60px;
  width: fit-content;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--text);
  color: var(--surface);
  font-size: 28px;
  font-weight: 850;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .game-list {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .bottom-grid,
  .battle-layout,
  .gamble-grid,
  .gamble-panels,
  .gamble-mode-layout,
  .yacht-layout,
  .indian-player-grid,
  .indian-duel-row,
  .yut-layout,
  .yut-tabletop,
  .stop-vote-box,
  .room-grid {
    grid-template-columns: 1fr;
  }

  .yut-tabletop {
    display: block;
  }

  .yut-board-stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "board";
  }

  .yut-board-perspective {
    width: 100%;
    height: auto;
  }

  .yut-throw-dock {
    width: min(40%, 220px);
  }

  .yut-status-strip {
    grid-template-columns: 1fr;
  }

  .mahjong-status-strip,
  .mahjong-player-grid {
    grid-template-columns: 1fr;
  }

  .mahjong-final-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .mahjong-final-row em,
  .mahjong-final-row small {
    grid-column: 1 / -1;
    justify-self: stretch;
  }

  .drawing-status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .drawing-status-strip .drawing-word-pill {
    grid-column: 1 / -1;
  }

  .drawing-play-layout {
    grid-template-columns: 1fr;
  }

  .drawing-chat-panel {
    height: clamp(260px, 42vh, 360px);
    max-height: 360px;
    min-height: 260px;
  }

  .yacht-score-wrap {
    overflow-x: auto;
  }

  .yacht-scoreboard {
    min-width: 620px;
  }

  .yut-board-perspective {
    max-width: 620px;
    margin: 0 auto;
  }

  .yut-board {
    transform: none;
  }

  .room-actions,
  .room-summary {
    justify-content: flex-start;
  }

  .indian-status-row {
    grid-template-columns: 1fr 70px;
  }

  .indian-status-row #indianPot {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  .sidebar,
  .stage {
    padding: 16px;
  }

  .stage-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .room-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .surface {
    padding: 14px;
  }

  .octave-row {
    grid-template-columns: 1fr;
  }

  .octave-label {
    min-height: 40px;
  }

  .white-keys {
    grid-template-columns: repeat(7, minmax(30px, 1fr));
    height: 96px;
  }

  .piano-octave {
    min-height: 96px;
  }

  .black-key {
    width: min(10%, 38px);
    height: 58px;
  }

  .slot-row {
    justify-content: center;
    gap: 8px;
  }

  .yacht-dice-tray {
    min-height: 0;
  }

  .yacht-board {
    min-height: 0;
  }

  .yacht-board-lane {
    right: 18px;
    left: 18px;
  }

  .yacht-save-lane {
    top: 20px;
    height: 66px;
  }

  .yacht-roll-lane {
    top: 98px;
    bottom: 20px;
  }

  .yacht-dice-row {
    right: 26px;
    bottom: 34px;
    left: 26px;
    grid-template-columns: repeat(5, minmax(38px, 1fr));
    gap: 7px;
  }

  .yacht-die {
    height: 72px;
  }

  .yacht-die.held {
    transform: translateY(-79px);
  }

  .yacht-die-body {
    width: min(58px, 100%);
  }

  .mahjong-tile {
    width: 48px;
    height: 74px;
  }

  .tile-number {
    font-size: 25px;
  }

  .tile-man {
    font-size: 22px;
  }

  .tile-hatsu {
    font-size: 36px;
  }

  .candidate-grid {
    grid-template-columns: 42px minmax(70px, 1fr) minmax(64px, 0.8fr) minmax(64px, 0.8fr);
  }

  .candidate-grid span:nth-child(5) {
    display: none;
  }
}

/* 2026 UI refresh — 팔레트 토큰은 파일 선두의 정본 :root로 통합됨 */

.app-shell {
  display: grid;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  grid-template-columns: 300px minmax(0, 1fr);
  grid-template-rows: 64px minmax(0, 1fr);
  grid-template-areas:
    "top top"
    "nav main";
}

.topbar {
  grid-area: top;
  display: grid;
  grid-template-columns: 300px minmax(140px, 1fr) minmax(280px, 390px) auto;
  grid-template-areas: "brand stage music actions";
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
}

.global-music-panel {
  grid-area: music;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 9px;
  width: min(390px, 100%);
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface-strong) 86%, transparent);
  box-shadow: 0 7px 22px rgba(30, 23, 20, 0.1);
}

.global-music-panel[hidden] { display: none; }

.global-music-copy {
  display: grid;
  flex: 1;
  min-width: 0;
  line-height: 1.15;
}

.global-music-copy strong,
.global-music-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.global-music-copy strong { font-size: 0.82rem; }
.global-music-copy small { color: var(--muted); font-size: 0.68rem; }

.global-music-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
}

.global-music-volume-control {
  position: relative;
  display: grid;
  flex: 0 0 auto;
}

.global-music-volume-popup {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  width: 132px;
  padding: 12px 10px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-strong) 96%, transparent);
  box-shadow: 0 12px 30px rgba(30, 23, 20, 0.2);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-5px);
  transition: opacity 140ms ease, transform 140ms ease, visibility 140ms;
}

.global-music-volume-popup::before {
  content: "";
  position: absolute;
  right: 10px;
  bottom: 100%;
  width: 12px;
  height: 12px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: var(--surface-strong);
  transform: translateY(6px) rotate(45deg);
}

.global-music-volume-control.is-open .global-music-volume-popup {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

@media (hover: hover) and (pointer: fine) {
  .global-music-volume-control:focus-within .global-music-volume-popup,
  .global-music-volume-control:hover .global-music-volume-popup {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }
}

.global-music-volume { width: 108px; }

.brand {
  grid-area: brand;
  min-width: 0;
  padding: 0 20px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 6px;
  border-radius: 8px;
  background: var(--text);
  box-shadow: none;
  place-items: stretch;
}

.brand-mark span {
  display: block;
  border-radius: 4px;
}

.brand-mark span:nth-child(1) {
  background: #42a5f5;
}

.brand-mark span:nth-child(2) {
  background: #ef6f5e;
}

.brand-mark span:nth-child(3) {
  background: #41b881;
}

.brand-mark span:nth-child(4) {
  background: #f0b541;
}

.brand h1 {
  font-size: 18px;
}

.stage-title {
  grid-area: stage;
  min-width: 0;
  padding: 0 18px;
}

.stage-title h2 {
  margin: 3px 0 0;
  overflow: hidden;
  font-size: 23px;
  line-height: 1.12;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 20px;
}

.top-stat {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.avatar {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: var(--blue);
  color: var(--on-accent);
  font-weight: 900;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar {
  grid-area: nav;
  gap: 18px;
  min-height: 0;
  height: calc(100vh - 64px);
  height: calc(100dvh - 64px);
  overflow: auto;
  padding: 18px;
}

.profile-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
}

.profile-panel > div {
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

.profile-head {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.profile-head strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-head .avatar {
  width: 42px;
  height: 42px;
}

.profile-head .auth-status {
  min-height: 0;
  margin: 3px 0 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

.profile-edit-field {
  display: grid;
  gap: 8px;
}

.language-field select {
  min-height: 38px;
}

.profile-edit-field[hidden] {
  display: none;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.profile-stats > div {
  min-height: 58px;
  border: 0;
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--soft);
}

.metric-cycle {
  transition: opacity 180ms ease, transform 180ms ease;
}

.metric-cycle.is-switching {
  opacity: 0.2;
  transform: translateY(2px);
}

.profile-stats strong {
  display: block;
  margin-top: 2px;
  font-size: 21px;
}

.game-list {
  display: grid;
  gap: 18px;
}

.section-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.game-section-list {
  display: grid;
  gap: 8px;
}

.game-tab {
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 18px;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  border-color: transparent;
  padding: 8px;
  color: var(--ink);
}

.game-tab::before {
  content: none;
}

.game-tab:hover,
.game-tab.active {
  border-color: rgba(36, 108, 186, 0.28);
  background: var(--surface);
  box-shadow: 0 8px 18px rgba(22, 34, 49, 0.06);
}

.game-tab[data-game="shop"] {
  border-color: rgba(49, 123, 207, 0.58);
  background: linear-gradient(180deg, #ffffff 0%, #f5f9ff 100%);
  box-shadow:
    0 0 0 1px rgba(74, 145, 226, 0.28),
    0 0 18px rgba(74, 145, 226, 0.36),
    0 10px 22px rgba(22, 34, 49, 0.08);
}

.game-tab[data-game="shop"]::after {
  content: "0% 할인!";
  position: absolute;
  left: -8px;
  top: -10px;
  z-index: 2;
  transform: rotate(-10deg);
  transform-origin: left center;
  border-radius: 7px;
  padding: 2px 7px 3px;
  background: #fff8d7;
  color: #b6463c;
  font-size: 13px;
  font-style: italic;
  font-weight: 900;
  line-height: 1.1;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
  box-shadow: 0 3px 10px rgba(182, 70, 70, 0.22);
  pointer-events: none;
}

.game-tab[data-game="shop"]:hover,
.game-tab[data-game="shop"].active {
  border-color: rgba(49, 123, 207, 0.78);
  box-shadow:
    0 0 0 1px rgba(74, 145, 226, 0.42),
    0 0 24px rgba(74, 145, 226, 0.48),
    0 12px 24px rgba(22, 34, 49, 0.1);
}

.game-tab .game-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--blue);
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Segoe UI Symbol", sans-serif;
  font-size: 21px;
  font-weight: 400;
  line-height: 1;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.game-tab.active .game-icon {
  background: color-mix(in srgb, var(--info) 12%, var(--surface));
  color: inherit;
}

.game-copy,
.game-copy strong,
.game-copy span {
  min-width: 0;
}

.game-state-dot,
.game-state-placeholder {
  display: block;
  width: 10px;
  height: 10px;
}

.game-tab .game-state-dot,
.game-tab .game-state-placeholder {
  display: block;
  justify-self: center;
  width: 10px;
  height: 10px;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.game-state-dot {
  border-radius: 999px;
  background: #2f7dd3;
  box-shadow: 0 0 0 4px rgba(47, 125, 211, 0.13);
}

.game-state-dot.idle {
  background: #2f7dd3;
  box-shadow: 0 0 0 4px rgba(47, 125, 211, 0.13);
}

.game-state-dot.running {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(182, 70, 70, 0.13);
}

.stage {
  grid-area: main;
  display: grid;
  align-content: start;
  gap: 16px;
  min-height: 0;
  height: calc(100vh - 64px);
  height: calc(100dvh - 64px);
  overflow: auto;
  padding: 20px;
}

.sidebar,
.stage,
.room-panel {
  scroll-margin-top: 76px;
}

.side-rail {
  display: grid;
  align-content: start;
  gap: 16px;
  min-width: 0;
  min-height: 0;
}

#rankingArea,
#refreshLeaderboard,
.mobile-dock [data-jump="#rankingArea"] {
  display: none;
}

/* Left sidebar (profile + game list) collapse. The ☰ toggle lives in the
   topbar (inside .brand) so it never overlays page content. */
.sidebar-menu-toggle {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 9px;
  background: #1d4ed8;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(29, 78, 216, 0.32);
  transition:
    background 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.sidebar-menu-toggle:hover {
  background: #1e40af;
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(29, 78, 216, 0.42);
}

.sidebar-menu-toggle:active {
  transform: translateY(0);
}

/* Panel hidden: dim the toggle slightly so its state reads at a glance. */
.sidebar-menu-toggle.is-collapsed {
  background: #2747a6;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

@media (min-width: 821px) {
  body.sidebar-collapsed #profileArea {
    display: none;
  }
  body.sidebar-collapsed .app-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "top"
      "main";
  }
}

@media (max-width: 820px) {
  .sidebar-menu-toggle {
    display: none;
  }
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-head h3 {
  margin: 0;
  font-size: 16px;
}

.log-panel,
.leader-panel {
  min-height: 0;
  box-shadow: none;
}

.surface {
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(430px, 1fr) minmax(340px, 0.42fr);
  gap: 16px;
  align-items: start;
}

.game-main-panel,
.game-settings-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.game-main-panel {
  container-type: inline-size;
  container-name: game-main;
  min-height: 520px;
  padding: 16px;
}

.game-settings-panel {
  position: sticky;
  top: 84px;
  padding: 14px;
}

.settings-stack {
  display: grid;
  gap: 14px;
}

.settings-stack > div,
.settings-section {
  display: grid;
  gap: 10px;
  min-width: 0;
  border: 1px solid rgba(36, 108, 186, 0.12);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.room-settings-section {
  border-color: rgba(36, 135, 91, 0.16);
  background: #fbfffc;
}

/* Feature 2: collapsible room configuration (rules/options). The ready and
   stop-vote buttons live in .room-settings-section and stay outside this group. */
.settings-stack > .room-config {
  display: grid;
  gap: 14px;
  border: 0;
  padding: 0;
  background: transparent;
}

.room-config-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: 1px solid rgba(36, 108, 186, 0.18);
  border-radius: 8px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease;
}

.room-config-toggle:hover {
  background: #e8eff8;
  border-color: rgba(36, 108, 186, 0.32);
}

.room-config-caret {
  font-size: 11px;
  transition: transform 180ms ease;
}

.room-config.is-collapsed .room-config-caret {
  transform: rotate(-90deg);
}

.room-config-body {
  display: grid;
  gap: 14px;
}

.room-config.is-collapsed .room-config-body {
  display: none;
}

.game-settings-panel .control-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 0;
}

.room-action-group,
.settings-action-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.settings-action-group:has(> :only-child) {
  grid-template-columns: 1fr;
}

.game-settings-panel button,
.settings-stack > button,
.settings-stack > div > button,
.room-action-group button,
.settings-action-group button {
  width: 100%;
}

.status-grid {
  display: grid;
  gap: 8px;
}

.compact-status-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.music-status {
  min-height: 48px;
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--soft);
}

.room-panel {
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.room-overview {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: var(--panel);
}

.room-overview-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.room-overview-head strong {
  display: block;
  overflow: hidden;
  font-size: 19px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-title-line {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  margin-top: 3px;
}

.room-title-line strong {
  min-width: 0;
}

.room-title-dot {
  flex: 0 0 auto;
}

.room-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.room-status-card {
  min-height: 62px;
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--soft);
}

.room-status-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.room-status-card strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  font-size: 19px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-top-button {
  white-space: nowrap;
}

.admin-layout .game-main-panel,
.admin-layout .game-settings-panel {
  min-width: 0;
}

.admin-panel,
.admin-side-panel {
  display: grid;
  gap: 14px;
}

.admin-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-panel-head h3 {
  margin: 2px 0 0;
  font-size: 24px;
}

.admin-section,
.admin-side-panel {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.admin-list {
  display: grid;
  gap: 8px;
}

.admin-user-management {
  display: grid;
  gap: 12px;
}

.admin-user-management > p {
  margin: 0;
  color: var(--text-muted);
}

.admin-user-search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.admin-user-search-form input {
  min-width: 0;
}

.admin-user-management-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(320px, 1.2fr);
  gap: 12px;
  align-items: start;
}

.admin-user-results {
  max-height: 620px;
  overflow: auto;
}

.admin-user-row {
  width: 100%;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.admin-user-row:hover {
  border-color: var(--accent);
}

.admin-user-balances {
  display: grid;
  gap: 3px;
  justify-items: end;
  color: var(--text-muted);
  font-size: 12px;
}

.admin-user-detail {
  display: grid;
  gap: 14px;
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: var(--panel);
}

.admin-user-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.admin-user-detail-head p,
.admin-user-detail-head h4 {
  margin: 0;
}

.admin-user-detail-head h4 {
  margin-top: 3px;
  font-size: 20px;
}

.admin-user-sync-state {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.admin-user-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.admin-user-stats > div {
  display: grid;
  gap: 4px;
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-soft);
}

.admin-user-stats span,
.admin-user-grant-form label > span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.admin-user-grant-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.admin-user-grant-form label {
  display: grid;
  gap: 5px;
}

.admin-user-grant-form input,
.admin-user-grant-form select {
  min-width: 0;
  width: 100%;
}

.admin-user-title-field,
.admin-user-grant-form .primary-button {
  grid-column: 1 / -1;
}

.admin-user-owned-titles > summary,
.admin-user-grant-history > summary {
  cursor: pointer;
  font-weight: 800;
}

.admin-user-owned-titles > div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.admin-user-grant-history > .admin-list {
  margin-top: 10px;
}

.admin-user-grant-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
  font-size: 12px;
}

.admin-user-grant-row span {
  color: var(--text-muted);
}

@media (max-width: 820px) {
  .admin-user-management-grid {
    grid-template-columns: 1fr;
  }

  .admin-user-results {
    max-height: 300px;
  }

  .admin-user-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.omok-card {
  display: grid;
  gap: 14px;
  justify-items: center;
}

.connect4-card {
  display: grid;
  gap: 14px;
  justify-items: center;
}

.connect4-header {
  width: min(100%, 620px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.connect4-players {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.connect4-player {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}

.connect4-player.current {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue) 18%, transparent);
}

.connect4-mini-disc,
.connect4-cell > span {
  display: block;
  border-radius: 50%;
}

.connect4-mini-disc {
  width: 14px;
  height: 14px;
}

.connect4-mini-disc.red,
.connect4-cell.red > span {
  background: linear-gradient(145deg, #ff7066, #c7272e);
}

.connect4-mini-disc.yellow,
.connect4-cell.yellow > span {
  background: linear-gradient(145deg, #ffe77a, #d99a16);
}

.connect4-clock {
  color: var(--blue);
  font-variant-numeric: tabular-nums;
}

.connect4-board-wrap {
  --connect4-cell: clamp(38px, 8vw, 68px);
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  padding: 8px;
  border-radius: 18px;
  background: linear-gradient(155deg, #2c79d8, #174caa);
  box-shadow: 0 18px 38px rgba(9, 39, 96, 0.24);
}

.connect4-column-actions,
.connect4-grid {
  display: grid;
  grid-template-columns: repeat(7, var(--connect4-cell));
}

.connect4-column-actions button {
  min-width: 0;
  height: 30px;
  border: 0;
  border-radius: 8px;
  color: white;
  background: transparent;
  font-size: 1.2rem;
  cursor: pointer;
}

.connect4-column-actions button:not(:disabled):hover,
.connect4-column-actions button:not(:disabled):focus-visible {
  background: rgba(255, 255, 255, 0.18);
}

.connect4-column-actions button:disabled {
  opacity: 0.3;
  cursor: default;
}

.connect4-cell {
  width: var(--connect4-cell);
  height: var(--connect4-cell);
  display: grid;
  place-items: center;
}

.connect4-cell > span {
  width: 78%;
  height: 78%;
  background: var(--surface);
  box-shadow: inset 0 5px 10px rgba(8, 27, 67, 0.25);
}

.connect4-cell.last-move > span {
  outline: 4px solid white;
  outline-offset: -5px;
}

.dotsboxes-card {
  display: grid;
  gap: 14px;
  justify-items: center;
}

.dotsboxes-header {
  width: min(100%, 560px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dotsboxes-players {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dotsboxes-player {
  display: grid;
  gap: 2px;
  min-width: 108px;
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.dotsboxes-player.player-1 { border-color: #2d85dc; }
.dotsboxes-player.player-2 { border-color: #e98b2a; }
.dotsboxes-player.current { box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 20%, transparent); }
.dotsboxes-clock { color: var(--blue); font-variant-numeric: tabular-nums; }
.dotsboxes-help { margin: 0; color: var(--muted); text-align: center; }

.dotsboxes-board-wrap {
  --dotsboxes-gap: clamp(42px, 10vw, 78px);
  max-width: 100%;
  overflow: auto;
  padding: 20px;
  border-radius: 20px;
  background: color-mix(in srgb, var(--panel) 88%, #dfeeff);
  box-shadow: 0 18px 38px rgba(22, 58, 94, 0.16);
}

.dotsboxes-grid {
  display: grid;
  grid-template-columns: repeat(3, 18px var(--dotsboxes-gap)) 18px;
  grid-template-rows: repeat(3, 18px var(--dotsboxes-gap)) 18px;
  align-items: center;
  justify-items: center;
  width: fit-content;
}

.dotsboxes-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
  z-index: 2;
}

.dotsboxes-edge {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 22%, transparent);
  cursor: pointer;
}

.dotsboxes-edge.horizontal { width: calc(var(--dotsboxes-gap) - 8px); height: 10px; }
.dotsboxes-edge.vertical { width: 10px; height: calc(var(--dotsboxes-gap) - 8px); }
.dotsboxes-edge:not(:disabled):hover,
.dotsboxes-edge:not(:disabled):focus-visible { background: var(--blue); transform: scale(1.06); }
.dotsboxes-edge.taken { background: #416f9f; opacity: 1; }
.dotsboxes-edge.last { box-shadow: 0 0 0 3px #ffd166; }

.dotsboxes-box {
  width: calc(var(--dotsboxes-gap) - 12px);
  height: calc(var(--dotsboxes-gap) - 12px);
  display: grid;
  place-items: center;
  border-radius: 12px;
  font-weight: 800;
  font-size: 1.25rem;
}

.dotsboxes-box.owner-1 { color: white; background: rgba(45, 133, 220, 0.76); }
.dotsboxes-box.owner-2 { color: white; background: rgba(233, 139, 42, 0.78); }

/* ── 먹번짐(Ink Bloom) ─────────────────────────────────────────────── */
.inkbloom-card {
  display: grid;
  gap: 12px;
  justify-items: center;
}

.inkbloom-header {
  width: min(100%, 680px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.inkbloom-players {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inkbloom-player {
  display: grid;
  min-width: 106px;
  gap: 2px;
  padding: 8px 12px;
  border: 2px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
}

.inkbloom-player.player-1 { border-color: #315f92; }
.inkbloom-player.player-2 { border-color: #a33c3c; }
.inkbloom-player small { color: var(--muted); }

.inkbloom-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-variant-numeric: tabular-nums;
}

#inkbloomClock {
  min-width: 3.5ch;
  color: #8d302f;
  text-align: right;
}

.inkbloom-help {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  text-align: center;
}

.inkbloom-board {
  position: relative;
  width: min(100%, 680px, 76vh);
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(77, 67, 53, 0.28);
  border-radius: 24px;
  background:
    radial-gradient(circle at 20% 12%, rgba(255, 255, 255, 0.82), transparent 34%),
    repeating-linear-gradient(8deg, rgba(93, 77, 55, 0.025) 0 1px, transparent 1px 5px),
    #f1eadb;
  box-shadow: inset 0 0 38px rgba(80, 62, 43, 0.1), 0 18px 45px rgba(30, 25, 20, 0.12);
  isolation: isolate;
}

.inkbloom-watercolor,
.inkbloom-grid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.inkbloom-watercolor {
  z-index: 0;
  opacity: 0.72;
  pointer-events: none;
}

.inkbloom-grid {
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(var(--inkbloom-size), 1fr);
  grid-template-rows: repeat(var(--inkbloom-size), 1fr);
  gap: 1px;
  padding: clamp(6px, 1.4vw, 12px);
  background: linear-gradient(rgba(84, 72, 57, 0.09), rgba(84, 72, 57, 0.03));
}

.inkbloom-cell {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 1px solid rgba(75, 68, 59, 0.12);
  border-radius: 22%;
  box-shadow: none;
  cursor: crosshair;
  transition: transform 120ms ease, outline-color 120ms ease, filter 180ms ease;
  touch-action: manipulation;
}

.inkbloom-cell:not(:disabled):hover,
.inkbloom-cell:not(:disabled):focus-visible {
  z-index: 2;
  transform: scale(1.12);
  outline: 3px solid rgba(45, 42, 35, 0.5);
  filter: saturate(1.18) contrast(1.06);
}

.inkbloom-cell:disabled { opacity: 1; cursor: default; }
.inkbloom-cell.owner-1 { box-shadow: inset 0 0 0 1px rgba(49, 95, 146, 0.38); }
.inkbloom-cell.owner-2 { box-shadow: inset 0 0 0 1px rgba(163, 60, 60, 0.38); }
.inkbloom-cell.chosen { z-index: 3; box-shadow: 0 0 0 2px rgba(213, 173, 75, 0.28); }
.inkbloom-drop {
  position: absolute;
  z-index: 4;
  width: 15%;
  height: 15%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
  filter: blur(1.5px);
  animation: inkbloom-drop-bloom 480ms ease-out both;
}
.inkbloom-drop.player-1 { background: radial-gradient(circle, rgba(49, 95, 146, 0.78), rgba(49, 95, 146, 0) 70%); }
.inkbloom-drop.player-2 { background: radial-gradient(circle, rgba(163, 60, 60, 0.78), rgba(163, 60, 60, 0) 70%); }
@keyframes inkbloom-drop-bloom {
  from { transform: translate(-50%, -50%) scale(0.35); opacity: 0.25; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
.inkbloom-cell.revealed-1 { animation: inkbloom-blue-reveal 900ms ease-out; }
.inkbloom-cell.revealed-2 { animation: inkbloom-red-reveal 900ms ease-out; }

@keyframes inkbloom-blue-reveal {
  0% { box-shadow: 0 0 0 0 rgba(49, 95, 146, 0.82); transform: scale(0.62); }
  100% { box-shadow: 0 0 0 18px rgba(49, 95, 146, 0); transform: scale(1); }
}

@keyframes inkbloom-red-reveal {
  0% { box-shadow: 0 0 0 0 rgba(163, 60, 60, 0.82); transform: scale(0.62); }
  100% { box-shadow: 0 0 0 18px rgba(163, 60, 60, 0); transform: scale(1); }
}

@media (max-width: 600px) {
  .inkbloom-header { align-items: flex-start; }
  .inkbloom-player { min-width: 88px; padding: 6px 8px; }
  .inkbloom-board { width: min(100%, 88vw); border-radius: 16px; }
  .inkbloom-grid { padding: 5px; }
}

/* ── 3D 바둑판 ─────────────────────────────────────────────────────────── */
.omok-board-3d {
  position: relative;
  width: min(100%, 720px);
  min-height: clamp(420px, 58vh, 700px);
  overflow: hidden;
  border: 1px solid rgba(74, 45, 17, 0.34);
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 40%, rgba(142, 96, 52, 0.42), transparent 62%),
    #14100b;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 18px 40px rgba(24, 15, 6, 0.24);
}

.omok-3d-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none; /* 캔버스 위 터치 제스처를 3D 조작으로 사용 */
}

/* 캔버스 GL 픽셀이 inset 그림자를 덮으므로 포커스 링은 컨테이너 테두리에 건다. */
.omok-board-3d:focus-within {
  box-shadow:
    inset 0 0 0 2px rgba(255, 210, 120, 0.7),
    0 18px 40px rgba(24, 15, 6, 0.24);
}

.omok-board-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 210, 120, 0.28);
  border-radius: 8px;
  background: rgba(20, 13, 6, 0.58);
  color: #ffd88a;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  pointer-events: none;
}

/* 3D가 주 조작 — 2D 격자는 접근성 폴백으로 접어 둔다. */
.omok-fallback {
  width: min(100%, 720px);
  border-top: 1px solid var(--border, rgba(120, 120, 120, 0.2));
  padding-top: 8px;
}

.omok-fallback > summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted, rgba(120, 130, 140, 0.9));
}

.omok-fallback-note {
  margin: 6px 0 10px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted, rgba(120, 130, 140, 0.9));
}

.omok-header {
  width: min(100%, 720px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.omok-players {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.omok-player {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-raised, rgba(255, 255, 255, 0.72));
}

.omok-player.current {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent);
}

.omok-player small {
  color: var(--muted);
}

.omok-mini-stone {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  box-shadow: inset -2px -2px 4px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.25);
}

.omok-mini-stone.black,
.omok-point.black .omok-stone {
  background: radial-gradient(circle at 34% 28%, #5d6269 0, #20242a 42%, #07090c 100%);
  color: #fff;
}

.omok-mini-stone.white,
.omok-point.white .omok-stone {
  background: radial-gradient(circle at 34% 28%, #fff 0, #f0eee7 50%, #bcb9ae 100%);
  color: #1d2024;
}

.omok-clock {
  min-width: 66px;
  padding: 7px 10px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.omok-board-wrap {
  width: min(100%, 720px);
  overflow: auto;
  padding: 10px;
  border-radius: 16px;
  background: #8e6034;
  box-shadow: inset 0 0 0 2px rgba(58, 32, 12, 0.3), 0 12px 28px rgba(32, 20, 10, 0.18);
}

.omok-board {
  --omok-cell: clamp(24px, 4.1vw, 42px);
  position: relative;
  display: grid;
  grid-template-columns: repeat(15, var(--omok-cell));
  grid-template-rows: repeat(15, var(--omok-cell));
  width: max-content;
  padding: calc(var(--omok-cell) / 2);
  background-color: #d9a861;
  background-image:
    linear-gradient(rgba(74, 45, 17, 0.72) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74, 45, 17, 0.72) 1px, transparent 1px);
  background-size: var(--omok-cell) var(--omok-cell);
  background-position: var(--omok-cell) var(--omok-cell);
  border-radius: 8px;
  user-select: none;
  touch-action: manipulation;
}

.omok-point {
  position: relative;
  width: var(--omok-cell);
  height: var(--omok-cell);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.yut-status-strip .yut-moves {
  display: none;
  grid-column: 1 / -1;
}

.yut-status-strip .yut-moves:has(button) {
  display: flex;
}

.omok-point:disabled {
  cursor: default;
  opacity: 1;
}

.omok-point:not(:disabled):hover,
.omok-point.selected {
  background: rgba(45, 99, 187, 0.24);
}

.omok-stone {
  position: absolute;
  inset: 7%;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: clamp(9px, 1.7vw, 13px);
  font-weight: 800;
  box-shadow: inset -3px -3px 7px rgba(0, 0, 0, 0.24), 0 2px 3px rgba(0, 0, 0, 0.3);
}

.omok-point.last-move .omok-stone::after {
  content: "";
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: #e43d48;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.65);
}

@media (max-width: 700px) {
  .omok-board {
    --omok-cell: 26px;
  }

  .omok-board-3d {
    min-height: 360px;
  }

  .omok-header {
    align-items: flex-start;
  }
}

.admin-feed-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 12px;
  margin-top: 12px;
}

.admin-feed-groups {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.admin-feed-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 3%, var(--panel));
}

.admin-feed-group > summary,
.admin-feed-template > summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}

.admin-feed-group > summary::-webkit-details-marker,
.admin-feed-template > summary::-webkit-details-marker {
  display: none;
}

.admin-feed-group > summary span,
.admin-feed-template > summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.admin-feed-group > .admin-feed-template-grid {
  margin: 0;
  border-top: 1px solid var(--line);
  padding: 12px;
}

.admin-feed-template {
  display: grid;
  gap: 10px;
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: var(--panel);
}

details.admin-feed-template {
  display: block;
  padding: 0;
}

.admin-feed-template-body {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 12px 14px 14px;
}

.admin-feed-template legend {
  padding: 0 6px;
  font-weight: 800;
}

.admin-feed-template label:not(.admin-feed-enabled) {
  display: grid;
  gap: 6px;
}

.admin-feed-template input[type="text"],
.admin-feed-template textarea {
  width: 100%;
  box-sizing: border-box;
}

.admin-feed-enabled {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-feed-variables {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.admin-feed-preview {
  display: grid;
  gap: 5px;
  border-left: 3px solid var(--accent);
  padding: 9px 11px;
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}

.admin-feed-preview p {
  margin: 0;
  white-space: pre-wrap;
}

.room-invite-action {
  display: grid;
  gap: 6px;
}

.admin-visibility-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 280px));
  justify-content: start;
  align-items: stretch;
}

.admin-visibility-grid .admin-row {
  grid-template-columns: minmax(0, 1fr) auto;
  height: 100%;
}

.admin-visibility-grid .admin-empty {
  grid-column: 1 / -1;
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
}

.admin-lab-row {
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.admin-lab-row:hover,
.admin-lab-row:focus-visible {
  border-color: rgba(34, 132, 98, 0.4);
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
}

.mahjong-draft-panel fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.mahjong-draft-panel legend { margin-bottom: 8px; color: #ffe8a8; font-weight: 700; }
.mahjong-draft-card { display: flex; gap: 8px; padding: 12px; border: 1px solid #577568; border-radius: 10px; background: #13362f; cursor: pointer; }
.mahjong-draft-card:has(input:checked) { border-color: #efd18c; background: #2c4d3c; }
.mahjong-draft-card input { flex: 0 0 18px; width: 18px; height: 18px; min-height: 0; margin: 2px 0 0; padding: 0; align-self: flex-start; accent-color: #efd18c; }
.mahjong-draft-card span { min-width: 0; display: grid; gap: 6px; }
.mahjong-draft-card small { color: #c8d8d1; line-height: 1.5; word-break: keep-all; }
.mahjong-actions-overlay .mahjong-draft-panel { width: min(760px, 96vw); max-height: min(560px, calc(100dvh - 160px)); }
.mahjong-open-waits { display: inline-flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.mahjong-open-waits .riichi-tile { width: 18px; height: 25px; }

.admin-lab-intro h3 { margin: 0; }
.admin-lab-heading { margin: 0; font-size: 13px; font-weight: 700; color: var(--muted); }
.admin-lab-intro p { margin: 6px 0 0; color: var(--muted); }
.admin-lab-section { display: grid; gap: 12px; }
.admin-lab-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); gap: 10px; }
.admin-lab-row { width: 100%; min-width: 0; text-align: left; box-sizing: border-box; }
.admin-lab-feature { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.admin-lab-details { padding: 0; }
.admin-lab-details > summary { display: flex; align-items: center; gap: 12px; padding: 16px; cursor: pointer; }
.admin-lab-details > summary::before { content: "›"; font-size: 22px; color: var(--muted); }
.admin-lab-details[open] > summary::before { transform: rotate(90deg); }
.admin-lab-details > summary::-webkit-details-marker { display: none; }
.admin-lab-details > summary > span:first-of-type { display: grid; gap: 5px; flex: 1; min-width: 0; }
.admin-lab-details summary small { color: var(--muted); font-weight: 400; }
.admin-lab-badge { flex-shrink: 0; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 20px; padding: 4px 7px; }
.admin-lab-detail-body { padding: 0 16px 16px; border-top: 1px solid var(--line); }

.admin-lab-open {
  color: var(--accent, #228462);
  font-weight: 600;
  white-space: nowrap;
}

.admin-room-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.admin-game-visibility-row {
  min-height: 56px;
  cursor: pointer;
}

.admin-visibility-toggle {
  display: inline-flex;
  min-width: 92px;
  min-height: 44px;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.admin-visibility-toggle input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.admin-visibility-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.admin-visibility-actions .result {
  margin: 0;
}

.admin-mortal-nickname-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.admin-mortal-nickname-form input {
  min-width: 0;
}

.admin-mortal-nickname-row {
  min-height: 52px;
}

.admin-mortal-nicknames .admin-list {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.admin-mortal-nickname-row {
  min-height: 44px;
  padding: 8px 10px;
}

.admin-mortal-nickname-row button {
  width: auto;
  min-height: 32px;
  padding: 5px 9px;
}

.admin-operations-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.admin-operations-summary > div {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: var(--panel);
}

.admin-operations-summary span,
.admin-operations-summary strong {
  display: block;
}

.admin-operations-summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.admin-operations-summary strong {
  margin-top: 3px;
  font-size: 22px;
}

.admin-operations-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.admin-operations-grid .admin-section {
  min-width: 0;
  margin: 0;
}

.admin-operations-grid .admin-room-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.admin-room-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.admin-room-controls .danger-button {
  width: auto;
  min-height: 34px;
  padding: 6px 10px;
  white-space: nowrap;
}

.admin-collapsible > summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  list-style: none;
}

.admin-collapsible > summary::-webkit-details-marker {
  display: none;
}

.admin-collapsible > summary span {
  color: var(--muted);
  font-size: 12px;
}

.admin-collapsible > .admin-list {
  margin-top: 12px;
}

.word-player.eliminated {
  opacity: 0.52;
  filter: saturate(0.45);
}

.word-player-order {
  display: inline-grid;
  min-width: 1.5em;
  min-height: 1.5em;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.admin-subtabs.context-tabs {
  margin: 0;
}

.admin-tab-pane {
  display: grid;
  gap: 14px;
}

.admin-tab-pane[hidden] {
  display: none;
}

.admin-character-lab-section > .admin-lab-detail-body {
  display: grid;
  gap: 12px;
}

.admin-character-lab-section > p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.admin-vrm-import-grid,
.admin-vrm-selection {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.admin-vrm-import-grid label:first-child,
.admin-vrm-selection label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.admin-vrm-import-grid input[type="file"],
.admin-vrm-selection select {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
}

.admin-vrm-rights {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 0.9rem;
}

.admin-vrm-selection {
  margin-top: 16px;
}

.admin-vrm-limits,
.admin-vrm-preview-empty {
  color: var(--text-muted);
  font-size: 0.86rem;
}

.admin-vrm-preview {
  min-height: 320px;
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #18202c;
}

.admin-vrm-preview-canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
}

.admin-vrm-model-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.admin-vrm-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-soft);
}

.admin-vrm-row.is-disabled {
  opacity: 0.72;
}

.admin-vrm-row > div:first-child {
  display: grid;
  gap: 3px;
}

.admin-vrm-row span,
.admin-vrm-row small,
.admin-vrm-empty {
  color: var(--text-muted);
}

.admin-vrm-state {
  font-weight: 800;
}

.admin-vrm-row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.character-lab-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(380px, 1.1fr);
  gap: 16px;
}

.character-lab-modes {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.character-lab-modes button {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.character-lab-modes button[aria-selected="true"] {
  border-color: var(--accent, #6fa8dc);
  color: var(--text);
  font-weight: 600;
}

.face-compare-layout {
  display: grid;
  gap: 12px;
}

.face-compare-layout canvas {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #2b2733;
  touch-action: none;
  cursor: grab;
}

.face-compare-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.face-compare-toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

.face-compare-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.face-compare-choices li {
  display: grid;
  gap: 4px;
}

.face-compare-choices button {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.face-compare-choices button[data-selected="true"] {
  border-color: var(--accent, #6fa8dc);
  font-weight: 600;
}

.face-compare-choices span,
.face-compare-status {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
}

.character-lab-preview {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #17202b;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08);
}

.character-lab-preview canvas {
  display: block;
  width: 100%;
  height: 520px;
  cursor: grab;
  touch-action: none;
}

.character-lab-preview canvas:active {
  cursor: grabbing;
}

.character-pose-lab { display: grid; gap: 8px; padding: 12px; font-size: .86rem; }
.character-pose-lab > div { display: flex; flex-wrap: wrap; gap: 6px; }
.character-pose-lab button { border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; background: var(--surface-soft); color: var(--text); cursor: pointer; }
.character-pose-lab button[aria-pressed="true"] { border-color: var(--accent); background: #244c70; color: #edf4ff; }
.character-pose-lab label { display: flex; align-items: center; gap: 8px; }
.character-pose-lab input[type="range"] { flex: 1; min-width: 0; }
.character-pose-lab output { color: var(--text-muted); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.character-lab-preview-pose .character-lab-status { position: static; margin: 0 12px 12px; }

.character-lab-status {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  margin: 0;
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(13, 20, 29, 0.86);
  color: #dcecff;
  font-size: 0.72rem;
  line-height: 1.45;
  backdrop-filter: blur(7px);
}

.character-lab-status[data-tone="positive"] {
  color: #a8efbd;
}

.character-lab-status[data-tone="danger"] {
  color: #ffb0b0;
}

.character-lab-editor {
  display: grid;
  align-content: start;
  gap: 14px;
}

.character-lab-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.character-lab-field {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.character-lab-field select {
  width: 100%;
  min-height: 42px;
}

/* Schema v2 splits the editor into the face and body axes and the wearable
   slots, each slot pairing a part with the palette that part allows. Twenty-one
   controls is more than a panel holds, so they are split across tabs. */
.character-lab-editor-body {
  display: grid;
  gap: 12px;
}

.character-lab-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}

.character-lab-tabs button {
  flex: 1 1 auto;
  border: 0;
  border-radius: 999px;
  padding: 7px 12px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
}

.character-lab-tabs button[aria-selected="true"] {
  background: var(--accent, #6fa8dc);
  color: #0f1720;
}

.character-lab-panel {
  display: grid;
  gap: 12px;
}

/* `display: grid` above beats the user agent's `[hidden] { display: none }`,
   so the panel that is meant to be put away has to be told again. */
.character-lab-panel[hidden] {
  display: none;
}

.character-lab-group {
  display: grid;
  gap: 8px;
}

.character-lab-group h4 {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.74rem;
  letter-spacing: 0.02em;
}

.character-lab-slots {
  display: grid;
  gap: 10px;
}

.character-lab-slot {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 10px;
}

.character-lab-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Five buttons at a 110px basis came to 582px against a 577px row, so the save
   wrapped onto a line of its own below the fold. */
.character-lab-actions button {
  flex: 1 1 88px;
}

/* The one that matters keeps the width the others give up. */
.character-lab-actions [data-character-action="save"] {
  flex: 2 1 132px;
}

.character-lab-json {
  display: grid;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.character-lab-json textarea {
  width: 100%;
  min-height: 230px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: color-mix(in srgb, var(--panel) 88%, #101722);
  color: var(--text);
  font: 0.75rem/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
}

@media (max-width: 1024px) {
  .character-lab-layout {
    grid-template-columns: 1fr;
  }

  .character-lab-preview,
  .character-lab-preview canvas {
    min-height: 460px;
    height: 460px;
  }
}

@media (max-width: 600px) {
  .admin-vrm-import-grid,
  .admin-vrm-selection {
    grid-template-columns: 1fr;
  }

  .admin-vrm-import-grid .primary-button,
  .admin-vrm-selection .primary-button {
    width: 100%;
  }

  .admin-vrm-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .admin-vrm-row-actions {
    justify-content: stretch;
  }

  .admin-vrm-row-actions button {
    flex: 1 1 140px;
  }

  .character-lab-controls,
  .character-lab-slot {
    grid-template-columns: 1fr;
  }

  .character-lab-preview,
  .character-lab-preview canvas {
    min-height: 410px;
    height: 410px;
  }

}

.info-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  gap: var(--space-4);
}

.info-card {
  display: grid;
  align-content: start;
  gap: var(--space-3);
}

.info-card h3,
.info-card p {
  margin: 0;
}

.info-card a {
  width: fit-content;
  text-decoration: none;
}

.minesweeper-rank-controls {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.minesweeper-rank-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.mine-rank-result {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.admin-row[data-health="blocked"],
.admin-row[data-health="warn"] {
  border-color: rgba(184, 75, 71, 0.36);
  background: #fff8f7;
}

.admin-row[data-health="running"] {
  border-color: rgba(34, 132, 98, 0.32);
  background: #f4fbf8;
}

.admin-row-main {
  min-width: 0;
}

.admin-row-main strong,
.admin-row-main span,
.admin-row-main small,
.admin-row-meta span {
  display: block;
  overflow-wrap: anywhere;
}

.admin-row-main span,
.admin-row-main small,
.admin-row-meta span,
.admin-side-panel p,
.admin-message,
.admin-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.admin-row-meta,
.admin-room-stats {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.admin-room-stats {
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.shop-lab-layout .game-main-panel,
.shop-lab-layout .game-settings-panel {
  min-width: 0;
}

.shop-lab-shell {
  display: grid;
  gap: 14px;
}

.shop-lab-head,
.shop-lab-section header,
.shop-lab-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.shop-lab-head h2,
.shop-lab-section h3,
.shop-lab-card h3 {
  margin: 0;
  letter-spacing: 0;
}

.shop-lab-head h2 {
  font-size: 26px;
}

.shop-lab-head p,
.shop-lab-section header span,
.shop-lab-card p,
.shop-lab-summary p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.shop-lab-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.shop-lab-section {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.shop-lab-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.shop-lab-card {
  display: grid;
  grid-template-columns: minmax(160px, 0.82fr) minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface);
}

.shop-lab-preview {
  min-width: 0;
}

.shop-lab-preview .shop-preview-stage,
.shop-lab-preview .shop-mahjong-preview,
.shop-lab-preview .shop-generic-preview,
.shop-lab-preview .shop-onecard-preview,
.shop-lab-preview .shop-mj-effect-preview,
.shop-lab-preview .shop-yacht-preview,
.shop-lab-preview .shop-yut-preview,
.shop-lab-preview .shop-drawing-preview {
  min-height: 186px;
}

.shop-lab-preview .shop-bundle-preview {
  min-height: 186px;
  padding: 12px;
}

.shop-lab-copy {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
}

.shop-lab-components {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.shop-lab-components span {
  border-radius: 999px;
  padding: 3px 7px;
  background: var(--soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.shop-lab-real-action {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  border: 1px solid rgba(48, 97, 255, 0.18);
  border-radius: 8px;
  padding: 8px;
  background: #f7f9ff;
}

.shop-lab-real-action .primary-button,
.shop-lab-real-action .ghost-button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  text-decoration: none;
}

.shop-lab-real-action span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
}

.shop-lab-real-action.is-pending {
  border-color: var(--line);
  background: var(--soft);
}

.shop-lab-admin-controls {
  display: grid;
  grid-template-columns: minmax(110px, 0.7fr) minmax(110px, 0.55fr) minmax(96px, 0.5fr) auto;
  gap: 8px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fbfcff;
}

/* ── 세트 관리(관리자 번들 CRUD) ── */
.shop-lab-bundle-manager .shop-lab-bundle-list {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.shop-lab-bundle-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.4fr) minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fbfcff;
}

.shop-lab-bundle-row span {
  color: var(--muted);
  font-size: 12px;
}

.shop-lab-bundle-empty {
  color: var(--muted);
  font-size: 13px;
}

.shop-lab-bundle-form {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fbfcff;
}

.shop-lab-bundle-fields {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(200px, 1.4fr) minmax(90px, 0.5fr) auto auto;
  gap: 10px;
  align-items: end;
}

.shop-lab-bundle-fields label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.shop-lab-bundle-fields input[type="text"],
.shop-lab-bundle-fields input:not([type]) ,
.shop-lab-bundle-fields input[type="number"] {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  color: var(--ink);
}

.shop-lab-bundle-components {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface);
}

.shop-lab-bundle-component {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
}

.shop-lab-bundle-component small {
  color: var(--muted);
}

.shop-lab-bundle-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.shop-lab-bundle-actions #shopBundlePriceHint {
  margin-right: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

@media (max-width: 820px) {
  .shop-lab-bundle-fields {
    grid-template-columns: 1fr;
  }

  .shop-lab-bundle-row {
    grid-template-columns: 1fr auto auto;
  }

  .shop-lab-bundle-row span {
    grid-column: 1 / -1;
  }
}

.shop-lab-admin-controls label {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.shop-lab-admin-controls input[type="number"] {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  color: var(--ink);
  font-weight: 850;
}

.shop-lab-admin-controls .shop-lab-toggle {
  grid-template-columns: auto 1fr;
  gap: 7px;
  align-items: center;
  min-height: 34px;
}

.shop-lab-admin-controls .ghost-button {
  min-height: 34px;
  padding: 0 10px;
}

.shop-runtime-lab-side {
  display: grid;
  gap: 10px;
  align-content: start;
}

.shop-runtime-lab-side strong {
  color: var(--ink);
  font-size: 18px;
}

.shop-runtime-lab-side p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.shop-lab-meta,
.shop-lab-summary dl {
  display: grid;
  gap: 6px;
  margin: 0;
}

.shop-lab-meta div,
.shop-lab-summary dl div {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}

.shop-lab-meta dt,
.shop-lab-meta dd,
.shop-lab-summary dt,
.shop-lab-summary dd {
  margin: 0;
}

.shop-lab-meta dt,
.shop-lab-summary dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.shop-lab-meta dd,
.shop-lab-summary dd {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
}

.room-roster-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.room-list {
  min-height: 74px;
  background: var(--soft);
}

.room-actions {
  align-content: center;
  justify-content: flex-end;
}

.leader-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
}

.mobile-dock {
  display: none;
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 300px minmax(0, 1fr);
    grid-template-areas:
      "top top"
      "nav main";
  }

  .topbar {
    grid-template-columns: 260px minmax(260px, 1fr) auto;
    grid-template-areas: "brand music actions";
  }

  .stage-title {
    display: none;
  }

}

@media (max-width: 1024px) {
  .game-layout,
  .battle-layout,
  .gamble-grid,
  .gamble-panels,
  .gamble-mode-layout,
  .yacht-layout,
  .room-overview-head,
  .room-roster-grid {
    grid-template-columns: 1fr;
  }

  .admin-row,
  .admin-room-row,
  .shop-lab-card {
    grid-template-columns: 1fr;
  }

  .shop-lab-admin-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-row-meta,
  .admin-room-stats,
  .shop-lab-actions {
    justify-content: flex-start;
  }

  .game-settings-panel {
    position: static;
  }

  .room-actions {
    justify-content: flex-start;
  }

  .yut-status-strip {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 820px) {
  .app-shell {
    display: block;
    height: auto;
    padding-bottom: 64px;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand actions";
    min-height: 64px;
    padding-top: env(safe-area-inset-top);
  }

  body.sidebar-collapsed .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand actions";
  }

  .brand {
    padding: 0 14px;
  }

  .stage-title {
    display: none;
  }

  .global-music-panel {
    position: absolute;
    grid-area: auto;
    left: 50%;
    min-width: 0;
    max-width: 44vw;
    transform: translateX(-50%);
  }

  .global-music-copy small {
    display: none;
  }

  .top-actions {
    padding: 0 14px;
  }

  #refreshLeaderboard,
  .top-stat {
    display: none;
  }

  .sidebar,
  .stage {
    height: auto;
    overflow: visible;
    padding: 16px;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .room-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compact-status-grid {
    grid-template-columns: 1fr;
  }

  .game-main-panel {
    min-height: 0;
    padding: 14px;
  }

  .mobile-dock {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 96%, transparent);
  }

  .mobile-dock button {
    min-height: 58px;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 850;
  }

  .mobile-dock .active {
    color: var(--blue);
  }
}

@media (max-width: 600px) {
  .brand p {
    display: none;
  }

  .room-status-grid,
  .profile-stats {
    grid-template-columns: 1fr;
  }

  .shop-lab-admin-controls {
    grid-template-columns: 1fr;
  }

  .game-tab {
    grid-template-columns: 38px minmax(0, 1fr) 18px;
  }

  .answer-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .drawing-status-strip,
  .drawing-word-setup,
  .drawing-word-setup-controls,
  .drawing-board-toolbar,
  .drawing-answer-row,
  .drawing-tool-actions,
  .mahjong-status-strip {
    grid-template-columns: 1fr;
  }

  .mahjong-tabletop {
    min-height: 0;
    padding: 10px;
  }

  .mahjong-status-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    padding: 5px;
  }

  .mahjong-status-strip > .mahjong-status-cell {
    min-height: 48px;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 0 5px;
    padding: 5px 6px;
    font-size: 8px;
  }

  .mahjong-status-cell > i {
    width: 23px;
    height: 23px;
    font-size: 11px;
  }

  .mahjong-status-strip .mahjong-status-cell strong {
    font-size: 11px;
  }

  .mahjong-table-3d {
    height: clamp(480px, 68svh, 620px);
    min-height: 480px;
  }

  .mahjong-3d-seat {
    max-width: 46%;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 4px;
    padding: 4px 6px;
    font-size: 10px;
  }

  .mahjong-3d-seat.seat-left,
  .mahjong-3d-seat.seat-right {
    top: 42%;
  }

  .mahjong-3d-seat i {
    display: none;
  }

  .mahjong-actions-overlay {
    flex-direction: column;
    /* Overflow must start inside the scrollport; flex-end clips the first controls. */
    justify-content: flex-start;
    gap: 8px;
    align-items: center;
    right: 8px;
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    left: 8px;
    max-height: 38%;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }

  /* 손을 마친 뒤 다음 국 조작은 결과 패널보다 앞에 두고, 고정 모바일 도크보다
     안전한 여백 위에 둔다. 결과 패널은 스크롤·복수 화료 페이저를 그대로 유지한다. */
  .mahjong-table-3d:has(#mahjongNextHand) .mahjong-actions-overlay {
    z-index: 8;
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  }

  .mahjong-3d-result-panel[data-result-kind="chombo"] .mahjong-3d-rdraw-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    overflow-wrap: anywhere;
  }

  .mahjong-3d-result-panel[data-result-kind="chombo"] .mahjong-3d-rscore {
    display: flex;
    flex-wrap: wrap;
    min-width: 0;
  }

  .mahjong-3d-result-panel[data-result-kind="chombo"] .mahjong-3d-rscore > span {
    min-width: 0;
  }

  .mahjong-wait-overlay {
    top: 8px;
    right: auto;
    bottom: auto;
    left: 8px;
    width: min(66%, 330px);
    max-height: 24%;
  }

  .mahjong-wait-overlay .mahjong-wait-heading {
    gap: 4px;
    font-size: 11px;
  }

  .mahjong-wait-overlay .mahjong-wait-tile {
    grid-template-columns: auto minmax(38px, auto);
    padding: 3px 5px 3px 3px;
  }

  .mahjong-wait-overlay .mahjong-wait-tile .mahjong-wait-face {
    width: 25px;
    height: 36px;
  }

  .mahjong-action-grid {
    display: grid;
    width: min(100%, 360px);
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mahjong-decision-stack,
  .mahjong-decision-banner {
    width: 100%;
  }

  .mahjong-decision-banner {
    grid-template-columns: 34px minmax(0, 1fr) 52px;
    padding: 6px;
  }

  .mahjong-decision-crest {
    width: 34px;
    height: 34px;
    font-size: 16px;
  }

  .mahjong-decision-clock {
    font-size: 18px;
  }

  .mahjong-action-grid button,
  .mahjong-riichi-toggle {
    width: 100%;
    min-width: 0;
    min-height: 46px;
  }

  .mahjong-command,
  .mahjong-riichi-toggle {
    min-height: 52px;
    grid-template-columns: 32px minmax(0, 1fr);
    padding: 6px 8px 6px 6px;
  }

  .mahjong-command-sigil {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }

  .mahjong-combination-panel {
    width: min(100%, 410px);
    max-height: 210px;
    overflow: auto;
  }

  .mahjong-combination-list {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 2px 2px 6px;
    scroll-snap-type: x proximity;
  }

  .mahjong-combination-option {
    flex: 0 0 auto;
    min-height: 62px;
    scroll-snap-align: center;
  }

  .mahjong-next-hand-control {
    display: grid;
    justify-items: stretch;
    text-align: center;
  }

  .mahjong-next-hand-control button {
    width: 100%;
  }

  .mahjong-hand-panel {
    padding: 8px;
  }

  .mahjong-wait-info {
    padding: 8px;
  }

  .mahjong-wait-list {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }

  .mahjong-wait-tile {
    flex: 0 0 auto;
  }

  .mahjong-final-row {
    grid-template-columns: 1fr;
  }

  .mahjong-final-row strong,
  .mahjong-final-row em {
    justify-self: start;
  }

  .mahjong-final-row small {
    white-space: normal;
  }

  .riichi-tile {
    width: 30px;
    height: 43px;
    font-size: 12px;
  }

  .play-action-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .game-settings-panel .control-grid,
  .room-action-group,
  .settings-action-group {
    grid-template-columns: 1fr;
  }

  .play-action-row button {
    width: 100%;
  }
}

.sudachi-surface .game-layout {
  grid-template-columns: minmax(520px, 1fr) minmax(280px, 0.34fr);
}

.sudachi-card {
  gap: 14px;
}

.sudachi-status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  /* Native light cards keep their own readable ink in every shell theme. */
  --text: #17202b;
  --muted: #687484;
}

.sudachi-stat,
.sudachi-meter {
  display: grid;
  gap: 3px;
  min-width: 0;
  min-height: 58px;
  border-radius: 8px;
  padding: 9px 10px;
  background: #f5f8f6;
}

.sudachi-stat span,
.sudachi-meter span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sudachi-stat strong,
.sudachi-meter strong {
  overflow: hidden;
  color: var(--text);
  font-size: 20px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sudachi-board {
  position: relative;
  width: 100%;
  min-height: 320px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid rgba(40, 57, 47, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0) 28%),
    linear-gradient(180deg, #f4eee3, #d9c5a8);
}

.sudachi-canvas,
.sudachi-3d-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.sudachi-canvas {
  cursor: crosshair;
  touch-action: none;
  transition: opacity 180ms ease, filter 180ms ease;
}

.sudachi-3d-canvas {
  touch-action: none;
}

.sudachi-canvas.is-dimmed {
  opacity: 0.18;
  filter: saturate(0.62);
}

.sudachi-mission {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 4;
  display: grid;
  min-width: min(420px, calc(100% - 48px));
  min-height: 72px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  padding: 0 18px;
  background: rgba(23, 32, 43, 0.76);
  color: #fff;
  font-size: 24px;
  font-weight: 900;
  text-align: center;
  transform: translate(-50%, -50%);
  transition: opacity 320ms ease, transform 320ms ease;
  pointer-events: none;
}

.sudachi-mission.is-fading {
  opacity: 0;
  transform: translate(-50%, -54%);
}

.sudachi-mission.is-hidden {
  display: none;
}

.sudachi-3d-panel {
  position: absolute;
  inset: 0;
  z-index: 3;
  background:
    radial-gradient(circle at 50% 34%, rgba(255, 255, 255, 0.54), rgba(255, 255, 255, 0.06) 38%, transparent 60%),
    linear-gradient(150deg, #dfe8e3, #aebfb9 48%, #879792);
}

.sudachi-3d-panel.is-orbit-ready .sudachi-3d-canvas {
  cursor: grab;
}

.sudachi-3d-panel.is-dragging .sudachi-3d-canvas {
  cursor: grabbing;
}

.sudachi-3d-panel.three-unavailable {
  display: grid;
  place-items: center;
  background: var(--surface-page);
}

.sudachi-final-result {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 5;
  display: grid;
  min-width: 132px;
  gap: 2px;
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.84);
  color: #17202b;
  box-shadow: 0 12px 26px rgba(23, 32, 43, 0.15);
  animation: sudachiResultPop 360ms cubic-bezier(0.16, 0.9, 0.22, 1.18);
  pointer-events: auto;
}

.sudachi-final-result span {
  color: #687484;
  font-size: 12px;
  font-weight: 850;
}

.sudachi-final-result strong {
  font-size: 28px;
  line-height: 1;
}

.sudachi-final-result small {
  color: #687484;
  font-size: 12px;
  font-weight: 800;
}

.sudachi-result-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
}

.sudachi-final-result button {
  min-width: 0;
  min-height: 32px;
  padding: 0 10px;
}

.sudachi-3d-status {
  position: absolute;
  right: 14px;
  bottom: 12px;
  z-index: 5;
  min-height: 30px;
  border-radius: 8px;
  padding: 6px 10px;
  background: rgba(23, 32, 43, 0.7);
  color: #fff;
  font-size: 13px;
  font-weight: 850;
  pointer-events: none;
}

@keyframes sudachiResultPop {
  0% {
    opacity: 0;
    transform: translateY(-8px) scale(0.94);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.sudachi-surface .result-line {
  margin: 0;
}

.sudachi-rank-controls {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.sudachi-rank-notice {
  min-height: 32px;
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.35;
}

.sudachi-rank-rows {
  display: grid;
  gap: 8px;
}

.sudachi-rank-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 0 8px;
  align-items: start;
  width: 100%;
  min-height: 58px;
  border: 1px solid rgba(35, 136, 95, 0.12);
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--surface-soft);
  color: inherit;
  box-shadow: 0 8px 18px rgba(25, 35, 55, 0.06);
  text-align: left;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
  will-change: transform;
}

.sudachi-rank-row:hover {
  border-color: rgba(36, 108, 186, 0.24);
  box-shadow: 0 10px 22px rgba(25, 35, 55, 0.09);
  transform: translateY(-1px);
}

.sudachi-rank-row.me {
  border-color: rgba(35, 136, 95, 0.46);
  background: #f0fbf4;
}

.sudachi-rank-row.perfect {
  border-color: rgba(185, 121, 25, 0.58);
  background:
    linear-gradient(135deg, rgba(255, 248, 217, 0.98), rgba(255, 232, 145, 0.9)),
    #fff2b8;
  box-shadow:
    0 10px 24px rgba(185, 121, 25, 0.16),
    0 0 0 1px rgba(255, 226, 130, 0.22);
}

.sudachi-rank-row.perfect.me {
  border-color: rgba(35, 136, 95, 0.76);
  background:
    linear-gradient(135deg, rgba(255, 249, 222, 0.98), rgba(255, 229, 119, 0.92)),
    #fff0a8;
  box-shadow:
    0 0 0 2px rgba(35, 136, 95, 0.3),
    0 12px 26px rgba(185, 121, 25, 0.18);
}

.sudachi-rank-row.is-updated {
  animation: sudachiRankPulse 880ms ease;
}

.sudachi-rank-place {
  grid-row: 1 / span 2;
  display: grid;
  width: 30px;
  height: 30px;
  margin-top: 2px;
  place-items: center;
  border-radius: 999px;
  background: color-mix(in srgb, var(--positive) 14%, var(--surface));
  color: var(--positive-text);
  font-size: 13px;
  font-weight: 900;
}

.sudachi-rank-row.perfect .sudachi-rank-place {
  background: #f4ce58;
  color: #704800;
}

.sudachi-rank-row.perfect.me .sudachi-rank-place {
  background: color-mix(in srgb, var(--positive) 14%, var(--surface));
  color: var(--positive-text);
  box-shadow: inset 0 0 0 2px rgba(185, 121, 25, 0.36);
}

.sudachi-rank-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: center;
  min-width: 0;
  min-height: 34px;
}

.sudachi-rank-name,
.sudachi-rank-row strong,
.sudachi-rank-separator,
.sudachi-rank-details span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sudachi-rank-name {
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
}

.sudachi-rank-separator {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.sudachi-rank-row strong {
  justify-self: end;
  /* Sits on var(--surface-soft), which flips dark; a hardcoded near-black went
     invisible in dark mode. Track the theme token like .sudachi-rank-name does. */
  color: var(--text);
  font-size: 15px;
}

.sudachi-rank-details {
  grid-column: 2;
  display: grid;
  gap: 4px;
  max-height: 0;
  margin-top: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-4px);
  transition:
    max-height 260ms ease,
    margin-top 260ms ease,
    opacity 200ms ease,
    transform 240ms ease;
}

.sudachi-rank-row.expanded .sudachi-rank-details {
  max-height: 96px;
  margin-top: 6px;
  opacity: 1;
  transform: translateY(0);
}

.sudachi-rank-details span {
  min-height: 23px;
  border-radius: 6px;
  padding: 4px 7px;
  background: rgba(36, 108, 186, 0.07);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.sudachi-rank-row.perfect .sudachi-rank-details span {
  background: rgba(122, 76, 0, 0.09);
  color: #75510d;
}

@keyframes sudachiRankPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(35, 136, 95, 0.32);
    transform: scale(0.98);
  }
  45% {
    box-shadow: 0 0 0 5px rgba(35, 136, 95, 0.12);
    transform: scale(1.02);
  }
  100% {
    box-shadow: 0 8px 18px rgba(25, 35, 55, 0.06);
    transform: scale(1);
  }
}

.sudachi-analysis {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.sudachi-analysis .panel-head {
  margin-bottom: 0;
}

.sudachi-distribution-canvas {
  display: block;
  width: 100%;
  height: 240px;
  border: 1px solid rgba(36, 108, 186, 0.12);
  border-radius: 8px;
  background: var(--surface-soft);
}

.sudachi-distribution-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.sudachi-distribution-stats span {
  display: grid;
  min-height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.sudachi-slice-table {
  display: grid;
  gap: 5px;
}

.sudachi-slice-row {
  display: grid;
  grid-template-columns: 42px repeat(3, minmax(0, 1fr));
  gap: 6px;
  align-items: center;
}

.sudachi-slice-row span {
  min-width: 0;
  border-radius: 8px;
  padding: 7px 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sudachi-slice-row.head span {
  background: var(--surface-soft);
  color: var(--muted);
}

.sudachi-slice-row.good span:first-child {
  background: color-mix(in srgb, var(--positive) 14%, var(--surface));
  color: var(--positive-text);
}

.sudachi-slice-row.ok span:first-child {
  background: #fff2d8;
  color: #805a12;
}

.sudachi-slice-row.bad span:first-child {
  background: #faecec;
  color: #7e2d2d;
}

@media (max-width: 1024px) {
  .sudachi-surface .game-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .sudachi-status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sudachi-board {
    min-height: 260px;
    aspect-ratio: 4 / 3;
  }

  .sudachi-mission {
    min-height: 64px;
    font-size: 20px;
  }

  .sudachi-distribution-stats {
    grid-template-columns: 1fr;
  }

  .sudachi-slice-row {
    grid-template-columns: 34px repeat(3, minmax(62px, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .mahjong-3d-automation-badge::before {
    animation: none;
  }

  .mahjong-3d-seat.current::after,
  .riichi-tile.reverse-joker-tile,
  .mahjong-command-feedback i,
  .mahjong-3d-result-panel.visible .mahjong-3d-result-row,
  .shop-catalog-grid,
  .shop-slot-list,
  .shop-slot-panel > .shop-catalog-grid {
    animation: none;
  }

  .mahjong-3d-event-label,
  .mahjong-3d-result-panel,
  .mahjong-3d-touch-hint,
  .mahjong-3d-recovery-badge,
  .mahjong-command-feedback,
  .shop-slot-panel,
  .shop-slot-chevron {
    transition-duration: 1ms;
  }
}

.shop-surface .game-layout {
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
}

.shop-board {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.shop-preview-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.82fr) minmax(280px, 1.18fr);
  gap: 16px;
  align-items: stretch;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface);
  color: var(--ink);
}

.shop-preview-copy {
  display: grid;
  align-content: center;
  gap: 10px;
  min-width: 0;
}

.shop-preview-copy h2,
.shop-card-copy h3 {
  margin: 0;
  overflow-wrap: anywhere;
  letter-spacing: 0;
}

.shop-preview-copy h2 {
  font-size: 26px;
  line-height: 1.15;
}

.shop-preview-copy p,
.shop-card-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.shop-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.shop-tag-interactive {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid rgba(31, 95, 66, 0.24);
  border-radius: 999px;
  padding: 3px 8px;
  background: color-mix(in srgb, var(--positive) 10%, var(--surface));
  color: var(--positive-text);
  font-size: 12px;
  font-weight: 900;
}

.shop-item-tags small {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
}

.shop-preview-actions,
.shop-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.shop-filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 4px;
  scrollbar-width: thin;
}

.shop-filter-tab {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 850;
  cursor: pointer;
}

.shop-filter-tab small {
  border-radius: 999px;
  padding: 2px 6px;
  background: #eef3f8;
  color: #1e3a5f;
  font-size: 11px;
  font-weight: 850;
}

.shop-filter-tab.active {
  border-color: rgba(36, 108, 186, 0.42);
  background: #eaf3ff;
  color: #174d8a;
  box-shadow: 0 0 0 2px rgba(36, 108, 186, 0.1);
}

.shop-preview-stage {
  display: grid;
  min-height: 226px;
  overflow: hidden;
  border: 1px solid rgba(25, 35, 55, 0.12);
  border-radius: 8px;
  background: linear-gradient(135deg, #eef3f8, #f8fafc);
}

.shop-mahjong-preview {
  display: grid;
  place-items: center;
  min-height: 226px;
  padding: 18px;
}

.shop-mahjong-table {
  position: relative;
  width: min(100%, 420px);
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 12px solid var(--shop-mj-rail, #543326);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 48%, color-mix(in srgb, var(--shop-mj-felt, #286655) 96%, white 8%), var(--shop-mj-felt, #286655) 64%, color-mix(in srgb, var(--shop-mj-felt, #286655) 72%, black 28%) 100%);
  box-shadow:
    inset 0 0 0 3px color-mix(in srgb, var(--shop-mj-brass, #c6a45c) 62%, transparent),
    inset 0 0 32px rgba(0, 0, 0, 0.2),
    0 16px 28px rgba(22, 34, 49, 0.16);
}

.shop-mahjong-table::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid color-mix(in srgb, var(--shop-mj-inlay, #d3b46b) 58%, transparent);
  border-radius: 8px;
  pointer-events: none;
}

.shop-mj-inlay {
  position: absolute;
  inset: 27%;
  z-index: 1;
  border: 1px solid color-mix(in srgb, var(--shop-mj-inlay, #d3b46b) 72%, transparent);
  border-radius: 8px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--shop-mj-center, #27383d) 78%, transparent), transparent),
    color-mix(in srgb, var(--shop-mj-center, #27383d) 68%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--shop-mj-center-edge, #d9c69a) 42%, transparent);
}

.shop-mj-seat {
  position: absolute;
  z-index: 2;
  display: grid;
  width: 34px;
  min-height: 32px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--shop-mj-brass, #c6a45c) 46%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--shop-mj-base, #654b37) 82%, white 8%);
  color: var(--shop-mj-center-edge, #d9c69a);
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
}

.shop-mj-seat small {
  color: color-mix(in srgb, var(--shop-mj-center-edge, #d9c69a) 74%, white 26%);
  font-size: 9px;
  font-weight: 800;
}

.shop-mj-seat.seat-east { left: 50%; top: 12px; transform: translateX(-50%); }
.shop-mj-seat.seat-south { right: 14px; top: 50%; transform: translateY(-50%); }
.shop-mj-seat.seat-west { left: 50%; bottom: 12px; transform: translateX(-50%); }
.shop-mj-seat.seat-north { left: 14px; top: 50%; transform: translateY(-50%); }

.shop-mj-tile-showcase {
  position: absolute;
  z-index: 3;
  display: flex;
  gap: clamp(4px, 1vw, 8px);
  align-items: flex-end;
  left: 50%;
  top: 52%;
  width: calc(100% - 96px);
  transform: translate(-50%, -50%);
  max-width: calc(100% - 96px);
}

.shop-mj-tile-canvas {
  display: block;
  flex: 1 1 0;
  min-width: 22px;
  max-width: 72px;
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 3 / 4;
  border-radius: 7px;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.22));
}

.shop-mj-tile-canvas:nth-child(2) {
  transform: translateY(-4px);
}

.shop-mj-tile-canvas:nth-child(6) {
  margin-left: clamp(2px, 0.8vw, 8px);
  transform: rotate(4deg);
}

.shop-mj-panel-sample {
  position: absolute;
  z-index: 4;
  right: 12px;
  bottom: 12px;
  display: grid;
  gap: 6px;
  width: min(42%, 164px);
}

.shop-mj-command-row {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.shop-mj-command,
.shop-mj-result-row {
  border: 1px solid color-mix(in srgb, var(--shop-mj-brass, #c6a45c) 46%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--shop-mj-base, #654b37) 82%, transparent);
  color: color-mix(in srgb, var(--shop-mj-center-edge, #d9c69a) 86%, white 14%);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
}

.shop-mj-command {
  min-width: 42px;
  padding: 5px 7px;
  font-size: 11px;
  font-weight: 850;
  text-align: center;
}

.shop-mj-command.is-primary {
  background: color-mix(in srgb, var(--shop-mj-brass, #c6a45c) 42%, var(--shop-mj-base, #654b37));
  color: #151515;
}

.shop-mj-result-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 800;
}

.shop-center-mark {
  position: absolute;
  z-index: 4;
  left: 12px;
  bottom: 12px;
  min-width: 44px;
  padding: 6px 8px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--shop-mj-center-edge, #d9c69a) 86%, white 14%);
  color: color-mix(in srgb, var(--shop-mj-center, #27383d) 82%, black 18%);
  font-size: 13px;
  font-weight: 850;
  text-align: center;
}

.shop-generic-preview {
  display: grid;
  place-content: center;
  gap: 8px;
  min-height: 226px;
  text-align: center;
}

.shop-generic-icon {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  justify-self: center;
  border: 1px solid rgba(36, 108, 186, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(36, 108, 186, 0.14), rgba(31, 95, 66, 0.12)),
    #fff;
  color: #174d8a;
  font-size: 18px;
  font-weight: 900;
}

.shop-lounge-preview {
  display: grid;
  gap: 8px;
  min-height: 226px;
  place-content: center;
  text-align: center;
}

.shop-lounge-preview small {
  color: var(--muted);
}

.shop-lounge-preview img {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
  border-radius: 10px;
}

.shop-stock-bar,
.shop-voice-samples > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.shop-stock-bar { margin: 12px 0 16px; }
.shop-stock-tab {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 12px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.shop-stock-tab[aria-pressed="true"] {
  border-color: #3278c8;
  box-shadow: inset 0 -2px #3278c8;
  font-weight: 700;
}
.shop-stock-tab small { margin-left: 4px; }
.shop-voice-samples {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  max-width: 440px;
}
.shop-voice-samples audio { width: 100%; min-width: 0; }
.shop-voice-samples small { color: var(--muted); min-height: 2.5em; }
.shop-skin-dialog {
  box-sizing: border-box;
  width: min(1100px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  background: var(--panel, white);
  color: var(--text);
}
.shop-skin-dialog::backdrop { background: rgba(12, 20, 34, 0.65); }
.shop-skin-dialog header,
.shop-skin-dialog footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.shop-skin-dialog h2 { margin: 0; font-size: 1.25rem; }
.shop-skin-dialog [data-preview-status] { min-height: 2.5em; }
.shop-skin-dialog .shop-skin-table { width: 100%; height: min(60dvh, 580px); min-height: 220px; }
.shop-skin-dialog footer { margin-top: 14px; }
.shop-skin-dialog footer small { color: var(--muted); }

.shop-onecard-preview {
  display: grid;
  min-height: 226px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background:
    radial-gradient(circle at 50% 34%, rgba(255, 255, 255, 0.76), transparent 30%),
    linear-gradient(145deg, #edf6f2, #dfe7f0);
}

.shop-onecard-fan {
  position: relative;
  width: 186px;
  height: 150px;
}

.shop-onecard-fan .shop-onecard-card-back {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: 50% 86%;
}

.shop-onecard-fan .shop-onecard-card-back:nth-child(1) {
  transform: translate(-78%, -50%) rotate(-16deg);
}

.shop-onecard-fan .shop-onecard-card-back:nth-child(2) {
  transform: translate(-50%, -56%) rotate(0deg);
}

.shop-onecard-fan .shop-onecard-card-back:nth-child(3) {
  transform: translate(-22%, -50%) rotate(16deg);
}

.shop-onecard-card-back,
.shop-onecard-face-card {
  display: grid;
  width: 74px;
  height: 104px;
  place-items: center;
  border: 4px solid var(--onecard-back-stroke, #d6b15c);
  border-radius: 8px;
  background: var(--onecard-back-fill, #232a35);
  box-shadow: 0 14px 24px rgba(15, 23, 42, 0.22);
  color: var(--onecard-back-text, #f7ead0);
  font-size: 13px;
  font-weight: 950;
}

.shop-onecard-card-back i {
  position: absolute;
  inset: 20px 12px;
  border: 3px solid var(--onecard-back-line, rgba(255, 255, 255, 0.68));
  border-radius: 8px;
  transform: rotate(45deg);
}

.shop-onecard-card-back b {
  position: relative;
  z-index: 1;
}

canvas.shop-onecard-card-back {
  display: block;
  border: 0;
  background: transparent;
  object-fit: fill;
}

[data-onecard-back="midnight"] {
  --onecard-back-fill: #101827;
  --onecard-back-stroke: #78dce8;
  --onecard-back-line: rgba(120, 220, 232, 0.78);
  --onecard-back-text: #d8fbff;
}

[data-onecard-back="candy"] {
  --onecard-back-fill: #fff2f7;
  --onecard-back-stroke: #ed7ea8;
  --onecard-back-line: rgba(91, 202, 178, 0.74);
  --onecard-back-text: #b62d61;
}

[data-onecard-back="hanafuda"] {
  --onecard-back-fill: #251019;
  --onecard-back-stroke: #d8a044;
  --onecard-back-line: rgba(241, 216, 148, 0.7);
  --onecard-back-text: #f3d78d;
}

[data-onecard-back="pixel"] {
  --onecard-back-fill: #17202e;
  --onecard-back-stroke: #8be26a;
  --onecard-back-line: rgba(255, 255, 255, 0.72);
  --onecard-back-text: #e9f9da;
}

[data-onecard-back="constellation"] {
  --onecard-back-fill: #0d1530;
  --onecard-back-stroke: #8fa8e8;
  --onecard-back-line: rgba(190, 205, 255, 0.62);
  --onecard-back-text: #e6ecff;
}

[data-onecard-back="constellation"] .shop-onecard-card-back,
.shop-onecard-card-back[data-onecard-back="constellation"] {
  background:
    radial-gradient(circle at 24% 22%, rgba(242, 217, 140, 0.9) 0 2px, transparent 3px),
    radial-gradient(circle at 66% 34%, rgba(242, 217, 140, 0.8) 0 2px, transparent 3px),
    radial-gradient(circle at 42% 58%, rgba(242, 217, 140, 0.85) 0 2px, transparent 3px),
    radial-gradient(circle at 76% 74%, rgba(242, 217, 140, 0.7) 0 1.6px, transparent 2.6px),
    radial-gradient(circle at 30% 82%, rgba(190, 205, 255, 0.7) 0 1.4px, transparent 2.4px),
    var(--onecard-back-fill);
}

.shop-onecard-table-sample {
  position: relative;
  width: min(100%, 300px);
  aspect-ratio: 1.38;
  border: 10px solid var(--onecard-felt-rim, #b58a46);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--onecard-felt, #194942) 78%, white 18%), var(--onecard-felt, #194942) 68%),
    var(--onecard-felt, #194942);
  box-shadow: inset 0 0 0 4px color-mix(in srgb, var(--onecard-felt-rim, #b58a46) 28%, transparent), 0 18px 28px rgba(15, 23, 42, 0.2);
}

[data-onecard-felt="arcade"] {
  --onecard-felt: #164d66;
  --onecard-felt-rim: #2bb8d6;
}

[data-onecard-felt="velvet"] {
  --onecard-felt: #6a1f36;
  --onecard-felt-rim: #d89a50;
}

[data-onecard-felt="paper"] {
  --onecard-felt: #d7ded5;
  --onecard-felt-rim: #6e8791;
}

[data-onecard-felt="constellation"] {
  --onecard-felt: #101c3d;
  --onecard-felt-rim: #8fa8e8;
}

[data-onecard-felt="constellation"] .shop-onecard-table-sample {
  background:
    radial-gradient(circle at 30% 28%, rgba(242, 217, 140, 0.9) 0 2px, transparent 3px),
    radial-gradient(circle at 58% 46%, rgba(242, 217, 140, 0.8) 0 2px, transparent 3px),
    radial-gradient(circle at 44% 70%, rgba(232, 238, 255, 0.8) 0 1.6px, transparent 2.6px),
    radial-gradient(circle at 72% 30%, rgba(232, 238, 255, 0.7) 0 1.4px, transparent 2.4px),
    radial-gradient(circle at 24% 56%, rgba(232, 238, 255, 0.6) 0 1.4px, transparent 2.4px),
    radial-gradient(circle at 66% 66%, rgba(96, 80, 168, 0.3), transparent 40%),
    radial-gradient(circle at 36% 40%, rgba(64, 120, 176, 0.26), transparent 44%),
    var(--onecard-felt);
}

.shop-onecard-seat {
  position: absolute;
  display: grid;
  min-width: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 999px;
  padding: 4px 7px;
  background: rgba(15, 23, 42, 0.68);
  color: #fff;
  font-size: 11px;
  font-weight: 850;
}

.shop-onecard-seat.seat-top {
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
}

.shop-onecard-seat.seat-right {
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.shop-onecard-seat.seat-bottom {
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
}

.shop-onecard-seat.seat-left {
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.shop-onecard-center-pile {
  position: absolute;
  left: 50%;
  top: 50%;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translate(-50%, -50%) rotate(-6deg);
}

.shop-onecard-table-sample .shop-onecard-card-back,
.shop-onecard-face-card {
  width: 46px;
  height: 64px;
  border-width: 3px;
  font-size: 10px;
}

.shop-onecard-table-sample .shop-onecard-card-back i {
  inset: 13px 8px;
  border-width: 2px;
}

.shop-onecard-face-card {
  background: #fffefa;
  color: #23895b;
  font-size: 34px;
}

.shop-card-preview .shop-onecard-preview {
  min-height: 142px;
  padding: 10px;
}

.shop-voice-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  height: 100%;
  padding: 8px;
}

.shop-voice-preview img {
  max-width: 100%;
  max-height: 168px;
  object-fit: contain;
}

.shop-voice-credit {
  font-size: 0.62rem;
  line-height: 1.35;
  opacity: 0.6;
  text-align: center;
}

.shop-card-preview .shop-onecard-fan {
  transform: scale(0.78);
}

.shop-card-preview .shop-onecard-seat {
  display: none;
}

.shop-mj-effect-preview {
  display: grid;
  min-height: 226px;
  place-items: center;
  gap: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.72), transparent 32%),
    linear-gradient(145deg, #eef5f3, #e7edf4);
  text-align: center;
}

.shop-mj-effect-preview strong {
  position: relative;
  z-index: 1;
}

/* 수묵 파문(felt_ripple) 미리보기: 먹의 동심원. */
.shop-mj-ripple-preview {
  position: relative;
  display: block;
  width: 132px;
  height: 132px;
}

.shop-mj-ripple-preview i {
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(28, 27, 24, 0.4);
  animation: shop-mj-ripple-loop 3s ease-out infinite;
}

.shop-mj-ripple-preview i:nth-child(1) { width: 44px; height: 44px; }
.shop-mj-ripple-preview i:nth-child(2) { width: 84px; height: 84px; border-color: rgba(28, 27, 24, 0.26); animation-delay: 0.28s; }
.shop-mj-ripple-preview i:nth-child(3) { width: 124px; height: 124px; border-color: rgba(28, 27, 24, 0.14); animation-delay: 0.56s; }

/* 수묵 파문: 먹빛 사색 동심원(먹·남·주). */
[data-mj-effect-variant="ripple_ink"] .shop-mj-ripple-preview i:nth-child(1) { border-color: rgba(28, 27, 24, 0.62); }
[data-mj-effect-variant="ripple_ink"] .shop-mj-ripple-preview i:nth-child(2) { border-color: rgba(39, 75, 138, 0.44); }
[data-mj-effect-variant="ripple_ink"] .shop-mj-ripple-preview i:nth-child(3) { border-color: rgba(158, 43, 37, 0.32); }

/* 기본(파문 없음): 옅은 단일 번짐만. */
[data-mj-effect-variant="ripple_none"] .shop-mj-ripple-preview i:nth-child(1) {
  background: rgba(28, 27, 24, 0.14);
  border-color: transparent;
}
[data-mj-effect-variant="ripple_none"] .shop-mj-ripple-preview i:nth-child(2),
[data-mj-effect-variant="ripple_none"] .shop-mj-ripple-preview i:nth-child(3) { display: none; }

.shop-mj-effect-stick {
  position: relative;
  display: block;
  width: 172px;
  height: 22px;
  border: 2px solid rgba(50, 45, 35, 0.16);
  border-radius: 999px;
  background: #f4efe0;
  box-shadow: 0 12px 20px rgba(15, 23, 42, 0.18);
}

.shop-mj-effect-stick i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #d23b32;
  transform: translate(-50%, -50%);
}

[data-mj-effect-variant="riichi_jade"] .shop-mj-effect-stick,
[data-mj-effect-variant="jade"] .shop-mj-effect-stick {
  background: #c8f0d8;
}

[data-mj-effect-variant="riichi_jade"] .shop-mj-effect-stick i,
[data-mj-effect-variant="jade"] .shop-mj-effect-stick i {
  background: #d89f36;
}

[data-mj-effect-variant="riichi_sapphire"] .shop-mj-effect-stick,
[data-mj-effect-variant="sapphire"] .shop-mj-effect-stick {
  background: #c4dcf4;
}

[data-mj-effect-variant="riichi_sapphire"] .shop-mj-effect-stick i,
[data-mj-effect-variant="sapphire"] .shop-mj-effect-stick i {
  background: #2b5aa8;
}

/* 화료 세리머니 미리보기: 인게임 mj-cere-* 마크업/키프레임을 미니 무대에서 그대로 재생한다.
   (좌표 변수만 app.js shopCeremonyMarkupHtml이 무대 크기에 맞춰 축소해 준다.) */
.shop-cere-stage {
  position: relative;
  display: block;
  width: min(100%, 232px);
  height: 150px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background:
    radial-gradient(circle at 50% 38%, rgba(37, 92, 71, 0.95), rgba(17, 49, 40, 0.98) 74%),
    #113128;
  box-shadow: 0 16px 28px rgba(15, 23, 42, 0.2);
}

.shop-cere-stage .mahjong-win-ceremony {
  z-index: 1;
}

/* 무대색만 연출 분위기에 맞춘다(등불·뇌우 = 어두운 하늘, 먹 붓글씨 = 한지, 벚꽃 = 밤 벚나무). */
[data-mj-effect-variant="ceremony_lantern"] .shop-cere-stage {
  background: linear-gradient(180deg, #241009, #47231a);
}

[data-mj-effect-variant="ceremony_sakura"] .shop-cere-stage {
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 199, 214, 0.2), transparent 60%),
    linear-gradient(180deg, #2b1420, #3c2231);
}

[data-mj-effect-variant="ceremony_ink"] .shop-cere-stage {
  border-color: rgba(50, 45, 35, 0.2);
  background: #f4efe4;
}

[data-mj-effect-variant="ceremony_storm"] .shop-cere-stage {
  background: linear-gradient(180deg, #10141f, #1c2537);
}

.shop-preview-stage.is-shop-preview-playing .shop-mj-ripple-preview i {
  animation: shop-mj-ripple-replay 1.2s ease-out 1;
}

.shop-preview-stage.is-shop-preview-playing .shop-mj-ripple-preview i:nth-child(2) {
  animation-delay: 0.16s;
}

.shop-preview-stage.is-shop-preview-playing .shop-mj-ripple-preview i:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes shop-mj-ripple-loop {
  0%, 64%, 100% { opacity: 0.22; transform: translate(-50%, -50%) scale(0.86); }
  82% { opacity: 0.72; transform: translate(-50%, -50%) scale(1.05); }
}

@keyframes shop-mj-ripple-replay {
  0% { opacity: 0.78; transform: translate(-50%, -50%) scale(0.44); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.36); }
}

@media (prefers-reduced-motion: reduce) {
  .shop-mj-ripple-preview i {
    animation: none !important;
  }
}

.shop-card-preview .shop-mj-effect-preview {
  min-height: 142px;
  padding: 10px;
}

.shop-card-preview .shop-mj-effect-stick {
  width: 126px;
}

.shop-yacht-preview {
  display: grid;
  min-height: 226px;
  place-items: center;
  gap: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: linear-gradient(145deg, #edf5f1, #e4ebf3);
  text-align: center;
}

.shop-yacht-tray-sample {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: min(100%, 270px);
  min-height: 150px;
  border: 10px solid var(--shop-yacht-rail, #8a6a4d);
  border-radius: 8px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--shop-yacht-save, #23624f) 86%, white 10%) 0 34%, var(--shop-yacht-roll, #17424d) 34%),
    var(--shop-yacht-felt, #173f3d);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.12), 0 16px 26px rgba(15, 23, 42, 0.18);
}

.shop-yacht-die-sample {
  position: relative;
  display: grid;
  width: 58px;
  height: 58px;
  grid-template: repeat(3, 8px) / repeat(3, 8px);
  place-content: space-between;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  background: var(--shop-yacht-die, #f8f9fb);
  box-shadow: 0 10px 16px rgba(15, 23, 42, 0.2);
}

.shop-yacht-die-sample i {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--shop-yacht-pip, #151a22);
}

.shop-yacht-die-sample.value-1 i { grid-area: 2 / 2; }
.shop-yacht-die-sample.value-5 i:nth-child(1) { grid-area: 1 / 1; }
.shop-yacht-die-sample.value-5 i:nth-child(2) { grid-area: 1 / 3; }
.shop-yacht-die-sample.value-5 i:nth-child(3) { grid-area: 2 / 2; }
.shop-yacht-die-sample.value-5 i:nth-child(4) { grid-area: 3 / 1; }
.shop-yacht-die-sample.value-5 i:nth-child(5) { grid-area: 3 / 3; }
.shop-yacht-die-sample.value-6 i:nth-child(1) { grid-area: 1 / 1; }
.shop-yacht-die-sample.value-6 i:nth-child(2) { grid-area: 1 / 3; }
.shop-yacht-die-sample.value-6 i:nth-child(3) { grid-area: 2 / 1; }
.shop-yacht-die-sample.value-6 i:nth-child(4) { grid-area: 2 / 3; }
.shop-yacht-die-sample.value-6 i:nth-child(5) { grid-area: 3 / 1; }
.shop-yacht-die-sample.value-6 i:nth-child(6) { grid-area: 3 / 3; }

[data-yacht-variant="neon"] {
  --shop-yacht-die: #151a22;
  --shop-yacht-pip: #78dce8;
}

[data-yacht-variant="ivory"] {
  --shop-yacht-die: #f1e3c6;
  --shop-yacht-pip: #b9363e;
}

[data-yacht-variant="cosmos"] {
  --shop-yacht-die: #1a1440;
  --shop-yacht-pip: #cfe4ff;
}

[data-yacht-variant="cosmos"] .shop-yacht-die-sample {
  box-shadow:
    0 14px 22px rgba(12, 10, 36, 0.4),
    inset 0 0 18px rgba(127, 157, 255, 0.35);
}

[data-yacht-variant="cosmos"] .shop-yacht-die-sample i {
  box-shadow: 0 0 8px rgba(159, 183, 255, 0.85);
}

[data-yacht-variant="navy"] {
  --shop-yacht-felt: #102a3a;
  --shop-yacht-save: #1b4e62;
  --shop-yacht-roll: #142d4a;
  --shop-yacht-rail: #b58a46;
}

.shop-card-preview .shop-yacht-preview {
  min-height: 142px;
  padding: 10px;
}

.shop-card-preview .shop-yacht-tray-sample {
  min-height: 100px;
  transform: scale(0.82);
}

.shop-yut-preview {
  display: grid;
  min-height: 226px;
  place-items: center;
  gap: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: linear-gradient(145deg, #f2f4ef, #e6edf2);
  text-align: center;
}

.shop-yut-board-sample {
  position: relative;
  width: min(100%, 230px);
  aspect-ratio: 1;
  border: 8px solid var(--shop-yut-board-rail, #8f6a42);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 50%, transparent 0 11%, var(--shop-yut-path, #d5b56f) 12% 14%, transparent 15%),
    linear-gradient(45deg, transparent 47%, var(--shop-yut-path, #d5b56f) 48% 52%, transparent 53%),
    linear-gradient(-45deg, transparent 47%, var(--shop-yut-path, #d5b56f) 48% 52%, transparent 53%),
    var(--shop-yut-board, #f1dfb8);
  box-shadow: 0 16px 26px rgba(15, 23, 42, 0.18);
}

.shop-yut-stick-sample {
  position: absolute;
  left: 24px;
  top: 28px;
  width: 28px;
  height: 104px;
  border-radius: 999px;
  background: var(--shop-yut-stick, #c9964d);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.16);
  transform: rotate(-22deg);
}

.shop-yut-stick-sample::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 16px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--shop-yut-mark, #51331e);
  transform: translateX(-50%);
}

.shop-yut-piece-sample {
  position: absolute;
  right: 42px;
  bottom: 46px;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--shop-yut-piece, #df5b5b);
  box-shadow: inset 0 -10px rgba(0, 0, 0, 0.14), 0 10px 18px rgba(15, 23, 42, 0.22);
}

.shop-yut-node-sample {
  position: absolute;
  right: 38px;
  top: 38px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--shop-yut-path, #d5b56f);
  box-shadow: -72px 0 var(--shop-yut-path, #d5b56f), -36px 60px var(--shop-yut-path, #d5b56f);
}

[data-yut-variant="flower"] {
  --shop-yut-piece: #e86b9a;
}

[data-yut-variant="obsidian"] {
  --shop-yut-stick: #242025;
  --shop-yut-mark: #d8a044;
}

[data-yut-variant="midnight"] {
  --shop-yut-board: #172033;
  --shop-yut-board-rail: #475a7a;
  --shop-yut-path: #78dce8;
}

[data-yut-variant="pearl"] {
  --shop-yut-piece: #cfdeea;
}

[data-yut-variant="dancheong"] {
  --shop-yut-stick: #2f8f6d;
  --shop-yut-mark: #2f5fae;
}

[data-yut-variant="hanji"] {
  --shop-yut-board: #f6f1e3;
  --shop-yut-board-rail: #8a6b4a;
  --shop-yut-path: #5c4a33;
}

.shop-card-preview .shop-yut-preview {
  min-height: 142px;
  padding: 10px;
}

.shop-card-preview .shop-yut-board-sample {
  transform: scale(0.78);
}

.shop-drawing-preview {
  display: grid;
  min-height: 226px;
  place-items: center;
  gap: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: linear-gradient(145deg, #f4f8fb, #e7eef4);
  text-align: center;
}

.shop-drawing-paper-sample {
  position: relative;
  width: min(100%, 250px);
  min-height: 150px;
  border: 1px solid rgba(36, 48, 68, 0.16);
  border-radius: 8px;
  background: var(--shop-drawing-paper, #fbfcf9);
  box-shadow: 0 16px 26px rgba(15, 23, 42, 0.14);
}

.shop-drawing-stroke-sample {
  position: absolute;
  left: 34px;
  top: 74px;
  width: 170px;
  height: 36px;
  border-top: 10px solid #246cba;
  border-radius: 50%;
  transform: rotate(-8deg);
}

[data-drawing-variant="grid"] .shop-drawing-paper-sample {
  --shop-drawing-paper: #f7fbff;
  background-image:
    linear-gradient(rgba(36, 108, 186, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(36, 108, 186, 0.08) 1px, transparent 1px);
  background-size: 18px 18px;
}

/* 밤하늘 도화지: 어두운 바탕+별 — 밝은 획이 돋보인다 */
[data-drawing-variant="night"] .shop-drawing-paper-sample {
  --shop-drawing-paper: #101a30;
  background-image:
    radial-gradient(circle 1.5px at 18% 24%, rgba(232, 240, 255, 0.9) 0 1.5px, transparent 2px),
    radial-gradient(circle 1px at 62% 14%, rgba(232, 240, 255, 0.7) 0 1px, transparent 1.5px),
    radial-gradient(circle 1px at 84% 42%, rgba(232, 240, 255, 0.55) 0 1px, transparent 1.5px),
    radial-gradient(circle 1.5px at 38% 66%, rgba(232, 240, 255, 0.8) 0 1.5px, transparent 2px),
    radial-gradient(circle 1px at 74% 82%, rgba(232, 240, 255, 0.6) 0 1px, transparent 1.5px),
    radial-gradient(circle 1px at 10% 78%, rgba(232, 240, 255, 0.5) 0 1px, transparent 1.5px);
}

[data-drawing-variant="night"] .shop-drawing-stroke-sample {
  border-top-color: #8fc1ff;
}

/* 칠판 도화지: 짙은 녹판 — 어두운 획은 분필 톤으로 자동 보정 */
[data-drawing-variant="chalkboard"] .shop-drawing-paper-sample {
  --shop-drawing-paper: #234534;
  background-image: linear-gradient(165deg, rgba(226, 232, 220, 0.05), transparent 45%, rgba(226, 232, 220, 0.03));
}

[data-drawing-variant="chalkboard"] .shop-drawing-stroke-sample {
  border-top-color: #f0ecd8;
  filter: blur(0.3px);
  opacity: 0.92;
}

/* 한지 도화지: 섬유 결이 비치는 따뜻한 바탕 */
[data-drawing-variant="hanji"] .shop-drawing-paper-sample {
  --shop-drawing-paper: #f6f1e3;
  background-image:
    repeating-linear-gradient(23deg, rgba(164, 142, 106, 0.07) 0 1px, transparent 1px 14px),
    repeating-linear-gradient(-31deg, rgba(164, 142, 106, 0.05) 0 1px, transparent 1px 19px);
}

[data-drawing-variant="soft"] .shop-drawing-stroke-sample {
  filter: drop-shadow(0 0 8px rgba(36, 108, 186, 0.48));
  opacity: 0.88;
}

/* 에어브러시(소프트 브러시): 가장자리가 스며드는 부드러운 획 */
[data-drawing-variant="airbrush"] .shop-drawing-stroke-sample {
  filter: blur(3px);
  opacity: 0.8;
}

/* 스프레이: 잔점 분사 획 */
[data-drawing-variant="spray"] .shop-drawing-stroke-sample {
  border-top-style: dotted;
  filter: blur(0.4px);
  opacity: 0.85;
}

/* 픽셀: 격자 스냅 각진 획 */
[data-drawing-variant="pixel"] .shop-drawing-stroke-sample {
  border-top-style: dashed;
  border-radius: 0;
}

/* 크레용: 결이 살아 있는 거친 질감 획 */
[data-drawing-variant="crayon"] .shop-drawing-stroke-sample {
  opacity: 0.92;
  -webkit-mask-image: repeating-linear-gradient(48deg, rgba(0, 0, 0, 0.95) 0 5px, rgba(0, 0, 0, 0.35) 5px 7px);
  mask-image: repeating-linear-gradient(48deg, rgba(0, 0, 0, 0.95) 0 5px, rgba(0, 0, 0, 0.35) 5px 7px);
}

/* 캘리그래피: 속도 따라 굵기가 변하는 붓획(굵기 테이퍼 실루엣) */
[data-drawing-variant="calligraphy"] .shop-drawing-stroke-sample {
  border-top: none;
  height: 16px;
  background: #246cba;
  clip-path: polygon(0 62%, 10% 34%, 42% 6%, 76% 18%, 100% 46%, 76% 66%, 42% 84%, 10% 70%);
}

.shop-card-preview .shop-drawing-preview {
  min-height: 142px;
  padding: 10px;
}

.shop-card-preview .shop-drawing-paper-sample {
  min-height: 100px;
  transform: scale(0.82);
}

.shop-bundle-preview {
  position: relative;
  display: grid;
  min-height: 226px;
  place-items: center;
  gap: 10px;
  overflow: hidden;
  padding: 18px;
  background:
    radial-gradient(circle at 18% 16%, rgba(36, 108, 186, 0.12), transparent 32%),
    linear-gradient(145deg, #f7f4ee, #eef5f6);
  text-align: center;
}

.shop-bundle-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  border: 1px solid rgba(36, 108, 186, 0.26);
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(255, 255, 255, 0.84);
  color: #174d8a;
  font-size: 12px;
  font-weight: 900;
}

.shop-bundle-components {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 420px);
  margin-top: 20px;
}

.shop-bundle-component {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
  border: 1px solid rgba(25, 35, 55, 0.1);
  border-radius: 8px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.72);
  text-align: left;
}

.shop-bundle-component.is-owned {
  border-color: rgba(31, 95, 66, 0.28);
  background: rgba(233, 246, 239, 0.84);
}

.shop-bundle-component-thumb {
  overflow: hidden;
  border-radius: 8px;
}

.shop-bundle-component-thumb .shop-preview-stage,
.shop-bundle-component-thumb .shop-mahjong-preview,
.shop-bundle-component-thumb .shop-generic-preview,
.shop-bundle-component-thumb .shop-onecard-preview,
.shop-bundle-component-thumb .shop-mj-effect-preview,
.shop-bundle-component-thumb .shop-yacht-preview,
.shop-bundle-component-thumb .shop-yut-preview,
.shop-bundle-component-thumb .shop-drawing-preview {
  min-height: 58px;
  border-radius: 8px;
  padding: 4px;
}

.shop-bundle-component-thumb strong,
.shop-bundle-component-thumb .shop-mj-panel-sample,
.shop-bundle-component-thumb .shop-center-mark,
.shop-bundle-component-thumb .shop-onecard-seat {
  display: none;
}

.shop-bundle-component-thumb .shop-mj-tile-showcase {
  width: calc(100% - 12px);
  max-width: calc(100% - 12px);
}

.shop-bundle-component-thumb .shop-mj-seat {
  display: none;
}

.shop-bundle-component-thumb .shop-onecard-fan,
.shop-bundle-component-thumb .shop-yacht-tray-sample,
.shop-bundle-component-thumb .shop-yut-board-sample,
.shop-bundle-component-thumb .shop-drawing-paper-sample,
.shop-bundle-component-thumb .shop-mj-ripple-preview,
.shop-bundle-component-thumb .shop-cere-stage,
.shop-bundle-component-thumb .shop-mj-effect-stick {
  transform: scale(0.44);
}

.shop-bundle-component-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.shop-bundle-component-copy strong,
.shop-bundle-component-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shop-bundle-component-copy strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.shop-bundle-component-copy small,
.shop-bundle-summary small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.shop-bundle-summary {
  display: grid;
  gap: 4px;
}

.shop-bundle-stack {
  position: relative;
  width: min(100%, 220px);
  height: 118px;
}

.shop-bundle-token {
  position: absolute;
  left: calc(24px + var(--bundle-token-index) * 36px);
  top: calc(26px + (var(--bundle-token-index) % 2) * 20px);
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  border: 1px solid rgba(25, 35, 55, 0.12);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 14px 24px rgba(15, 23, 42, 0.14);
  font-size: 16px;
  font-weight: 900;
  transform: rotate(calc((var(--bundle-token-index) - 1.5) * 5deg));
}

.shop-bundle-preview small {
  color: var(--muted);
  font-weight: 850;
}

.shop-card-preview .shop-bundle-preview {
  min-height: 142px;
  padding: 10px;
}

.shop-card-preview .shop-bundle-components {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 16px;
}

.shop-card-preview .shop-bundle-component {
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 5px;
}

.shop-card-preview .shop-bundle-component-thumb .shop-preview-stage,
.shop-card-preview .shop-bundle-component-thumb .shop-mahjong-preview,
.shop-card-preview .shop-bundle-component-thumb .shop-generic-preview,
.shop-card-preview .shop-bundle-component-thumb .shop-onecard-preview,
.shop-card-preview .shop-bundle-component-thumb .shop-mj-effect-preview,
.shop-card-preview .shop-bundle-component-thumb .shop-yacht-preview,
.shop-card-preview .shop-bundle-component-thumb .shop-yut-preview,
.shop-card-preview .shop-bundle-component-thumb .shop-drawing-preview {
  min-height: 42px;
}

.shop-card-preview .shop-bundle-component-copy small,
.shop-card-preview .shop-bundle-summary small {
  display: none;
}

.shop-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  animation: shop-catalog-enter 0.2s ease both;
}

.shop-slot-list {
  display: grid;
  gap: 10px;
  animation: shop-catalog-enter 0.2s ease both;
}

.shop-slot-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.shop-slot-panel[open] {
  border-color: rgba(36, 108, 186, 0.32);
  box-shadow: 0 10px 24px rgba(34, 49, 75, 0.08);
}

.shop-slot-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
}

.shop-slot-summary::-webkit-details-marker {
  display: none;
}

.shop-slot-title {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.shop-slot-name {
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
}

.shop-slot-equipped {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shop-slot-count {
  border-radius: 999px;
  padding: 5px 9px;
  background: #eef3f8;
  color: #1e3a5f;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.shop-slot-chevron {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 900;
  transition: transform 0.18s ease;
}

.shop-slot-panel[open] .shop-slot-chevron {
  transform: rotate(180deg);
}

.shop-slot-panel > .shop-catalog-grid {
  padding: 0 12px 12px;
  animation: shop-slot-open 0.2s ease both;
}

@keyframes shop-catalog-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shop-slot-open {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.shop-item-card {
  display: grid;
  grid-template-rows: auto minmax(108px, 1fr) auto;
  gap: 10px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface);
  color: var(--ink);
}

.shop-item-card.is-selected {
  border-color: rgba(36, 108, 186, 0.42);
  box-shadow: 0 0 0 2px rgba(36, 108, 186, 0.1);
}

.shop-card-preview {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.shop-card-preview .shop-preview-stage,
.shop-card-preview .shop-mahjong-preview,
.shop-card-preview .shop-generic-preview {
  min-height: 142px;
}

.shop-card-preview .shop-mahjong-preview {
  padding: 12px;
}

.shop-card-preview .shop-mahjong-table {
  border-width: 8px;
}

.shop-card-preview .shop-mj-seat,
.shop-card-preview .shop-mj-panel-sample,
.shop-card-preview .shop-center-mark {
  display: none;
}

.shop-card-preview .shop-mj-tile-showcase {
  width: calc(100% - 24px);
  max-width: calc(100% - 24px);
}

.shop-card-kind {
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
}

.shop-card-copy {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
}

.shop-card-copy h3 {
  font-size: 18px;
  line-height: 1.2;
}

.shop-card-copy p {
  display: -webkit-box;
  min-height: 42px;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.shop-card-actions {
  justify-content: space-between;
  min-height: 36px;
}

.shop-card-price {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 5px 10px;
  background: #eef3f8;
  color: #1e3a5f;
  font-size: 13px;
  font-weight: 850;
}

.shop-card-price.owned {
  background: color-mix(in srgb, var(--positive) 10%, var(--surface));
  color: var(--positive-text);
}

.shop-card-price.equipped {
  background: #e4f1ff;
  color: #174d8a;
}

.shop-card-price.pending {
  background: #f1f3f5;
  color: #667085;
}

.shop-card-price.free {
  background: #f3efe1;
  color: #6d4d16;
}

.shop-wallet {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
}

.shop-wallet span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.shop-wallet strong {
  color: var(--ink);
  font-size: 22px;
}

.shop-wallet-balance,
.shop-wallet-progress {
  display: grid;
  gap: 4px;
}

.shop-wallet-progress,
.shop-coin-guide {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.shop-wallet-progress strong {
  font-size: 18px;
}

.shop-coin-guide {
  color: var(--muted);
}

.shop-coin-guide summary {
  width: fit-content;
  cursor: pointer;
  color: var(--blue);
  font-size: 13px;
  font-weight: 850;
}

.shop-coin-guide p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.shop-purchase-modal {
  position: relative;
  display: grid;
  gap: 10px;
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.24);
}

.shop-purchase-modal h3,
.shop-purchase-modal p {
  margin: 0;
}

.shop-purchase-modal h3 {
  padding-right: 30px;
  font-size: 22px;
}

.shop-purchase-modal p {
  color: var(--muted);
  line-height: 1.45;
}

.shop-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}

.shop-modal-close:hover {
  border-color: color-mix(in srgb, var(--blue) 38%, var(--line));
  color: var(--blue);
}

.shop-purchase-summary {
  display: grid;
  gap: 8px;
  margin: 4px 0;
}

.shop-purchase-summary div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--soft);
}

.shop-purchase-summary dt,
.shop-purchase-summary dd {
  margin: 0;
}

.shop-purchase-summary dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.shop-purchase-summary dd {
  color: var(--ink);
  font-weight: 900;
}

.shop-purchase-summary .is-negative {
  color: #b42318;
}

.shop-modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.shop-empty {
  display: grid;
  min-height: 140px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 820px) {
  .shop-surface .game-layout,
  .shop-preview-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .shop-slot-summary {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .shop-slot-count {
    justify-self: start;
  }

  .shop-slot-chevron {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .shop-preview-panel .shop-mj-panel-sample {
    display: none;
  }

  .shop-preview-panel .shop-mj-tile-showcase {
    width: calc(100% - 42px);
    max-width: calc(100% - 42px);
  }
}

/* Shop browsing keeps the catalog visible; detail is a modal only on small screens. */
body.shop-active .stage { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main"; }
body.shop-active #contextToggle,
body.shop-active #contextPanel,
body.shop-active #contextOverlayBackdrop,
body.shop-active .mobile-dock [data-mobile-view="settings"] { display: none; }
body.shop-dialog-open { overflow: hidden; }
.shop-surface .game-main-panel { padding: clamp(12px, 2vw, 24px); border: 0; background: transparent; box-shadow: none; }
.shop-surface .shop-board { gap: 22px; }
.shop-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 24px; }
.shop-eyebrow { color: var(--blue); font-size: 12px; font-weight: 700; }
.shop-intro h1 { margin: 5px 0 8px; color: var(--ink); font-size: 34px; line-height: 1.1; letter-spacing: -0.04em; }
.shop-intro p { margin: 0; color: var(--muted); font-size: 14px; word-break: keep-all; }
.shop-header .shop-wallet { grid-template-columns: auto auto; gap: 8px 24px; padding: 0; border: 0; background: none; }
.shop-header .shop-wallet-progress { padding: 0; border: 0; }
.shop-header .shop-wallet-progress strong { font-size: 22px; }
.shop-header .shop-coin-guide { grid-column: 1 / -1; max-width: 290px; padding: 0; border: 0; text-align: right; font-size: 12px; }
.shop-header .shop-coin-guide summary { cursor: pointer; }
.shop-header .shop-coin-guide p { padding: 10px; border-radius: 10px; background: var(--surface); text-align: left; }
.shop-toolbar { min-width: 0; }
.shop-category-nav { display: flex; gap: 6px; min-width: 0; border-bottom: 1px solid var(--line); }
.shop-surface .shop-filter-bar { flex: 1; min-width: 0; gap: 6px; padding: 0; scrollbar-width: none; }
.shop-surface .shop-filter-tab { min-height: 44px; padding: 9px 12px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; box-shadow: none; color: var(--muted); font-weight: 650; }
.shop-surface .shop-filter-tab.active { border-bottom-color: var(--blue); color: var(--ink); font-weight: 800; }
.shop-surface .shop-filter-tab.is-empty:not(.active) { color: var(--muted); }
.shop-surface .shop-filter-tab small { padding: 0 2px; background: transparent; color: inherit; font-weight: 500; }
.shop-filter-next { flex: 0 0 38px; align-self: center; display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink); font-size: 24px; cursor: pointer; }
.shop-filter-next[hidden], .shop-notice[hidden] { display: none; }
.shop-toolbar-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 14px; }
.shop-surface .shop-stock-bar { margin: 0; gap: 3px; padding: 3px; border-radius: 10px; background: color-mix(in srgb, var(--ink) 5%, var(--surface)); }
.shop-surface .shop-stock-tab { min-height: 36px; padding: 7px 11px; border: 0; background: transparent; color: var(--muted); font-size: 13px; }
.shop-surface .shop-stock-tab[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px #00000012; }
.shop-surface #shopRefresh { min-height: 36px; padding: 7px 10px; background: transparent; color: var(--muted); font-size: 12px; box-shadow: none; }
.shop-browser { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 340px); gap: 24px; align-items: start; }
.shop-browser.is-empty { grid-template-columns: minmax(0, 1fr); }
.shop-products { min-width: 0; }
.shop-results-heading { display: flex; align-items: baseline; gap: 8px; margin-bottom: 14px; }
.shop-results-heading h2 { margin: 0; color: var(--ink); font-size: 15px; font-weight: 750; }
.shop-results-heading > span { color: var(--muted); font-size: 13px; }
.shop-results-heading small { margin-left: auto; color: var(--muted); font-size: 12px; }
.shop-surface .shop-catalog-grid { grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 16px; }
.shop-surface .shop-item-card { display: block; padding: 0; overflow: hidden; border-radius: 14px; background: var(--surface); box-shadow: none; transition: border-color .15s, box-shadow .15s; }
.shop-surface .shop-item-card:hover { border-color: color-mix(in srgb, var(--blue) 55%, var(--line)); }
.shop-surface .shop-item-card.is-selected { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.shop-surface .shop-card-preview { height: 100%; border-radius: inherit; color: var(--ink); text-align: left; box-shadow: none; }
.shop-surface .shop-card-preview:focus-visible { outline: 3px solid var(--blue); outline-offset: -3px; }
.shop-card-art { display: grid; width: 100%; aspect-ratio: 3 / 2; overflow: hidden; background: #edf2f7; }
.shop-card-art > .shop-preview-stage { min-height: 0; height: 100%; border: 0; border-radius: 0; background: transparent; }
.shop-card-art .shop-mahjong-preview,
.shop-card-art .shop-generic-preview,
.shop-card-art .shop-lounge-preview { min-height: 0; height: 100%; padding: 10px; }
.shop-card-art .shop-lounge-preview { padding: 0; }
.shop-card-art .shop-lounge-preview img { width: 100%; height: 100%; object-fit: contain; border-radius: 0; }
.shop-card-art .shop-lounge-preview > strong,
.shop-card-art .shop-lounge-preview > small,
.shop-card-art .shop-generic-preview > strong,
.shop-card-art .shop-generic-preview > span:not(.shop-generic-icon) { display: none; }
.shop-card-art .shop-voice-preview { min-height: 0; height: 100%; gap: 3px; padding: 6px; }
.shop-card-art .shop-voice-preview img { min-height: 0; height: calc(100% - 30px); max-height: 140px; width: 100%; object-fit: contain; }
.shop-card-art .shop-voice-credit { flex-shrink: 0; font-size: 10px; line-height: 1.25; text-align: center; color: #536174; }
.shop-surface .shop-card-copy { gap: 7px; padding: 13px; }
.shop-surface .shop-card-copy .shop-card-kind { color: var(--muted); font-size: 11px; font-weight: 500; }
.shop-surface .shop-card-copy h3 { display: -webkit-box; min-height: 2.6em; margin: 0; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 15px; line-height: 1.3; font-weight: 750; word-break: keep-all; }
.shop-surface .shop-card-actions { min-height: 24px; gap: 8px; }
.shop-surface .shop-card-actions .shop-card-price { min-height: 24px; padding: 0; background: transparent; color: var(--ink); font-size: 13px; }
.shop-surface .shop-card-actions .shop-card-price.owned,
.shop-surface .shop-card-actions .shop-card-price.equipped { color: var(--positive-text); }
.shop-surface .shop-card-actions .shop-card-price.pending { color: var(--muted); }
.shop-card-more { margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 500; white-space: nowrap; }
.shop-detail { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0; min-height: 0; margin: 0; padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); }
aside.shop-detail { position: sticky; top: 84px; max-height: calc(100dvh - 104px); overflow-y: auto; scrollbar-width: thin; }
.shop-detail-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.shop-detail-caption { color: var(--muted); font-size: 11px; }
.shop-detail h2 { margin: 0; font-size: 22px; line-height: 1.3; letter-spacing: -.02em; word-break: keep-all; overflow-wrap: anywhere; }
.shop-detail-art { min-width: 0; overflow: hidden; border-radius: 12px; }
.shop-detail-art .shop-preview-stage { min-height: 0; border: 0; }
.shop-detail-art .shop-mj-seat,
.shop-detail-art .shop-mj-panel-sample,
.shop-detail-art .shop-center-mark { display: none; }
.shop-detail-art .shop-mj-tile-showcase { width: calc(100% - 24px); max-width: calc(100% - 24px); }
.shop-detail-art .shop-lounge-preview { min-height: 0; padding: 0; }
.shop-detail-art .shop-lounge-preview > strong,
.shop-detail-art .shop-lounge-preview > small { display: none; }
.shop-detail-art .shop-voice-preview { min-height: 0; padding: 10px; background: #edf2f7; }
.shop-detail-art .shop-voice-preview img { height: 170px; max-width: 100%; object-fit: contain; }
.shop-detail-art .shop-voice-credit { color: #536174; }
.shop-detail .shop-preview-copy { gap: 12px; }
.shop-detail .shop-preview-copy p { color: var(--muted); font-size: 14px; line-height: 1.6; }
.shop-detail .shop-item-tags { align-items: start; }
.shop-detail .shop-voice-samples { margin: 0; }
.shop-detail .shop-voice-samples > div { gap: 6px; }
.shop-detail .shop-voice-samples button { min-height: 38px; padding: 8px 10px; font-size: 13px; }
.shop-detail-purchase { position: sticky; bottom: -20px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: -20px; padding: 14px 0 20px; border-top: 1px solid var(--line); background: var(--surface); }
.shop-detail-purchase .primary-button { min-height: 42px; min-width: 100px; box-shadow: none; }
.shop-detail-purchase .shop-card-price { background: transparent; padding: 0; font-size: 16px; color: var(--ink); }
.shop-notice { margin: 0; padding: 12px; border-radius: 10px; background: color-mix(in srgb, var(--blue) 9%, var(--surface)); color: var(--ink); font-size: 13px; line-height: 1.5; }
.shop-title-collection { padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.shop-title-collection > summary { color: var(--ink); font-size: 14px; font-weight: 700; cursor: pointer; }
.shop-title-collection .shop-titles-panel { margin-top: 14px; }
.shop-title-collection .shop-titles-head { display: grid; gap: 6px; }
.shop-surface .shop-slot-panel { border: 0; background: transparent; }
.shop-surface .shop-slot-summary { padding: 12px 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.shop-surface .shop-slot-panel > .shop-catalog-grid { padding: 14px 0; }
.shop-surface .shop-empty { display: grid; justify-items: center; gap: 10px; padding: 40px 20px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); }
.shop-surface .shop-empty strong { color: var(--ink); }
.shop-surface .shop-empty p { margin: 0; }
dialog.shop-purchase-modal { position: fixed; inset: 0; margin: auto; width: min(420px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; border-radius: 16px; }
dialog.shop-detail:not([open]), dialog.shop-purchase-modal:not([open]) { display: none; }
dialog.shop-detail::backdrop, dialog.shop-purchase-modal::backdrop { background: #15243c80; }
@media (max-width: 1024px) {
  .shop-browser { grid-template-columns: minmax(0, 1fr); }
  dialog.shop-detail { position: fixed; inset: auto 0 0; width: min(560px, 100%); max-width: 100%; max-height: 92dvh; margin: 0 auto; padding-bottom: calc(20px + env(safe-area-inset-bottom)); border-radius: 20px 20px 0 0; overflow-y: auto; overscroll-behavior: contain; }
  .shop-detail-art .shop-mahjong-preview { min-height: 0; }
  .shop-detail-close { min-height: 40px; }
  .shop-surface .shop-item-card.is-selected { border-color: var(--line); box-shadow: none; }
}
@media (max-width: 600px) {
  .shop-surface .game-main-panel { padding: 12px; }
  .shop-surface .shop-board { gap: 18px; }
  .shop-header { gap: 12px; }
  .shop-intro h1 { font-size: 30px; }
  .shop-intro p { max-width: 180px; font-size: 12px; line-height: 1.5; }
  .shop-header .shop-wallet { grid-template-columns: 1fr; gap: 6px; text-align: right; }
  .shop-header .shop-wallet-balance strong { font-size: 20px; }
  .shop-header .shop-wallet-progress { display: flex; justify-content: flex-end; align-items: center; gap: 6px; }
  .shop-header .shop-wallet-progress span, .shop-header .shop-wallet-progress strong { font-size: 10px; }
  .shop-header .shop-coin-guide { max-width: 160px; font-size: 11px; }
  .shop-toolbar-row { flex-wrap: wrap; gap: 8px; }
  .shop-surface .shop-stock-tab { padding: 7px 9px; font-size: 12px; }
  .shop-surface .shop-stock-tab small { margin-left: 2px; }
  .shop-surface #shopRefresh { margin-left: auto; }
  .shop-results-heading small { display: none; }
  .shop-surface .shop-catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .shop-surface .shop-card-copy { padding: 11px; }
  .shop-surface .shop-card-copy h3 { font-size: 14px; }
  .shop-card-art .shop-mahjong-preview { padding: 8px; }
}

.mahjong-shop-notice {
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--mj-brass, #c6a45c) 48%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--mj-brass, #c6a45c) 10%, transparent);
  color: var(--mj-ivory, #f7f1dc);
  font-size: 13px;
  line-height: 1.45;
}

.mahjong-shop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--mj-ivory, #f7f1dc);
  font-size: 13px;
}

.mahjong-shop-row[hidden],
.mahjong-shop-notice[hidden] {
  display: none;
}

/* ======================================================================
   단청(dancheong) 스킨: 청록 작탁과 주홍 레일, 금색 인레이를 조합한
   표준 유료 스킨. UI 구조는 유지하고 팔레트만 바꾼다.
   ====================================================================== */
[data-mj-skin="dancheong"] {
  --mj-night: #182b28;
  --mj-ink: #2a211c;
  --mj-jade: #1f6f63;
  --mj-jade-bright: #2e9c86;
  --mj-brass: #d8ad4e;
  --mj-brass-light: #f0d39d;
  --mj-ivory: #fff6df;
  --mj-vermillion: #b23a2e;
  --mj-wood: #633722;
}

/* 작탁 밖 = 궁궐 밤. 먹남색 바탕 위에 금색 보상화(팔각 별 + 원) 사방연속
   문양을 얹어 classic의 무지 배경과 확실히 구분한다. 정적 SVG 반복이라
   리페인트 비용이 없다. */
[data-mj-skin="dancheong"] .mahjong-table-3d {
  background:
    url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='88'%20height='88'%3E%3Cg%20fill='none'%20stroke='%23d8ad4e'%20stroke-opacity='.09'%3E%3Ccircle%20cx='44'%20cy='44'%20r='10'/%3E%3Cpath%20d='M44%2024%2050%2038%2064%2044%2050%2050%2044%2064%2038%2050%2024%2044%2038%2038Z'/%3E%3Ccircle%20cx='0'%20cy='0'%20r='9'/%3E%3Ccircle%20cx='88'%20cy='0'%20r='9'/%3E%3Ccircle%20cx='0'%20cy='88'%20r='9'/%3E%3Ccircle%20cx='88'%20cy='88'%20r='9'/%3E%3C/g%3E%3C/svg%3E") repeat,
    radial-gradient(125% 95% at 50% 0%, #223c36 0%, #14232a 50%, #0a1013 100%);
}

/* 단청 게임 패널: 먹남색 현판 위에 금 테를 두르고, 행동 슬롯별로 오방색
   계열 포인트만 바꾼다. 밝은 작탁 위에서도 패널 대비를 유지한다. */
[data-mj-skin="dancheong"] .mahjong-command,
[data-mj-skin="dancheong"] .mahjong-riichi-toggle {
  background: rgba(23, 36, 46, 0.92);
  border-color: rgba(216, 173, 78, 0.45);
  box-shadow: none;
}
[data-mj-skin="dancheong"] .mahjong-command::after,
[data-mj-skin="dancheong"] .mahjong-riichi-toggle::after {
  display: none;
}
[data-mj-skin="dancheong"] .mahjong-command-sigil {
  border-radius: 9px;
  background: rgba(216, 173, 78, 0.14);
  border-color: rgba(216, 173, 78, 0.5);
  box-shadow: none;
  color: #f0d39d;
  font-family: "Noto Serif JP", "Yu Mincho", "MS Mincho", serif;
}
[data-mj-skin="dancheong"] .mahjong-command-ron,
[data-mj-skin="dancheong"] .mahjong-command-tsumo {
  background: rgba(58, 22, 18, 0.94);
  border-color: rgba(178, 58, 46, 0.6);
}
[data-mj-skin="dancheong"] .mahjong-command-ron .mahjong-command-sigil,
[data-mj-skin="dancheong"] .mahjong-command-tsumo .mahjong-command-sigil {
  background: rgba(178, 58, 46, 0.16);
  border-color: rgba(178, 58, 46, 0.6);
  color: #f0a08e;
}
[data-mj-skin="dancheong"] .mahjong-command-chi,
[data-mj-skin="dancheong"] .mahjong-command-pon {
  border-color: rgba(46, 156, 134, 0.55);
}
[data-mj-skin="dancheong"] .mahjong-command-kan,
[data-mj-skin="dancheong"] .mahjong-command-open-kan,
[data-mj-skin="dancheong"] .mahjong-command-closed-kan,
[data-mj-skin="dancheong"] .mahjong-command-added-kan {
  border-color: rgba(63, 111, 180, 0.55);
}
[data-mj-skin="dancheong"] .mahjong-command-kan .mahjong-command-sigil,
[data-mj-skin="dancheong"] .mahjong-command-open-kan .mahjong-command-sigil,
[data-mj-skin="dancheong"] .mahjong-command-closed-kan .mahjong-command-sigil,
[data-mj-skin="dancheong"] .mahjong-command-added-kan .mahjong-command-sigil {
  background: rgba(63, 111, 180, 0.16);
  border-color: rgba(63, 111, 180, 0.55);
  color: #a8c4ec;
}
[data-mj-skin="dancheong"] .mahjong-command-power {
  background: rgba(40, 28, 52, 0.92);
  border-color: rgba(160, 120, 210, 0.5);
}
[data-mj-skin="dancheong"] .mahjong-command-power .mahjong-command-sigil {
  background: rgba(160, 120, 210, 0.16);
  border-color: rgba(160, 120, 210, 0.5);
  color: #c8ace8;
}
[data-mj-skin="dancheong"] .mahjong-command-pass,
[data-mj-skin="dancheong"] .mahjong-command-abortive-draw {
  background: rgba(30, 38, 44, 0.92);
  border-color: rgba(130, 140, 150, 0.4);
}
[data-mj-skin="dancheong"] .mahjong-command.is-selected,
[data-mj-skin="dancheong"] .mahjong-reaction-type.is-selected {
  border-color: rgba(240, 211, 157, 0.85);
  box-shadow: 0 0 0 2px rgba(216, 173, 78, 0.32);
}
[data-mj-skin="dancheong"] .mahjong-decision-banner {
  background: rgba(23, 36, 46, 0.95);
  border-color: rgba(216, 173, 78, 0.45);
  box-shadow: none;
}
[data-mj-skin="dancheong"] .mahjong-decision-banner.is-urgent {
  background: rgba(58, 22, 18, 0.95);
  border-color: rgba(178, 58, 46, 0.6);
  box-shadow: none;
}
[data-mj-skin="dancheong"] .mahjong-decision-crest {
  border-radius: 9px;
  background: rgba(216, 173, 78, 0.14);
  border-color: rgba(216, 173, 78, 0.5);
  color: #f0d39d;
  font-family: "Noto Serif JP", "Yu Mincho", "MS Mincho", serif;
}
[data-mj-skin="dancheong"] .mahjong-decision-clock {
  color: #f0d39d;
}
[data-mj-skin="dancheong"] .mahjong-decision-banner.is-urgent .mahjong-decision-clock {
  color: #f0a08e;
  text-shadow: none;
}
[data-mj-skin="dancheong"] .mahjong-command-feedback {
  background: rgba(23, 36, 46, 0.95);
  border-color: rgba(216, 173, 78, 0.45);
}
[data-mj-skin="dancheong"] .mahjong-command-feedback-sigil {
  color: #f0d39d;
  font-family: "Noto Serif JP", "Yu Mincho", "MS Mincho", serif;
}
[data-mj-skin="dancheong"] .mahjong-3d-seat {
  background: rgba(23, 36, 46, 0.78);
  border-left-color: rgba(216, 173, 78, 0.55);
}
[data-mj-skin="dancheong"] .mahjong-3d-seat.current {
  border-left-color: #d8ad4e;
}
[data-mj-skin="dancheong"] .mahjong-3d-seat span {
  color: #b8c2c8;
}
[data-mj-skin="dancheong"] .mahjong-3d-seat i {
  color: #f0d39d;
}
[data-mj-skin="dancheong"] .mahjong-3d-result-panel {
  background: rgba(19, 30, 38, 0.96);
  border-color: rgba(216, 173, 78, 0.45);
  box-shadow: 0 24px 60px rgba(8, 12, 16, 0.5);
}
[data-mj-skin="dancheong"] .mahjong-3d-result-title {
  color: #f0d39d;
  font-family: "Noto Serif JP", "Yu Mincho", "MS Mincho", serif;
}
[data-mj-skin="dancheong"] .mahjong-3d-result-row {
  background: rgba(216, 173, 78, 0.06);
}
[data-mj-skin="dancheong"] .mahjong-3d-rtype,
[data-mj-skin="dancheong"] .mahjong-3d-rhan { color: #f0d39d; }
[data-mj-skin="dancheong"] .mahjong-3d-rtile.is-agari { outline-color: #d8ad4e; }
[data-mj-skin="dancheong"] .mahjong-3d-rscore-d.is-positive,
[data-mj-skin="dancheong"] .mahjong-3d-rmove-val.is-positive,
[data-mj-skin="dancheong"] .mahjong-3d-rdelta.is-positive { color: #8fd0b0; }
[data-mj-skin="dancheong"] .mahjong-3d-rscore-d.is-negative,
[data-mj-skin="dancheong"] .mahjong-3d-rmove-val.is-negative,
[data-mj-skin="dancheong"] .mahjong-3d-rdelta.is-negative { color: #f0a08e; }
[data-mj-skin="dancheong"] .mahjong-3d-automation-badge,
[data-mj-skin="dancheong"] .mahjong-3d-event-label {
  background: rgba(23, 36, 46, 0.9);
  border-color: rgba(216, 173, 78, 0.45);
  color: #e8ecef;
}

/* ======================================================================
   사쿠라(sakura) 스킨: 봄 저녁 라벤더 하늘 + 흩뿌린 꽃잎(정적 SVG).
   3D 벚나무·수면·흩날림은 MahjongTableScene(SakuraScenery)이 그린다.
   ====================================================================== */
[data-mj-skin="sakura"] {
  --mj-night: #f3e7ee;
  --mj-ink: #3a2e35;
  --mj-jade: #4d9d68;
  --mj-jade-bright: #6fbd8c;
  --mj-brass: #d8a08a;
  --mj-brass-light: #f0c9bc;
  --mj-ivory: #fdf6f4;
  --mj-vermillion: #c94f66;
  --mj-wood: #7a5a55;
}
[data-mj-skin="sakura"] .mahjong-table-3d {
  background:
    url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='140'%20height='140'%3E%3Cg%20fill='%23e298b4'%20fill-opacity='.14'%3E%3Cpath%20d='M22%2030c-5-4-6-11-1.2-12q1.2%202%202.4%200c4.8%201%203.8%208-1.2%2012z'/%3E%3Cpath%20d='M96%2074c-4-3.2-4.8-8.8-1-9.6q1%201.6%202%200c3.8.8%203%206.4-1%209.6z'%20transform='rotate(40%2096%2074)'/%3E%3Cpath%20d='M52%20118c-4-3.2-4.8-8.8-1-9.6q1%201.6%202%200c3.8.8%203%206.4-1%209.6z'%20transform='rotate(-30%2052%20118)'/%3E%3C/g%3E%3C/svg%3E") repeat,
    radial-gradient(125% 95% at 50% 0%, #f6eef3 0%, #e6d5e6 52%, #c9b4cf 100%);
}

/* 사쿠라 게임 패널: 어스름 자주(패 뒷면·중앙 콘솔과 동일 계열) 유리 패널 +
   벚분홍 보더. 글꼴은 패면과 같은 Kaisei Decol. 셀렉터 구성은 neoCity 블록과
   1:1 대응(향후 수묵담채/단청 패널 테마도 이 인벤토리를 따른다). */
[data-mj-skin="sakura"] .mahjong-command,
[data-mj-skin="sakura"] .mahjong-riichi-toggle {
  background: rgba(56, 42, 58, 0.92);
  border-color: rgba(232, 167, 184, 0.4);
  box-shadow: none;
}
[data-mj-skin="sakura"] .mahjong-command::after,
[data-mj-skin="sakura"] .mahjong-riichi-toggle::after {
  display: none;
}
[data-mj-skin="sakura"] .mahjong-command-sigil {
  border-radius: 50%;
  background: rgba(233, 152, 180, 0.14);
  border-color: rgba(233, 152, 180, 0.5);
  box-shadow: none;
  color: #ffc2d4;
  font-family: "Kaisei Decol", "Yu Mincho", "MS Mincho", serif;
}
[data-mj-skin="sakura"] .mahjong-command-ron,
[data-mj-skin="sakura"] .mahjong-command-tsumo {
  background: rgba(74, 30, 44, 0.94);
  border-color: rgba(255, 122, 158, 0.55);
}
[data-mj-skin="sakura"] .mahjong-command-ron .mahjong-command-sigil,
[data-mj-skin="sakura"] .mahjong-command-tsumo .mahjong-command-sigil {
  background: rgba(255, 122, 158, 0.16);
  border-color: rgba(255, 122, 158, 0.55);
  color: #ff9ebb;
}
[data-mj-skin="sakura"] .mahjong-command-chi,
[data-mj-skin="sakura"] .mahjong-command-pon {
  border-color: rgba(111, 189, 140, 0.5);
}
[data-mj-skin="sakura"] .mahjong-command-kan,
[data-mj-skin="sakura"] .mahjong-command-open-kan,
[data-mj-skin="sakura"] .mahjong-command-closed-kan,
[data-mj-skin="sakura"] .mahjong-command-added-kan {
  border-color: rgba(122, 143, 204, 0.55);
}
[data-mj-skin="sakura"] .mahjong-command-kan .mahjong-command-sigil,
[data-mj-skin="sakura"] .mahjong-command-open-kan .mahjong-command-sigil,
[data-mj-skin="sakura"] .mahjong-command-closed-kan .mahjong-command-sigil,
[data-mj-skin="sakura"] .mahjong-command-added-kan .mahjong-command-sigil {
  background: rgba(122, 143, 204, 0.16);
  border-color: rgba(122, 143, 204, 0.55);
  color: #b3c4f0;
}
[data-mj-skin="sakura"] .mahjong-command-power {
  background: rgba(52, 38, 66, 0.92);
  border-color: rgba(176, 124, 255, 0.5);
}
[data-mj-skin="sakura"] .mahjong-command-power .mahjong-command-sigil {
  background: rgba(176, 124, 255, 0.16);
  border-color: rgba(176, 124, 255, 0.5);
  color: #c6a3ff;
}
[data-mj-skin="sakura"] .mahjong-command-pass,
[data-mj-skin="sakura"] .mahjong-command-abortive-draw {
  background: rgba(48, 42, 50, 0.92);
  border-color: rgba(150, 135, 145, 0.4);
}
[data-mj-skin="sakura"] .mahjong-command.is-selected,
[data-mj-skin="sakura"] .mahjong-reaction-type.is-selected {
  border-color: rgba(255, 194, 212, 0.8);
  box-shadow: 0 0 0 2px rgba(233, 152, 180, 0.3);
}
[data-mj-skin="sakura"] .mahjong-decision-banner {
  background: rgba(56, 42, 58, 0.95);
  border-color: rgba(232, 167, 184, 0.4);
  box-shadow: none;
}
[data-mj-skin="sakura"] .mahjong-decision-banner.is-urgent {
  background: rgba(74, 26, 40, 0.95);
  border-color: rgba(255, 122, 158, 0.5);
  box-shadow: none;
}
[data-mj-skin="sakura"] .mahjong-decision-crest {
  border-radius: 50%;
  background: rgba(233, 152, 180, 0.14);
  border-color: rgba(233, 152, 180, 0.5);
  color: #ffc2d4;
  font-family: "Kaisei Decol", "Yu Mincho", "MS Mincho", serif;
}
[data-mj-skin="sakura"] .mahjong-decision-clock {
  color: #ffc2d4;
}
[data-mj-skin="sakura"] .mahjong-decision-banner.is-urgent .mahjong-decision-clock {
  color: #ff9ebb;
  text-shadow: none;
}
[data-mj-skin="sakura"] .mahjong-command-feedback {
  background: rgba(56, 42, 58, 0.95);
  border-color: rgba(232, 167, 184, 0.45);
}
[data-mj-skin="sakura"] .mahjong-command-feedback-sigil {
  color: #ffc2d4;
  font-family: "Kaisei Decol", "Yu Mincho", "MS Mincho", serif;
}
[data-mj-skin="sakura"] .mahjong-3d-seat {
  background: rgba(52, 40, 52, 0.78);
  border-left-color: rgba(233, 152, 180, 0.55);
}
[data-mj-skin="sakura"] .mahjong-3d-seat.current {
  border-left-color: #e298b4;
}
[data-mj-skin="sakura"] .mahjong-3d-seat span {
  color: #d8b8c4;
}
[data-mj-skin="sakura"] .mahjong-3d-seat i {
  color: #ffc2d4;
}
[data-mj-skin="sakura"] .mahjong-3d-result-panel {
  background: rgba(50, 36, 52, 0.96);
  border-color: rgba(233, 152, 180, 0.45);
  box-shadow: 0 24px 60px rgba(40, 20, 34, 0.45);
}
[data-mj-skin="sakura"] .mahjong-3d-result-title {
  color: #ffc2d4;
  font-family: "Kaisei Decol", "Yu Mincho", "MS Mincho", serif;
}
[data-mj-skin="sakura"] .mahjong-3d-result-row {
  background: rgba(233, 152, 180, 0.07);
}
[data-mj-skin="sakura"] .mahjong-3d-rtype,
[data-mj-skin="sakura"] .mahjong-3d-rhan { color: #ffc2d4; }
[data-mj-skin="sakura"] .mahjong-3d-rtile.is-agari { outline-color: #e298b4; }
[data-mj-skin="sakura"] .mahjong-3d-rscore-d.is-positive,
[data-mj-skin="sakura"] .mahjong-3d-rmove-val.is-positive,
[data-mj-skin="sakura"] .mahjong-3d-rdelta.is-positive { color: #9fd8c0; }
[data-mj-skin="sakura"] .mahjong-3d-rscore-d.is-negative,
[data-mj-skin="sakura"] .mahjong-3d-rmove-val.is-negative,
[data-mj-skin="sakura"] .mahjong-3d-rdelta.is-negative { color: #ff9ebb; }
[data-mj-skin="sakura"] .mahjong-3d-automation-badge,
[data-mj-skin="sakura"] .mahjong-3d-event-label {
  background: rgba(52, 38, 54, 0.9);
  border-color: rgba(232, 167, 184, 0.4);
  color: #f7e9ee;
}

/* ======================================================================
   수묵담채(watercolor) 스킨: UI는 평면 유지(가독성 1순위). --mj-* 팔레트만
   먹/남청/청록/홍/옅은 금으로 조정하고, 작탁 밖은 옅은 종이 wash 배경으로.
   data-mj-skin="watercolor"는 MahjongTableScene가 root/body에 설정한다.
   ====================================================================== */
[data-mj-skin="watercolor"] {
  --mj-night: #e9ece4;
  --mj-ink: #2a2722;
  --mj-jade: #1f5e57;
  --mj-jade-bright: #2f7d76;
  --mj-brass: #b89b62;
  --mj-brass-light: #cdb985;
  --mj-ivory: #f7f6f1;
  --mj-vermillion: #9e2b25;
  --mj-wood: #8c8170;
}
[data-mj-skin="watercolor"] .mahjong-table-3d {
  background: radial-gradient(125% 95% at 50% 0%, #eef0ea 0%, #dfe4e1 55%, #cdd3cb 100%);
}

/* 수묵담채 게임 패널: 밝은 종이 작탁 위에 먹색 패널과 옅은 금 테를
   얹고, 시질은 낙관 도장처럼 둥글게 처리한다. */
[data-mj-skin="watercolor"] .mahjong-command,
[data-mj-skin="watercolor"] .mahjong-riichi-toggle {
  background: rgba(43, 42, 38, 0.92);
  border-color: rgba(184, 155, 98, 0.45);
  box-shadow: none;
}
[data-mj-skin="watercolor"] .mahjong-command::after,
[data-mj-skin="watercolor"] .mahjong-riichi-toggle::after {
  display: none;
}
[data-mj-skin="watercolor"] .mahjong-command-sigil {
  border-radius: 50%;
  background: rgba(205, 185, 133, 0.14);
  border-color: rgba(205, 185, 133, 0.5);
  box-shadow: none;
  color: #e8d9ae;
  font-family: "Yuji Syuku", "Yu Mincho", "MS Mincho", serif;
}
[data-mj-skin="watercolor"] .mahjong-command-ron,
[data-mj-skin="watercolor"] .mahjong-command-tsumo {
  background: rgba(56, 26, 24, 0.94);
  border-color: rgba(158, 43, 37, 0.6);
}
[data-mj-skin="watercolor"] .mahjong-command-ron .mahjong-command-sigil,
[data-mj-skin="watercolor"] .mahjong-command-tsumo .mahjong-command-sigil {
  background: rgba(158, 43, 37, 0.16);
  border-color: rgba(158, 43, 37, 0.6);
  color: #e8a49b;
}
[data-mj-skin="watercolor"] .mahjong-command-chi,
[data-mj-skin="watercolor"] .mahjong-command-pon {
  border-color: rgba(127, 184, 173, 0.5);
}
[data-mj-skin="watercolor"] .mahjong-command-kan,
[data-mj-skin="watercolor"] .mahjong-command-open-kan,
[data-mj-skin="watercolor"] .mahjong-command-closed-kan,
[data-mj-skin="watercolor"] .mahjong-command-added-kan {
  border-color: rgba(90, 122, 176, 0.55);
}
[data-mj-skin="watercolor"] .mahjong-command-kan .mahjong-command-sigil,
[data-mj-skin="watercolor"] .mahjong-command-open-kan .mahjong-command-sigil,
[data-mj-skin="watercolor"] .mahjong-command-closed-kan .mahjong-command-sigil,
[data-mj-skin="watercolor"] .mahjong-command-added-kan .mahjong-command-sigil {
  background: rgba(90, 122, 176, 0.16);
  border-color: rgba(90, 122, 176, 0.55);
  color: #aebfe0;
}
[data-mj-skin="watercolor"] .mahjong-command-power {
  background: rgba(45, 38, 56, 0.92);
  border-color: rgba(150, 122, 190, 0.5);
}
[data-mj-skin="watercolor"] .mahjong-command-power .mahjong-command-sigil {
  background: rgba(150, 122, 190, 0.16);
  border-color: rgba(150, 122, 190, 0.5);
  color: #c0a8e0;
}
[data-mj-skin="watercolor"] .mahjong-command-pass,
[data-mj-skin="watercolor"] .mahjong-command-abortive-draw {
  background: rgba(44, 44, 40, 0.92);
  border-color: rgba(140, 138, 128, 0.4);
}
[data-mj-skin="watercolor"] .mahjong-command.is-selected,
[data-mj-skin="watercolor"] .mahjong-reaction-type.is-selected {
  border-color: rgba(232, 217, 174, 0.8);
  box-shadow: 0 0 0 2px rgba(205, 185, 133, 0.3);
}
[data-mj-skin="watercolor"] .mahjong-decision-banner {
  background: rgba(43, 42, 38, 0.95);
  border-color: rgba(184, 155, 98, 0.45);
  box-shadow: none;
}
[data-mj-skin="watercolor"] .mahjong-decision-banner.is-urgent {
  background: rgba(56, 26, 24, 0.95);
  border-color: rgba(158, 43, 37, 0.6);
  box-shadow: none;
}
[data-mj-skin="watercolor"] .mahjong-decision-crest {
  border-radius: 50%;
  background: rgba(205, 185, 133, 0.14);
  border-color: rgba(205, 185, 133, 0.5);
  color: #e8d9ae;
  font-family: "Yuji Syuku", "Yu Mincho", "MS Mincho", serif;
}
[data-mj-skin="watercolor"] .mahjong-decision-clock {
  color: #e8d9ae;
}
[data-mj-skin="watercolor"] .mahjong-decision-banner.is-urgent .mahjong-decision-clock {
  color: #e8a49b;
  text-shadow: none;
}
[data-mj-skin="watercolor"] .mahjong-command-feedback {
  background: rgba(43, 42, 38, 0.95);
  border-color: rgba(184, 155, 98, 0.45);
}
[data-mj-skin="watercolor"] .mahjong-command-feedback-sigil {
  color: #e8d9ae;
  font-family: "Yuji Syuku", "Yu Mincho", "MS Mincho", serif;
}
[data-mj-skin="watercolor"] .mahjong-3d-seat {
  background: rgba(43, 42, 38, 0.78);
  border-left-color: rgba(205, 185, 133, 0.55);
}
[data-mj-skin="watercolor"] .mahjong-3d-seat.current {
  border-left-color: #c8a35a;
}
[data-mj-skin="watercolor"] .mahjong-3d-seat span {
  color: #c9c2ad;
}
[data-mj-skin="watercolor"] .mahjong-3d-seat i {
  color: #e8d9ae;
}
[data-mj-skin="watercolor"] .mahjong-3d-result-panel {
  background: rgba(38, 37, 33, 0.96);
  border-color: rgba(184, 155, 98, 0.45);
  box-shadow: 0 24px 60px rgba(38, 37, 33, 0.45);
}
[data-mj-skin="watercolor"] .mahjong-3d-result-title {
  color: #e8d9ae;
  font-family: "Yuji Syuku", "Yu Mincho", "MS Mincho", serif;
}
[data-mj-skin="watercolor"] .mahjong-3d-result-row {
  background: rgba(205, 185, 133, 0.06);
}
[data-mj-skin="watercolor"] .mahjong-3d-rtype,
[data-mj-skin="watercolor"] .mahjong-3d-rhan {
  color: #e8d9ae;
  font-family: "Yuji Syuku", "Yu Mincho", "MS Mincho", serif;
}
[data-mj-skin="watercolor"] .mahjong-3d-rtile.is-agari { outline-color: #c8a35a; }
[data-mj-skin="watercolor"] .mahjong-3d-rscore-d.is-positive,
[data-mj-skin="watercolor"] .mahjong-3d-rmove-val.is-positive,
[data-mj-skin="watercolor"] .mahjong-3d-rdelta.is-positive { color: #9fc8a8; }
[data-mj-skin="watercolor"] .mahjong-3d-rscore-d.is-negative,
[data-mj-skin="watercolor"] .mahjong-3d-rmove-val.is-negative,
[data-mj-skin="watercolor"] .mahjong-3d-rdelta.is-negative { color: #e8a49b; }
[data-mj-skin="watercolor"] .mahjong-3d-automation-badge,
[data-mj-skin="watercolor"] .mahjong-3d-event-label {
  background: rgba(43, 42, 38, 0.9);
  border-color: rgba(184, 155, 98, 0.45);
  color: #efe9d8;
}

/* ======================================================================
   NEO-CITY 스킨: 마작 UI 패널을 플랫 다크 글래스 + 얇은 네온 하이라인으로.
   data-mj-skin="neoCity"는 MahjongTableScene가 root/body에 설정한다.
   ====================================================================== */
[data-mj-skin="neoCity"] {
  --mj-night: #070d18;
  --mj-ink: #0c1424;
  --mj-jade: #0a9f6c;
  --mj-jade-bright: #36e6dd;
  --mj-brass: #36e6dd;
  --mj-brass-light: #7af0ff;
  --mj-ivory: #eef3fa;
  --mj-vermillion: #e8195e;
  --mj-wood: #2c3a48;
}

/* 작탁 밖 = 밤하늘. 작탁 레일(스틸톤)보다 확실히 어둡게 골라 윤곽이 분리되도록. */
[data-mj-skin="neoCity"] .mahjong-table-3d {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(125% 95% at 50% 0%, #0d1830 0%, #070d1c 52%, #03060e 100%);
}
[data-mj-skin="neoCity"] .mahjong-3d-canvas {
  position: relative;
  z-index: 1;
}
/* 별·별똥별은 JS 파티클 캔버스(.mahjong-3d-nightsky, MahjongTableScene.updateNightSky)가
   그린다. CSS 그라디언트 애니메이션은 매 프레임 레이어 리페인트가 비싸 제거했다. */

/* 행동 버튼: 광택 그라데 → 플랫 다크 + 네온 보더, 사각 칩 시질. */
[data-mj-skin="neoCity"] .mahjong-command,
[data-mj-skin="neoCity"] .mahjong-riichi-toggle {
  background: rgba(16, 28, 48, 0.92);
  border-color: rgba(120, 180, 210, 0.28);
  box-shadow: none;
}
[data-mj-skin="neoCity"] .mahjong-command::after,
[data-mj-skin="neoCity"] .mahjong-riichi-toggle::after {
  display: none;
}
[data-mj-skin="neoCity"] .mahjong-command-sigil {
  border-radius: 9px;
  background: rgba(54, 230, 221, 0.12);
  border-color: rgba(54, 230, 221, 0.42);
  box-shadow: none;
  color: #7af0ff;
  font-family: "DotGothic16", "Yu Mincho", "MS Mincho", serif;
}
[data-mj-skin="neoCity"] .mahjong-command-ron,
[data-mj-skin="neoCity"] .mahjong-command-tsumo {
  background: rgba(40, 14, 30, 0.92);
  border-color: rgba(255, 77, 125, 0.5);
}
[data-mj-skin="neoCity"] .mahjong-command-ron .mahjong-command-sigil,
[data-mj-skin="neoCity"] .mahjong-command-tsumo .mahjong-command-sigil {
  background: rgba(255, 77, 125, 0.14);
  border-color: rgba(255, 77, 125, 0.5);
  color: #ff8aac;
}
[data-mj-skin="neoCity"] .mahjong-command-chi,
[data-mj-skin="neoCity"] .mahjong-command-pon {
  border-color: rgba(63, 208, 224, 0.45);
}
[data-mj-skin="neoCity"] .mahjong-command-kan,
[data-mj-skin="neoCity"] .mahjong-command-open-kan,
[data-mj-skin="neoCity"] .mahjong-command-closed-kan,
[data-mj-skin="neoCity"] .mahjong-command-added-kan {
  border-color: rgba(77, 142, 240, 0.5);
}
[data-mj-skin="neoCity"] .mahjong-command-kan .mahjong-command-sigil,
[data-mj-skin="neoCity"] .mahjong-command-open-kan .mahjong-command-sigil,
[data-mj-skin="neoCity"] .mahjong-command-closed-kan .mahjong-command-sigil,
[data-mj-skin="neoCity"] .mahjong-command-added-kan .mahjong-command-sigil {
  background: rgba(77, 142, 240, 0.14);
  border-color: rgba(77, 142, 240, 0.5);
  color: #9cc2ff;
}
[data-mj-skin="neoCity"] .mahjong-command-power {
  background: rgba(28, 18, 44, 0.92);
  border-color: rgba(176, 124, 255, 0.5);
}
[data-mj-skin="neoCity"] .mahjong-command-power .mahjong-command-sigil {
  background: rgba(176, 124, 255, 0.16);
  border-color: rgba(176, 124, 255, 0.5);
  color: #c6a3ff;
}
[data-mj-skin="neoCity"] .mahjong-command-pass,
[data-mj-skin="neoCity"] .mahjong-command-abortive-draw {
  background: rgba(20, 28, 38, 0.92);
  border-color: rgba(120, 140, 160, 0.4);
}
[data-mj-skin="neoCity"] .mahjong-command.is-selected,
[data-mj-skin="neoCity"] .mahjong-reaction-type.is-selected {
  border-color: rgba(54, 230, 221, 0.75);
  box-shadow: 0 0 0 2px rgba(54, 230, 221, 0.28);
}

/* 결정 배너. */
[data-mj-skin="neoCity"] .mahjong-decision-banner {
  background: rgba(14, 26, 44, 0.95);
  border-color: rgba(63, 208, 224, 0.35);
  box-shadow: none;
}
[data-mj-skin="neoCity"] .mahjong-decision-banner.is-urgent {
  background: rgba(36, 12, 28, 0.95);
  border-color: rgba(255, 77, 125, 0.46);
  box-shadow: none;
}
[data-mj-skin="neoCity"] .mahjong-decision-crest {
  border-radius: 9px;
  background: rgba(54, 230, 221, 0.12);
  border-color: rgba(54, 230, 221, 0.42);
  color: #7af0ff;
  font-family: "DotGothic16", "Yu Mincho", "MS Mincho", serif;
}
[data-mj-skin="neoCity"] .mahjong-decision-clock {
  color: #7af0ff;
  font-family: "DotGothic16", "Consolas", monospace;
}
[data-mj-skin="neoCity"] .mahjong-decision-banner.is-urgent .mahjong-decision-clock {
  color: #ff8aac;
  text-shadow: none;
}

/* 행동 피드백 토스트. */
[data-mj-skin="neoCity"] .mahjong-command-feedback {
  background: rgba(15, 26, 46, 0.95);
  border-color: rgba(63, 208, 224, 0.4);
}
[data-mj-skin="neoCity"] .mahjong-command-feedback-sigil {
  color: #7af0ff;
  font-family: "DotGothic16", "Yu Mincho", "MS Mincho", serif;
}

/* 좌석 프로필 칩. */
[data-mj-skin="neoCity"] .mahjong-3d-seat {
  background: rgba(12, 22, 40, 0.78);
  border-left-color: rgba(63, 208, 224, 0.5);
}
[data-mj-skin="neoCity"] .mahjong-3d-seat.current {
  border-left-color: #36e6dd;
}
[data-mj-skin="neoCity"] .mahjong-3d-seat span {
  color: #79c7d8;
}
[data-mj-skin="neoCity"] .mahjong-3d-seat i {
  color: #7af0ff;
}

/* 유국/화료 결과 패널. */
[data-mj-skin="neoCity"] .mahjong-3d-result-panel {
  background: rgba(12, 22, 40, 0.96);
  border-color: rgba(63, 208, 224, 0.4);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
[data-mj-skin="neoCity"] .mahjong-3d-result-title {
  color: #7af0ff;
  font-family: "DotGothic16", "Yu Mincho", "MS Mincho", serif;
}
[data-mj-skin="neoCity"] .mahjong-3d-result-row {
  background: rgba(54, 230, 221, 0.06);
}

/* 자동 연출 배지 · 이벤트 라벨 · 국 준비 안내. */
[data-mj-skin="neoCity"] .mahjong-3d-automation-badge,
[data-mj-skin="neoCity"] .mahjong-3d-event-label {
  background: rgba(12, 22, 40, 0.9);
  border-color: rgba(63, 208, 224, 0.4);
  color: #dfeefb;
}

/* ======================================================================
   결과 패널(화료/황패유국) 재구성 — 한눈에 들어오는 카드 레이아웃.
   ====================================================================== */
.mahjong-3d-result-card + .mahjong-3d-result-card {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.mahjong-3d-result-steps {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}
.mahjong-3d-result-step {
  display: grid;
  gap: 10px;
  border-left: 3px solid rgba(255, 209, 102, 0.72);
  border-radius: 5px;
  padding: 6px 9px;
  background: rgba(255, 209, 102, 0.08);
  transition: opacity 320ms ease, transform 320ms ease;
}
.mahjong-3d-result-step-heading {
  display: flex;
  gap: 12px;
  align-items: baseline;
  justify-content: space-between;
}
.mahjong-3d-result-step .mahjong-3d-result-card {
  padding-top: 9px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.mahjong-3d-result-step-label { color: #ffe49a; font-size: 12px; }
.mahjong-3d-result-step-detail { color: #d9e5df; font-size: 11px; text-align: right; }
.mahjong-3d-result-step[hidden],
.mahjong-3d-result-aggregate[hidden],
.mahjong-3d-final-card[hidden] { display: none; }
.mahjong-3d-result-window { display: grid; gap: 10px; animation: mahjong-result-arrive 200ms ease-out; }
.mahjong-3d-result-next { position: sticky; bottom: -14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; background: #142524; color: #d9e5df; font-size: 12px; }
.mahjong-3d-result-next button { min-width: 76px; }
@keyframes mahjong-result-arrive { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .mahjong-3d-result-window { animation: none; } }
.mahjong-3d-rhead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.mahjong-3d-rname { font-size: 15px; font-weight: 900; color: #f6f2e5; }
.mahjong-3d-rtype { font-size: 17px; font-weight: 900; color: #ffe49a; letter-spacing: 0.06em; }
.mahjong-3d-rhand {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 10px;
}
.mahjong-3d-rtile { display: block; border-radius: 4px; }
.mahjong-3d-rtile.is-agari { outline: 2px solid #ffd166; outline-offset: 1px; }
.mahjong-3d-rmeld {
  display: flex;
  gap: 2px;
  margin-left: 6px;
  padding-left: 8px;
  border-left: 1px dashed rgba(255, 255, 255, 0.25);
}
.mahjong-3d-rdora { display: flex; gap: 16px; align-items: center; margin-bottom: 10px; }
.mahjong-3d-rdora-grp { display: flex; gap: 3px; align-items: center; }
.mahjong-3d-rdora-tag { font-size: 11px; color: #c8b983; margin-right: 2px; }
.mahjong-3d-ryaku {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}
.mahjong-3d-ryaku-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 7px;
  padding: 6px 11px;
  font-size: 13px;
  color: #f1ead6;
}
.mahjong-3d-ryaku-item.is-double-yaku {
  border: 1px solid rgba(255, 226, 137, 0.46);
  background: rgba(242, 195, 83, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.mahjong-3d-rx2 {
  margin-left: auto;
  border-radius: 999px;
  padding: 2px 6px;
  background: rgba(255, 226, 137, 0.2);
  color: #ffe49a;
  font-size: 11px;
  font-weight: 1000;
}
.mahjong-3d-rhan { color: #ffe49a; font-weight: 900; white-space: nowrap; }
.mahjong-3d-rtotal {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}
.mahjong-3d-rhf { font-size: 14px; color: #e6dcc0; text-align: right; }
.mahjong-3d-rpts-wrap {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}
.mahjong-3d-rpts { font-size: 26px; font-weight: 900; color: #ffe49a; font-variant-numeric: tabular-nums; }
.mahjong-3d-rpts.is-limit { color: #ff9a88; }
.mahjong-3d-rpts-sep,
.mahjong-3d-rpts-bonus {
  font-size: 15px;
  font-weight: 900;
  color: #d9c98d;
}
.mahjong-3d-rmove {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.16);
}
.mahjong-3d-rmove-item { display: flex; gap: 6px; align-items: baseline; font-size: 13px; }
.mahjong-3d-rmove-name { color: #a9cbbf; }
.mahjong-3d-rmove-val { font-weight: 900; font-variant-numeric: tabular-nums; }
.mahjong-3d-rmove-val.is-positive,
.mahjong-3d-rdelta.is-positive { color: #8fe3b0; }
.mahjong-3d-rmove-val.is-negative,
.mahjong-3d-rdelta.is-negative { color: #ff9a88; }
.mahjong-3d-rhead-draw {
  font-size: 16px;
  font-weight: 900;
  color: #ffe49a;
  text-align: center;
  margin-bottom: 12px;
  font-family: "Yu Mincho", "MS Mincho", serif;
}
.mahjong-3d-rdraw-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.mahjong-3d-rdraw-row:last-child { border-bottom: none; }
.mahjong-3d-rdraw-name { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mahjong-3d-rbadge {
  align-self: flex-start;
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 20px;
  font-weight: 700;
}
.mahjong-3d-rbadge.is-tenpai { background: rgba(255, 209, 102, 0.16); color: #ffe49a; }
.mahjong-3d-rbadge.is-noten { background: rgba(255, 255, 255, 0.08); color: #b9d5cd; }
.mahjong-3d-rdraw-waits { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.mahjong-3d-rwl { font-size: 11px; color: #c8b983; }
.mahjong-3d-rdelta { font-size: 16px; font-weight: 900; font-variant-numeric: tabular-nums; }
.mahjong-3d-rscore { display: inline-flex; gap: 6px; align-items: baseline; }
.mahjong-3d-rscore-amt { font-weight: 900; font-variant-numeric: tabular-nums; color: #e9e1c8; }
.mahjong-3d-rscore-d { font-size: 0.82em; font-weight: 900; font-variant-numeric: tabular-nums; }
.mahjong-3d-rscore-d.is-positive { color: #8fe3b0; }
.mahjong-3d-rscore-d.is-negative { color: #ff9a88; }
[data-mj-skin="neoCity"] .mahjong-3d-rscore-amt { color: #e6eefb; }
[data-mj-skin="neoCity"] .mahjong-3d-rscore-d.is-positive { color: #7af0ff; }
[data-mj-skin="neoCity"] .mahjong-3d-rscore-d.is-negative { color: #ff8aac; }

/* NEO-CITY 변형: 시안/마젠타 + LED·Orbitron 숫자. */
[data-mj-skin="neoCity"] .mahjong-3d-rtype,
[data-mj-skin="neoCity"] .mahjong-3d-rhan { color: #7af0ff; }
[data-mj-skin="neoCity"] .mahjong-3d-rhan { font-family: "DotGothic16", sans-serif; }
[data-mj-skin="neoCity"] .mahjong-3d-ryaku-item { background: rgba(54, 230, 221, 0.06); }
[data-mj-skin="neoCity"] .mahjong-3d-rpts { color: #7af0ff; font-family: "Orbitron", sans-serif; }
[data-mj-skin="neoCity"] .mahjong-3d-rpts.is-limit { color: #ff8aac; }
[data-mj-skin="neoCity"] .mahjong-3d-rpts-sep,
[data-mj-skin="neoCity"] .mahjong-3d-rpts-bonus { color: #79c7d8; font-family: "Orbitron", sans-serif; }
[data-mj-skin="neoCity"] .mahjong-3d-rdora-tag,
[data-mj-skin="neoCity"] .mahjong-3d-rwl { color: #79c7d8; }
[data-mj-skin="neoCity"] .mahjong-3d-rmove-val.is-positive,
[data-mj-skin="neoCity"] .mahjong-3d-rdelta.is-positive { color: #7af0ff; }
[data-mj-skin="neoCity"] .mahjong-3d-rmove-val.is-negative,
[data-mj-skin="neoCity"] .mahjong-3d-rdelta.is-negative { color: #ff8aac; }
[data-mj-skin="neoCity"] .mahjong-3d-rtile.is-agari { outline-color: #36e6dd; }
[data-mj-skin="neoCity"] .mahjong-3d-rbadge.is-tenpai { background: rgba(54, 230, 221, 0.14); color: #7af0ff; }
[data-mj-skin="neoCity"] .mahjong-3d-rhead-draw { color: #7af0ff; font-family: "DotGothic16", sans-serif; }

/* ======================================================================
   종국 카드(.mahjong-3d-final-*) 스킨별 톤 — 화료/유국 결과와 색·서체를 통일.
   ====================================================================== */
[data-mj-skin="dancheong"] .mahjong-3d-ftitle {
  color: #f0d39d;
  font-family: "Noto Serif JP", "Yu Mincho", "MS Mincho", serif;
}
[data-mj-skin="dancheong"] .mahjong-3d-frow.rank-1 {
  border-color: rgba(216, 173, 78, 0.55);
  background: rgba(216, 173, 78, 0.12);
}
[data-mj-skin="dancheong"] .mahjong-3d-frow.rank-1 .mahjong-3d-frank {
  background: radial-gradient(circle at 35% 28%, #f6e2b0, #d8ad4e 72%);
  color: #3a2a12;
}
[data-mj-skin="dancheong"] .mahjong-3d-fsettle.is-pos { color: #8fd0b0; }
[data-mj-skin="dancheong"] .mahjong-3d-fsettle.is-neg { color: #f0a08e; }

[data-mj-skin="sakura"] .mahjong-3d-ftitle {
  color: #ffc2d4;
  font-family: "Kaisei Decol", "Yu Mincho", "MS Mincho", serif;
}
[data-mj-skin="sakura"] .mahjong-3d-frow.rank-1 {
  border-color: rgba(233, 152, 180, 0.55);
  background: rgba(233, 152, 180, 0.12);
}
[data-mj-skin="sakura"] .mahjong-3d-frow.rank-1 .mahjong-3d-frank {
  background: radial-gradient(circle at 35% 28%, #ffd9e6, #e298b4 72%);
  color: #5c2438;
}
[data-mj-skin="sakura"] .mahjong-3d-fsettle.is-pos { color: #9fd8c0; }
[data-mj-skin="sakura"] .mahjong-3d-fsettle.is-neg { color: #ff9ebb; }

[data-mj-skin="watercolor"] .mahjong-3d-ftitle {
  color: #e8d9ae;
  font-family: "Yuji Syuku", "Yu Mincho", "MS Mincho", serif;
}
[data-mj-skin="watercolor"] .mahjong-3d-frow.rank-1 {
  border-color: rgba(200, 163, 90, 0.55);
  background: rgba(200, 163, 90, 0.12);
}
[data-mj-skin="watercolor"] .mahjong-3d-frow.rank-1 .mahjong-3d-frank {
  background: radial-gradient(circle at 35% 28%, #efe0b6, #c8a35a 72%);
  color: #3a2f18;
}
[data-mj-skin="watercolor"] .mahjong-3d-fsettle.is-pos { color: #9fc8a8; }
[data-mj-skin="watercolor"] .mahjong-3d-fsettle.is-neg { color: #e8a49b; }

[data-mj-skin="neoCity"] .mahjong-3d-ftitle {
  color: #7af0ff;
  font-family: "DotGothic16", "Yu Mincho", "MS Mincho", serif;
}
[data-mj-skin="neoCity"] .mahjong-3d-frank { color: #7af0ff; }
[data-mj-skin="neoCity"] .mahjong-3d-fpts {
  color: #cdeffa;
  font-family: "Orbitron", sans-serif;
}
[data-mj-skin="neoCity"] .mahjong-3d-fsettle.is-pos { color: #7af0ff; }
[data-mj-skin="neoCity"] .mahjong-3d-fsettle.is-neg { color: #ff8aac; }
[data-mj-skin="neoCity"] .mahjong-3d-frow.rank-1 {
  border-color: rgba(122, 240, 255, 0.5);
  background: rgba(54, 230, 221, 0.1);
}
[data-mj-skin="neoCity"] .mahjong-3d-fcoin,
[data-mj-skin="neoCity"] .mahjong-3d-fexp {
  background: rgba(54, 230, 221, 0.14);
  color: #a8ecff;
}
[data-mj-skin="neoCity"] .mahjong-3d-frow.rank-1 .mahjong-3d-frank {
  color: transparent;
  background:
    url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%209%206'%20shape-rendering='crispEdges'%3E%3Cpath%20fill='%23ffd45e'%20d='M0%200h1v2H0z%20M4%200h1v2H4z%20M8%200h1v2H8z%20M0%202h2v1H0z%20M3%202h3v1H3z%20M7%202h2v1H7z%20M0%203h9v2H0z%20M1%205h7v1H1z'/%3E%3Cpath%20fill='%23ff4fd8'%20d='M2%203h1v1H2z%20M6%203h1v1H6z'/%3E%3C/svg%3E")
      center / 22px auto no-repeat,
    #0a1626;
  border: 1px solid rgba(122, 240, 255, 0.6);
  box-shadow: 0 0 8px rgba(54, 230, 221, 0.4);
  image-rendering: pixelated;
}

/* 결과 패널 단계적 공개: 역/대기패/점수를 순차로 페이드인. */
.mahjong-3d-ryaku-item,
.mahjong-3d-rtotal,
.mahjong-3d-rmove,
.mahjong-3d-rdraw-waits .mahjong-3d-rtile,
.mahjong-3d-rdelta {
  transition: opacity 320ms ease, transform 320ms ease;
}
.mahjong-3d-result-panel .mj-rstage-hidden {
  opacity: 0;
  transform: translateY(7px);
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .mahjong-3d-result-step,
  .mahjong-3d-ryaku-item,
  .mahjong-3d-rtotal,
  .mahjong-3d-rmove,
  .mahjong-3d-rdraw-waits .mahjong-3d-rtile,
  .mahjong-3d-rdelta {
    transition: none;
  }
}

/* 초능력 일람 모달: 등장 가능한 모든 초능력을 카드로 열람. */
.mahjong-power-codex-open {
  margin-top: 8px;
  width: 100%;
}

.mahjong-power-codex {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.mahjong-power-codex[hidden] {
  display: none;
}

.mpx-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 12, 11, 0.66);
  backdrop-filter: blur(2px);
}

.mpx-dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(940px, 100%);
  max-height: min(86vh, 900px);
  border: 1px solid rgba(247, 223, 155, 0.5);
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% -10%, rgba(247, 223, 155, 0.14), transparent 60%),
    rgba(6, 20, 18, 0.98);
  color: #f4efe0;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.mpx-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(247, 223, 155, 0.22);
}

.mpx-dialog-head h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.02em;
}

.mpx-close {
  border: 0;
  background: transparent;
  color: #f4efe0;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
}

.mpx-close:hover {
  background: rgba(255, 255, 255, 0.12);
}

.mpx-note {
  margin: 0;
  padding: 12px 20px 4px;
  color: #c9d6cf;
  font-size: 13px;
}

.mpx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  padding: 12px 20px 20px;
  overflow-y: auto;
}

.mpx-card {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.mpx-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.mpx-card-head h4 {
  margin: 0;
  font-size: 15px;
  color: #ffe9a8;
}

.mpx-card-head code {
  font-size: 11px;
  color: #9fb4ab;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 5px;
  white-space: nowrap;
}

.mpx-row {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.5;
}

.mpx-dt {
  color: #8fb9ad;
  font-weight: 700;
}

.mpx-dd {
  color: #eef3ee;
}

.mpx-penalty .mpx-dd {
  color: #ffbfa6;
}

@media (max-width: 600px) {
  .mpx-grid {
    grid-template-columns: 1fr;
  }
}

.onecard-surface .game-main-panel {
  min-width: 0;
}

.onecard-card {
  display: grid;
  gap: 14px;
  padding: 14px;
  background:
    radial-gradient(circle at 50% -8%, rgba(214, 165, 45, 0.20), transparent 42%),
    linear-gradient(180deg, #192528, #10191c);
  color: #f6efe3;
}

.onecard-table-3d {
  position: relative;
  min-height: clamp(440px, 62vh, 760px);
  overflow: hidden;
  border: 1px solid rgba(214, 177, 92, 0.34);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 42%, rgba(52, 112, 95, 0.42), transparent 58%),
    #0d1719;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 22px 50px rgba(7, 15, 18, 0.28);
}

.onecard-3d-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none; /* 캔버스 위 터치 제스처를 3D 조작으로 사용 */
}

/* 캔버스 GL 픽셀이 inset 그림자를 덮으므로 포커스 링은 컨테이너 테두리에 건다. */
.onecard-table-3d:focus-within {
  box-shadow:
    inset 0 0 0 2px rgba(255, 226, 160, 0.7),
    0 22px 50px rgba(7, 15, 18, 0.28);
}

/* 3D가 주 조작 — HTML 손패 패널은 접근성 폴백으로 시각적으로 강등한다. */
.onecard-fallback-note {
  margin: 2px 0 8px;
  font-size: 12px;
  line-height: 1.4;
  color: rgba(120, 130, 140, 0.9);
}

.onecard-table-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 226, 160, 0.28);
  border-radius: 8px;
  background: rgba(7, 13, 16, 0.58);
  color: #ffe2a0;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.onecard-hud {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.onecard-hud > div,
.onecard-info-grid > div {
  min-width: 0;
  border: 1px solid rgba(214, 177, 92, 0.18);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.055);
}

.onecard-hud strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.onecard-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.onecard-hand {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 8px;
}

.onecard-hand-card {
  display: grid;
  min-height: 88px;
  align-content: space-between;
  justify-items: center;
  gap: 6px;
  padding: 10px 6px;
  border: 2px solid currentColor;
  border-radius: 8px;
  background: #fffefa;
  color: #303642;
  font-weight: 900;
  box-shadow: 0 10px 20px rgba(7, 15, 18, 0.20);
  cursor: pointer;
}

.onecard-hand-card span {
  font-size: 24px;
  line-height: 1;
}

.onecard-hand-card small {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: currentColor;
  font-size: 11px;
}

.onecard-hand-card:disabled {
  cursor: not-allowed;
  filter: saturate(0.25);
  opacity: 0.46;
}

.onecard-hand-card.color-red {
  color: #d64245;
}

.onecard-hand-card.color-blue {
  color: #2869c8;
}

.onecard-hand-card.color-green {
  color: #23895b;
}

.onecard-hand-card.color-yellow {
  color: #d6a52d;
}

.onecard-hand-card.color-wild {
  color: #303642;
}

.onecard-hand-empty {
  min-height: 72px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(214, 177, 92, 0.30);
  border-radius: 8px;
  color: rgba(246, 239, 227, 0.72);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.onecard-color-picker {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.onecard-color-picker:empty {
  display: none;
}

.onecard-color-picker-title {
  color: rgba(246, 239, 227, 0.78);
  font-size: 12px;
  font-weight: 900;
}

.onecard-color-picker-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(52px, 1fr));
  gap: 8px;
}

.onecard-color-choice {
  min-height: 42px;
  border: 2px solid rgba(255, 255, 255, 0.50);
  border-radius: 8px;
  color: #fffefa;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(7, 15, 18, 0.22);
}

.onecard-color-choice.color-red {
  background: #d64245;
}

.onecard-color-choice.color-blue {
  background: #2869c8;
}

.onecard-color-choice.color-green {
  background: #23895b;
}

.onecard-color-choice.color-yellow {
  background: #d6a52d;
  color: #2f2a18;
}

.onecard-player-list {
  display: grid;
  gap: 8px;
}

.onecard-player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 36px;
  padding: 7px 9px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: #e7efe9;
  font-size: 13px;
}

.onecard-player-row.is-me {
  box-shadow: inset 3px 0 0 #ffe2a0;
}

.onecard-player-row.is-active {
  background: rgba(214, 165, 45, 0.18);
  color: #fff3d0;
}

.onecard-player-row strong {
  white-space: nowrap;
  color: #ffe2a0;
}

.onecard-log {
  max-height: 180px;
  overflow: auto;
  background: transparent;
}

.onecard-rule-list {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

@media (max-width: 820px) {
  .onecard-hud,
  .onecard-info-grid {
    grid-template-columns: 1fr;
  }

  .onecard-table-3d {
    min-height: 420px;
  }
}

/* ── 칭호 배지 — 등급 = 달성 난도 = 디자인 화려함 (G9) ─────────────── */
.title-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.35;
  white-space: nowrap;
  vertical-align: middle;
}

.title-badge.inline {
  margin-left: 6px;
  font-size: 11px;
  padding: 1px 7px;
}

/* 등급별 색상 체계(검수 피드백: 무채색 아쉬움) — 1=옥빛, 2=청금, 3=자금. */
/* 등급 1: 옥빛 단색 칩. 정적. */
.title-badge.grade-1 {
  background: linear-gradient(120deg, #d9f0e4, #eaf7ef);
  border: 1px solid #6fae90;
  color: #1e6b4b;
}

/* 등급 2: 청옥 그라디언트 + 금속 테두리. */
.title-badge.grade-2 {
  background: linear-gradient(120deg, #22518e, #3f7cc4 55%, #22518e);
  border: 1px solid #c8a24f;
  box-shadow: inset 0 0 0 1px rgba(255, 235, 190, 0.3);
  color: #f4ecd8;
}

/* 등급 3: 엠보스 + 시머 스윕. */
.title-badge.grade-3 {
  position: relative;
  overflow: hidden;
  background: linear-gradient(120deg, #4a2c60, #7c4a9c 45%, #b8862c 100%);
  border: 1px solid #e8c66a;
  box-shadow:
    inset 0 1px 0 rgba(255, 244, 214, 0.4),
    inset 0 -1px 0 rgba(20, 10, 30, 0.4),
    0 0 10px rgba(232, 198, 106, 0.28);
  color: #fdf6e2;
  text-shadow: 0 1px 2px rgba(30, 15, 45, 0.55);
}

.title-badge.grade-3::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 249, 228, 0.5) 48% 52%, transparent 70%);
  transform: translateX(-120%);
  animation: title-badge-sheen 3.2s ease-in-out infinite;
}

@keyframes title-badge-sheen {
  0%, 55% { transform: translateX(-120%); }
  80%, 100% { transform: translateX(120%); }
}

@media (prefers-reduced-motion: reduce) {
  .title-badge.grade-3::after {
    animation: none;
    transform: translateX(0);
    opacity: 0.14;
  }
}

.title-badge.is-locked {
  /* 완전 무채색이면 등급 색 구분이 사라져 잠금 상태에서도 색조를 약간 남긴다. */
  filter: grayscale(0.72);
  opacity: 0.6;
}

/* 상점 프로필 필터의 칭호 패널 */
.shop-titles-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--panel, rgba(255, 255, 255, 0.6));
}

.shop-titles-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.shop-titles-head h3 {
  margin: 0;
  font-size: 16px;
}

.shop-titles-head small {
  color: var(--muted);
}

.shop-title-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 420px;
  overflow: auto;
}

.shop-title-row {
  display: grid;
  grid-template-columns: minmax(120px, auto) 1fr auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
}

.shop-title-row.displayed {
  border-color: #c8a24f;
  box-shadow: 0 0 0 1px rgba(200, 162, 79, 0.35);
}

.shop-title-row.locked {
  opacity: 0.78;
}

.shop-title-copy p {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--muted);
}

.shop-title-progress {
  position: relative;
  height: 14px;
  border-radius: 999px;
  background: rgba(120, 134, 156, 0.18);
  overflow: hidden;
}

.shop-title-progress i {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #4f86c8, var(--positive));
}

.shop-title-progress small {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 800;
  color: #223047;
}

.shop-title-state.pending {
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 820px) {
  .shop-title-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

/* 명패 프레임 상점 미리보기(G12) — 방 명단 카드와 같은 마크업을 재사용한다. */
.shop-nameplate-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 12px;
}

.shop-nameplate-preview .room-user {
  min-width: 108px;
}

.shop-nameplate-note {
  font-size: 12px;
  color: var(--muted);
}

/* Palette Arcade shared shell ------------------------------------------------ */
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #edf3fb;
  --muted: #aab8ca;
  --line: #2b3950;
  --panel: #121a29;
  --bg: #0a101c;
  --soft: #192438;
  --blue: #78aff8;
  --green: #62d39a;
  --red: #ff8f8f;
  --amber: #e3b35f;
  --teal: #65c7d7;
  --positive-text: #62d39a;
  --warning-text: #e3b35f;
  --danger-text: #ff8f8f;
  --info-text: #65c7d7;
  /* --blue flips light here, so accent-filled buttons need dark text on it. */
  --on-accent: #0b1424;
  --shadow: 0 18px 38px rgba(0, 0, 0, 0.34);
}

:root[data-theme="atelier"] {
  color-scheme: light;
  --ink: #26394c;
  --muted: #665f56;
  --line: #d7c19f;
  --panel: #fffdf7;
  --bg: #f6eedd;
  --soft: #f4e4c7;
  --blue: #45688c;
  --green: #276c5b;
  --red: #a6493f;
  --amber: #9a672d;
  --teal: #2d7781;
  --positive-text: #276c5b;
  --warning-text: #7a5531;
  --danger-text: #8f3733;
  --info-text: #3a6068;
  --word-display-bg: #26394c;
  --word-display-text: #fff8ea;
  --shadow: 0 18px 36px rgba(74, 56, 36, 0.14);
}

.theme-switcher {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 2px;
  background: var(--soft);
}

.theme-button {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 7px;
  padding: 0 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.theme-button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--panel);
  box-shadow: 0 3px 10px rgba(22, 34, 49, 0.15);
}

.context-panel-toggle {
  position: fixed;
  top: 50%;
  right: 0;
  z-index: 42;
  display: none;
  min-width: 44px;
  min-height: 124px;
  place-items: center;
  gap: 7px;
  border: 0;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  padding: 12px 9px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--text-sm);
  font-weight: 800;
  box-shadow: -8px 10px 24px color-mix(in srgb, var(--text) 22%, transparent);
  transform: translateY(-50%);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.context-panel-toggle:hover,
.context-panel-toggle.is-collapsed {
  background: var(--accent);
  color: var(--on-accent);
}

.context-panel-toggle:hover {
  transform: translate(-3px, -50%);
  box-shadow: -12px 12px 28px color-mix(in srgb, var(--text) 28%, transparent);
}

.context-toggle-label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

.context-toggle-glyph {
  font-size: 18px;
  line-height: 1;
}

.context-overlay-backdrop {
  position: fixed;
  inset: 64px 0 0;
  z-index: 39;
  display: none;
  background: color-mix(in srgb, var(--text) 28%, transparent);
  opacity: 0;
  transition: opacity 180ms ease;
}

@media (min-width: 821px) {
  body.sidebar-collapsed .app-shell {
    grid-template-columns: 92px minmax(0, 1fr);
    grid-template-areas:
      "top top"
      "nav main";
  }


  body.sidebar-collapsed .topbar {
    grid-template-columns: 92px minmax(140px, 1fr) minmax(280px, 390px) auto;
    grid-template-areas: "brand stage music actions";
  }

  body.sidebar-collapsed #profileArea {
    display: flex;
    gap: 12px;
    padding: 12px 8px;
  }

  body.sidebar-collapsed .sidebar .profile-panel,
  body.sidebar-collapsed .section-title,
  body.sidebar-collapsed .game-copy span {
    display: none;
  }

  body.sidebar-collapsed .brand {
    justify-content: center;
    gap: 6px;
    padding: 0 8px;
  }

  body.sidebar-collapsed .brand > div {
    display: none;
  }

  body.sidebar-collapsed .brand-mark {
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    gap: 3px;
    padding: 5px;
  }

  body.sidebar-collapsed .sidebar-menu-toggle {
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    border-radius: 8px;
    font-size: 15px;
  }

  body.sidebar-collapsed .game-list,
  body.sidebar-collapsed .game-section-list {
    gap: 7px;
  }

  body.sidebar-collapsed .game-tab {
    position: relative;
    grid-template-columns: 1fr;
    gap: 5px;
    min-height: 64px;
    justify-items: center;
    padding: 7px 4px;
    text-align: center;
  }

  body.sidebar-collapsed .game-tab .game-icon {
    width: 34px;
    height: 34px;
    justify-self: center;
  }

  body.sidebar-collapsed .game-copy strong {
    display: block;
    max-width: 72px;
    overflow: hidden;
    color: var(--ink);
    font-size: 11px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.sidebar-collapsed .game-state-dot {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 7px;
    height: 7px;
    box-shadow: 0 0 0 3px rgba(47, 125, 211, 0.13);
  }

  body.sidebar-collapsed .game-state-placeholder {
    display: none;
  }

  body.sidebar-collapsed .game-tab[data-game="shop"]::after {
    left: 1px;
    top: -5px;
    font-size: 10px;
  }
}

@media (max-width: 1024px) {
  .theme-label {
    display: none;
  }

  .theme-button {
    width: 30px;
    padding: 0;
  }

  body.sidebar-collapsed .topbar {
    grid-template-columns: 92px minmax(260px, 1fr) auto;
    grid-template-areas: "brand music actions";
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: flex;
    flex-direction: column;
  }

  body.sidebar-collapsed .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand actions";
  }

  .topbar { order: 0; }
  .stage { order: 1; }
  .sidebar { order: 2; }

  .theme-switcher {
    flex: 0 0 auto;
  }
}

@media (max-width: 600px) {
  .brand-mark {
    display: none;
  }

  .brand {
    padding-right: 4px;
  }

  .brand h1 {
    font-size: 16px;
  }

  .top-actions {
    gap: 5px;
    padding-left: 4px;
  }
}

/* Palette Arcade context shell — 간격·모서리 토큰은 파일 선두의 정본 :root로 통합됨 */

.account-menu {
  position: relative;
}

.account-menu > summary {
  list-style: none;
}

.account-menu > summary::-webkit-details-marker {
  display: none;
}

.account-menu-button {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 3px 8px 3px 3px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.account-menu-button .avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
}

.account-caret {
  color: var(--muted);
  transition: transform 160ms ease;
}

.account-menu[open] .account-caret {
  transform: rotate(180deg);
}

.account-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
  display: grid;
  width: min(340px, calc(100vw - 20px));
  gap: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.account-popover .profile-panel {
  display: grid;
  gap: var(--space-3);
  border: 0;
  padding: 0;
  box-shadow: none;
}

.stage {
  grid-template-columns: minmax(0, 1fr) var(--context-width);
  grid-template-areas: "main context";
  align-items: start;
}

#gameSurface {
  grid-area: main;
  min-width: 0;
}

.stage .game-layout,
.stage.has-room .game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.stage.has-room {
  grid-template-columns: minmax(0, 1fr) var(--context-width);
  grid-template-areas: "main context";
}

.stage.has-room #gameSurface {
  display: block;
  grid-area: main;
}

.context-panel {
  grid-area: context;
  position: sticky;
  top: 20px;
  z-index: 10;
  display: grid;
  align-content: start;
  min-width: 0;
  max-height: calc(100vh - 104px);
  max-height: calc(100dvh - 104px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: transform 180ms ease, opacity 180ms ease;
}

.context-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-3) var(--space-2);
}

.context-panel-head strong {
  font-size: 15px;
}

.context-close {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--soft);
  color: var(--ink);
  font-size: 22px;
}

.context-close-mobile {
  display: none;
}

.context-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 3px;
  margin: 0 var(--space-3);
  border-radius: var(--radius-md);
  padding: 3px;
  background: var(--soft);
}

.context-tabs button {
  min-height: 34px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.context-tabs button.active,
.context-tabs button[aria-selected="true"] {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 3px 10px rgba(22, 34, 49, 0.1);
}

.context-pane {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-3);
}

.context-pane[hidden] {
  display: none;
}

.context-pane.game-settings-panel {
  grid-area: auto;
  position: static;
  top: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.context-pane .settings-stack,
.context-pane .settings-stack > div,
.context-pane .settings-section {
  min-width: 0;
}

.context-pane .game-settings-panel button,
.context-pane .settings-stack > button,
.context-pane .settings-stack > div > button {
  width: 100%;
}

.context-pane #rankingArea {
  display: grid !important;
  width: auto;
  height: auto;
  min-height: 0;
  gap: var(--space-3);
  overflow: visible;
  border: 0;
  padding: 0;
  background: transparent;
}

.context-pane .leader-panel,
.context-pane .log-panel {
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding-top: var(--space-3);
  background: transparent;
}

.context-pane .leader-panel[hidden] {
  display: none;
}

.context-pane #refreshLeaderboard {
  display: inline-flex;
  width: auto;
  min-height: 32px;
  padding: 0 9px;
  font-size: 11px;
}

.context-primary-action {
  width: 100%;
  min-height: 46px;
}

.context-secondary-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-1);
}

.context-secondary-actions button {
  width: 100%;
}

.context-empty {
  margin: 0;
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.context-pane .room-overview {
  gap: var(--space-3);
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.context-pane .room-overview-head,
.context-pane .room-roster-grid {
  grid-template-columns: 1fr;
}

.context-pane .room-status-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-1);
}

.context-pane .room-status-card {
  min-height: 58px;
  padding: 8px;
}

.context-pane .room-status-card strong {
  font-size: 16px;
}

.game-availability {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  grid-column: 2;
  margin-top: -3px;
}

.game-availability .game-state-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
}

.game-state-copy {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body:not(.sidebar-collapsed) .game-tab {
  grid-template-columns: 38px minmax(0, 1fr);
}

body:not(.sidebar-collapsed) .game-state-placeholder {
  display: none;
}

@media (min-width: 821px) {
  body.sidebar-collapsed .game-availability {
    position: absolute;
    top: 7px;
    right: 7px;
    display: block;
    grid-column: auto;
    margin: 0;
  }

  body.sidebar-collapsed .game-availability .game-state-dot {
    position: static;
    display: block;
  }

  body.sidebar-collapsed .game-state-copy {
    display: none;
  }

  body.context-collapsed .stage,
  body.context-collapsed .stage.has-room {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "main"
      "footer";
  }

  body.context-collapsed .context-panel {
    display: none;
  }

  body.context-collapsed:not(.context-overlay-mode) .context-panel-toggle,
  body.context-overlay-mode:not(.context-overlay-open) .context-panel-toggle {
    display: grid;
  }
}

.context-tabs button[hidden] {
  display: none;
}

@media (max-width: 1180px) and (min-width: 821px) {
  :root {
    --context-width: 292px;
  }

  .top-stat:nth-of-type(2) {
    display: none;
  }
}

@media (min-width: 821px) {
  body.context-overlay-mode .stage,
  body.context-overlay-mode .stage.has-room {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "main"
      "footer";
  }

  body.context-overlay-mode .context-panel,
  body.context-overlay-mode.context-collapsed .context-panel {
    position: fixed;
    top: 64px;
    right: 0;
    bottom: 0;
    left: auto;
    z-index: 41;
    display: grid;
    width: min(520px, 92vw);
    max-height: none;
    border-top: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    opacity: 0;
    pointer-events: none;
    transform: translateX(100%);
    box-shadow: -24px 0 48px color-mix(in srgb, var(--text) 24%, transparent);
  }

  body.context-overlay-mode.context-overlay-open .context-panel {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
  }

  body.context-overlay-mode.context-overlay-open .context-overlay-backdrop {
    display: block;
    opacity: 1;
  }

  body.context-overlay-mode .room-list > div {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body.context-overlay-mode .room-user {
    width: 100%;
    max-width: none;
  }
}

.onecard-swap-picker {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 12, 14, 0.52);
  backdrop-filter: blur(3px);
}

.onecard-swap-picker:empty {
  display: none;
}

.onecard-swap-dialog {
  position: relative;
  display: grid;
  gap: 14px;
  width: min(100%, 430px);
  padding: 22px;
  border: 1px solid rgba(255, 226, 160, 0.5);
  border-radius: 8px;
  background: rgba(17, 28, 31, 0.97);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.46);
}

.onecard-swap-dialog h3 {
  margin: 0;
  padding-right: 34px;
  color: #fff3d0;
  font-size: 20px;
}

.onecard-swap-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  color: rgba(246, 239, 227, 0.72);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.onecard-swap-targets {
  display: grid;
  gap: 8px;
}

.onecard-swap-target {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 52px;
  padding: 10px 14px;
  border: 1px solid rgba(214, 177, 92, 0.3);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  color: #f6efe3;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

.onecard-swap-target:hover:not(:disabled),
.onecard-swap-target:focus-visible {
  border-color: #ffe2a0;
  background: rgba(214, 165, 45, 0.18);
}

.onecard-swap-target strong {
  color: #ffe2a0;
}

.onecard-swap-target:disabled {
  cursor: not-allowed;
  filter: grayscale(0.75);
  opacity: 0.36;
}

.shop-onecard-face-preview {
  display: flex;
  min-height: 226px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #e8edf0;
}

.shop-onecard-skin-card {
  --face-accent: #d64245;
  position: relative;
  display: grid;
  width: 74px;
  height: 104px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border: 4px solid var(--face-accent);
  border-radius: 8px;
  background: #fffefa;
  box-shadow: 0 12px 20px rgba(15, 23, 42, 0.2);
  color: var(--face-accent);
}

.shop-onecard-skin-card.color-blue { --face-accent: #2869c8; }
.shop-onecard-skin-card.color-neutral { --face-accent: #353b45; }
.shop-onecard-skin-card b { font-size: 42px; line-height: 1; }

canvas.shop-onecard-skin-card {
  display: block;
  border: 0;
  background: transparent;
  object-fit: fill;
}

.shop-onecard-shield {
  width: 38px;
  height: 46px;
  border: 5px solid currentColor;
  clip-path: polygon(50% 0, 100% 18%, 90% 70%, 50% 100%, 10% 70%, 0 18%);
}

[data-onecard-face="neo_city"] .shop-onecard-face-preview {
  background: #09111d;
}

[data-onecard-face="neo_city"] .shop-onecard-skin-card {
  border-radius: 2px;
  background:
    linear-gradient(rgba(111, 220, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(111, 220, 255, 0.08) 1px, transparent 1px),
    #101722;
  background-size: 10px 10px;
  box-shadow: 0 0 16px color-mix(in srgb, var(--face-accent) 55%, transparent);
  color: #eefbff;
  font-family: "DotGothic16", Consolas, monospace;
}

[data-onecard-face="neo_city"] .shop-onecard-shield {
  border-radius: 0;
}

[data-onecard-face="ink_wash"] .shop-onecard-face-preview {
  background: #ded4bf;
}

[data-onecard-face="ink_wash"] .shop-onecard-skin-card {
  border: 2px solid color-mix(in srgb, var(--face-accent) 68%, #29241e);
  border-radius: 6px 4px 7px 5px;
  background:
    radial-gradient(circle at 50% 44%, color-mix(in srgb, var(--face-accent) 25%, transparent), transparent 48%),
    linear-gradient(150deg, #fbf6e9, #e5d9bf);
  box-shadow: 0 12px 20px rgba(66, 52, 33, 0.2);
  color: color-mix(in srgb, var(--face-accent) 76%, #29241e);
  font-family: "Ma Shan Zheng", "Nanum Brush Script", serif;
  transform: rotate(-1deg);
}

[data-onecard-face="ink_wash"] .shop-onecard-skin-card:nth-child(2) { transform: rotate(1.2deg); }
[data-onecard-face="ink_wash"] .shop-onecard-shield { border-width: 6px 4px 3px 6px; }

@media (max-width: 820px) {
  .context-panel .room-list > div {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .context-panel .room-user {
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .context-panel-toggle {
    display: none;
  }

  .stage,
  .stage.has-room {
    display: block;
    height: auto;
    overflow: visible;
    padding: 12px;
  }

  .sidebar {
    position: fixed;
    top: auto;
    right: 0;
    bottom: calc(58px + env(safe-area-inset-bottom));
    left: 0;
    z-index: 29;
    height: auto;
    max-height: min(78vh, 720px);
    max-height: min(78dvh, 720px);
    overflow: auto;
    overscroll-behavior: contain;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: var(--space-3);
    background: var(--surface);
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(calc(100% + 70px));
    transition: transform 220ms ease, opacity 180ms ease;
  }

  body.mobile-games-open .sidebar {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  body.mobile-games-open .game-list {
    gap: 12px;
  }

  body.mobile-games-open .game-section-list {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
  }

  body.mobile-games-open .game-tab {
    grid-template-columns: 36px minmax(0, 1fr);
    min-height: 64px;
    max-height: 72px;
    padding: 6px 8px;
  }

  body.mobile-games-open .game-tab .game-icon {
    width: 36px;
    height: 36px;
  }

  body.mobile-games-open .game-copy span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.mobile-games-open .game-availability {
    position: absolute;
    top: 6px;
    right: 6px;
    display: block;
    grid-column: auto;
    margin: 0;
  }

  body.mobile-games-open .game-state-copy {
    display: none;
  }

  body.mobile-games-open .shop-game-section .game-section-list {
    grid-template-columns: minmax(0, 1fr);
  }

  body.mobile-games-open .shop-game-section .game-tab {
    min-height: 60px;
    max-height: 64px;
  }

  .context-panel {
    position: fixed;
    top: auto;
    right: 0;
    bottom: calc(58px + env(safe-area-inset-bottom));
    left: 0;
    z-index: 29;
    max-height: min(78vh, 720px);
    max-height: min(78dvh, 720px);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 18px 18px 0 0;
    opacity: 0;
    pointer-events: none;
    transform: translateY(calc(100% + 70px));
    transition: transform 220ms ease, opacity 180ms ease;
  }

  body.mobile-context-open .context-panel {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .context-panel-head {
    padding-top: 10px;
  }

  .context-close {
    display: grid;
  }

  .context-close-desktop {
    display: none;
  }

  .context-close-mobile {
    display: inline;
  }

  .context-tabs {
    position: sticky;
    top: 0;
    z-index: 2;
  }

  .mobile-dock {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .account-menu-button #topAccountName,
  .account-caret {
    display: none;
  }

  .account-menu-button {
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    border: 0;
    padding: 0;
    background: transparent;
  }

  .account-popover {
    right: -4px;
    max-width: calc(100vw - 16px);
  }
}

@media (max-width: 600px) {
  .game-tab {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .game-availability {
    grid-column: 2;
  }

  .context-pane .room-status-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .context-panel,
  .context-panel-toggle,
  .context-overlay-backdrop,
  .sidebar,
  .account-caret {
    transition: none;
  }
}


/* Context panel rhythm: keep dense game controls legible in the narrow rail. */
.context-pane {
  align-content: start;
}

.context-pane .settings-stack {
  gap: var(--space-3);
}

.context-pane .settings-stack > div,
.context-pane .settings-section {
  gap: var(--space-2);
  margin: 0;
  border-color: color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: var(--radius-md);
  padding: 13px;
  background: color-mix(in srgb, var(--soft) 72%, var(--panel));
  box-shadow: none;
}

.context-pane .section-title,
.context-pane .panel-head,
.context-pane .room-overview-head {
  min-width: 0;
  margin: 0;
}

.context-pane .section-title {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  line-height: 1.35;
}

.context-pane .control-grid,
.context-pane .settings-grid,
.context-pane .field-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin: 0;
}

.context-pane label,
.context-pane .field-label {
  min-width: 0;
  line-height: 1.35;
}

.context-pane label:has(> input:not([type="checkbox"]):not([type="radio"])),
.context-pane label:has(> select),
.context-pane label:has(> textarea) {
  display: grid;
  align-items: start;
  gap: 7px;
}

.context-pane label[hidden] {
  display: none !important;
}

.context-pane input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
.context-pane select,
.context-pane textarea {
  width: 100%;
  min-width: 0;
}

.context-pane .action-row,
.context-pane .button-row,
.context-pane .settings-actions {
  align-items: stretch;
  gap: var(--space-2);
}

.context-pane .action-row > button,
.context-pane .button-row > button,
.context-pane .settings-actions > button {
  min-width: 0;
  flex: 1 1 120px;
}

.context-pane .room-panel {
  display: grid;
  align-content: start;
  gap: var(--space-3);
  min-width: 0;
}

.context-pane .room-overview-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--space-2);
}

.context-pane .room-status-card {
  display: grid;
  align-content: center;
  justify-items: center;
  min-width: 0;
  text-align: center;
}

.context-pane .room-status-card span,
.context-pane .room-status-card strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.context-pane .room-roster-grid,
.context-pane .room-member-list,
.context-pane .room-spectator-list {
  min-width: 0;
  gap: var(--space-2);
}

.context-pane #rankingArea .panel-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2);
}

.context-pane .leader-panel,
.context-pane .log-panel {
  display: grid;
  align-content: start;
  gap: var(--space-2);
  min-width: 0;
  min-height: 0;
  padding: var(--space-3) 0 0;
}

.context-pane .leaderboard,
.context-pane .log {
  min-width: 0;
  gap: 7px;
}

.context-pane .leader-row,
.context-pane .log-entry {
  min-width: 0;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: var(--radius-md);
  padding: 10px 11px;
  overflow-wrap: anywhere;
  background: color-mix(in srgb, var(--soft) 78%, var(--panel));
}

/* Shared branded range control, including dynamically rendered game settings. */
input[type="range"] {
  --range-progress: 50%;
  width: 100%;
  min-width: 96px;
  height: 28px;
  margin: 0;
  padding: 0;
  border: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 8px;
  border: 1px solid color-mix(in srgb, var(--blue) 16%, var(--line));
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--blue) 0 var(--range-progress),
    color-mix(in srgb, var(--line) 72%, var(--soft)) var(--range-progress) 100%
  );
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
}

input[type="range"]::-webkit-slider-thumb {
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border: 3px solid var(--panel);
  border-radius: 50%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--blue);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--blue) 72%, var(--ink)), 0 3px 8px rgba(15, 23, 42, 0.2);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

input[type="range"]::-moz-range-track {
  width: 100%;
  height: 6px;
  border: 1px solid color-mix(in srgb, var(--blue) 16%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 72%, var(--soft));
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
}

input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--blue);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 3px solid var(--panel);
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--blue) 72%, var(--ink)), 0 3px 8px rgba(15, 23, 42, 0.2);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

input[type="range"]:hover::-webkit-slider-thumb {
  transform: scale(1.08);
}

input[type="range"]:hover::-moz-range-thumb {
  transform: scale(1.08);
}

input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 24%, transparent), 0 0 0 1px var(--blue);
}

input[type="range"]:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 24%, transparent), 0 0 0 1px var(--blue);
}

input[type="range"]:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  filter: saturate(0.45);
}

@media (prefers-reduced-motion: reduce) {
  input[type="range"]::-webkit-slider-thumb,
  input[type="range"]::-moz-range-thumb {
    transition: none;
  }
}

/* Omok bot difficulty: engine dropdown + a shared, tick-marked range slider.
   Each tier draws a vertical line through the track with its name above it, and
   the selected tier is highlighted. Ticks are inset by half the thumb width so
   they line up with the thumb centre at both ends. */
.omok-rapfi-warning {
  margin: 6px 0 0;
  padding: 7px 10px;
  border-radius: var(--radius-md, 10px);
  font-size: 0.76rem;
  line-height: 1.35;
  color: color-mix(in srgb, var(--warn, #b45309) 82%, var(--ink));
  background: color-mix(in srgb, var(--warn, #f59e0b) 14%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--warn, #f59e0b) 34%, var(--line));
}
.omok-tier-field {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}
.omok-tier-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.omok-tier-caption { font-size: 0.82rem; color: var(--muted); }
.omok-tier-name {
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--blue);
  letter-spacing: 0.01em;
}
.omok-tier-slider { position: relative; padding-top: 20px; }
.omok-tier-input { position: relative; z-index: 2; display: block; width: 100%; }
.omok-tier-ticks {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 0;
  bottom: 0;
  z-index: 1;
  pointer-events: none;
}
.omok-tick { position: absolute; top: 0; bottom: 0; width: 0; }
.omok-tick-label {
  position: absolute;
  top: 0;
  left: 0;
  transform: translateX(-50%);
  font-size: 0.62rem;
  line-height: 1;
  white-space: nowrap;
  color: var(--muted);
  transition: color 120ms ease, font-weight 120ms ease;
}
.omok-tick-line {
  position: absolute;
  left: 0;
  top: 22px;
  width: 2px;
  height: 20px;
  transform: translateX(-50%);
  border-radius: 2px;
  background: color-mix(in srgb, var(--blue) 26%, var(--line));
  transition: background 120ms ease, box-shadow 120ms ease;
}
.omok-tick.active .omok-tick-label { color: var(--blue); font-weight: 800; }
.omok-tick.active .omok-tick-line {
  width: 3px;
  background: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 20%, transparent);
}

/* Figma global themes ------------------------------------------------------
   The shell selection maps Light → Clear Play, Dark → Night Circuit, and
   Atelier → Atelier. The renderer applies that choice to every non-native game
   and its context chrome; native visual games retain their established assets.
   Sources: A 48:3, B 48:4, C 48:5 in Palette Mini — Visual Direction 2026. */
:is(.game-layout, .context-panel, .context-panel-toggle, .context-pane)[data-game-theme="atelier"] {
  --game-page: #f6eedd;
  --game-surface: #fffdf7;
  --game-surface-soft: #f4e4c7;
  --game-room-surface: #f7f0e2;
  --game-line: #cbaf87;
  --game-text: #26394c;
  --game-muted: #665f56;
  --game-accent: #d47759;
  --game-accent-text: #211c19;
  --game-secondary: #45688c;
  --game-secondary-soft: #efe7d6;
  --game-stage: #26394c;
  --game-stage-text: #f4ecdb;
  --game-light-surface: #f4e4c7;
  --game-light-text: #26394c;
  --game-light-muted: #665f56;
  --game-positive-bg: #e7f3ee;
  --game-positive-text: #276c5b;
  --game-warning-bg: #f4e4c7;
  --game-warning-text: #7a5531;
  --game-danger-bg: #fff3ee;
  --game-danger-text: #8f3733;
  --game-info-bg: #e7ecf0;
  --game-info-text: #3a6068;
  --game-shadow: 0 16px 34px color-mix(in srgb, var(--game-text) 14%, transparent);
}

:is(.game-layout, .context-panel, .context-panel-toggle, .context-pane)[data-game-theme="night-circuit"] {
  --game-page: #0b1424;
  --game-surface: #111d33;
  --game-surface-soft: #182844;
  --game-room-surface: #111d33;
  --game-line: #324a70;
  --game-text: #f4f7ff;
  --game-muted: #b4c2d8;
  --game-accent: #56dff5;
  --game-accent-text: #080d19;
  --game-secondary: #6b5cff;
  --game-secondary-soft: #201a43;
  --game-stage: #070c17;
  --game-stage-text: #eaf1ff;
  --game-light-surface: #cfdae8;
  --game-light-text: #18243b;
  --game-light-muted: #40516a;
  --game-positive-bg: #12312f;
  --game-positive-text: #75e9c7;
  --game-warning-bg: #201a43;
  --game-warning-text: #bfb4ff;
  --game-danger-bg: #3a1730;
  --game-danger-text: #ff8cbd;
  --game-info-bg: #162945;
  --game-info-text: #7be9fa;
  --game-shadow: 0 20px 44px color-mix(in srgb, var(--game-accent) 14%, transparent);
}

:is(.game-layout, .context-panel, .context-panel-toggle, .context-pane)[data-game-theme="clear-play"] {
  --game-page: #f2f6fc;
  --game-surface: #ffffff;
  --game-surface-soft: #f4f7fb;
  --game-room-surface: #ffffff;
  --game-line: #d8e1ed;
  --game-text: #1e2d42;
  --game-muted: #56657a;
  --game-accent: #2f76d2;
  --game-accent-text: #ffffff;
  --game-secondary: #2a68b3;
  --game-secondary-soft: #eaf3ff;
  --game-stage: #17243a;
  --game-stage-text: #eef4fc;
  --game-light-surface: #eaf3ff;
  --game-light-text: #1e2d42;
  --game-light-muted: #56657a;
  --game-positive-bg: #e8f5ef;
  --game-positive-text: #1f6a48;
  --game-warning-bg: #fff4df;
  --game-warning-text: #8a5a10;
  --game-danger-bg: #fff0ef;
  --game-danger-text: #8f3733;
  --game-info-bg: #eaf3ff;
  --game-info-text: #1d626f;
  --game-shadow: 0 14px 30px color-mix(in srgb, var(--game-secondary) 12%, transparent);
}

.game-layout[data-game-theme] .game-main-panel,
.context-pane.game-settings-panel[data-game-theme] {
  border-color: var(--game-line);
  border-radius: var(--radius-lg);
  background: var(--game-surface);
  color: var(--game-text);
  box-shadow: var(--game-shadow);
}

.context-panel[data-game-theme] {
  border-color: var(--game-line);
  background: var(--game-page);
  color: var(--game-text);
  box-shadow: var(--game-shadow);
}

.context-panel[data-game-theme] > .context-pane.game-settings-panel {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.context-panel[data-game-theme] .context-panel-head strong {
  color: var(--game-text);
}

.context-panel[data-game-theme] .context-close {
  background: var(--game-surface-soft);
  color: var(--game-text);
}

.context-panel[data-game-theme] .context-tabs {
  background: var(--game-surface-soft);
}

.context-panel[data-game-theme] .context-tabs button {
  color: var(--game-muted);
}

.context-panel[data-game-theme] .context-tabs button:is(.active, [aria-selected="true"]) {
  background: var(--game-surface);
  color: var(--game-text);
  box-shadow: 0 3px 10px color-mix(in srgb, var(--game-text) 13%, transparent);
}

.context-panel-toggle[data-game-theme] {
  background: var(--game-accent);
  color: var(--game-accent-text);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--game-accent) 24%, transparent);
}

.game-layout[data-game-theme] .game-card {
  color: var(--game-text);
}

:is(.game-layout, .context-pane)[data-game-theme] :is(.meta, .muted, .section-title, .field-label) {
  color: var(--game-muted);
}

:is(.game-layout, .context-pane)[data-game-theme] :is(
  input:not([type="range"]):not([type="checkbox"]):not([type="radio"]),
  select
) {
  border-color: var(--game-line);
  border-radius: var(--radius-md);
  background: var(--game-surface);
  color: var(--game-text);
}

.context-panel[data-game-theme] :is(.context-pane, .section-title, label, .field-label) {
  color: var(--game-text);
}

.context-panel[data-game-theme] .section-title {
  border-color: var(--game-line);
}

.context-panel[data-game-theme] :is(.meta, .muted, label > span, .field-label) {
  color: var(--game-muted);
}

.context-panel[data-game-theme] :is(.leader-row, .log-entry, .room-status-card) {
  border-color: var(--game-line);
  background: var(--game-surface-soft);
  color: var(--game-text);
}

.context-pane[data-game-theme] :is(.settings-stack > div, .settings-section) {
  border-color: var(--game-line);
  border-radius: var(--radius-lg);
  background: var(--game-surface-soft);
}

.context-pane[data-game-theme] .room-settings-section {
  background: color-mix(in srgb, var(--game-positive-bg) 82%, var(--game-surface));
}

.context-pane[data-game-theme] .room-config-toggle {
  border-color: var(--game-line);
  background: var(--game-surface-soft);
  color: var(--game-muted);
}

.context-pane[data-game-theme] .room-config-toggle:hover {
  border-color: var(--game-accent);
  background: var(--game-info-bg);
}

:is(.game-layout, .context-pane)[data-game-theme] .primary-button,
.context-panel[data-game-theme] .primary-button {
  border: 1px solid color-mix(in srgb, var(--game-accent) 82%, var(--game-line));
  border-radius: var(--radius-md);
  background: var(--game-accent);
  color: var(--game-accent-text);
  box-shadow: 0 7px 16px color-mix(in srgb, var(--game-accent) 22%, transparent);
}

:is(.game-layout, .context-pane)[data-game-theme] :is(.ghost-button, .choice-button),
.context-panel[data-game-theme] :is(.ghost-button, .choice-button) {
  border: 1px solid var(--game-line);
  border-radius: var(--radius-md);
  background: var(--game-surface-soft);
  color: var(--game-text);
}

:is(.game-layout, .context-pane)[data-game-theme] .danger-button,
.context-panel[data-game-theme] .danger-button {
  border: 1px solid color-mix(in srgb, var(--game-danger-text) 48%, var(--game-line));
  border-radius: var(--radius-md);
  background: var(--game-danger-bg);
  color: var(--game-danger-text);
}

:is(.game-layout, .context-pane)[data-game-theme] :is(button, input, select):focus-visible,
.context-panel[data-game-theme] :is(button, input, select):focus-visible {
  outline-color: var(--game-accent);
}

.context-panel[data-game-theme] :is(.room-list, .context-empty) {
  border: 1px solid var(--game-line);
  background: var(--game-room-surface);
  color: var(--game-text);
}

.context-panel[data-game-theme] .room-list > .field-label {
  color: var(--game-muted);
}

.context-panel[data-game-theme] .room-user {
  border-color: color-mix(in srgb, var(--game-line) 74%, transparent);
  background: var(--game-surface-soft);
  color: var(--game-text);
}

.context-panel[data-game-theme] .room-user.me {
  border-color: color-mix(in srgb, var(--game-positive-text) 42%, var(--game-line));
  background: var(--game-positive-bg);
  color: var(--game-positive-text);
}

.context-panel[data-game-theme] .room-user.auto-join {
  background:
    linear-gradient(var(--game-surface-soft), var(--game-surface-soft)) padding-box,
    conic-gradient(from var(--auto-angle), var(--game-positive-text), var(--game-positive-text) 24%, transparent 32%, transparent 100%) border-box;
  color: var(--game-positive-text);
}

.context-panel[data-game-theme] .room-user.ready {
  background:
    linear-gradient(var(--game-surface-soft), var(--game-surface-soft)) padding-box,
    conic-gradient(from var(--ready-angle), var(--game-accent), var(--game-accent) 24%, transparent 32%, transparent 100%) border-box;
  color: var(--game-accent);
}

.context-panel[data-game-theme] .room-user.me.ready {
  background:
    linear-gradient(var(--game-positive-bg), var(--game-positive-bg)) padding-box,
    conic-gradient(from var(--ready-angle), var(--game-accent), var(--game-accent) 28%, transparent 36%, transparent 100%) border-box;
  color: var(--game-positive-text);
}

.context-panel[data-game-theme] .room-user-state,
.context-panel[data-game-theme] .room-user.me .room-user-state {
  background: color-mix(in srgb, var(--game-accent) 16%, var(--game-surface));
  color: var(--game-text);
}

.game-layout[data-game-theme] .result-line {
  background: var(--game-positive-bg);
  color: var(--game-positive-text);
}

.game-layout[data-game-theme] .result-line[data-tone="warn"] {
  background: var(--game-warning-bg);
  color: var(--game-warning-text);
}

.game-layout[data-game-theme] .result-line[data-tone="danger"] {
  background: var(--game-danger-bg);
  color: var(--game-danger-text);
}

.game-layout[data-game-theme] .result-line[data-tone="info"] {
  background: var(--game-info-bg);
  color: var(--game-info-text);
}

/* Game adapters first developed for A, now driven by every global theme. */
.dotsboxes-surface[data-game-theme] .game-main-panel {
  background:
    linear-gradient(color-mix(in srgb, var(--game-surface) 96%, transparent), color-mix(in srgb, var(--game-page) 72%, var(--game-surface)));
}

.dotsboxes-surface[data-game-theme] .dotsboxes-player {
  border-color: var(--game-line);
  background: var(--game-surface);
  color: var(--game-text);
}

.dotsboxes-surface[data-game-theme] .dotsboxes-player.player-1 {
  border-color: var(--game-secondary);
}

.dotsboxes-surface[data-game-theme] .dotsboxes-player.player-2 {
  border-color: var(--game-accent);
}

.dotsboxes-surface[data-game-theme] .dotsboxes-player.current {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--game-secondary) 22%, transparent);
}

.dotsboxes-surface[data-game-theme] :is(.dotsboxes-clock, .dotsboxes-help) {
  color: var(--game-muted);
}

.dotsboxes-surface[data-game-theme] .dotsboxes-clock {
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  background: var(--game-text);
  color: var(--game-page);
}

.dotsboxes-surface[data-game-theme] .dotsboxes-board-wrap {
  border: 1px solid var(--game-line);
  background: color-mix(in srgb, var(--game-surface-soft) 74%, var(--game-page));
  box-shadow:
    inset 0 0 28px color-mix(in srgb, var(--game-line) 26%, transparent),
    0 16px 28px color-mix(in srgb, var(--game-text) 12%, transparent);
}

.dotsboxes-surface[data-game-theme] .dotsboxes-dot {
  background: var(--game-text);
  box-shadow: 0 3px 5px color-mix(in srgb, var(--game-text) 28%, transparent);
}

.dotsboxes-surface[data-game-theme] .dotsboxes-edge {
  background: color-mix(in srgb, var(--game-line) 82%, transparent);
}

.dotsboxes-surface[data-game-theme] .dotsboxes-edge:not(:disabled):is(:hover, :focus-visible),
.dotsboxes-surface[data-game-theme] .dotsboxes-edge.taken {
  background: var(--game-secondary);
}

.dotsboxes-surface[data-game-theme] .dotsboxes-edge.last {
  box-shadow: 0 0 0 3px var(--game-warning-text);
}

.dotsboxes-surface[data-game-theme] .dotsboxes-box.owner-1 {
  background: color-mix(in srgb, var(--game-secondary) 78%, transparent);
}

.dotsboxes-surface[data-game-theme] .dotsboxes-box.owner-2 {
  background: color-mix(in srgb, var(--game-accent) 78%, transparent);
}

.connect4-surface[data-game-theme] .game-main-panel,
.inkbloom-surface[data-game-theme] .game-main-panel {
  background:
    linear-gradient(color-mix(in srgb, var(--game-surface) 96%, transparent), color-mix(in srgb, var(--game-page) 72%, var(--game-surface)));
}

.connect4-surface[data-game-theme] .connect4-player,
.inkbloom-surface[data-game-theme] .inkbloom-player {
  border-color: var(--game-line);
  background: var(--game-surface);
  color: var(--game-text);
}

.connect4-surface[data-game-theme] .connect4-player.current {
  border-color: var(--game-secondary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--game-secondary) 20%, transparent);
}

.connect4-surface[data-game-theme] .connect4-clock {
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  background: var(--game-text);
  color: var(--game-page);
}

.connect4-surface[data-game-theme] .connect4-board-wrap {
  border: 1px solid color-mix(in srgb, var(--game-text) 72%, var(--game-line));
  background: linear-gradient(155deg, color-mix(in srgb, var(--game-text) 84%, var(--game-secondary)), var(--game-text));
  box-shadow: 0 18px 38px color-mix(in srgb, var(--game-text) 22%, transparent);
}

.connect4-surface[data-game-theme] .connect4-column-actions button {
  color: var(--game-page);
}

.connect4-surface[data-game-theme] .connect4-cell:not(.red):not(.yellow) > span {
  background: var(--game-page);
  box-shadow: inset 0 5px 10px color-mix(in srgb, var(--game-text) 28%, transparent);
}

.connect4-surface[data-game-theme] .connect4-cell.last-move > span {
  outline-color: var(--game-surface);
}

.inkbloom-surface[data-game-theme] .inkbloom-player.player-1 {
  border-color: var(--game-secondary);
}

.inkbloom-surface[data-game-theme] .inkbloom-player.player-2 {
  border-color: var(--game-accent);
}

.inkbloom-surface[data-game-theme] :is(.inkbloom-player small, .inkbloom-help) {
  color: var(--game-muted);
}

.inkbloom-surface[data-game-theme] #inkbloomClock {
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  background: var(--game-text);
  color: var(--game-page);
}

.inkbloom-surface[data-game-theme] .inkbloom-board {
  border-color: var(--game-line);
  box-shadow:
    inset 0 0 38px rgba(80, 62, 43, 0.1),
    0 18px 38px color-mix(in srgb, var(--game-text) 15%, transparent);
}

:is(
  .drawing-surface,
  .wordchain-surface,
  .indian-surface
)[data-game-theme] .game-main-panel {
  background:
    linear-gradient(color-mix(in srgb, var(--game-surface) 96%, transparent), color-mix(in srgb, var(--game-page) 72%, var(--game-surface)));
}

.drawing-surface[data-game-theme] .drawing-status-strip span {
  border-color: var(--game-line);
  background: var(--game-surface-soft);
  color: var(--game-muted);
}

.drawing-surface[data-game-theme] .drawing-status-strip strong {
  color: var(--game-text);
}

.drawing-surface[data-game-theme] .drawing-word-pill {
  border-color: color-mix(in srgb, var(--game-warning-text) 38%, var(--game-line));
  background: var(--game-warning-bg) !important;
}

.drawing-surface[data-game-theme] :is(.drawing-board-toolbar, .drawing-chat-panel) {
  border-color: var(--game-line);
  background: color-mix(in srgb, var(--game-surface-soft) 72%, var(--game-surface));
  color: var(--game-text);
}

.drawing-surface[data-game-theme] .drawing-board-wrap {
  border-color: var(--game-line);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--game-text) 4%, transparent) 1px, transparent 1px),
    linear-gradient(color-mix(in srgb, var(--game-text) 4%, transparent) 1px, transparent 1px),
    color-mix(in srgb, var(--game-surface-soft) 70%, var(--game-page));
  background-size: 28px 28px;
  box-shadow: 0 12px 26px color-mix(in srgb, var(--game-text) 10%, transparent);
}

.drawing-surface[data-game-theme] :is(.drawing-chat-message, .drawing-chat-empty, .drawing-player, .drawing-guess, .drawing-guess-empty) {
  border-color: var(--game-line);
  background: var(--game-surface);
  color: var(--game-text);
}

.drawing-surface[data-game-theme] :is(.drawing-chat-message strong, .drawing-chat-empty) {
  color: var(--game-muted);
}

.drawing-surface[data-game-theme] .drawing-player.drawer span {
  background: var(--game-warning-bg);
  color: var(--game-warning-text);
}

.drawing-surface[data-game-theme] .drawing-word-setup {
  border-color: var(--game-line);
  background: color-mix(in srgb, var(--game-surface) 97%, transparent);
  color: var(--game-text);
  box-shadow: var(--game-shadow);
}

.wordchain-surface[data-game-theme] .word-status,
.wordchain-surface[data-game-theme] .word-chat-panel {
  border-color: var(--game-line);
  background: color-mix(in srgb, var(--game-surface-soft) 72%, var(--game-surface));
  color: var(--game-text);
}

.wordchain-surface[data-game-theme] .current-word {
  border: 1px solid color-mix(in srgb, var(--game-text) 48%, var(--game-line));
  border-radius: var(--radius-md);
  background: var(--game-text);
  color: var(--game-page);
  box-shadow: inset 0 0 28px color-mix(in srgb, var(--game-secondary) 13%, transparent);
}

.wordchain-surface[data-game-theme] .word-character-last {
  /* The current-word box is filled with --game-text and its body copy is
     --game-page, so the last-character accent must be mixed against
     --game-page to stay legible; mixing with --game-light-text turned it
     dark-on-dark (~1.6:1) in the light/warm themes. */
  color: color-mix(in srgb, var(--game-secondary) 45%, var(--game-page));
}

.wordchain-surface[data-game-theme] .word-timer-track {
  border-color: var(--game-line);
  background: var(--game-surface);
}

.wordchain-surface[data-game-theme] .word-timer-track span {
  background: var(--game-secondary);
}

.wordchain-surface[data-game-theme] #wordClock {
  background: var(--game-text);
  color: var(--game-page);
}

.wordchain-surface[data-game-theme] .answer-row {
  border-color: var(--game-line);
  background: color-mix(in srgb, var(--game-surface-soft) 72%, var(--game-surface));
  box-shadow: 0 10px 22px color-mix(in srgb, var(--game-text) 10%, transparent);
}

.wordchain-surface[data-game-theme] :is(.word-history-chip, .word-event, .word-player) {
  border-color: var(--game-line);
  background: var(--game-surface);
  color: var(--game-text);
}

.wordchain-surface[data-game-theme] .word-player.current {
  border-color: var(--game-secondary);
  background: var(--game-secondary-soft);
  color: var(--game-info-text);
}

.wordchain-surface[data-game-theme] .word-request-card {
  border-color: var(--game-line);
  background: var(--game-surface);
  color: var(--game-text);
  box-shadow: var(--game-shadow);
}

.indian-surface[data-game-theme] .indian-table {
  border-color: var(--game-line);
  background: color-mix(in srgb, var(--game-surface-soft) 72%, var(--game-surface));
}

.indian-surface[data-game-theme] .indian-player-card {
  border-color: var(--game-line);
  background: var(--game-surface);
  color: var(--game-text);
  box-shadow: 0 10px 22px color-mix(in srgb, var(--game-text) 10%, transparent);
}

.indian-surface[data-game-theme] .indian-player-card.mine {
  border-color: color-mix(in srgb, var(--game-positive-text) 42%, var(--game-line));
  background: var(--game-positive-bg);
}

.indian-surface[data-game-theme] :is(.indian-status-row strong, .indian-rolling-label) {
  background: var(--game-text);
  color: var(--game-page);
}

.indian-surface[data-game-theme] .indian-player-head em {
  background: var(--game-secondary-soft);
  color: var(--game-secondary);
}

.indian-surface[data-game-theme] .indian-d20-stage {
  border-color: var(--game-line);
  box-shadow: inset 0 0 30px color-mix(in srgb, var(--game-line) 18%, transparent);
}

.indian-surface[data-game-theme] .yacht-log-panel {
  border-color: var(--game-line);
}

/* Game adapters first developed for B, now driven by every global theme. */
.music-battle-surface[data-game-theme] .game-main-panel,
.music-surface[data-game-theme] .game-main-panel,
.pitch-surface[data-game-theme] .game-main-panel {
  background: var(--game-page);
}

.music-battle-surface[data-game-theme] .battle-layout {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.38fr);
  align-items: stretch;
  gap: var(--space-4);
}

.music-battle-surface[data-game-theme] .battle-layout > section {
  display: grid;
  align-content: start;
  gap: var(--space-3);
  min-height: 100%;
  border-color: var(--game-line);
  padding: var(--space-4);
  background: var(--game-surface-soft);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--game-text) 9%, transparent);
}

.music-battle-surface[data-game-theme] .battle-layout > section > h3 {
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--game-line);
  color: var(--game-text);
  font-size: var(--text-lg);
}

.music-battle-surface[data-game-theme] .music-status {
  min-height: 48px;
  border: 1px solid var(--game-line);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  background: var(--game-light-surface);
  color: var(--game-light-text);
  box-shadow: none;
}

.music-battle-surface[data-game-theme] .music-status .meta {
  color: var(--game-light-muted);
  font-weight: 750;
}

.music-battle-surface[data-game-theme] .music-status strong {
  color: var(--game-light-text);
  text-shadow: none;
}

.music-battle-surface[data-game-theme] .mask {
  display: grid;
  min-height: 104px;
  place-items: center;
  border-color: color-mix(in srgb, var(--game-accent) 34%, var(--game-line));
  padding: var(--space-4);
  background: var(--game-stage);
  color: var(--game-stage-text);
  font-size: clamp(var(--text-lg), 2.2cqi, var(--text-xl));
  line-height: 1.45;
  text-align: center;
  box-shadow: inset 0 0 28px color-mix(in srgb, var(--game-accent) 10%, transparent);
}

.music-battle-surface[data-game-theme] #battleResult {
  min-height: 48px;
  border: 1px solid color-mix(in srgb, var(--game-positive-text) 36%, var(--game-line));
  padding: var(--space-3);
  font-weight: 750;
}

.music-battle-surface[data-game-theme] .answer-row {
  gap: var(--space-3);
}

.music-battle-surface[data-game-theme] .answer-row input {
  min-height: 50px;
  border-color: color-mix(in srgb, var(--game-accent) 38%, var(--game-line));
  background: var(--game-surface);
}

.music-battle-surface[data-game-theme] .answer-row input::placeholder {
  color: var(--game-muted);
  opacity: 1;
}

.music-battle-surface[data-game-theme] :is(.leader-row, .log-entry) {
  border: 1px solid var(--game-line);
  background: var(--game-surface);
  color: var(--game-text);
}

.music-battle-surface[data-game-theme] #battleLog:not(:empty) {
  border: 1px solid var(--game-line);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  background: var(--game-surface);
}

.music-battle-surface[data-game-theme] .candidate-grid {
  border-color: var(--game-line);
  background: var(--game-surface);
  color: var(--game-text);
}

.music-battle-surface[data-game-theme] .candidate-grid.winner {
  border-color: var(--game-accent);
  background: var(--game-info-bg);
}

.music-surface[data-game-theme] .mask-board {
  border-color: var(--game-line);
  background: var(--game-surface-soft);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--game-text) 9%, transparent);
}

:is(
  .music-surface,
  .pitch-surface
)[data-game-theme] .music-status {
  border: 1px solid var(--game-line);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  background: var(--game-light-surface);
  color: var(--game-light-text);
  box-shadow: none;
}

:is(
  .music-surface,
  .pitch-surface
)[data-game-theme] .music-status .meta {
  color: var(--game-light-muted);
  font-weight: 750;
}

:is(
  .music-surface,
  .pitch-surface
)[data-game-theme] .music-status strong {
  color: var(--game-light-text);
  text-shadow: none;
}

.music-surface[data-game-theme] .mask {
  min-height: 132px;
  display: grid;
  place-items: center;
  border-color: color-mix(in srgb, var(--game-accent) 34%, var(--game-line));
  background: var(--game-stage);
  color: var(--game-stage-text);
  text-align: center;
  box-shadow: inset 0 0 28px color-mix(in srgb, var(--game-accent) 10%, transparent);
}

.music-surface[data-game-theme] .answer-row input {
  border-color: color-mix(in srgb, var(--game-accent) 38%, var(--game-line));
  background: var(--game-surface);
}

.music-surface[data-game-theme] .answer-row input::placeholder {
  color: var(--game-muted);
  opacity: 1;
}

.pitch-surface[data-game-theme] .pitch-keyboard-empty {
  border-color: var(--game-line);
  background: var(--game-surface-soft);
  color: var(--game-muted);
}

.pitch-surface[data-game-theme] .pitch-answer-stage {
  border-color: color-mix(in srgb, var(--game-accent) 42%, var(--game-line));
  background:
    radial-gradient(circle at center, color-mix(in srgb, var(--game-accent) 16%, transparent) 0 3%, transparent 3.5% 100%),
    radial-gradient(circle at center, transparent 0 31%, color-mix(in srgb, var(--game-accent) 13%, transparent) 31.5% 32%, transparent 32.5% 100%),
    radial-gradient(circle at center, transparent 0 42%, color-mix(in srgb, var(--game-line) 68%, transparent) 42.5% 43%, transparent 43.5% 100%),
    var(--game-stage);
  box-shadow: inset 0 0 40px color-mix(in srgb, var(--game-accent) 10%, transparent);
}

.pitch-surface[data-game-theme] .pitch-orbit-note {
  border-color: color-mix(in srgb, var(--game-accent) 70%, var(--game-line));
  background: var(--game-accent);
  color: var(--game-accent-text);
  box-shadow: 0 7px 18px color-mix(in srgb, var(--game-accent) 28%, transparent);
}

.pitch-surface[data-game-theme] .pitch-control-dock .log:not(:empty) {
  border: 1px solid var(--game-line);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  background: var(--game-surface);
  color: var(--game-text);
}

:is(
  .gamble-surface,
  .mafia-surface
)[data-game-theme] .game-main-panel {
  background: var(--game-page);
}

.gamble-surface[data-game-theme] .gamble-mode-card {
  border-color: var(--game-line);
  background: var(--game-surface-soft);
  color: var(--game-text);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--game-text) 8%, transparent);
}

.gamble-surface[data-game-theme] .gamble-mode-card .panel-head {
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--game-line);
}

.gamble-surface[data-game-theme] :is(.dice-scene, .slot-row) {
  border-color: color-mix(in srgb, var(--game-accent) 34%, var(--game-line));
  background: var(--game-stage);
  box-shadow: inset 0 0 28px color-mix(in srgb, var(--game-accent) 10%, transparent);
}

.gamble-surface[data-game-theme] .gamble-controls input,
.gamble-surface[data-game-theme] .gamble-mode-card > label input {
  border-color: color-mix(in srgb, var(--game-accent) 38%, var(--game-line));
  background: var(--game-surface);
  color: var(--game-text);
}

.context-pane[data-game-theme] .setting-note {
  border-color: var(--game-line);
  background: var(--game-surface-soft);
  color: var(--game-muted);
}

.mafia-surface[data-game-theme] .mafia-card {
  color: var(--game-text);
}

.mafia-surface[data-game-theme] .mafia-phase-banner {
  border-color: var(--game-line);
  background: linear-gradient(135deg, var(--game-surface-soft), color-mix(in srgb, var(--game-surface-soft) 74%, var(--game-secondary)));
  color: var(--game-text);
}

.mafia-surface[data-game-theme] .mafia-phase-banner span {
  color: var(--game-muted);
}

.mafia-surface[data-game-theme] .mafia-phase-banner.phase-night {
  border-color: color-mix(in srgb, var(--game-secondary) 56%, var(--game-line));
  background: linear-gradient(135deg, var(--game-secondary-soft), color-mix(in srgb, var(--game-secondary-soft) 68%, var(--game-secondary)));
}

.mafia-surface[data-game-theme] .mafia-phase-banner.phase-day {
  border-color: color-mix(in srgb, var(--game-warning-text) 44%, var(--game-line));
  background: linear-gradient(135deg, var(--game-warning-bg), color-mix(in srgb, var(--game-warning-bg) 76%, var(--game-warning-text)));
}

.mafia-surface[data-game-theme] .mafia-phase-banner.phase-vote {
  border-color: color-mix(in srgb, var(--game-danger-text) 44%, var(--game-line));
  background: linear-gradient(135deg, var(--game-danger-bg), color-mix(in srgb, var(--game-danger-bg) 76%, var(--game-danger-text)));
}

.mafia-surface[data-game-theme] :is(.mafia-player-card, .mafia-wait-panel, .mafia-lobby, .mafia-private-log) {
  border-color: var(--game-line);
  background: var(--game-surface-soft);
  color: var(--game-text);
}

.mafia-surface[data-game-theme] .mafia-player-card.is-selected {
  border-color: var(--game-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--game-accent) 22%, transparent);
}

.mafia-surface[data-game-theme] .mafia-role-card {
  border-color: color-mix(in srgb, var(--game-secondary) 58%, var(--game-line));
  background: linear-gradient(145deg, var(--game-secondary-soft), var(--game-surface));
  color: var(--game-text);
}

/* The resolution overlay is a dark scrim over the board in every theme, so it
   keeps the dark stage background but must pair it with light stage text. */
.mafia-surface[data-game-theme] .mafia-resolution-overlay {
  background: color-mix(in srgb, var(--game-stage) 90%, transparent);
  color: var(--game-stage-text);
}

/* Game adapters first developed for C, now driven by every global theme. */
.color-surface[data-game-theme] .game-main-panel {
  background: var(--game-surface);
}

.color-surface[data-game-theme] .music-status {
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  background: var(--game-secondary-soft);
}

.color-surface[data-game-theme] .music-status strong {
  color: var(--game-secondary);
}

.color-surface[data-game-theme] .color-grid {
  border: 1px solid color-mix(in srgb, var(--game-secondary) 38%, var(--game-line));
  background: color-mix(in srgb, var(--game-text) 92%, var(--game-secondary));
  box-shadow: 0 14px 28px color-mix(in srgb, var(--game-secondary) 14%, transparent);
}

.color-surface[data-game-theme] .choice-button {
  min-height: 46px;
  background: var(--game-surface-soft);
  color: var(--game-text);
}

.color-surface[data-game-theme] .choice-button:is(:hover, :focus-visible) {
  border-color: var(--game-accent);
  background: var(--game-secondary-soft);
  color: var(--game-secondary);
}

.color-surface[data-game-theme] .color-symbol-badge {
  background: var(--game-secondary-soft);
  color: var(--game-secondary);
}

.minesweeper-surface[data-game-theme] .game-main-panel {
  background: var(--game-surface);
}

.minesweeper-surface[data-game-theme] .mine-counter {
  border-color: var(--game-line);
  background: var(--game-surface-soft);
  color: var(--game-text);
}

.minesweeper-surface[data-game-theme] .mine-counter span {
  color: var(--game-muted);
}

.minesweeper-surface[data-game-theme] .mine-mode-button {
  border-color: var(--game-line);
  background: var(--game-surface-soft);
  color: var(--game-text);
}

.minesweeper-surface[data-game-theme] .mine-mode-button[aria-pressed="true"] {
  border-color: var(--game-accent);
  background: var(--game-secondary-soft);
  color: var(--game-secondary);
}

.minesweeper-surface[data-game-theme] .mine-status {
  color: var(--game-muted);
}

.minesweeper-surface[data-game-theme] .mine-status[data-tone="success"] {
  color: var(--game-positive-text);
}

.minesweeper-surface[data-game-theme] .mine-status[data-tone="danger"] {
  color: var(--game-danger-text);
}

.minesweeper-surface[data-game-theme] .mine-board {
  border-color: color-mix(in srgb, var(--game-secondary) 46%, var(--game-line));
  background: var(--game-secondary-soft);
  box-shadow: 0 12px 28px color-mix(in srgb, var(--game-secondary) 13%, transparent);
}

.minesweeper-surface[data-game-theme] .mine-cell {
  border-color: color-mix(in srgb, var(--game-line) 82%, var(--game-text));
  background: color-mix(in srgb, var(--game-secondary) 10%, var(--game-surface));
  color: var(--game-text);
}

.minesweeper-surface[data-game-theme] .mine-cell:hover:not(.is-revealed) {
  background: color-mix(in srgb, var(--game-secondary) 18%, var(--game-surface));
}

.minesweeper-surface[data-game-theme] .mine-cell.is-revealed {
  background: var(--game-surface-soft);
}

/* The classic per-count number palette and the flag red are semantic data —
   they must survive theming. The .mine-cell rule above sets color:var(--game-text)
   at the same specificity, so restore them here (later + equal/higher specificity). */
.minesweeper-surface[data-game-theme] .mine-cell.is-flagged {
  color: var(--game-danger-text);
}

.minesweeper-surface[data-game-theme] .mine-near-0 { color: var(--game-muted); }
.minesweeper-surface[data-game-theme] :is(.mine-near-1, .mine-near-9, .mine-near-17, .mine-near-25) { color: #246cba; }
.minesweeper-surface[data-game-theme] :is(.mine-near-2, .mine-near-10, .mine-near-18, .mine-near-26) { color: #24875b; }
.minesweeper-surface[data-game-theme] :is(.mine-near-3, .mine-near-11, .mine-near-19, .mine-near-27) { color: #b64646; }
.minesweeper-surface[data-game-theme] :is(.mine-near-4, .mine-near-12, .mine-near-20, .mine-near-28) { color: #7251b5; }
.minesweeper-surface[data-game-theme] :is(.mine-near-5, .mine-near-13, .mine-near-21, .mine-near-29) { color: #9a5a16; }
.minesweeper-surface[data-game-theme] :is(.mine-near-6, .mine-near-14, .mine-near-22, .mine-near-30) { color: #247c8d; }
.minesweeper-surface[data-game-theme] :is(.mine-near-7, .mine-near-15, .mine-near-23, .mine-near-31) { color: #8c3d6b; }
.minesweeper-surface[data-game-theme] :is(.mine-near-8, .mine-near-16, .mine-near-24, .mine-near-32) { color: var(--game-text); }

/* Night Circuit reveals numbers on a dark cell, where the classic palette dips
   below AA. Lift each hue so the count colours stay legible without losing identity. */
.minesweeper-surface[data-game-theme="night-circuit"] :is(.mine-near-1, .mine-near-9, .mine-near-17, .mine-near-25) { color: #74b6ff; }
.minesweeper-surface[data-game-theme="night-circuit"] :is(.mine-near-2, .mine-near-10, .mine-near-18, .mine-near-26) { color: #5fd39a; }
.minesweeper-surface[data-game-theme="night-circuit"] :is(.mine-near-3, .mine-near-11, .mine-near-19, .mine-near-27) { color: #ff8f8f; }
.minesweeper-surface[data-game-theme="night-circuit"] :is(.mine-near-4, .mine-near-12, .mine-near-20, .mine-near-28) { color: #bda6ff; }
.minesweeper-surface[data-game-theme="night-circuit"] :is(.mine-near-5, .mine-near-13, .mine-near-21, .mine-near-29) { color: #e6b15a; }
.minesweeper-surface[data-game-theme="night-circuit"] :is(.mine-near-6, .mine-near-14, .mine-near-22, .mine-near-30) { color: #58cede; }
.minesweeper-surface[data-game-theme="night-circuit"] :is(.mine-near-7, .mine-near-15, .mine-near-23, .mine-near-31) { color: #f19ad0; }

.context-pane[data-game-theme] :is(.mine-help, .mine-license-note, .mine-custom-note) {
  color: var(--game-muted);
}

/* Phase 3: non-3D game surface polish ------------------------------------- */
:where(
  .gamble-surface,
  .color-surface,
  .pitch-surface,
  .music-surface,
  .music-battle-surface,
  .wordchain-surface,
  .indian-surface,
  .drawing-surface
) .game-card {
  gap: var(--space-4);
}

.game-layout:is(
  .gamble-surface,
  .color-surface,
  .pitch-surface,
  .music-surface,
  .music-battle-surface,
  .wordchain-surface,
  .indian-surface,
  .drawing-surface
) :is(input, select, button) {
  min-height: 44px;
}

.game-layout:is(
  .gamble-surface,
  .color-surface,
  .pitch-surface,
  .music-surface,
  .music-battle-surface,
  .wordchain-surface,
  .indian-surface,
  .drawing-surface
) :is(.primary-button, .choice-button) {
  min-height: 48px;
}

/* U2 — betting controls and presentation areas stay visually separate. */
.gamble-panels,
.gamble-mode-layout,
.gamble-controls {
  gap: var(--space-4);
}

.gamble-mode-card {
  border-color: var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  background: var(--surface);
}

.gamble-mode-card > label,
.gamble-controls > label {
  display: grid;
  gap: var(--space-1);
}

.gamble-mode-card input[type="number"],
.gamble-controls input[type="number"] {
  min-height: 48px;
  font-size: var(--text-lg);
  font-weight: 800;
}

.gamble-controls .choice-row {
  gap: var(--space-2);
}

.dice-scene,
.slot-row {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  background: color-mix(in srgb, var(--surface-soft) 86%, var(--surface));
}

/* U3 — keep the board centered and make answers feel like primary play. */
.color-surface #colorBoard {
  display: grid;
  place-items: center;
  min-height: min(54dvh, 560px);
}

.color-surface .color-grid {
  gap: var(--space-1);
  border-radius: var(--radius-md);
  padding: var(--space-2);
}

.color-surface .choice-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--space-2);
}

.color-surface .music-status strong,
.pitch-surface .music-status strong,
.music-surface .music-status strong,
.music-battle-surface .music-status strong {
  font-size: var(--text-lg);
  font-variant-numeric: tabular-nums;
}

/* U4 — playback and answer controls share one predictable rhythm. */
.pitch-surface .pitch-keyboard,
.pitch-surface .pitch-keyboard-empty {
  width: 100%;
  max-width: none;
}

.pitch-play-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  align-items: start;
}

.pitch-play-primary,
.pitch-play-secondary {
  display: grid;
  min-width: 0;
  gap: var(--space-3);
  align-content: start;
}

.pitch-answer-stage {
  position: relative;
  container-type: inline-size;
  display: grid;
  width: min(100%, 520px);
  aspect-ratio: 1;
  min-height: 0;
  place-items: center;
  justify-self: center;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--line));
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at center, color-mix(in srgb, var(--accent) 13%, transparent) 0 3%, transparent 3.5% 100%),
    radial-gradient(circle at center, transparent 0 31%, color-mix(in srgb, var(--accent) 12%, transparent) 31.5% 32%, transparent 32.5% 100%),
    radial-gradient(circle at center, transparent 0 42%, color-mix(in srgb, var(--line) 64%, transparent) 42.5% 43%, transparent 43.5% 100%),
    linear-gradient(145deg, color-mix(in srgb, var(--surface) 92%, var(--accent)), var(--surface));
  box-shadow: inset 0 0 36px color-mix(in srgb, var(--accent) 9%, transparent);
}

.pitch-answer-orbit {
  position: absolute;
  inset: 0;
}

.pitch-orbit-item {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  animation: pitch-orbit-clockwise var(--orbit-duration) linear infinite;
  transform-origin: 0 0;
  will-change: transform;
}

.pitch-orbit-note {
  display: grid;
  min-width: 2.3em;
  min-height: 2.3em;
  place-items: center;
  transform: translate(-50%, -50%);
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line));
  border-radius: 999px;
  padding: 0.42em 0.62em;
  background: color-mix(in srgb, var(--accent) 82%, #ffffff);
  color: #fff;
  font-size: var(--orbit-size);
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 7px 18px color-mix(in srgb, var(--accent) 28%, transparent);
  cursor: pointer;
}

.pitch-orbit-note:hover,
.pitch-orbit-note:focus-visible {
  filter: brightness(1.12);
  outline: 3px solid color-mix(in srgb, var(--accent) 24%, transparent);
  outline-offset: 2px;
}

.pitch-answer-feedback {
  position: relative;
  z-index: 4;
  color: var(--accent);
  font-size: clamp(68px, 25cqi, 128px);
  font-weight: 950;
  line-height: 1;
  opacity: 0;
  transform: scale(0.72);
  transition: opacity 160ms ease, transform 240ms cubic-bezier(.2, .8, .2, 1);
  pointer-events: none;
}

.pitch-answer-stage[data-feedback="correct"] .pitch-answer-feedback,
.pitch-answer-stage[data-feedback="wrong"] .pitch-answer-feedback {
  opacity: 0.92;
  transform: scale(1);
}

.pitch-answer-stage[data-feedback="wrong"] .pitch-answer-feedback {
  color: var(--danger);
}

.pitch-control-dock {
  display: grid;
  gap: var(--space-2);
  align-self: end;
}

.pitch-control-dock .log {
  max-height: 84px;
  overflow: auto;
}

@keyframes pitch-orbit-clockwise {
  from {
    transform: rotate(var(--orbit-start)) translateX(var(--orbit-radius));
  }
  to {
    transform: rotate(calc(var(--orbit-start) + 360deg)) translateX(var(--orbit-radius));
  }
}

.pitch-surface .answer-row,
.pitch-surface .play-action-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-2);
}

.pitch-surface .answer-row input {
  width: 100%;
  max-width: none;
}

.pitch-surface .piano-key {
  min-height: 48px;
}

/* U5 — question progress, answer, score, and result are distinct surfaces. */
.music-surface .mask-board,
.music-battle-surface .battle-layout > section {
  width: 100%;
  max-width: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  background: var(--surface-soft);
}

.music-surface .answer-row,
.music-battle-surface .answer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-2);
}

.music-surface .answer-row input,
.music-battle-surface .answer-row input {
  width: 100%;
  max-width: none;
}

.music-battle-surface .battle-layout {
  gap: var(--space-3);
}

.candidate-grid.winner {
  border-color: color-mix(in srgb, var(--positive) 45%, var(--line));
  background: color-mix(in srgb, var(--positive) 12%, var(--surface));
}

/* U6 — turn, clock, participants, and entry remain easy to scan. */
.wordchain-game-card,
.wordchain-play-grid,
.wordchain-play-column {
  width: 100%;
  min-width: 0;
}

.wordchain-play-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: var(--space-3);
}

.wordchain-play-column {
  display: grid;
  align-content: start;
  gap: var(--space-3);
}

.wordchain-surface .word-status {
  position: relative;
  width: 100%;
  max-width: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  background: var(--surface-soft);
}

.wordchain-surface .word-clock,
.wordchain-surface #wordClock {
  min-height: 44px;
  align-self: start;
  font-size: var(--text-lg);
  font-variant-numeric: tabular-nums;
}

.wordchain-surface .word-player-list {
  gap: var(--space-2);
}

.wordchain-surface .current-word {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 112px;
  align-items: center;
  justify-content: center;
  gap: var(--word-fitted-gap, 0.08em);
  overflow: hidden;
  box-sizing: border-box;
  background: var(--word-display-bg);
  color: var(--word-display-text);
  font-size: var(--word-fitted-font-size, clamp(2.3rem, 8cqi, 4.8rem));
  font-weight: 800;
  letter-spacing: var(--word-fitted-letter-spacing, 0.04em);
  text-align: center;
}

.word-character {
  display: inline-block;
  transform-origin: center;
}

.word-character-last {
  color: var(--warning);
  font-size: 1.28em;
  text-shadow: 0 0 0.5em color-mix(in srgb, var(--warning) 28%, transparent);
}

.word-timer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2);
}

.word-timer-track {
  height: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.word-timer-track span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms linear;
}

.word-history {
  display: flex;
  min-height: 42px;
  gap: var(--space-2);
  overflow-x: auto;
  padding-block: var(--space-1);
  scrollbar-width: thin;
}

.word-history-chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: var(--space-1) var(--space-2);
  background: var(--surface-soft);
  color: var(--text-muted);
}

.word-source-fieldset {
  display: grid;
  gap: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.word-source-choices,
.word-time-fields {
  display: grid;
  gap: var(--space-2);
}

.word-source-choice,
.word-custom-toggle {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: var(--space-2);
}

.word-time-fields input[type="range"] {
  width: 100%;
}

.word-chat-panel {
  display: grid;
  min-width: 0;
  min-height: 100%;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  background: var(--surface-soft);
}

.word-event-log {
  display: flex;
  min-height: 420px;
  max-height: min(70vh, 720px);
  flex-direction: column;
  gap: var(--space-2);
  overflow-y: auto;
}

.word-event {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  color: var(--text);
}

.word-event-success {
  border-color: color-mix(in srgb, var(--positive) 48%, var(--line));
  background: color-mix(in srgb, var(--positive) 14%, var(--surface));
  color: var(--positive-text);
}

.word-event-failure {
  border-color: color-mix(in srgb, var(--danger) 48%, var(--line));
  background: color-mix(in srgb, var(--danger) 13%, var(--surface));
  color: var(--danger-text);
}

.word-event-system {
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}

.word-event-chat {
  justify-content: flex-start;
}

.word-event-chat strong {
  color: var(--text-muted);
}

.word-chat-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-2);
}

.word-request-modal {
  position: fixed;
  z-index: 30;
  inset: 0;
  place-items: center;
  padding: var(--space-3);
  background: color-mix(in srgb, var(--text) 35%, transparent);
}

.word-request-modal:not([hidden]) {
  display: grid;
}

.word-request-card {
  display: grid;
  width: min(520px, 100%);
  gap: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.word-request-card label {
  display: grid;
  gap: var(--space-1);
}

.word-request-card textarea {
  min-height: 96px;
  resize: vertical;
}

.admin-word-request-row,
.admin-word-request-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.admin-word-request-row {
  justify-content: space-between;
}

.wordchain-surface .word-player {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding-inline: var(--space-3);
}

.word-player.current {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--info-text);
}

.word-player.loser {
  border-color: color-mix(in srgb, var(--danger) 42%, var(--line));
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  color: var(--danger-text);
}

.wordchain-surface .answer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: var(--space-2);
}

.wordchain-surface .answer-row input {
  width: 100%;
  max-width: none;
}

/* U7 — preserve the card and die drama while standardizing controls. */
.indian-table {
  gap: var(--space-3);
  border-color: var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  background: color-mix(in srgb, var(--surface-soft) 82%, var(--surface));
}

.indian-player-card {
  gap: var(--space-2);
  border-color: var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.indian-player-card.mine {
  border-color: color-mix(in srgb, var(--positive) 34%, var(--line));
  background: color-mix(in srgb, var(--positive) 7%, var(--surface));
}

.indian-status-row strong,
.indian-rolling-label {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  color: var(--text);
}

.indian-player-head em {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--info-text);
}

.indian-d20-stage {
  border-color: var(--line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--surface) 70%, transparent), transparent 38%),
    linear-gradient(145deg, var(--surface-soft), color-mix(in srgb, var(--line) 72%, var(--surface)));
}

.indian-d20-values span.hidden,
.indian-number.hidden {
  background: color-mix(in srgb, var(--line) 58%, var(--surface));
  color: var(--text-muted);
}

.indian-action-buttons {
  gap: var(--space-2);
}

.indian-action-buttons button {
  min-height: 48px;
}

/* U8 — toolbar and chat use shell surfaces; the drawing paper remains game media. */
.drawing-status-strip,
.drawing-play-layout,
.drawing-board-column,
.drawing-board-toolbar,
.drawing-chat-panel,
.drawing-tool-actions {
  gap: var(--space-2);
}

.drawing-status-strip span,
.drawing-board-toolbar,
.drawing-chat-panel {
  border-color: var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.drawing-word-pill {
  background: color-mix(in srgb, var(--warning) 12%, var(--surface)) !important;
}

.drawing-word-setup {
  gap: var(--space-2);
  border-color: var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: color-mix(in srgb, var(--surface) 97%, transparent);
  box-shadow: var(--shadow);
}

.drawing-board-wrap {
  border-color: var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--text) 4%, transparent) 1px, transparent 1px),
    linear-gradient(color-mix(in srgb, var(--text) 4%, transparent) 1px, transparent 1px),
    var(--surface-soft);
}

.drawing-chat-message,
.drawing-chat-empty,
.drawing-guess,
.drawing-guess-empty {
  border-color: var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
}

.drawing-chat-message strong {
  color: var(--text-muted);
}

.drawing-player span,
.drawing-player em {
  background: var(--surface-soft);
  color: var(--text-muted);
}

.drawing-player.drawer span {
  background: color-mix(in srgb, var(--warning) 14%, var(--surface));
  color: var(--warning-text);
}

.drawing-brush-field select {
  min-height: 44px;
  border-color: var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.drawing-tool-actions button,
.drawing-color-field input {
  min-height: 44px;
}

@media (max-width: 820px) {
  .music-battle-surface[data-game-theme] .battle-layout,
  .music-battle-surface .battle-layout,
  .indian-duel-row,
  .drawing-play-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .wordchain-surface .answer-row {
    position: sticky;
    bottom: calc(58px + env(safe-area-inset-bottom));
    z-index: 3;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: var(--space-2);
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .drawing-board-column {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .drawing-board-toolbar,
  .drawing-board-toolbar:has(.drawing-brush-field:not([hidden])) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .drawing-tool-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  .gamble-mode-card {
    padding: var(--space-3);
  }

  .color-surface #colorBoard {
    min-height: auto;
  }

  .color-surface .choice-row,
  .pitch-surface .answer-row,
  .pitch-surface .play-action-row,
  .music-surface .answer-row,
  .music-battle-surface .answer-row,
  .wordchain-surface .answer-row,
  .drawing-word-setup-controls,
  .drawing-answer-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .word-chat-compose,
  .admin-word-request-row,
  .admin-word-request-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-word-request-row,
  .admin-word-request-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .music-surface .answer-row button,
  .music-battle-surface .answer-row button,
  .wordchain-surface .answer-row button,
  .drawing-answer-row button {
    width: 100%;
  }

  .drawing-board-toolbar,
  .drawing-board-toolbar:has(.drawing-brush-field:not([hidden])) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .drawing-tool-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-column: 1 / -1;
  }

  .drawing-tool-actions button {
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .word-character,
  .word-timer-track span {
    animation: none;
    transition: none;
  }
}

/* Phase 5 pilot: component thresholds follow the real game panel width. */
@container game-main (max-width: 720px) {
  .wordchain-play-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .wordchain-surface .current-word {
    min-height: 92px;
    font-size: var(--word-fitted-font-size, clamp(2rem, 15cqi, 3.6rem));
  }

  .wordchain-surface .answer-row,
  .word-chat-compose {
    grid-template-columns: minmax(0, 1fr);
  }

  .word-event-log {
    min-height: 280px;
    max-height: 460px;
  }

  .yut-tabletop {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas: "board";
  }

  .drawing-play-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .drawing-board-toolbar,
  .drawing-board-toolbar:has(.drawing-brush-field:not([hidden])) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .drawing-tool-actions {
    grid-column: 1 / -1;
  }

  .indian-duel-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .indian-player-card.left-seat {
    grid-column: 1;
    grid-row: 1;
  }

  .indian-player-card.right-seat {
    grid-column: 2;
    grid-row: 1;
  }

  .indian-center-panel {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

/* Desktop play surfaces fit the usable browser height. The main panel itself
   never scrolls; each board/canvas receives the remaining row instead. */
@media (min-width: 821px) {
  .game-layout:is(
    .minesweeper-surface,
    .sudachi-surface,
    .color-surface,
    .pitch-surface,
    .yacht-surface,
    .yut-surface,
    .omok-surface,
    .drawing-surface,
    .mahjong-surface
  ) .game-main-panel {
    height: var(--desktop-play-height);
    min-height: 0;
    max-height: var(--desktop-play-height);
    overflow: hidden;
  }

  .game-layout:is(.color-surface, .music-surface) {
    width: min(100%, 780px);
    justify-self: center;
    margin-inline: auto;
  }

  .game-layout.pitch-surface {
    width: 80%;
    margin-inline: auto;
  }

  .game-layout:is(.yacht-surface, .yut-surface) {
    width: 80%;
    margin-inline: auto;
  }

  .pitch-surface .game-card,
  .pitch-play-grid,
  .pitch-play-primary,
  .pitch-play-secondary {
    height: 100%;
    min-height: 0;
  }

  .pitch-play-grid {
    align-items: stretch;
  }

  .pitch-play-primary {
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }

  .pitch-play-secondary {
    grid-template-rows: minmax(0, 1fr) auto;
    overflow: hidden;
  }

  .pitch-surface .pitch-keyboard {
    height: 100%;
    min-height: 0;
    grid-template-rows: repeat(5, minmax(0, 1fr));
    gap: clamp(5px, 1vh, 10px);
    align-content: start;
  }

  .pitch-surface .octave-row,
  .pitch-surface .octave-label,
  .pitch-surface .piano-octave {
    min-height: 0;
  }

  .pitch-surface .white-keys {
    height: 100%;
  }

  .pitch-surface .piano-key {
    min-height: 0;
  }

  .pitch-surface .black-key {
    height: 62%;
  }

  .pitch-surface .pitch-answer-stage {
    width: auto;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
  }

  .game-layout:is(
    .minesweeper-surface,
    .sudachi-surface,
    .yacht-surface,
    .yut-surface,
    .omok-surface,
    .drawing-surface,
    .mahjong-surface
  ) .game-card {
    height: 100%;
    min-height: 0;
  }

  .mine-card {
    grid-template-rows: auto auto auto minmax(0, 1fr);
    gap: var(--space-2);
  }

  .mine-board-scroll {
    height: 100%;
    min-height: 0;
  }

  .sudachi-card {
    position: relative;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: var(--space-2);
  }

  .sudachi-board {
    height: 100%;
    min-height: 0;
    aspect-ratio: auto;
  }

  .sudachi-analysis:not(.is-hidden) {
    position: absolute;
    right: var(--space-3);
    bottom: 58px;
    z-index: 7;
    width: min(52%, 560px);
    max-height: calc(100% - 150px);
    overflow: auto;
    box-shadow: var(--shadow);
  }

  .yacht-card {
    grid-template-rows: minmax(0, 1fr) auto;
    gap: var(--space-2);
  }

  .yacht-layout,
  .yacht-play,
  .yacht-score-wrap {
    min-height: 0;
  }

  .yacht-layout {
    height: 100%;
    grid-template-columns: minmax(330px, 0.92fr) minmax(370px, 1.08fr);
    align-items: stretch;
    gap: var(--space-3);
  }

  .yacht-play {
    height: 100%;
    grid-template-rows: auto minmax(0, 1fr) auto auto auto;
    gap: var(--space-2);
  }

  .yacht-dice-tray,
  .yacht-board {
    width: 100%;
    height: auto;
    min-height: 0;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1;
    align-self: center;
    justify-self: center;
  }

  .yacht-score-wrap {
    overflow: hidden;
  }

  .yacht-scoreboard,
  .yacht-score-head,
  .yacht-score-row {
    gap: 3px;
  }

  .yacht-score-row > span,
  .yacht-score-row > strong,
  .score-pick {
    min-height: 28px;
    padding-block: 4px;
    font-size: 12px;
  }

  .yacht-log-panel .log {
    max-height: 72px;
  }

  .yut-card {
    grid-template-rows: auto minmax(0, 1fr);
    gap: var(--space-2);
  }

  .yut-layout {
    display: grid;
    height: 100%;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-3);
  }

  .yut-tabletop {
    height: 100%;
    min-height: 0;
    padding: var(--space-2);
  }

  .yut-board-stage {
    width: 100%;
    height: 100%;
  }

  .yut-board-wrap {
    display: grid;
    min-height: 0;
    place-items: center;
    overflow: hidden;
  }

  .yut-board-perspective {
    width: 100%;
    height: auto;
    max-height: 100%;
    aspect-ratio: 16 / 10;
    margin: 0 auto;
  }

  .yut-board {
    width: 100%;
    height: auto;
  }

  .yut-throw-dock {
    min-height: 0;
    overflow: hidden;
  }

  .yut-side-column {
    display: grid;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: var(--space-2);
    overflow: hidden;
  }

  .yut-side-column .yut-player-grid {
    align-content: start;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-1);
    overflow: hidden;
  }

  .yut-side-column .yut-player {
    gap: var(--space-1);
    padding: 7px;
  }

  .yut-side-column .yut-player p,
  .yut-side-column .yut-piece-summary span {
    padding: 5px 6px;
    font-size: 11px;
  }

  .omok-card {
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    gap: var(--space-2);
  }

  .omok-board-wrap {
    align-self: center;
    width: fit-content;
    max-width: 100%;
    max-height: 100%;
    overflow: hidden;
    padding: 7px;
  }

  .omok-board {
    --omok-cell: clamp(22px, calc((var(--desktop-play-height) - 248px) / 16), 36px);
  }

  .drawing-card {
    grid-template-rows: auto minmax(0, 1fr) auto auto auto;
    gap: var(--space-2);
  }

  .drawing-play-layout,
  .drawing-board-column,
  .drawing-board-wrap {
    height: 100%;
    min-height: 0;
  }

  .drawing-board-wrap {
    display: grid;
    place-items: center;
    overflow: hidden;
  }

  .drawing-canvas {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 100%;
  }

  .drawing-status-strip span {
    padding-block: 6px;
  }

  .drawing-player-grid {
    gap: var(--space-1);
  }

  .drawing-player {
    padding: 6px 8px;
  }

  .mahjong-card:is(.mahjong-3d-pending, .mahjong-3d-active) {
    grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
    gap: var(--space-2);
  }

  .mahjong-card:is(.mahjong-3d-pending, .mahjong-3d-active) .mahjong-status-strip,
  .mahjong-card.mahjong-3d-pending .mahjong-hand-panel {
    display: none;
  }

  .mahjong-card:is(.mahjong-3d-pending, .mahjong-3d-active) .mahjong-table-3d {
    height: 100%;
    min-height: 0;
  }
}

@media (max-width: 820px) {
  .pitch-play-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-operations-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Lounge Phase 1 --------------------------------------------------------- */
.game-layout.lounge-surface {
  display: block;
  height: 100%;
}

.lounge-surface .game-main-panel {
  min-height: min(860px, calc(100svh - 92px));
  height: calc(100svh - 92px);
  overflow: hidden;
  padding: 0;
  background: #151b24;
}

.lounge-heading-actions {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.lounge-heading-buttons,
.lounge-heading-toolbar,
.lounge-2d-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.lounge-heading-toolbar {
  flex-wrap: nowrap;
}

.lounge-presence-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 12px;
}

.lounge-presence-controls button {
  min-width: 0;
  padding-inline: 8px;
}

.lounge-cookie-status {
  margin: 10px 0 0;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  border-radius: 13px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface-strong) 88%, transparent);
}

.lounge-cookie-status[data-tone="positive"] {
  color: var(--positive-text, #2f7657);
  border-color: color-mix(in srgb, #4f9b72 45%, var(--line));
}

.lounge-cookie-status[data-tone="warn"] {
  color: var(--warning-text, #966423);
  border-color: color-mix(in srgb, #c58a3b 48%, var(--line));
}

.lounge-cookie-status[data-tone="danger"] {
  color: var(--danger-text, #a34b4b);
  border-color: color-mix(in srgb, #c95f5f 45%, var(--line));
}

.lounge-phase-five-controls,
.lounge-decor-admin {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px 0;
  background: #111721;
}

.lounge-phase-five-controls > span {
  margin-left: auto;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 6px 10px;
  color: #e9c38f;
  font-size: 0.74rem;
}

.lounge-decor-admin {
  padding-bottom: 9px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.lounge-settings .lounge-decor-admin {
  display: grid;
  align-items: stretch;
  padding: var(--space-3);
  background: transparent;
  border-top: 0;
}

.lounge-2d-actions {
  justify-content: flex-start;
  margin-bottom: 10px;
}

.lounge-2d-actions > span {
  margin-left: auto;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 6px 10px;
  color: #e9c38f;
  font-size: 0.74rem;
}

.lounge-decor-admin[hidden] {
  display: none;
}

.lounge-weather-controls[hidden],
.lounge-weather-fields[hidden] {
  display: none;
}

.lounge-weather-fields {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 4px 0 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

.lounge-weather-fields legend {
  padding: 0 5px;
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 800;
}

.lounge-decor-admin label {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.78rem;
  font-weight: 800;
}

.lounge-decor-admin select {
  min-width: 160px;
}

.lounge-teapot-status {
  position: absolute;
  left: 50%;
  top: 46%;
  z-index: 7;
  display: grid;
  gap: 3px;
  min-width: min(330px, calc(100% - 32px));
  transform: translate(-50%, -50%);
  border: 1px solid rgba(242, 209, 139, 0.52);
  border-radius: 14px;
  padding: 12px 16px;
  background: rgba(16, 24, 30, 0.92);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.34);
  color: #f7f1e7;
  text-align: center;
  pointer-events: none;
  backdrop-filter: blur(10px);
}

.lounge-teapot-status[hidden] {
  display: none;
}

.lounge-teapot-status strong {
  color: #f2d18b;
  font-size: 1.05rem;
}

.lounge-teapot-status span {
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.8rem;
}

.lounge-music-dialog {
  width: min(520px, calc(100vw - 28px));
  padding: 22px;
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  border-radius: 22px;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 96%, #2d1c18 4%);
  box-shadow: 0 26px 80px rgba(24, 15, 13, 0.32);
}

.lounge-music-dialog::backdrop {
  background: rgba(28, 19, 17, 0.58);
  backdrop-filter: blur(4px);
}

.lounge-music-dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.lounge-music-dialog-head h3,
.lounge-music-dialog-head p { margin: 0; }
.lounge-music-meta { color: var(--muted); }
.lounge-music-progress { width: 100%; }

.lounge-music-admin {
  display: grid;
  gap: 9px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.lounge-music-admin[hidden] { display: none; }

.lounge-music-admin-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.lounge-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
  min-height: 0;
  color: #f6f2ea;
}

.lounge-heading {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 14px 18px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(18, 24, 34, 0.98), rgba(18, 24, 34, 0.86));
}

.lounge-heading h3,
.lounge-heading p {
  margin: 0;
}

.lounge-heading h3 {
  margin-top: 2px;
  font-size: clamp(1.2rem, 2vw, 1.65rem);
}

.lounge-heading .meta {
  color: #e2b779;
}

.lounge-heading > div:first-child > p:last-child {
  margin-top: 4px;
  color: rgba(246, 242, 234, 0.72);
}

.lounge-scene-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.lounge-scene-badges span {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(9, 13, 20, 0.58);
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.72rem;
  text-transform: capitalize;
  backdrop-filter: blur(8px);
}

.lounge-scene-frame {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 25%, rgba(130, 173, 215, 0.24), transparent 44%),
    #111722;
  isolation: isolate;
}

.lounge-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 420px;
  outline: none;
  touch-action: none;
  cursor: grab;
  opacity: 0;
  transition: opacity 320ms ease;
}

.lounge-scene-frame.is-ready .lounge-canvas {
  opacity: 1;
}

.lounge-canvas:active {
  cursor: grabbing;
}

.lounge-canvas:focus-visible {
  box-shadow: inset 0 0 0 3px var(--focus-ring);
}

/* Lounge Phase 6: avatar billboards -------------------------------------- */
.lounge-presence-stage {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

.lounge-presence-billboard {
  position: absolute;
  left: var(--presence-x);
  top: var(--presence-y);
  z-index: calc(2 + var(--presence-order));
  display: grid;
  justify-items: center;
  transform: translate(-50%, -100%);
  filter: drop-shadow(0 7px 9px rgba(0, 0, 0, 0.34));
  transform-origin: 50% 100%;
}

.lounge-presence-billboard:not(.is-2d) .lounge-presence-avatar {
  display: none;
}

.lounge-presence-billboard.is-2d .lounge-presence-nameplate {
  margin-top: -2px;
}

.lounge-presence-avatar {
  position: relative;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 50%;
  background: linear-gradient(145deg, #789aa4, #465c71);
  color: #fff8e9;
  font-weight: 900;
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.34);
}

.lounge-presence-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lounge-presence-nameplate {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 150px;
  margin-top: -2px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  padding: 3px 8px;
  background: rgba(12, 18, 27, 0.88);
  color: #fff9ef;
  white-space: nowrap;
  backdrop-filter: blur(7px);
}

.lounge-presence-nameplate strong {
  overflow: hidden;
  max-width: 90px;
  font-size: 0.68rem;
  text-overflow: ellipsis;
}

.lounge-presence-nameplate small {
  border-radius: 999px;
  padding: 1px 4px;
  background: #5f89b6;
  color: #fff;
  font-size: 0.56rem;
  font-weight: 900;
}

.lounge-presence-title {
  max-width: 54px;
  overflow: hidden;
  font-size: 0.54rem;
  text-overflow: ellipsis;
}

.lounge-presence-billboard.is-self .lounge-presence-avatar {
  border-color: #8fd6ff;
  box-shadow: 0 0 0 3px rgba(103, 187, 235, 0.22), 0 5px 16px rgba(0, 0, 0, 0.34);
}

.lounge-presence-billboard.nameplate-gilt .lounge-presence-nameplate {
  border-color: #e9c873;
  background: linear-gradient(100deg, rgba(67, 44, 17, 0.94), rgba(120, 82, 29, 0.9));
}

.lounge-presence-billboard.nameplate-pearl .lounge-presence-nameplate {
  border-color: #ddedf0;
  background: linear-gradient(100deg, rgba(47, 64, 75, 0.94), rgba(102, 119, 132, 0.9));
}

.lounge-presence-billboard.nameplate-inkline .lounge-presence-nameplate {
  border-color: #d7cec0;
  background: rgba(27, 29, 32, 0.94);
}

.lounge-presence-action {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 5px);
  animation: lounge-presence-action 1.5s ease both;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(18, 24, 31, 0.94);
  color: #fff3d8;
  font-size: 0.7rem;
  font-weight: 900;
  white-space: nowrap;
}

.lounge-presence-billboard.is-joining {
  animation: lounge-presence-arrive 520ms cubic-bezier(.2, .85, .24, 1.18) both;
}

.lounge-presence-billboard.is-leaving {
  animation: lounge-presence-leave 500ms ease-in both;
}

@keyframes lounge-presence-arrive {
  from { opacity: 0; transform: translate(-50%, -80%) scale(0.55); }
  to { opacity: 1; transform: translate(-50%, -100%) scale(1); }
}

@keyframes lounge-presence-leave {
  to { opacity: 0; transform: translate(-50%, -125%) scale(0.72); }
}

@keyframes lounge-presence-action {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(0.8); }
  18%, 76% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -10px) scale(0.9); }
}

.lounge-loading,
.lounge-fallback {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: linear-gradient(145deg, #172131, #26354b);
}

.lounge-loading[hidden],
.lounge-fallback[hidden] {
  display: none;
}

.lounge-loading-orbit {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255, 255, 255, 0.16);
  border-top-color: #e6b77b;
  border-radius: 50%;
  animation: lounge-loading-spin 900ms linear infinite;
}

@keyframes lounge-loading-spin {
  to { transform: rotate(360deg); }
}

.lounge-fallback {
  background:
    linear-gradient(rgba(20, 29, 42, 0.9), rgba(20, 29, 42, 0.96)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0 12px, transparent 12px 24px);
}

.lounge-fallback p {
  max-width: 520px;
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
}

.lounge-scene-frame.is-fallback .lounge-canvas,
.lounge-scene-frame.is-fallback .lounge-controls-hint {
  display: none;
}

.lounge-portal-tooltip {
  position: absolute;
  z-index: 5;
  display: grid;
  min-width: 170px;
  max-width: min(280px, calc(100% - 24px));
  transform: translate(-50%, -100%);
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 10px;
  padding: 9px 12px;
  background: rgba(10, 15, 23, 0.9);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.32);
  color: white;
  text-align: center;
  backdrop-filter: blur(10px);
}

.lounge-portal-tooltip[hidden] {
  display: none;
}

.lounge-portal-tooltip span {
  margin-top: 2px;
  color: #e9c38f;
  font-size: 0.78rem;
}

.lounge-activity-preview,
.lounge-room-alerts {
  position: absolute;
  top: 12px;
  z-index: 4;
  width: min(270px, calc(50% - 24px));
  max-height: min(310px, calc(100% - 58px));
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.19);
  border-radius: 12px;
  padding: 10px;
  background: rgba(9, 14, 22, 0.82);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
  color: #f7f1e7;
  backdrop-filter: blur(10px);
}

.lounge-activity-preview { left: 12px; }
.lounge-room-alerts { right: 12px; }

.lounge-activity-preview > div,
.lounge-room-alerts > header,
.lounge-room-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.lounge-activity-preview > div > button {
  min-height: 28px;
  border: 0;
  padding: 2px 5px;
  background: transparent;
  color: #e9c38f;
  font-size: 0.72rem;
}

.lounge-activity-preview ol,
.lounge-activity-dialog-list {
  display: grid;
  gap: 6px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.lounge-activity-preview li > button,
.lounge-activity-dialog-list li > button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
  width: 100%;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 7px 8px;
  background: rgba(255, 255, 255, 0.055);
  color: inherit;
  text-align: left;
}

.lounge-activity-preview li > button:hover,
.lounge-activity-preview li > button:focus-visible,
.lounge-activity-dialog-list li > button:hover,
.lounge-activity-dialog-list li > button:focus-visible {
  border-color: #e5b571;
  background: rgba(229, 181, 113, 0.12);
}

.lounge-activity-preview li span,
.lounge-activity-dialog-list li span {
  display: grid;
  min-width: 0;
}

.lounge-activity-preview li strong,
.lounge-activity-preview li small,
.lounge-activity-dialog-list li strong,
.lounge-activity-dialog-list li small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lounge-activity-preview li small,
.lounge-activity-preview time,
.lounge-activity-dialog-list li small,
.lounge-activity-dialog-list time {
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.68rem;
}

.lounge-room-alerts > header > span {
  min-width: 24px;
  border-radius: 999px;
  padding: 2px 7px;
  background: #9b5154;
  text-align: center;
  font-size: 0.72rem;
}

.lounge-room-alert-list {
  display: grid;
  gap: 7px;
  margin-top: 8px;
}

.lounge-room-card {
  border-left: 3px solid #ba8b4b;
  border-radius: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.lounge-room-card[data-status="startable"] { border-left-color: #72c895; }
.lounge-room-card[data-status="running"] { border-left-color: #a999e7; }

.lounge-room-card-head span {
  color: #e9c38f;
  font-size: 0.68rem;
}

.lounge-room-card p {
  margin: 4px 0 7px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.7rem;
}

.lounge-room-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.lounge-room-actions button {
  min-height: 30px;
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 0.7rem;
}

.lounge-empty-state {
  margin: 0;
  padding: 10px 6px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.76rem;
}

.lounge-activity-dialog {
  width: min(680px, calc(100vw - 28px));
  max-height: min(760px, calc(100svh - 28px));
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  padding: 22px;
  background: #18212e;
  color: #f8f4ec;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.44);
}

.lounge-activity-dialog::backdrop {
  background: rgba(28, 19, 17, 0.58);
  backdrop-filter: blur(4px);
}

/* The editor is a preview beside two columns of controls, so it needs the width
   the other lounge dialogs do not. */
.lounge-customizer-dialog {
  width: min(1120px, calc(100vw - 28px));
  max-height: min(880px, calc(100svh - 28px));
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  padding: 22px;
  background: #18212e;
  color: #f8f4ec;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.44);
}

.lounge-customizer-dialog::backdrop {
  background: rgba(28, 19, 17, 0.58);
  backdrop-filter: blur(4px);
}

.lounge-customizer-host {
  margin-top: 14px;
}

.character-customizer-notice {
  margin: 0;
  border: 1px solid rgba(126, 178, 235, 0.34);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(94, 169, 239, 0.12);
  color: #dbe9fb;
  font-size: 0.8rem;
  line-height: 1.55;
}

.character-customizer-notice.is-guest {
  border-color: rgba(235, 197, 126, 0.34);
  background: rgba(239, 191, 94, 0.12);
  color: #f6e7c9;
}

.character-customizer-status {
  margin: 0;
  min-height: 1.2em;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.8rem;
  line-height: 1.5;
}

.character-customizer-status[data-tone="positive"] { color: #a8efbd; }
.character-customizer-status[data-tone="danger"] { color: #ffb0b0; }

/* A save with something to save says so, rather than looking the same as one
   that would be a no-op. */
[data-character-action="save"][data-dirty="true"]::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 7px;
  border-radius: 50%;
  background: #ffd479;
  vertical-align: middle;
}

.character-lab-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.character-lab-swatch {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: var(--swatch, #888);
  cursor: pointer;
  /* A pale swatch on a pale panel needs an edge of its own to be a circle. */
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.28);
  transition: transform 120ms ease, border-color 120ms ease;
}

.character-lab-swatch:hover { transform: scale(1.12); }

.character-lab-swatch:focus-visible {
  outline: 2px solid var(--accent, #6fa8dc);
  outline-offset: 2px;
}

/* The ring, not just a colour change: the chosen swatch has to be findable
   among eleven others without relying on telling two browns apart. */
.character-lab-swatch[aria-pressed="true"] {
  border-color: #fff;
  transform: scale(1.12);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.28), 0 0 0 2px var(--accent, #6fa8dc);
}

/* The colour of one's own, at the end of the palette row. It is an input rather
   than a button because the browser's own picker is the control; the label is
   only here to give it the same 26px circle as its neighbours. */
.character-lab-swatch-custom {
  position: relative;
  width: 26px;
  height: 26px;
  border: 2px dashed rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  background: var(--swatch, #888);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.28);
  transition: transform 120ms ease, border-color 120ms ease;
}

.character-lab-swatch-custom:hover { transform: scale(1.12); }

.character-lab-swatch-custom[data-selected="true"] {
  border-style: solid;
  border-color: #fff;
  transform: scale(1.12);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.28), 0 0 0 2px var(--accent, #6fa8dc);
}

/* The input fills the circle and is invisible: clicking anywhere on the swatch
   opens the picker, and the swatch itself shows the colour. */
.character-lab-swatch-custom input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.character-lab-swatch-custom:focus-within {
  outline: 2px solid var(--accent, #6fa8dc);
  outline-offset: 2px;
}

.character-lab-preview-views {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 3px;
  background: rgba(13, 20, 29, 0.82);
  backdrop-filter: blur(7px);
}

.character-lab-preview-views button {
  border: 0;
  border-radius: 999px;
  padding: 4px 11px;
  background: transparent;
  color: #cfe0f3;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.character-lab-preview-views button[aria-pressed="true"] {
  background: rgba(94, 169, 239, 0.28);
  color: #fff;
}

/* Kept here rather than with the other character-lab breakpoints further up the
   file: these swatch rules are declared below that block, so an override placed
   there loses on order despite matching. */
@media (max-width: 600px) {
  /* 26px clears the minimum but is a small thing to hit with a thumb, and the
     controls are a single column at this width, so there is room to spend. */
  .character-lab-swatch,
  .character-lab-swatch-custom {
    width: 34px;
    height: 34px;
  }

  .character-lab-swatches {
    gap: 8px;
  }
}

.lounge-activity-dialog h3,
.lounge-activity-dialog p { margin: 0; }
.lounge-activity-help {
  margin-top: 10px !important;
  color: rgba(255, 255, 255, 0.68);
}

.lounge-controls-hint {
  position: absolute;
  right: 12px;
  bottom: 10px;
  z-index: 2;
  max-width: min(420px, calc(100% - 24px));
  margin: 0;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(8, 13, 20, 0.62);
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.72rem;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.lounge-directory {
  position: relative;
  z-index: 5;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(17, 23, 33, 0.98);
  color: #f7f1e7;
}

.lounge-directory > summary {
  min-height: 42px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 800;
}

.lounge-directory > p {
  margin: 0;
  padding: 0 16px 10px;
  color: rgba(255, 255, 255, 0.66);
  font-size: 0.8rem;
}

.lounge-directory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  max-height: 190px;
  overflow: auto;
  padding: 0 12px 12px;
}

.lounge-directory-portal {
  display: grid;
  gap: 2px;
  min-width: 0;
  min-height: 54px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  text-align: left;
}

.lounge-directory-portal:hover,
.lounge-directory-portal:focus-visible,
.lounge-directory-portal.is-selected {
  border-color: #e5b571;
  background: rgba(229, 181, 113, 0.14);
}

.lounge-directory-portal span {
  overflow: hidden;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Lounge Phase 7: split views and movable billboards --------------------- */
.lounge-view-switch {
  display: inline-flex;
  justify-self: end;
  gap: 3px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  padding: 3px;
  background: rgba(7, 12, 19, 0.55);
}

.lounge-view-switch button {
  min-height: 30px;
  border: 0;
  border-radius: 999px;
  padding: 4px 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.72rem;
  font-weight: 800;
}

.lounge-view-switch button[aria-pressed="true"] {
  background: #d7a55e;
  color: #20160d;
}

.lounge-presence-billboard.is-self {
  pointer-events: none;
}

.lounge-presence-billboard[data-moving="true"] .lounge-presence-nameplate {
  border-color: rgba(143, 214, 255, 0.72);
  transform: translateY(-2px);
}

.lounge-presence-nameplate {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: center;
  width: max-content;
  max-width: 200px;
  border-radius: 12px;
  white-space: normal;
}

.lounge-presence-nameplate strong {
  max-width: 142px;
  overflow-wrap: anywhere;
  text-align: center;
}

.lounge-presence-title {
  grid-column: 1 / -1;
  max-width: 182px;
  overflow: visible;
  text-align: center;
  text-overflow: clip;
  white-space: normal;
}

.lounge-2d-panel {
  position: absolute;
  inset: 0;
  z-index: 8;
  overflow: auto;
  padding: 18px;
  background:
    radial-gradient(circle at 20% 0%, rgba(119, 174, 187, 0.18), transparent 42%),
    rgba(12, 18, 27, 0.97);
  color: #f7f1e7;
}

.lounge-2d-panel[hidden] {
  display: none;
}

.lounge-2d-panel > header,
.lounge-2d-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.lounge-2d-panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.lounge-2d-panel h4,
.lounge-2d-panel p {
  margin: 0;
}

.lounge-2d-panel .lounge-activity-preview,
.lounge-2d-panel .lounge-room-alerts {
  position: static;
  width: auto;
  max-height: none;
}

.lounge-2d-portals {
  margin-top: 14px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.045);
}

.lounge-2d-portals .lounge-directory-grid {
  margin-top: 9px;
}

.lounge-scene-frame[data-view="2d"] .lounge-canvas,
.lounge-scene-frame[data-view="2d"] .lounge-presence-stage,
.lounge-scene-frame[data-view="2d"] .lounge-loading,
.lounge-scene-frame[data-view="2d"] .lounge-controls-hint,
.lounge-scene-frame[data-view="2d"] .lounge-portal-tooltip,
.lounge-scene-frame[data-view="2d"] .lounge-teapot-status {
  visibility: hidden;
}

.lounge-settings .settings-section > p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.82rem;
}

@media (max-width: 820px) {
  .lounge-surface .game-main-panel {
    min-height: calc(100svh - 116px);
    height: calc(100svh - 116px);
  }

  .lounge-heading {
    grid-template-columns: 1fr;
    padding: 10px 12px;
  }

  .lounge-heading-actions {
    justify-items: stretch;
  }

  .lounge-heading-buttons,
  .lounge-heading-toolbar {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .lounge-heading-buttons button,
  .lounge-heading-toolbar button {
    min-width: 0;
  }

  .lounge-heading > div:first-child > p:last-child {
    display: none;
  }

  .lounge-scene-badges {
    max-width: none;
    justify-content: flex-start;
  }

  .lounge-canvas {
    min-height: 360px;
  }

  .lounge-presence-avatar {
    width: 36px;
    height: 36px;
  }

  .lounge-presence-nameplate {
    max-width: 108px;
    padding: 2px 6px;
  }

  .lounge-presence-nameplate strong {
    max-width: 72px;
    font-size: 0.61rem;
  }

  .lounge-presence-title {
    display: block;
    max-width: 118px;
    font-size: 0.48rem;
    line-height: 1.15;
  }

  .lounge-2d-dashboard {
    grid-template-columns: 1fr;
  }

  .lounge-2d-panel {
    padding: 12px;
  }

  .lounge-controls-hint {
    left: 50%;
    right: auto;
    width: max-content;
    transform: translateX(-50%);
    text-align: center;
  }

  .lounge-activity-preview {
    display: none;
  }

  .lounge-room-alerts {
    width: min(230px, calc(100% - 24px));
    max-height: 185px;
  }

  .lounge-room-card p {
    display: none;
  }

  .lounge-phase-five-controls > span {
    width: 100%;
    margin-left: 0;
  }

  .lounge-directory-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (pointer: coarse) {
  .lounge-canvas {
    cursor: default;
  }

  .lounge-directory-portal {
    min-height: 58px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lounge-canvas {
    transition: none;
  }

  .lounge-loading-orbit {
    animation: none;
    border-color: #e6b77b;
  }

  .lounge-presence-billboard.is-joining,
  .lounge-presence-billboard.is-leaving,
  .lounge-presence-action {
    animation: none;
  }
}

.activity-stage-message,
.webgl-recovery-message {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: none;
  align-content: center;
  justify-items: center;
  gap: 8px;
  padding: 24px;
  background: rgba(9, 15, 18, 0.9);
  color: #f7f2e8;
  text-align: center;
}

.activity-stage-message strong {
  font-size: clamp(17px, 3vw, 24px);
}

.activity-stage-message span,
.webgl-recovery-message {
  font-size: 13px;
  line-height: 1.55;
}

[data-webgl-state="lost"] .webgl-recovery-message {
  display: grid;
}


/* Discord Activity 전환/로딩 키프레임. keyframes 내부 from/to 블록은 root-gate 규칙에
   맞지 않으므로 활동 CSS 구역 마커 위(일반 구역)에 둔다. 애니메이션 참조는 게이트 안에서만. */
@keyframes activity-spin {
  to { transform: rotate(360deg); }
}

@keyframes activity-fade-in {
  from { opacity: 0; transform: translateY(8px) scale(0.995); }
  to { opacity: 1; transform: none; }
}

@keyframes yutActivityThrowGlow {
  from { filter: brightness(0.96); }
  to { filter: brightness(1.12); }
}

@keyframes activityMenuTileIn {
  from { opacity: 0; transform: translateY(7px) scale(0.9); }
  to { opacity: 1; transform: none; }
}

@keyframes activitySurfaceForwardOld {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(-18%); }
}

@keyframes activitySurfaceForwardNew {
  from { opacity: 0; transform: translateX(9%); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes activitySurfaceBackOld {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(9%); }
}

@keyframes activitySurfaceBackNew {
  from { opacity: 0; transform: translateX(-18%); }
  to { opacity: 1; transform: translateX(0); }
}

.deferred-game-loading {
  display: grid;
  min-height: min(420px, var(--desktop-play-height));
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--text-muted);
  text-align: center;
}

.deferred-game-loading p {
  margin: 0;
}

.deferred-game-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: activity-spin 720ms linear infinite;
}

/* Discord Activity focus layout (T1/T2). Keep every rule below root-gated. */
:root[data-activity="1"],
:root[data-activity="1"] body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

:root[data-activity="1"] .activity-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 17, 28, 0.62);
  opacity: 0;
  transition: opacity 160ms ease;
  backdrop-filter: blur(4px);
}

:root[data-activity="1"] .activity-confirm-overlay.is-open {
  opacity: 1;
}

:root[data-activity="1"] .activity-confirm-dialog {
  display: grid;
  width: min(420px, 100%);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
  transform: translateY(8px) scale(0.98);
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-activity="1"] .activity-confirm-overlay.is-open .activity-confirm-dialog {
  transform: translateY(0) scale(1);
}

:root[data-activity="1"] .activity-confirm-dialog h3,
:root[data-activity="1"] .activity-confirm-dialog p {
  margin: 0;
}

:root[data-activity="1"] .activity-confirm-dialog p {
  color: var(--text-muted);
  line-height: 1.55;
  white-space: pre-wrap;
}

:root[data-activity="1"] .activity-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* 소프트웨어 렌더링(HW 가속 꺼짐) 1회 안내 토스트. Activity 전용. */
:root[data-activity="1"] .activity-gpu-notice {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(560px, calc(100% - 24px));
  padding: 10px 12px 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(20, 27, 38, 0.94);
  color: #f3f6fb;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  transform: translate(-50%, 16px);
  opacity: 0;
  transition: opacity 240ms ease, transform 240ms ease;
}

:root[data-activity="1"] .activity-gpu-notice.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

:root[data-activity="1"] .activity-gpu-notice-text {
  min-width: 0;
}

:root[data-activity="1"] .activity-gpu-notice-close {
  flex: none;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

:root[data-activity="1"] .activity-gpu-notice-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

@media (prefers-reduced-motion: reduce) {
  :root[data-activity="1"] .activity-gpu-notice {
    transition: none;
  }
}

/* A2: Activity에서는 텍스트 드래그 선택을 막아 네이티브 앱 감을 준다. 단, 실제 입력·
   편집 요소는 반드시 선택/편집이 가능해야 한다(끝말잇기 답·닉네임·채팅 등). */
:root[data-activity="1"] {
  -webkit-user-select: none;
  user-select: none;
}

:root[data-activity="1"] input,
:root[data-activity="1"] textarea,
:root[data-activity="1"] select,
:root[data-activity="1"] [contenteditable="true"],
:root[data-activity="1"] [contenteditable=""] {
  -webkit-user-select: text;
  user-select: text;
}

:root[data-activity="1"] .app-shell {
  width: 100%;
  max-width: 100vw;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 56px minmax(0, 1fr);
  grid-template-areas:
    "top"
    "main";
}

:root[data-activity="1"] #profileArea,
:root[data-activity="1"] #sidebarToggle,
:root[data-activity="1"] #globalMusicPanel,
:root[data-activity="1"] .brand,
:root[data-activity="1"] .top-actions,
:root[data-activity="1"] .mobile-dock {
  display: none !important;
}

:root[data-activity="1"] .topbar {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "stage";
  min-width: 0;
  min-height: 56px;
}

:root[data-activity="1"] .stage-title {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  min-width: 0;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}

:root[data-activity="1"] .stage-title h2 {
  min-width: 0;
  text-align: center;
}

:root[data-activity="1"] .activity-participants {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-radius: 999px;
  padding: 4px 9px 4px 6px;
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
  color: var(--ink);
  font-size: 12px;
  white-space: nowrap;
}

:root[data-activity="1"] .activity-participant-avatars {
  display: flex;
  padding-left: 4px;
}

:root[data-activity="1"] .activity-participant-avatar {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  margin-left: -5px;
  place-items: center;
  overflow: hidden;
  box-sizing: border-box;
  border: 2px solid var(--panel);
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 10px;
  font-weight: 900;
}

:root[data-activity="1"] .activity-participant-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

:root[data-activity="1"] .stage,
:root[data-activity="1"] .stage.has-room {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 100%;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "main";
  gap: 0;
  overflow-x: hidden;
  padding: 12px;
}

:root[data-activity="1"] #gameSurface {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
  view-transition-name: activity-surface;
}

:root[data-activity="1"] body.activity-transitioning {
  cursor: wait;
}

:root[data-activity="1"] body.activity-transitioning #gameSurface,
:root[data-activity="1"] body.activity-transitioning .activity-game-menu-back {
  pointer-events: none;
}

:root[data-activity="1"][data-activity-transition="forward"]::view-transition-old(activity-surface),
:root[data-activity="1"][data-activity-transition="forward"]::view-transition-new(activity-surface),
:root[data-activity="1"][data-activity-transition="back"]::view-transition-old(activity-surface),
:root[data-activity="1"][data-activity-transition="back"]::view-transition-new(activity-surface) {
  animation-duration: 700ms;
  animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  animation-fill-mode: both;
}

:root[data-activity="1"][data-activity-transition="forward"]::view-transition-old(activity-surface) {
  animation-name: activitySurfaceForwardOld;
}

:root[data-activity="1"][data-activity-transition="forward"]::view-transition-new(activity-surface) {
  animation-name: activitySurfaceForwardNew;
}

:root[data-activity="1"][data-activity-transition="back"]::view-transition-old(activity-surface) {
  animation-name: activitySurfaceBackOld;
}

:root[data-activity="1"][data-activity-transition="back"]::view-transition-new(activity-surface) {
  animation-name: activitySurfaceBackNew;
}

:root[data-activity="1"] #gameSurface > * {
  max-width: 100%;
  min-width: 0;
}

:root[data-activity="1"] body.activity-game-active .game-layout,
:root[data-activity="1"] body.activity-game-active .game-main-panel {
  min-height: 0;
}

:root[data-activity="1"] body.activity-game-active .game-main-panel {
  padding: clamp(8px, 1.4vw, 16px);
}

/* F2: desktop Activity game panels use the iframe's real height as their
   layout budget.  Keep this separate from the <=820px mobile branch, whose
   scrolling layout is intentionally unchanged for this cycle. */
@media (min-width: 821px) {
  :root[data-activity="1"] .yacht-surface .game-main-panel,
  :root[data-activity="1"] .drawing-surface .game-main-panel,
  :root[data-activity="1"] .yut-surface .game-main-panel {
    height: clamp(0px, calc(100vh - 80px), 900px);
    height: clamp(0px, calc(100dvh - 80px), 900px);
    max-height: none;
    overflow: hidden;
  }

  :root[data-activity="1"] .yacht-surface .yacht-card,
  :root[data-activity="1"] .drawing-surface .drawing-card,
  :root[data-activity="1"] .yut-surface .yut-card {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  :root[data-activity="1"] .yacht-surface {
    width: 100%;
    margin-inline: 0;
  }

  :root[data-activity="1"] .yacht-surface .yacht-dice-tray,
  :root[data-activity="1"] .yacht-surface .yacht-board {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: auto;
  }

  :root[data-activity="1"] .yacht-surface .yacht-play {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  :root[data-activity="1"] .yacht-surface #yachtResult,
  :root[data-activity="1"] .yacht-surface #yachtRuleSummary {
    display: none;
  }

  :root[data-activity="1"] .yacht-surface .yacht-log-panel .log {
    max-height: 56px;
  }

  :root[data-activity="1"] .drawing-surface .drawing-card {
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    gap: 7px;
  }

  :root[data-activity="1"] .drawing-surface #drawingResult {
    display: none;
  }

  :root[data-activity="1"] .drawing-surface .drawing-play-layout {
    height: 100%;
    min-width: 0;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 0.3fr);
    gap: 8px;
    overflow: hidden;
  }

  :root[data-activity="1"] .drawing-surface .drawing-board-column {
    height: 100%;
    width: min(100%, 1040px);
    min-width: 0;
    min-height: 0;
    grid-template-columns: clamp(96px, 11vw, 132px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 8px;
    justify-self: center;
    overflow: hidden;
  }

  :root[data-activity="1"] .drawing-surface .drawing-board-toolbar,
  :root[data-activity="1"] .drawing-surface .drawing-board-wrap,
  :root[data-activity="1"] .drawing-surface .drawing-chat-panel {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
  }

  :root[data-activity="1"] .drawing-surface .drawing-board-toolbar,
  :root[data-activity="1"] .drawing-surface .drawing-board-toolbar:has(.drawing-brush-field:not([hidden])) {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: min-content;
    gap: 8px;
    align-content: start;
    align-items: stretch;
    padding: 8px;
    overflow-y: auto;
  }

  :root[data-activity="1"] .drawing-surface .drawing-board-toolbar label {
    display: grid;
    min-width: 0;
    gap: 5px;
  }

  :root[data-activity="1"] .drawing-surface .drawing-board-toolbar .field-label {
    font-size: 10px;
    white-space: nowrap;
  }

  :root[data-activity="1"] .drawing-surface .drawing-color-field input {
    width: 100%;
    min-width: 0;
    height: 34px;
  }

  :root[data-activity="1"] .drawing-surface .drawing-size-field input {
    width: 100%;
    min-width: 0;
  }

  :root[data-activity="1"] .drawing-surface .drawing-brush-field select {
    width: 100%;
    min-width: 0;
    min-height: 30px;
  }

  :root[data-activity="1"] .drawing-surface .drawing-tool-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
  }

  :root[data-activity="1"] .drawing-surface .drawing-tool-actions button {
    min-width: 0;
    min-height: 30px;
    padding: 4px 7px;
    font-size: 11px;
  }

  :root[data-activity="1"] .drawing-surface .drawing-board-wrap {
    display: grid;
    height: 100%;
    width: min(100%, 920px);
    max-height: 100%;
    aspect-ratio: 4 / 3;
    justify-self: center;
    place-items: center;
    padding: 6px;
    box-sizing: border-box;
  }

  :root[data-activity="1"] .drawing-surface .drawing-canvas {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 4 / 3;
  }

  :root[data-activity="1"] .drawing-surface .drawing-answer-row {
    min-width: 0;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-row: 3;
    align-self: end;
  }

  :root[data-activity="1"] .drawing-surface .drawing-answer-row input {
    width: 100%;
    min-width: 0;
  }

  :root[data-activity="1"] .drawing-surface .drawing-chat-panel {
    height: 100%;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  :root[data-activity="1"] .drawing-surface .drawing-chat-list {
    min-height: 0;
    overflow-y: auto;
  }

  :root[data-activity="1"] .drawing-surface .drawing-status-strip {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }

  :root[data-activity="1"] .drawing-surface .drawing-status-strip span {
    display: flex;
    min-height: 28px;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
    font-size: 10px;
    white-space: nowrap;
  }

  :root[data-activity="1"] .drawing-surface .drawing-status-strip strong {
    font-size: 13px;
  }

  :root[data-activity="1"] .drawing-surface .drawing-player-grid {
    gap: 4px;
  }

  :root[data-activity="1"] .drawing-surface .drawing-player {
    padding: 5px 7px;
  }

  :root[data-activity="1"] .drawing-surface .yacht-log-panel .log {
    max-height: 46px;
  }

  :root[data-activity="1"] .yut-surface {
    width: 100%;
    margin-inline: 0;
  }

  :root[data-activity="1"] .yut-surface .yut-card {
    position: relative;
    grid-template-rows: minmax(0, 1fr);
  }

  :root[data-activity="1"] .yut-surface .yut-status-strip {
    position: absolute;
    inset: 0;
    z-index: 8;
    pointer-events: none;
  }

  :root[data-activity="1"] .yut-surface .yut-status-strip .music-status,
  :root[data-activity="1"] .yut-surface .yut-status-strip .result-line,
  :root[data-activity="1"] .yut-surface .yut-status-strip .yut-moves {
    display: none;
  }

  :root[data-activity="1"] .yut-surface .yut-status-strip .play-action-row {
    position: absolute;
    top: 14px;
    right: 4%;
    z-index: 2;
    min-height: 0;
    padding: 0;
    pointer-events: auto;
  }

  :root[data-activity="1"] .yut-surface .yut-board-stage,
  :root[data-activity="1"] .yut-surface .yut-board-wrap,
  :root[data-activity="1"] .yut-surface .yut-board-perspective {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: 100%;
  }

  :root[data-activity="1"] .yut-surface .yut-board-perspective {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
  }

  :root[data-activity="1"] .yut-surface .yut-board {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
  }

  :root[data-activity="1"] .yut-surface .yut-tabletop {
    border: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
  }

  :root[data-activity="1"] .yut-surface .yut-throw-dock {
    width: min(34%, 300px);
    padding: 14px;
  }

  :root[data-activity="1"] .yut-surface #throwYut {
    display: none;
  }

  :root[data-activity="1"] .yut-surface .yut-throw-dock.can-throw {
    border-radius: 50%;
    cursor: pointer;
    background: radial-gradient(circle, rgba(67, 221, 145, 0.18), rgba(67, 221, 145, 0) 68%);
    box-shadow: inset 0 0 0 3px rgba(67, 221, 145, 0.32), 0 0 30px rgba(67, 221, 145, 0.42);
    animation: yutActivityThrowGlow 900ms ease-in-out infinite alternate;
  }

  :root[data-activity="1"] .yut-surface .yut-throw-dock[aria-disabled="true"] {
    cursor: default;
  }

  :root[data-activity="1"] .connect4-surface .game-main-panel,
  :root[data-activity="1"] .dotsboxes-surface .game-main-panel,
  :root[data-activity="1"] .indian-surface .game-main-panel,
  :root[data-activity="1"] .wordchain-surface .game-main-panel,
  :root[data-activity="1"] .mahjong-surface .game-main-panel {
    height: clamp(0px, calc(100vh - 80px), 900px);
    height: clamp(0px, calc(100dvh - 80px), 900px);
    max-height: none;
    overflow: hidden;
  }

  :root[data-activity="1"] .connect4-surface .connect4-card,
  :root[data-activity="1"] .dotsboxes-surface .dotsboxes-card,
  :root[data-activity="1"] .indian-surface .indian-card,
  :root[data-activity="1"] .wordchain-surface .wordchain-game-card,
  :root[data-activity="1"] .mahjong-surface .mahjong-card {
    height: 100%;
    min-height: 0;
    gap: 8px;
    overflow: hidden;
  }

  :root[data-activity="1"] .connect4-surface .connect4-card {
    grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  }

  :root[data-activity="1"] .connect4-surface .connect4-board-wrap {
    --connect4-cell: clamp(28px, min(8vw, calc((100vh - 300px) / 6)), 68px);
    --connect4-cell: clamp(28px, min(8vw, calc((100dvh - 300px) / 6)), 68px);
    align-self: center;
    justify-self: center;
  }

  :root[data-activity="1"] .dotsboxes-surface .dotsboxes-card {
    grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
  }

  :root[data-activity="1"] .dotsboxes-surface .dotsboxes-board-wrap {
    --dotsboxes-gap: clamp(30px, min(10vw, calc((100vh - 394px) / 3)), 78px);
    --dotsboxes-gap: clamp(30px, min(10vw, calc((100dvh - 394px) / 3)), 78px);
    align-self: center;
    justify-self: center;
    padding: clamp(10px, 2vh, 20px);
  }

  :root[data-activity="1"] .indian-surface .indian-card {
    grid-template-rows: minmax(0, 1fr) auto;
  }

  :root[data-activity="1"] .indian-surface .indian-table {
    min-height: 0;
    gap: 8px;
    padding: 8px;
    overflow: hidden;
  }

  :root[data-activity="1"] .indian-surface .indian-duel-row {
    height: 100%;
    min-height: 0;
    gap: 8px;
  }

  :root[data-activity="1"] .indian-surface .indian-player-card {
    align-content: start;
    gap: 6px;
    padding: 8px;
  }

  :root[data-activity="1"] .indian-surface .indian-number {
    min-height: clamp(76px, calc(100vh - 500px), 112px);
    min-height: clamp(76px, calc(100dvh - 500px), 112px);
  }

  :root[data-activity="1"] .indian-surface .indian-d20-stage,
  :root[data-activity="1"] .indian-surface .indian-d20-canvas {
    height: clamp(160px, calc(100vh - 410px), 300px);
    height: clamp(160px, calc(100dvh - 410px), 300px);
    min-height: 0;
  }

  :root[data-activity="1"] .indian-surface .yacht-log-panel {
    min-height: 0;
  }

  :root[data-activity="1"] .indian-surface .yacht-log-panel .log {
    max-height: clamp(56px, calc(100vh - 610px), 112px);
    max-height: clamp(56px, calc(100dvh - 610px), 112px);
    overflow: auto;
  }

  :root[data-activity="1"] .wordchain-surface .wordchain-play-grid {
    height: 100%;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
  }

  :root[data-activity="1"] .wordchain-surface .wordchain-play-column {
    height: 100%;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr) auto auto auto auto;
    gap: 6px;
    overflow: hidden;
  }

  :root[data-activity="1"] .wordchain-surface .wordchain-scene-stack {
    height: 100%;
  }

  :root[data-activity="1"] .wordchain-surface .wordchain-table-3d {
    height: 100%;
  }

  :root[data-activity="1"] .wordchain-surface #wordClock,
  :root[data-activity="1"] .wordchain-surface .answer-row button {
    min-height: 36px;
  }

  :root[data-activity="1"] .wordchain-surface .word-dictionary-license {
    padding-top: 4px;
    font-size: 10px;
    line-height: 1.25;
  }

  :root[data-activity="1"] .mahjong-surface .mahjong-card.mahjong-3d-active {
    grid-template-rows: minmax(0, 1fr);
    padding: 7px;
  }

  :root[data-activity="1"] .mahjong-surface .mahjong-card.mahjong-3d-active > .mahjong-status-strip,
  :root[data-activity="1"] .mahjong-surface .mahjong-card.mahjong-3d-active > #mahjongResult,
  :root[data-activity="1"] .mahjong-surface .mahjong-card.mahjong-3d-active > .mahjong-effect-strip,
  :root[data-activity="1"] .mahjong-surface .mahjong-card.mahjong-3d-active > #mahjongFinal,
  :root[data-activity="1"] .mahjong-surface .mahjong-card.mahjong-3d-active > .mahjong-hand-panel {
    display: none;
  }

  :root[data-activity="1"] .mahjong-surface .mahjong-table-3d {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: 100%;
  }

  :root[data-activity="1"] .mahjong-surface [data-activity-stage-mode="compact"] .mahjong-actions-overlay {
    right: 8px;
    bottom: calc(18% + var(--mahjong-bottom-safe-offset, 0px));
    left: 8px;
  }
}

:root[data-activity="1"] .mahjong-surface .mahjong-table-3d {
  max-height: calc(100vh - 80px);
  max-height: calc(100dvh - 80px);
}

:root[data-activity="1"] [data-activity-stage-mode="blocked"].mahjong-table-3d {
  min-height: min(320px, calc(100vh - 96px));
  min-height: min(320px, calc(100dvh - 96px));
}

@media (max-width: 820px) {
  :root[data-activity="1"] .mahjong-surface .game-main-panel {
    height: clamp(0px, calc(100vh - 72px), 820px);
    height: clamp(0px, calc(100dvh - 72px), 820px);
    min-height: 0;
    overflow: hidden;
  }

  :root[data-activity="1"] .mahjong-surface .mahjong-card {
    height: 100%;
    min-height: 0;
    gap: 6px;
    overflow: hidden;
  }

  :root[data-activity="1"] .mahjong-surface .mahjong-card.mahjong-3d-active {
    grid-template-rows: minmax(0, 1fr);
    padding: 5px;
  }

  :root[data-activity="1"] .mahjong-surface .mahjong-card.mahjong-3d-active > .mahjong-status-strip,
  :root[data-activity="1"] .mahjong-surface .mahjong-card.mahjong-3d-active > #mahjongResult,
  :root[data-activity="1"] .mahjong-surface .mahjong-card.mahjong-3d-active > .mahjong-effect-strip,
  :root[data-activity="1"] .mahjong-surface .mahjong-card.mahjong-3d-active > #mahjongFinal,
  :root[data-activity="1"] .mahjong-surface .mahjong-card.mahjong-3d-active > .mahjong-hand-panel {
    display: none;
  }

  :root[data-activity="1"] .mahjong-surface .mahjong-table-3d {
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  :root[data-activity="1"] .mahjong-surface .mahjong-actions-overlay {
    right: 7px;
    left: 7px;
  }
}

:root[data-activity="1"] .wordchain-surface .wordchain-play-grid {
  grid-template-columns: minmax(0, 1fr);
}

:root[data-activity="1"] .wordchain-surface .word-chat-panel,
:root[data-activity="1"] .wordchain-surface .word-event-log,
:root[data-activity="1"] .wordchain-surface .word-chat-compose {
  display: none;
}

:root[data-activity="1"] .wordchain-surface .wordchain-scene-stack {
  position: relative;
  min-width: 0;
  min-height: min(68dvh, 720px);
  overflow: hidden;
  border-radius: var(--radius-lg);
}

:root[data-activity="1"] .wordchain-surface .wordchain-table-3d {
  position: absolute;
  inset: 0;
  min-width: 0;
  min-height: 300px;
  overflow: hidden;
  border: 1px solid rgba(227, 188, 112, 0.22);
  border-radius: var(--radius-lg);
  background: #0d161c;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

:root[data-activity="1"] .wordchain-surface .wordchain-table-3d.wordchain-3d-fallback {
  display: none;
}

:root[data-activity="1"] .wordchain-surface .wordchain-3d-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

:root[data-activity="1"] .wordchain-surface .wordchain-player-overlays {
  position: absolute;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  pointer-events: none;
}

:root[data-activity="1"] .wordchain-surface .wordchain-player-anchor {
  position: absolute;
  display: grid;
  justify-items: center;
  gap: 4px;
  max-width: 180px;
  transform: translate(-50%, -100%) scale(var(--wordchain-player-scale, 1));
  transform-origin: center bottom;
}

:root[data-activity="1"] .wordchain-surface .wordchain-player-name,
:root[data-activity="1"] .wordchain-surface .wordchain-player-bubble {
  max-width: 180px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(10, 16, 22, 0.9);
  color: #fff;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.38);
}

:root[data-activity="1"] .wordchain-surface .wordchain-player-anchor.is-current .wordchain-player-name {
  border-color: #ffd668;
  background: rgba(79, 56, 11, 0.95);
  color: #fff0b8;
  box-shadow: 0 0 0 2px rgba(255, 214, 104, 0.28), 0 0 22px rgba(255, 202, 75, 0.72);
}

:root[data-activity="1"] .wordchain-surface .wordchain-player-anchor.is-eliminated .wordchain-player-name {
  opacity: 0.58;
}

:root[data-activity="1"] .wordchain-surface .wordchain-player-bubble {
  position: relative;
  border-radius: 10px;
  font-size: 14px;
}

:root[data-activity="1"] .wordchain-surface .wordchain-player-bubble.is-accepted {
  border-color: rgba(159, 255, 198, 0.86);
  background: rgba(22, 112, 65, 0.94);
}

:root[data-activity="1"] .wordchain-surface .wordchain-player-bubble.is-rejected {
  border-color: rgba(255, 180, 180, 0.88);
  background: rgba(157, 38, 45, 0.95);
}

:root[data-activity="1"] .wordchain-surface .wordchain-table-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 5;
  border: 1px solid rgba(255, 214, 132, 0.3);
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(9, 17, 22, 0.72);
  color: #f4d595;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  pointer-events: none;
}

:root[data-activity="1"] .wordchain-surface .wordchain-3d-active .word-status {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 6;
  width: min(46%, 520px);
  min-width: 270px;
  gap: 5px;
  border: 0;
  padding: 0;
  background: transparent;
  color: #f8f3e7;
  text-align: center;
  pointer-events: none;
  transform: translate(-50%, -51%);
}

:root[data-activity="1"] .wordchain-surface .wordchain-3d-active .word-status .meta,
:root[data-activity="1"] .wordchain-surface .wordchain-3d-active #wordStarts {
  color: rgba(244, 239, 225, 0.82);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
}

:root[data-activity="1"] .wordchain-surface .wordchain-3d-active .current-word {
  min-height: 92px;
  border: 6px solid transparent;
  border-radius: 999px;
  padding-inline: 18px;
  background:
    linear-gradient(rgba(13, 24, 29, 0.94), rgba(13, 24, 29, 0.94)) padding-box,
    conic-gradient(var(--accent) calc(var(--word-timer-ratio, 1) * 1turn), rgba(255, 255, 255, 0.15) 0) border-box;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.38), inset 0 0 22px rgba(255, 255, 255, 0.04);
  font-size: var(--word-fitted-font-size, clamp(2rem, 6cqi, 4.2rem));
}

:root[data-activity="1"] .wordchain-surface .wordchain-3d-active .word-timer-row {
  display: flex;
  justify-content: center;
}

:root[data-activity="1"] .wordchain-surface .wordchain-3d-active .word-timer-track,
:root[data-activity="1"] .wordchain-surface .wordchain-3d-active #wordRuleSummary,
:root[data-activity="1"] .wordchain-surface .wordchain-3d-active #wordPlayers,
:root[data-activity="1"] .wordchain-surface .wordchain-3d-active #wordHistory {
  display: none;
}

:root[data-activity="1"] .wordchain-surface .wordchain-3d-active #wordClock {
  min-height: 30px;
  border: 1px solid rgba(255, 220, 145, 0.25);
  background: rgba(12, 20, 25, 0.82);
  color: #ffe19b;
  font-size: 13px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.24);
}

:root[data-activity="1"] .wordchain-surface .wordchain-3d-active .answer-row {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  z-index: 7;
  border: 1px solid rgba(255, 222, 150, 0.24);
  border-radius: 12px;
  padding: 8px;
  background: rgba(8, 14, 19, 0.86);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(8px);
}

:root[data-activity="1"] .wordchain-surface .wordchain-3d-active #wordResult {
  display: none;
}

:root[data-activity="1"] .wordchain-surface .wordchain-activity-attribution {
  gap: 6px;
}

:root[data-activity="1"] .wordchain-surface .wordchain-activity-attribution .word-dictionary-license {
  padding-top: 0;
  font-size: 10px;
  line-height: 1.35;
}

:root[data-activity="1"] [data-activity-stage-mode="compact"].wordchain-table-3d .wordchain-table-badge {
  padding: 4px 7px;
  font-size: 9px;
}

:root[data-activity="1"] [data-activity-stage-mode="blocked"].wordchain-table-3d {
  min-height: 240px;
}

:root[data-activity="1"] .onecard-surface .game-main-panel,
:root[data-activity="1"] .omok-surface .game-main-panel {
  height: auto;
  max-height: none;
  overflow: visible;
}

:root[data-activity="1"] .onecard-surface .onecard-info-grid,
:root[data-activity="1"] .omok-surface .omok-fallback {
  display: none;
}

:root[data-activity="1"] .activity-3d-live-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

:root[data-activity="1"] .activity-omok-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 7px;
}

:root[data-activity="1"] .activity-omok-controls button {
  min-width: 0;
  min-height: 34px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
}

:root[data-activity="1"] .activity-omok-clock {
  min-width: 0;
  border: 1px solid rgba(255, 210, 120, 0.28);
  border-radius: 999px;
  padding: 7px 11px;
  background: rgba(20, 13, 6, 0.72);
  color: #ffd88a;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

:root[data-activity="1"] .activity-omok-clock:empty {
  display: none;
}

:root[data-activity="1"] .activity-omok-clock:not(:empty)::before {
  content: "남은 시간 · ";
  color: rgba(255, 232, 185, 0.78);
}

/* The canvas stays fluid; its camera keeps a contained 16:9 safe composition. */
:root[data-activity="1"] .onecard-surface .onecard-table-3d {
  width: 100%;
  height: clamp(0px, calc(100vh - 145px), 760px);
  height: clamp(0px, calc(100dvh - 145px), 760px);
  min-height: 0;
}

:root[data-activity="1"] .omok-surface .omok-board-3d {
  width: min(100%, 960px);
  height: clamp(0px, calc(100vh - 145px), 700px);
  height: clamp(0px, calc(100dvh - 145px), 700px);
  min-height: 0;
}

:root[data-activity="1"] [data-activity-stage-mode="compact"] .onecard-table-badge,
:root[data-activity="1"] [data-activity-stage-mode="compact"] .omok-board-badge {
  padding: 4px 7px;
  font-size: 10px;
}

:root[data-activity="1"] [data-activity-stage-mode="blocked"] canvas {
  opacity: 0.22;
  pointer-events: none;
}

:root[data-activity="1"] [data-activity-stage-mode="blocked"].onecard-table-3d,
:root[data-activity="1"] [data-activity-stage-mode="blocked"].omok-board-3d {
  height: min(320px, calc(100vh - 170px));
  height: min(320px, calc(100dvh - 170px));
}

:root[data-activity="1"] [data-activity-stage-mode="blocked"] .activity-stage-message {
  display: grid;
}

:root[data-activity="1"] .activity-game-menu-back {
  display: inline-flex;
  min-height: 36px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 800;
}

:root[data-activity="1"] .activity-game-menu-back[hidden] {
  display: none;
}

:root[data-activity="1"] .activity-game-menu {
  display: grid;
  width: min(1080px, 100%);
  min-height: 100%;
  grid-template-columns: auto minmax(0, 1fr);
  align-content: start;
  align-items: baseline;
  gap: 4px 10px;
  margin: 0 auto;
  padding: clamp(8px, 1.5vw, 16px);
}

:root[data-activity="1"] .activity-game-menu h3 {
  margin: 0;
  font-size: clamp(18px, 2.2vw, 26px);
}

:root[data-activity="1"] .activity-game-menu-description,
:root[data-activity="1"] .activity-game-menu-empty {
  margin: 0;
  color: var(--text-muted);
}

:root[data-activity="1"] .activity-game-menu-description {
  font-size: var(--text-sm);
}

/* A3: 고정 격자 대신 반응형 auto-fit. 폭에 따라 2~5열로 채워 어떤 크기에서도 정렬. */
:root[data-activity="1"] .activity-game-menu-grid {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(6px, 1vw, 10px);
  margin-top: 4px;
}

:root[data-activity="1"] .activity-game-menu-item {
  display: grid;
  min-width: 0;
  min-height: clamp(78px, 12.5vh, 104px);
  align-content: center;
  justify-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 9px 10px;
  background: var(--surface);
  color: var(--text);
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
  animation: activityMenuTileIn 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--activity-menu-index, 0) * 28ms);
}

:root[data-activity="1"] .activity-game-menu-item:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  transform: translateY(-2px);
}

:root[data-activity="1"] .activity-game-menu-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

:root[data-activity="1"] .activity-game-menu-icon {
  font-size: clamp(24px, 4.5vw, 38px);
  line-height: 1;
}

:root[data-activity="1"] .activity-game-menu-item strong,
:root[data-activity="1"] .activity-game-menu-kind {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

:root[data-activity="1"] .activity-game-menu-item strong {
  font-size: var(--text-lg);
}

/* #4: 메뉴 타일을 compact하게 — 게임별 설명(종류) 줄은 활동 메뉴에서 숨긴다. */
:root[data-activity="1"] .activity-game-menu-kind {
  display: none;
}

/* A1: 로딩 스플래시 — 부트스트랩 동안 라운지/기본 게임 flash를 가린다. */
:root[data-activity="1"] .activity-loading {
  display: grid;
  width: min(560px, 100%);
  min-height: min(420px, calc(100vh - 90px));
  min-height: min(420px, calc(100dvh - 90px));
  align-content: center;
  justify-items: center;
  gap: 18px;
  margin: 0 auto;
  padding: clamp(24px, 6vw, 56px);
  text-align: center;
}

:root[data-activity="1"] .activity-loading-mark {
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 900;
  letter-spacing: 0.01em;
  color: var(--text);
}

:root[data-activity="1"] .activity-loading-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  border-top-color: var(--accent);
  animation: activity-spin 720ms linear infinite;
}

:root[data-activity="1"] .activity-loading-copy {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* A4: 창 전환 — transform/opacity만. 각 화면이 새로 삽입될 때 1회 재생. */
:root[data-activity="1"] .activity-loading,
:root[data-activity="1"] .activity-game-menu,
:root[data-activity="1"] .activity-bootstrap-error {
  animation: activity-fade-in 200ms ease both;
}

:root[data-activity="1"] body.activity-enter-game .stage {
  animation: activity-fade-in 240ms ease both;
}

:root[data-activity="1"] .activity-bootstrap-error {
  display: grid;
  width: min(560px, 100%);
  min-height: min(420px, calc(100vh - 90px));
  min-height: min(420px, calc(100dvh - 90px));
  align-content: center;
  justify-items: center;
  gap: 14px;
  margin: 0 auto;
  padding: clamp(24px, 6vw, 56px);
  text-align: center;
}

:root[data-activity="1"] .activity-bootstrap-error h3,
:root[data-activity="1"] .activity-bootstrap-error p {
  margin: 0;
}

:root[data-activity="1"] .activity-bootstrap-error p {
  max-width: 48ch;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

:root[data-activity="1"] .activity-bootstrap-error button {
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0 18px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 800;
}

:root[data-activity="1"] body.activity-menu-open #contextPanel,
:root[data-activity="1"] body.activity-menu-open #contextToggle,
:root[data-activity="1"] body.activity-menu-open #contextOverlayBackdrop,
:root[data-activity="1"] body.activity-loading #contextPanel,
:root[data-activity="1"] body.activity-loading #contextToggle,
:root[data-activity="1"] body.activity-loading #contextOverlayBackdrop,
:root[data-activity="1"] body.activity-bootstrap-failed #contextPanel,
:root[data-activity="1"] body.activity-bootstrap-failed #contextToggle,
:root[data-activity="1"] body.activity-bootstrap-failed #contextOverlayBackdrop {
  display: none !important;
}

@media (max-width: 820px) {
  :root[data-activity="1"] .app-shell {
    display: grid;
    padding-bottom: 0;
  }

  :root[data-activity="1"] .topbar {
    position: sticky;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "stage";
    padding-top: env(safe-area-inset-top);
  }

  :root[data-activity="1"] .stage-title {
    display: flex;
    padding: 0 10px;
  }

  :root[data-activity="1"] .stage-title .meta {
    display: none;
  }

  :root[data-activity="1"] .stage-title h2 {
    flex: 1 1 auto;
    margin: 0;
    font-size: 18px;
    text-align: left;
  }

  :root[data-activity="1"] .stage,
  :root[data-activity="1"] .stage.has-room {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 8px;
  }

  :root[data-activity="1"] body.activity-game-active .context-panel-toggle {
    position: fixed;
    top: auto;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 32;
    display: inline-flex;
    width: auto;
    min-width: 0;
    min-height: 42px;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 0 14px;
    transform: none;
  }

  :root[data-activity="1"] body.activity-game-active .context-panel-toggle:hover {
    transform: none;
  }

  :root[data-activity="1"] body.activity-game-active .context-toggle-label {
    writing-mode: horizontal-tb;
  }

  :root[data-activity="1"] body.activity-game-active .context-panel {
    bottom: 0;
    max-height: min(82vh, 720px);
    max-height: min(82dvh, 720px);
  }

  :root[data-activity="1"] .activity-game-menu {
    min-height: 100%;
    padding: 16px 8px;
  }

  :root[data-activity="1"] .activity-game-menu-grid {
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
  }

  :root[data-activity="1"] .activity-game-menu-item {
    min-height: 104px;
    padding: 12px 10px;
  }
}

@media (max-height: 600px) {
  :root[data-activity="1"] body.activity-game-active .stage,
  :root[data-activity="1"] body.activity-game-active .stage.has-room {
    padding: 6px;
  }

  :root[data-activity="1"] body.activity-game-active .game-main-panel,
  :root[data-activity="1"] .onecard-surface .onecard-card,
  :root[data-activity="1"] .omok-surface .omok-card {
    padding: 7px;
  }

  :root[data-activity="1"] .activity-omok-controls {
    top: 8px;
    right: 8px;
    gap: 5px;
  }

  :root[data-activity="1"] .activity-omok-controls button,
  :root[data-activity="1"] .activity-omok-clock {
    min-height: 30px;
    padding: 4px 8px;
    font-size: 11px;
  }

  :root[data-activity="1"] .onecard-surface .onecard-card,
  :root[data-activity="1"] .omok-surface .omok-card {
    gap: 7px;
  }

  :root[data-activity="1"] .onecard-surface .onecard-table-3d {
    height: clamp(0px, calc(100vh - 110px), 520px);
    height: clamp(0px, calc(100dvh - 110px), 520px);
  }

  :root[data-activity="1"] .omok-surface .omok-board-3d {
    height: clamp(0px, calc(100vh - 110px), 480px);
    height: clamp(0px, calc(100dvh - 110px), 480px);
  }
}

@media (max-width: 600px) {
  :root[data-activity="1"] .activity-participant-avatars {
    display: none;
  }

  :root[data-activity="1"] .activity-participants {
    padding-left: 9px;
  }

  :root[data-activity="1"] .activity-game-menu-back {
    min-height: 34px;
    padding: 0 9px;
    font-size: var(--text-xs);
  }

  :root[data-activity="1"] .activity-game-menu h3 {
    font-size: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root[data-activity="1"]::view-transition-old(activity-surface),
  :root[data-activity="1"]::view-transition-new(activity-surface),
  :root[data-activity="1"] .activity-confirm-overlay,
  :root[data-activity="1"] .activity-confirm-dialog,
  :root[data-activity="1"] .yut-surface .yut-throw-dock.can-throw,
  :root[data-activity="1"] .activity-game-menu-item,
  :root[data-activity="1"] .activity-game-menu-back {
    transition: none;
    animation: none;
  }

  /* A4: 모션 축소 시 전환 애니메이션 제거(스피너는 로딩 피드백이라 유지). */
  :root[data-activity="1"] .activity-loading,
  :root[data-activity="1"] .activity-game-menu,
  :root[data-activity="1"] .activity-bootstrap-error,
  :root[data-activity="1"] body.activity-enter-game .stage {
    animation: none;
  }

  :root[data-activity="1"] .activity-game-menu-item:hover {
    transform: none;
  }
}

/* Front/back artwork belongs to the shared character editor. */
.character-artwork-editor {
  grid-column: 1 / -1;
  min-width: 0;
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border, #c9cbd4);
}
.character-artwork-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.character-artwork-toolbar label { display: inline-flex; align-items: center; gap: 6px; }
.character-artwork-toolbar input[type="range"] { width: 88px; }
.character-artwork-toolbar input[type="color"] { width: 32px; height: 30px; padding: 2px; }
.character-artwork-toolbar button[aria-pressed="true"] { outline: 2px solid #728ae1; outline-offset: 1px; }
.character-artwork-toolbar output { color: var(--text-muted); font-size: .85rem; }
.character-artwork-editor canvas {
  display: block;
  width: min(100%, 256px);
  height: auto;
  aspect-ratio: 1;
  border: 1px solid #9297a3;
  border-radius: 8px;
  background-color: #e6e8ed;
  background-image: conic-gradient(#f8f9fc 25%, transparent 0 50%, #f8f9fc 0 75%, transparent 0);
  background-size: 20px 20px;
  touch-action: none;
  cursor: crosshair;
}
.character-artwork-editor p { margin: 0; font-size: .85rem; line-height: 1.5; }

@media (max-width: 600px) {
  .character-lab-layout-artwork-active .character-lab-preview,
  .character-lab-layout-artwork-active .character-lab-preview canvas {
    min-height: 180px;
    height: 180px;
  }

  .character-lab-layout-artwork-active .character-lab-preview {
    position: sticky;
    top: 0;
    z-index: 2;
  }
}

/* 금지 문양도 무늬를 읽을 수 있도록, 일반 타패 금지보다 조금 더 어둡게 표시한다. */
.riichi-tile.power-forbidden-suit {
  filter: brightness(0.7);
  opacity: 1;
}

.mahjong-fake-riichi-badge {
  border-color: rgba(167, 139, 250, 0.58) !important;
  background: rgba(76, 29, 149, 0.72) !important;
  color: #ede9fe !important;
}

/* Shared live/Lab surfaces for tile custody and alternate objectives. */
.mahjong-market-status { display:flex; align-items:center; justify-content:space-between; gap:14px; padding:10px 14px; margin-bottom:10px; border:1px solid #caab60; border-radius:12px; background:linear-gradient(120deg,#283d3b,#17282d); color:#fff1c6; }
.mahjong-market-status small,.mahjong-magic-status small { display:block; margin-top:5px; font-size:11px; opacity:.8; }
.mahjong-market-status>div { display:flex; gap:7px; }
.mahjong-market-status .riichi-tile { width:32px; height:44px; }
.mahjong-expansion-option .mahjong-command-sigil:has(.riichi-tile) { width:auto; min-width:36px; }
.mahjong-expansion-choice { width:100%; box-sizing:border-box; padding:12px; border:1px solid #756288; border-radius:12px; background:#292438; color:#f1e7ff; }
.mahjong-expansion-choice .mahjong-combination-head { color:#f1e7ff; }
.mahjong-expansion-choice .mahjong-power-target-grid { grid-template-columns:repeat(auto-fit,minmax(120px,1fr)); }
.mahjong-magic-status { margin:8px 0; padding:10px 14px; border:1px solid #9e82d0; border-radius:12px; background:rgba(47,32,72,.94); color:#f1e7ff; }
.mahjong-magic-status summary { cursor:pointer; font-weight:700; }
.mahjong-magic-workspace { display:flex; gap:18px; align-items:center; margin-top:10px; }
.mahjong-magic-grid { display:grid; grid-template-columns:repeat(3,44px); gap:4px; }
.mahjong-magic-cell { display:grid; place-items:center; height:52px; padding:3px; border:1px solid #a48ac3; border-radius:5px; background:#322743; color:#c5aedf; }
.mahjong-magic-cell:disabled { opacity:.8; cursor:default; }
.mahjong-magic-cell .riichi-tile { width:30px; height:42px; }
.mahjong-magic-workspace p { margin:0 0 8px; font-size:12px; }
.mahjong-magic-workspace label { display:grid; gap:4px; }
.mahjong-magic-tiles { display:flex; flex-wrap:wrap; gap:5px; max-width:280px; max-height:168px; overflow:auto; padding:5px; }
.mahjong-magic-tiles button { padding:2px; background:transparent; border:2px solid transparent; border-radius:6px; }
.mahjong-magic-tiles button[aria-pressed="true"] { border-color:#f5d979; background:#665031; }
.mahjong-magic-tiles .riichi-tile, .mahjong-power-target .riichi-tile { width:26px; height:36px; }
.mahjong-power-target .mahjong-command-sigil:has(.riichi-tile) { display:flex; align-items:center; gap:3px; width:auto; min-width:36px; font-size:13px; }
@media(max-width:600px) { .mahjong-market-status { gap:7px; padding:8px; } .mahjong-market-status strong { font-size:12px; } .mahjong-market-status small { max-width:180px; font-size:10px; } .mahjong-market-status .riichi-tile { width:25px; height:36px; } .mahjong-magic-workspace { gap:10px; } }
