:root {
  color-scheme: dark;
  --dm-bg: #05090d;
  --dm-panel: #0b1419;
  --dm-panel-2: #101d22;
  --dm-line: rgba(170, 202, 190, 0.14);
  --dm-line-strong: rgba(170, 202, 190, 0.26);
  --dm-text: #f3f7f5;
  --dm-muted: #91a49d;
  --dm-green: #bff255;
  --dm-mint: #65e6bd;
  --dm-amber: #f2bd61;
  --dm-red: #ff6f78;
  --dm-board-light: #d9dfd8;
  --dm-board-dark: #285d51;
  --dm-white-piece: #f1eee6;
  --dm-black-piece: #172126;
  --dm-display: "Sora", "Segoe UI", system-ui, sans-serif;
  --dm-body-font: "Inter", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body.dm-body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(101, 230, 189, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(101, 230, 189, 0.025) 1px, transparent 1px),
    radial-gradient(44rem 26rem at 88% -8%, rgba(101, 230, 189, 0.08), transparent 70%),
    radial-gradient(36rem 24rem at 2% 18%, rgba(191, 242, 85, 0.055), transparent 72%),
    var(--dm-bg);
  background-size: 48px 48px, 48px 48px, auto, auto, auto;
  color: var(--dm-text);
  font-family: var(--dm-body-font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input { font: inherit; }

button,
a { -webkit-tap-highlight-color: transparent; }

a { color: inherit; text-decoration: none; }

.hidden { display: none !important; }

.dm-page {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.page-header { max-width: none; }

.dm-hero {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) auto;
  align-items: center;
  gap: 28px;
  min-height: 250px;
  padding: 30px 0 34px;
  border-bottom: 1px solid var(--dm-line);
}

.dm-hero-art {
  display: grid;
  place-items: center;
  width: 180px;
  aspect-ratio: 1;
  border: 1px solid var(--dm-line);
  border-radius: 8px;
  background: rgba(14, 29, 31, 0.68);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}

.dm-mini-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: 126px;
  aspect-ratio: 1;
  overflow: hidden;
  border: 6px solid #152a28;
  border-radius: 4px;
  background: var(--dm-board-light);
  transform: rotate(-5deg);
  box-shadow: 0 18px 28px rgba(0, 0, 0, 0.36);
}

.dm-mini-board i:nth-child(odd) { background: var(--dm-board-dark); }
.dm-mini-board i:nth-child(even) { background: #cbd4cc; }

.dm-mini-piece {
  position: absolute;
  width: 32px;
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow: inset 0 0 0 5px rgba(0, 0, 0, 0.12), 0 7px 10px rgba(0, 0, 0, 0.25);
}

.dm-mini-piece.white { left: 13px; bottom: 16px; background: var(--dm-white-piece); }
.dm-mini-piece.black { top: 16px; right: 13px; background: var(--dm-black-piece); border: 2px solid #496158; }
.dm-mini-piece.king {
  right: 42px;
  bottom: 45px;
  display: grid;
  place-items: center;
  background: var(--dm-green);
  color: #183229;
  font-size: 14px;
}

.dm-kicker,
.dm-eyebrow {
  display: block;
  color: var(--dm-green);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.dm-hero-copy h1,
.dm-section-heading h2,
.dm-room h2,
.dm-result h2 {
  margin: 5px 0 0;
  font-family: var(--dm-display);
  letter-spacing: 0;
}

.dm-hero-copy h1 { font-size: clamp(38px, 5vw, 64px); line-height: 1; }

.dm-hero-copy p {
  max-width: 660px;
  margin: 16px 0 18px;
  color: var(--dm-muted);
  font-size: 15px;
}

.dm-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dm-meta span {
  padding: 6px 10px;
  border: 1px solid var(--dm-line);
  border-radius: 7px;
  color: #b8c8c2;
  font-size: 11px;
  font-weight: 700;
}

.dm-meta .online { border-color: rgba(101, 230, 189, 0.3); color: var(--dm-mint); }

.dm-profile-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 190px;
  padding: 10px 12px;
  border: 1px solid var(--dm-line);
  border-radius: 8px;
  background: rgba(11, 20, 25, 0.74);
}

.dm-profile-avatar {
  display: grid;
  place-items: center;
  width: 36px;
  aspect-ratio: 1;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--dm-green);
  color: #102219;
  font-weight: 900;
}

.dm-profile-pill div { min-width: 0; }
.dm-profile-pill strong,
.dm-profile-pill small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-profile-pill strong { font-size: 12px; }
.dm-profile-pill small { margin-top: 2px; color: var(--dm-muted); font-size: 10px; }

main { padding: 28px 0 70px; }

.dm-panel {
  border: 1px solid var(--dm-line);
  border-radius: 8px;
  background: rgba(9, 17, 21, 0.82);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.18);
}

.dm-setup { padding: 24px; }

.dm-section-heading,
.dm-room-head,
.dm-room-footer,
.dm-card-heading,
.dm-status-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.dm-section-heading { margin-bottom: 22px; }
.dm-section-heading h2 { font-size: 23px; }

.dm-mode-tabs,
.dm-segmented {
  display: flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--dm-line);
  border-radius: 8px;
  background: #071014;
}

.dm-mode-tabs button,
.dm-segmented button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--dm-muted);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.dm-mode-tabs button { min-width: 112px; padding: 0 14px; }
.dm-segmented button { flex: 1; padding: 0 10px; }

.dm-mode-tabs button.active,
.dm-segmented button.active {
  background: #1b332f;
  color: var(--dm-text);
  box-shadow: inset 0 -2px var(--dm-green);
}

.dm-setup-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(430px, 1.1fr);
  gap: 20px;
}

.dm-preview {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  align-items: center;
  min-height: 390px;
  overflow: hidden;
  padding: 32px;
  border: 1px solid var(--dm-line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(101, 230, 189, 0.08), transparent 48%),
    #0b181a;
}

.dm-preview::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.16;
  background:
    linear-gradient(90deg, transparent 49%, rgba(255, 255, 255, 0.08) 50%, transparent 51%),
    linear-gradient(transparent 49%, rgba(255, 255, 255, 0.08) 50%, transparent 51%);
  background-size: 42px 42px;
}

.dm-preview-copy { position: relative; z-index: 1; align-self: start; }
.dm-preview-copy span { color: var(--dm-mint); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.dm-preview-copy strong { display: block; max-width: 250px; margin-top: 8px; font-family: var(--dm-display); font-size: 25px; line-height: 1.16; }
.dm-preview-copy small { display: block; max-width: 260px; margin-top: 12px; color: var(--dm-muted); font-size: 12px; }

.dm-preview-board {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  align-self: end;
  width: 240px;
  aspect-ratio: 1;
  border: 10px solid #18312e;
  border-radius: 5px;
  box-shadow: -24px 30px 46px rgba(0, 0, 0, 0.34);
  transform: rotate(6deg) translate(10px, 22px);
}

.dm-preview-board span { position: relative; background: #cdd7d0; }
.dm-preview-board span.dark { background: #326c5f; }
.dm-preview-board span::after {
  content: "";
  position: absolute;
  inset: 16%;
  display: none;
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px rgba(0, 0, 0, 0.12), 0 3px 4px rgba(0, 0, 0, 0.24);
}
.dm-preview-board span.white-piece::after { display: block; background: #eeeae1; }
.dm-preview-board span.black-piece::after { display: block; background: #172126; border: 1px solid #536960; }

.dm-preview-rule {
  position: absolute;
  left: 32px;
  bottom: 28px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 270px;
  color: #c7d4cf;
  font-size: 11px;
}

.dm-preview-rule b,
.dm-capture-alert b {
  display: grid;
  place-items: center;
  width: 24px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--dm-amber);
  color: #2b2110;
}

.dm-settings {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dm-setting {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(270px, 1.2fr);
  align-items: center;
  gap: 18px;
  min-height: 86px;
  padding: 15px 16px;
  border: 1px solid var(--dm-line);
  border-radius: 8px;
  background: rgba(15, 28, 32, 0.56);
}

.dm-setting strong,
.dm-setting small { display: block; }
.dm-setting strong { font-size: 12px; }
.dm-setting small { margin-top: 3px; color: var(--dm-muted); font-size: 10px; }

.dm-primary-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 80px;
  margin-top: auto;
  padding: 14px 16px;
  border: 1px solid rgba(191, 242, 85, 0.2);
  border-radius: 8px;
  background: rgba(191, 242, 85, 0.055);
}

.dm-primary-action > div strong,
.dm-primary-action > div span { display: block; }
.dm-primary-action > div strong { font-size: 12px; }
.dm-primary-action div > span { max-width: 330px; margin-top: 3px; color: var(--dm-muted); font-size: 10px; }

.dm-primary,
.dm-secondary,
.dm-danger,
.dm-join-row button,
.dm-icon-button {
  border-radius: 7px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.dm-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 17px;
  border: 1px solid var(--dm-green);
  background: var(--dm-green);
  color: #142114;
}

.dm-primary > span {
  display: inline;
  font-size: 14px;
  line-height: 1;
}

.dm-primary:hover { transform: translateY(-1px); background: #cdf96b; }
.dm-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.dm-secondary,
.dm-danger {
  display: inline-grid;
  place-items: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--dm-line-strong);
  background: #0b171b;
  color: #b6c5c0;
  font-size: 11px;
}

.dm-danger { border-color: rgba(255, 111, 120, 0.3); color: #ff9299; }
.dm-secondary:hover { border-color: rgba(191, 242, 85, 0.38); color: #fff; }
.dm-danger:hover { border-color: rgba(255, 111, 120, 0.62); background: rgba(255, 111, 120, 0.07); }

.dm-online-actions {
  display: grid;
  gap: 10px;
}

.dm-online-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 76px;
  padding: 12px 14px;
  border: 1px solid var(--dm-line);
  border-radius: 8px;
  background: rgba(15, 28, 32, 0.56);
}

.dm-step { color: var(--dm-mint); font-family: var(--dm-display); font-size: 13px; }
.dm-online-option strong,
.dm-online-option small { display: block; }
.dm-online-option strong { font-size: 12px; }
.dm-online-option small { margin-top: 3px; color: var(--dm-muted); font-size: 10px; }

.dm-join-row { display: flex; gap: 6px; }
.dm-join-row input {
  width: 94px;
  min-height: 42px;
  border: 1px solid var(--dm-line-strong);
  border-radius: 7px;
  outline: 0;
  background: #071014;
  color: #fff;
  text-align: center;
  text-transform: uppercase;
  font-weight: 900;
}
.dm-join-row input:focus { border-color: var(--dm-green); }
.dm-join-row button {
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid var(--dm-line-strong);
  background: #172c2b;
  color: #fff;
}

#dm-online-note { margin: 0; color: var(--dm-muted); font-size: 10px; }

.dm-room { padding: 24px; }
.dm-room-head { padding-bottom: 20px; border-bottom: 1px solid var(--dm-line); }
.dm-room-code-line { display: flex; align-items: center; gap: 10px; }
.dm-room-code-line h2 { color: var(--dm-green); font-size: 34px; letter-spacing: 3px; }
.dm-room-head p { margin: 4px 0 0; color: var(--dm-muted); font-size: 11px; }
.dm-icon-button { width: 36px; aspect-ratio: 1; border: 1px solid var(--dm-line); background: #101f22; color: #b9cbc4; }

.dm-seats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 20px 0;
}

.dm-seat {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 78px;
  padding: 13px 15px;
  border: 1px solid var(--dm-line);
  border-radius: 8px;
  background: #0c171b;
}

.dm-seat.empty { border-style: dashed; color: var(--dm-muted); }
.dm-seat-avatar { display: grid; place-items: center; width: 42px; aspect-ratio: 1; border-radius: 50%; background: #1d3431; color: var(--dm-green); font-weight: 900; }
.dm-seat strong,
.dm-seat small { display: block; }
.dm-seat strong { font-size: 12px; }
.dm-seat small { margin-top: 2px; color: var(--dm-muted); font-size: 10px; }
.dm-room-status-ready { color: var(--dm-mint); }

.dm-game { position: relative; }

.dm-match-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.dm-player-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 10px 13px;
  border: 1px solid var(--dm-line);
  border-radius: 8px;
  background: rgba(10, 19, 23, 0.86);
}

.dm-player-card.black { justify-content: flex-end; text-align: right; }
.dm-player-card.active { border-color: rgba(191, 242, 85, 0.55); box-shadow: inset 0 -2px var(--dm-green); }
.dm-player-card div { min-width: 0; }
.dm-player-card small,
.dm-player-card strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-player-card small { color: var(--dm-muted); font-size: 9px; text-transform: uppercase; }
.dm-player-card strong { font-size: 12px; }
.dm-player-card time { margin-left: auto; color: #dbe7e2; font-family: var(--dm-display); font-size: 18px; font-variant-numeric: tabular-nums; }
.dm-player-card.black time { margin: 0 auto 0 0; }
.dm-player-card time.low { color: var(--dm-red); }

.dm-player-piece {
  position: relative;
  display: inline-block;
  width: 34px;
  aspect-ratio: 1;
  flex: 0 0 auto;
  border-radius: 50%;
  box-shadow: inset 0 0 0 5px rgba(0, 0, 0, 0.11), 0 4px 8px rgba(0, 0, 0, 0.26);
}
.dm-player-piece.white { background: var(--dm-white-piece); border: 1px solid #fff; }
.dm-player-piece.black { background: var(--dm-black-piece); border: 1px solid #52635e; }

.dm-match-center { min-width: 170px; text-align: center; }
.dm-match-center span,
.dm-match-center strong { display: block; }
.dm-match-center span { color: var(--dm-muted); font-size: 9px; text-transform: uppercase; }
.dm-match-center strong { margin-top: 4px; color: var(--dm-green); font-size: 12px; }

.dm-game-layout {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) 330px;
  gap: 16px;
  align-items: stretch;
}

.dm-board-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 650px;
  overflow: hidden;
  border: 1px solid var(--dm-line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(101, 230, 189, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(101, 230, 189, 0.035) 1px, transparent 1px),
    #091317;
  background-size: 32px 32px;
}

.dm-board-frame {
  position: relative;
  width: min(600px, calc(100% - 54px));
  aspect-ratio: 1;
  padding: 15px;
  border: 1px solid rgba(191, 242, 85, 0.24);
  border-radius: 7px;
  background: linear-gradient(145deg, #29413d, #132623);
  box-shadow: 0 28px 65px rgba(0, 0, 0, 0.4), inset 0 0 0 5px rgba(0, 0, 0, 0.17);
}

.dm-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, minmax(0, 1fr));
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 2px;
  transform: rotate(0deg);
}

.dm-board.flipped { transform: rotate(180deg); }
.dm-board.flipped .dm-square > * { transform: rotate(180deg); }

.dm-square {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  border: 0;
  padding: 0;
  background: var(--dm-board-light);
}

button.dm-square { cursor: default; }
.dm-square.dark { background: var(--dm-board-dark); }
.dm-square.dark::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.035), transparent 55%);
}
.dm-square.playable { cursor: pointer; }
.dm-square.source::after {
  content: "";
  position: absolute;
  inset: 7%;
  border: 3px solid rgba(191, 242, 85, 0.8);
  border-radius: 50%;
}
.dm-square.destination::after {
  content: "";
  position: absolute;
  z-index: 3;
  width: 24%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--dm-green);
  box-shadow: 0 0 0 6px rgba(191, 242, 85, 0.16);
}
.dm-square.capture-destination::after {
  width: 72%;
  border: 4px solid var(--dm-amber);
  background: transparent;
  box-shadow: 0 0 0 5px rgba(242, 189, 97, 0.12);
}
.dm-square.last-from { box-shadow: inset 0 0 0 4px rgba(101, 230, 189, 0.3); }
.dm-square.last-to { box-shadow: inset 0 0 0 4px rgba(191, 242, 85, 0.62); }

.dm-piece {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 72%;
  aspect-ratio: 1;
  border-radius: 50%;
  transition: transform 150ms ease, filter 150ms ease;
  animation: dmPieceIn 180ms ease both;
}

.dm-piece.white {
  border: 2px solid #fff;
  background: radial-gradient(circle at 34% 28%, #fff, #e5e1d8 66%, #c7c1b7);
  box-shadow: inset 0 0 0 8px rgba(111, 110, 102, 0.1), 0 7px 10px rgba(0, 0, 0, 0.25);
}

.dm-piece.black {
  border: 2px solid #52645f;
  background: radial-gradient(circle at 34% 28%, #3c4b4c, #172126 68%, #0b1013);
  box-shadow: inset 0 0 0 8px rgba(255, 255, 255, 0.045), 0 7px 10px rgba(0, 0, 0, 0.35);
}

.dm-square.playable:hover .dm-piece { transform: translateY(-3px); filter: brightness(1.08); }
.dm-piece.king::before {
  content: "◆";
  display: grid;
  place-items: center;
  width: 48%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--dm-amber);
  color: #38280d;
  font-size: clamp(10px, 1.5vw, 17px);
  box-shadow: 0 0 0 4px rgba(242, 189, 97, 0.16);
}

.dm-piece.hint { box-shadow: 0 0 0 4px rgba(191, 242, 85, 0.45), 0 0 22px rgba(191, 242, 85, 0.28); }

.dm-coord {
  position: absolute;
  z-index: 1;
  color: rgba(12, 31, 27, 0.48);
  font-size: 8px;
  font-weight: 900;
  pointer-events: none;
}
.dm-coord.file { right: 4px; bottom: 2px; }
.dm-coord.rank { left: 4px; top: 2px; }
.dm-square.dark .dm-coord { color: rgba(235, 247, 240, 0.5); }

.dm-board-message {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  background: rgba(3, 8, 10, 0.58);
  backdrop-filter: blur(3px);
  color: #fff;
  font-family: var(--dm-display);
  font-size: 20px;
}

.dm-sidebar {
  display: grid;
  grid-template-rows: auto auto minmax(260px, 1fr) auto;
  gap: 10px;
}

.dm-status-card,
.dm-material-card,
.dm-history-card {
  border: 1px solid var(--dm-line);
  border-radius: 8px;
  background: rgba(10, 19, 23, 0.88);
}

.dm-status-card { min-height: 150px; padding: 15px; }
.dm-live-dot { color: var(--dm-mint); font-size: 9px; font-weight: 800; }
.dm-status-card > strong { display: block; margin-top: 18px; font-family: var(--dm-display); font-size: 17px; }
.dm-status-card > p { margin: 6px 0 0; color: var(--dm-muted); font-size: 11px; }
.dm-capture-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 13px;
  color: var(--dm-amber);
  font-size: 11px;
  font-weight: 800;
}

.dm-capture-alert.optional {
  padding: 6px 8px;
  border: 1px solid rgba(101, 230, 189, 0.28);
  border-radius: 6px;
  background: rgba(101, 230, 189, 0.08);
  color: var(--dm-mint);
}

.dm-capture-alert.optional b {
  background: var(--dm-mint);
  color: #09201b;
}
.dm-capture-alert b { width: 20px; }

.dm-material-card {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 86px;
  padding: 12px;
}
.dm-material-card > div {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0 8px;
}
.dm-material-card > div:last-child { text-align: right; grid-template-columns: 1fr auto; }
.dm-material-card > div:last-child .dm-player-piece { grid-column: 2; grid-row: 1 / span 2; }
.dm-material-card .dm-player-piece { grid-row: 1 / span 2; width: 28px; }
.dm-material-card strong { font-family: var(--dm-display); font-size: 15px; }
.dm-material-card small { color: var(--dm-muted); font-size: 8px; }
.dm-material-diff { color: var(--dm-muted); font-size: 10px; }

.dm-history-card { display: flex; min-height: 0; flex-direction: column; overflow: hidden; }
.dm-card-heading { min-height: 66px; padding: 12px 14px; border-bottom: 1px solid var(--dm-line); }
.dm-card-heading strong { display: block; margin-top: 3px; font-size: 12px; }
.dm-card-heading > span { color: var(--dm-muted); font-size: 10px; }
.dm-history-card ol {
  min-height: 240px;
  max-height: 320px;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  list-style: none;
  scrollbar-width: thin;
  scrollbar-color: #33564f transparent;
}
.dm-history-card li {
  display: grid;
  grid-template-columns: 28px 1fr 1fr;
  align-items: center;
  min-height: 31px;
  border-bottom: 1px solid rgba(170, 202, 190, 0.07);
  color: #c5d3ce;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.dm-history-card li span:first-child { color: #60766f; }
.dm-history-card li b { font-weight: 700; }
.dm-history-empty { display: grid !important; grid-template-columns: 1fr !important; place-items: center; min-height: 210px !important; border: 0 !important; color: var(--dm-muted) !important; text-align: center; }

.dm-game-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.dm-result {
  margin-top: 16px;
  padding: 32px;
  border: 1px solid rgba(191, 242, 85, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(105deg, rgba(191, 242, 85, 0.08), transparent 55%),
    #0b171a;
  text-align: center;
}
.dm-result-mark { display: grid; place-items: center; width: 56px; aspect-ratio: 1; margin: 0 auto 12px; border-radius: 50%; background: var(--dm-green); color: #182715; font-size: 22px; }
.dm-result h2 { font-size: 30px; }
.dm-result > p { margin: 9px 0 22px; color: var(--dm-muted); font-size: 12px; }
.dm-result-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 130px)); justify-content: center; gap: 8px; }
.dm-result-stats div { padding: 12px; border: 1px solid var(--dm-line); border-radius: 7px; background: rgba(0, 0, 0, 0.12); }
.dm-result-stats strong,
.dm-result-stats span { display: block; }
.dm-result-stats strong { font-family: var(--dm-display); font-size: 19px; }
.dm-result-stats span { margin-top: 2px; color: var(--dm-muted); font-size: 9px; }
.dm-result-actions { display: flex; justify-content: center; gap: 8px; margin-top: 20px; }

.dm-info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}
.dm-info-grid article { min-height: 138px; padding: 20px; border-top: 1px solid var(--dm-line); }
.dm-info-number { color: var(--dm-mint); font-family: var(--dm-display); font-size: 11px; }
.dm-info-grid strong { display: block; margin-top: 14px; font-family: var(--dm-display); font-size: 14px; }
.dm-info-grid p { margin: 7px 0 0; color: var(--dm-muted); font-size: 10px; }

.dm-footer {
  display: flex;
  align-items: center;
  gap: 22px;
  min-height: 70px;
  border-top: 1px solid var(--dm-line);
  color: var(--dm-muted);
  font-size: 10px;
}
.dm-footer span { margin-right: auto; color: #c7d5d0; font-weight: 800; }
.dm-footer a:hover { color: #fff; }

.dm-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  max-width: 360px;
  padding: 12px 15px;
  border: 1px solid rgba(191, 242, 85, 0.35);
  border-radius: 8px;
  background: #12231f;
  color: #f3f7f5;
  font-size: 11px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
}
.dm-toast.show { opacity: 1; transform: none; }
.dm-toast.error { border-color: rgba(255, 111, 120, 0.5); background: #2a1519; }

@keyframes dmPieceIn {
  from { opacity: 0; transform: scale(0.82); }
  to { opacity: 1; transform: scale(1); }
}

@media (max-width: 980px) {
  .dm-hero { grid-template-columns: 140px minmax(0, 1fr); }
  .dm-hero-art { width: 140px; }
  .dm-mini-board { width: 98px; }
  .dm-mini-piece { width: 25px; }
  .dm-mini-piece.white { left: 10px; bottom: 12px; }
  .dm-mini-piece.black { top: 12px; right: 10px; }
  .dm-mini-piece.king { right: 32px; bottom: 34px; }
  .dm-profile-pill { grid-column: 1 / -1; width: 100%; }
  .dm-setup-layout { grid-template-columns: 1fr; }
  .dm-preview { min-height: 330px; }
  .dm-game-layout { grid-template-columns: 1fr; }
  .dm-sidebar { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; }
  .dm-history-card { grid-column: 2; grid-row: 1 / span 2; }
  .dm-game-actions { grid-column: 1; }
}

@media (max-width: 700px) {
  .dm-page { width: min(100% - 24px, 1180px); }
  .dm-hero { grid-template-columns: 92px minmax(0, 1fr); gap: 16px; min-height: 210px; padding: 22px 0; }
  .dm-hero-art { width: 92px; }
  .dm-mini-board { width: 68px; border-width: 4px; }
  .dm-mini-piece { width: 17px; }
  .dm-mini-piece.white { left: 7px; bottom: 8px; }
  .dm-mini-piece.black { top: 8px; right: 7px; }
  .dm-mini-piece.king { right: 22px; bottom: 23px; font-size: 8px; }
  .dm-hero-copy h1 { font-size: 36px; }
  .dm-hero-copy p { margin-block: 10px 12px; font-size: 12px; }
  .dm-meta span { font-size: 9px; }
  .dm-profile-pill { min-width: 0; }
  main { padding-top: 16px; }
  .dm-setup,
  .dm-room { padding: 14px; }
  .dm-section-heading { align-items: flex-start; flex-direction: column; }
  .dm-mode-tabs { width: 100%; }
  .dm-mode-tabs button { flex: 1; min-width: 0; }
  .dm-preview { grid-template-columns: 1fr 150px; min-height: 250px; padding: 20px; }
  .dm-preview-copy strong { font-size: 18px; }
  .dm-preview-copy small { display: none; }
  .dm-preview-board { width: 158px; border-width: 7px; transform: rotate(6deg) translate(8px, 16px); }
  .dm-preview-rule { left: 20px; bottom: 18px; max-width: 200px; }
  .dm-setting { grid-template-columns: 1fr; gap: 10px; }
  .dm-primary-action { align-items: stretch; flex-direction: column; }
  .dm-online-option { grid-template-columns: auto 1fr; }
  .dm-online-option > .dm-primary,
  .dm-online-option > .dm-join-row { grid-column: 2; }
  .dm-seats { grid-template-columns: 1fr; }
  .dm-match-bar { grid-template-columns: 1fr 1fr; gap: 8px; }
  .dm-match-center { grid-column: 1 / -1; grid-row: 1; min-width: 0; }
  .dm-player-card { grid-row: 2; }
  .dm-player-card time { font-size: 14px; }
  .dm-game-layout { gap: 10px; }
  .dm-board-wrap { min-height: 0; padding-block: 18px; }
  .dm-board-frame { width: calc(100% - 24px); padding: 8px; }
  .dm-sidebar { display: grid; grid-template-columns: 1fr; grid-template-rows: auto; }
  .dm-history-card { grid-column: 1; grid-row: auto; }
  .dm-history-card ol { max-height: 220px; min-height: 180px; }
  .dm-game-actions { grid-column: 1; }
  .dm-info-grid { grid-template-columns: 1fr; }
  .dm-info-grid article { min-height: 0; }
  .dm-result { padding: 24px 14px; }
  .dm-result-stats { grid-template-columns: repeat(3, 1fr); }
  .dm-result-actions { align-items: stretch; flex-direction: column; }
  .dm-footer { flex-wrap: wrap; padding-block: 18px; }
  .dm-footer span { width: 100%; }
}

@media (max-width: 430px) {
  .dm-hero { grid-template-columns: 1fr; }
  .dm-hero-art { display: none; }
  .dm-profile-pill { grid-column: 1; }
  .dm-preview { display: block; min-height: 210px; }
  .dm-preview-board { position: absolute; right: -18px; bottom: -24px; width: 150px; opacity: 0.72; }
  .dm-preview-copy { max-width: 190px; }
  .dm-preview-rule { max-width: 180px; }
  .dm-segmented { display: grid; grid-template-columns: repeat(3, 1fr); }
  .dm-setting .dm-segmented button { padding-inline: 4px; font-size: 10px; }
  .dm-room-footer { align-items: stretch; flex-direction: column; }
  .dm-room-footer .dm-primary { width: 100%; }
  .dm-player-card { padding: 8px; }
  .dm-player-piece { width: 26px; }
  .dm-player-card strong { max-width: 82px; }
  .dm-player-card time { font-size: 12px; }
  .dm-board-frame { width: calc(100% - 10px); padding: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001s !important;
    transition-duration: 0.001s !important;
  }
}
