/* Daily Mines - game-specific layout.
   Colors, type ramp, radii, shadows, button styles all come from /css/site.css.
   Anything that starts with --dm-* below is local to this game. */

:root {
  --dm-cell-border: rgba(0, 0, 0, 0.10);
  --dm-board-border: #14181f;
  --dm-cover: #cfd5dd;
  --dm-cover-press: #b9c0ca;
  --dm-revealed: #f5efe6;
  --dm-revealed-warm: #ece4d4;
  --dm-mine-hit: #e23b46;
  --dm-flag: #d8483a;
  --dm-life: #fb7185;

  /* Classic Minesweeper number palette (ish) */
  --dm-n1: #1d4ed8;
  --dm-n2: #15803d;
  --dm-n3: #c0392b;
  --dm-n4: #1e3a8a;
  --dm-n5: #9b1c1c;
  --dm-n6: #0e7490;
  --dm-n7: #1f2937;
  --dm-n8: #6b7280;
}

/* --- One-screen viewport (no page scroll) -------------------------------- */
html.dm-page {
  height: 100%;
  overflow: hidden;
}

body.dm-page {
  height: 100%;
  max-height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  overscroll-behavior: none;
}

@supports (height: 100dvh) {
  body.dm-page {
    min-height: 100dvh;
    max-height: 100dvh;
  }
}

@supports (height: 100svh) {
  body.dm-page {
    min-height: 100svh;
    max-height: 100svh;
  }
}

body.dm-page .blob-field {
  opacity: 0.4;
}

body.dm-page .layout {
  min-height: 0;
  height: 100%;
  max-height: inherit;
  overflow: hidden;
  min-height: 100dvh;
}

@supports not (min-height: 100dvh) {
  body.dm-page .layout {
    min-height: 100vh;
  }
}

/* Pre-run: hide game UI until Start. */
.dm-main--intro .dm-top-stats,
.dm-main--intro .dm-card__viewport,
.dm-main--intro .dm-complete {
  display: none !important;
}

.dm-main--intro .dm-card {
  position: relative;
  z-index: 5;
}

.dm-card--intro .dm-intro {
  position: relative;
  inset: auto;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  z-index: 1;
}

/* Wider game shell + one-screen sizing. */
body.dm-page main.game-shell.game-shell--wide {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  row-gap: clamp(0.35rem, 1.4vmin, 0.65rem);
  width: 100%;
  max-width: min(800px, 100%);
  margin-inline: auto;
  margin-block: 0;
  padding: clamp(0.75rem, 3.5vmin, 1.75rem) clamp(1rem, 7vw, 3.25rem);
  padding-left: max(clamp(1rem, 7vw, 3.25rem), env(safe-area-inset-left, 0px));
  padding-right: max(clamp(1rem, 7vw, 3.25rem), env(safe-area-inset-right, 0px));
  padding-bottom: max(clamp(0.75rem, 3.5vmin, 1.75rem), env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
}

body.dm-page .game-shell--wide .back-link {
  margin-bottom: 0.35rem;
}

body.dm-page .game-shell--wide h1 {
  margin: 0 0 0.2rem;
  font-size: var(--fs-2xl);
  font-weight: 700;
  letter-spacing: -0.038em;
  line-height: 1.1;
}

body.dm-page .game-shell--wide .lede {
  margin: 0 0 0.45rem;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: 1.4;
}

.dm-shell-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.dm-shell-head__chrome {
  min-width: 0;
  flex: 1 1 auto;
}

.dm-top-stats {
  flex: 0 0 auto;
  text-align: right;
  margin-bottom: 0.55rem;
}

.dm-top-stats__date {
  margin: 0 0 0.2rem;
  font-size: var(--fs-3xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.dm-top-stats__date:empty {
  display: none;
}

.dm-top-stats__line {
  margin: 0;
  font-size: var(--fs-3xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1.4;
}

.dm-top-stats__item {
  white-space: nowrap;
}

.dm-top-stats__item .dm-num {
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  display: inline-block;
  transform-origin: 50% 60%;
}

@keyframes dm-num-bump {
  0%   { transform: scale(1);    color: var(--text); }
  35%  { transform: scale(1.32); color: var(--dm-mine-hit, #e23b46); }
  100% { transform: scale(1);    color: var(--text); }
}

.dm-num--bump {
  animation: dm-num-bump 380ms ease-out 1;
}

@media (prefers-reduced-motion: reduce) {
  .dm-num--bump { animation: none; }
}

.dm-top-stats__dot {
  margin: 0 0.2rem;
  opacity: 0.45;
}

.dm-top-stats__lives {
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
  vertical-align: -2px;
}

.dm-heart {
  font-size: 0.85rem;
  line-height: 1;
  color: var(--dm-life);
  display: inline-block;
  transform-origin: 50% 60%;
  transition: color 180ms ease, opacity 180ms ease;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.15));
}

.dm-heart.is-lost {
  color: rgba(20, 24, 30, 0.16);
  opacity: 0.7;
}

@keyframes dm-heart-burst {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.55); }
  70%  { transform: scale(0.85); }
  100% { transform: scale(1); }
}

.dm-heart--burst {
  animation: dm-heart-burst 420ms cubic-bezier(0.2, 0.8, 0.2, 1.4) 1;
}

@media (prefers-reduced-motion: reduce) {
  .dm-heart--burst { animation: none; }
}

.dm-top-stats__streak {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.dm-top-stats__streak[hidden],
.dm-top-stats__dot--streak[hidden] {
  display: none;
}

.dm-top-stats__streak-icon {
  font-size: 0.95em;
  line-height: 1;
}

/* Stage + card */
.dm-stage {
  position: relative;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  text-align: left;
  min-height: auto;
  padding: clamp(1.25rem, 4vw, 1.75rem);
  overflow: hidden;
}

body.dm-page .game-stage.dm-stage {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  height: auto;
  max-height: min(82dvh, 720px);
  padding: 0;
  align-items: stretch;
  justify-content: center;
  background: transparent;
  border: none;
  box-shadow: none;
}

@supports not (height: 82dvh) {
  body.dm-page .game-stage.dm-stage {
    max-height: min(82vh, 720px);
  }
}

.dm-card {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  overflow: hidden;
}

.dm-card__viewport {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: clamp(0.75rem, 2.4vmin, 1.25rem);
  gap: clamp(0.75rem, 2.4vmin, 1.1rem);
}

/* --- Board ------------------------------------------------------------- */
.dm-board-wrap {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  container-type: size;
  container-name: dm-board-wrap;
}

.dm-board {
  --dm-w: 9;
  --dm-h: 9;
  width: min(100cqw, 100cqh, 560px);
  height: min(100cqw, 100cqh, 560px);
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(var(--dm-w), minmax(0, 1fr));
  grid-template-rows: repeat(var(--dm-h), minmax(0, 1fr));
  background: var(--dm-board-border);
  border: 2px solid var(--dm-board-border);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(20, 24, 30, 0.12);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

@supports not (width: 100cqh) {
  .dm-board {
    width: min(100%, calc(72dvh - 6rem), 560px);
    height: auto;
  }
}

@supports not (height: 72dvh) {
  .dm-board {
    width: min(100%, calc(72vh - 6rem), 560px);
    height: auto;
  }
}

.dm-cell {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  background: var(--dm-cover);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 110ms ease, transform 80ms ease;
  box-shadow:
    inset 0 -1px 0 var(--dm-cell-border),
    inset -1px 0 0 var(--dm-cell-border),
    inset 1px 1px 0 rgba(255, 255, 255, 0.55);
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  border: none;
  padding: 0;
}

.dm-cell:hover:not(.dm-cell--revealed) {
  background: var(--dm-cover-press);
}

.dm-cell:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: -3px;
  z-index: 2;
}

.dm-cell.is-active-press:not(.dm-cell--revealed) {
  transform: scale(0.94);
  background: var(--dm-cover-press);
}

.dm-cell--revealed {
  background: var(--dm-revealed);
  cursor: default;
  box-shadow:
    inset 0 -1px 0 var(--dm-cell-border),
    inset -1px 0 0 var(--dm-cell-border);
}

/* Subtle warm tint on every other revealed cell so the open area still
   reads as a board, not a flat slab. */
.dm-cell--revealed.dm-cell--alt {
  background: var(--dm-revealed-warm);
}

.dm-cell--mine {
  background: rgba(20, 24, 30, 0.08);
}

.dm-cell--mine-hit {
  background: var(--dm-mine-hit);
  animation: dm-mine-flash 480ms cubic-bezier(0.3, 0.9, 0.3, 1.4);
}

@keyframes dm-mine-flash {
  0%   { background: var(--dm-mine-hit); }
  40%  { background: #ffb3b8; }
  100% { background: var(--dm-mine-hit); }
}

@media (prefers-reduced-motion: reduce) {
  .dm-cell--mine-hit { animation: none; }
}

.dm-cell--flag .dm-cell__mark svg {
  color: var(--dm-flag);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.18));
  animation: dm-flag-pop 200ms cubic-bezier(0.2, 0.9, 0.3, 1.4);
}

@keyframes dm-flag-pop {
  0%   { transform: scale(0.4); opacity: 0; }
  60%  { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .dm-cell--flag .dm-cell__mark svg { animation: none; }
}

.dm-cell--mine .dm-cell__mark svg {
  color: var(--text);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2));
}

.dm-cell--mine-hit .dm-cell__mark svg {
  color: #fff;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.32));
}

/* Number sizing scales with cell. */
.dm-cell__num {
  font-size: clamp(0.85rem, 4cqi, 1.6rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  animation: dm-num-pop 220ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes dm-num-pop {
  0%   { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .dm-cell__num { animation: none; }
}

.dm-cell--n1 .dm-cell__num { color: var(--dm-n1); }
.dm-cell--n2 .dm-cell__num { color: var(--dm-n2); }
.dm-cell--n3 .dm-cell__num { color: var(--dm-n3); }
.dm-cell--n4 .dm-cell__num { color: var(--dm-n4); }
.dm-cell--n5 .dm-cell__num { color: var(--dm-n5); }
.dm-cell--n6 .dm-cell__num { color: var(--dm-n6); }
.dm-cell--n7 .dm-cell__num { color: var(--dm-n7); }
.dm-cell--n8 .dm-cell__num { color: var(--dm-n8); }

/* Glyphs (mine + flag) */
.dm-cell__mark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.dm-cell__mark svg {
  width: 60%;
  height: 60%;
  display: block;
}

.dm-cell--flag .dm-cell__mark svg {
  width: 56%;
  height: 56%;
}

.dm-cell--mine .dm-cell__mark svg {
  width: 52%;
  height: 52%;
}

.dm-board.is-locked .dm-cell {
  cursor: default;
  pointer-events: none;
}

/* Toolbar (flag mode toggle / reset / hint) */
.dm-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.dm-tool {
  padding: 0.5rem 0.85rem;
  font-size: var(--fs-xs);
}

.dm-tool--flag[aria-pressed="true"] {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}

.dm-tool__cost {
  margin-left: 0.25rem;
  font-size: var(--fs-3xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.dm-tool--flag[aria-pressed="true"] .dm-tool__cost {
  color: var(--inverse-muted);
}

.dm-confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
}

/* --- Complete overlay -------------------------------------------------- */
.dm-complete {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: clamp(1rem, 3vmin, 1.5rem) max(0.9rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom))
    max(0.9rem, env(safe-area-inset-left));
  text-align: center;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.dm-complete > * {
  flex: 0 0 auto;
}

.dm-complete[hidden] {
  display: none !important;
}

.dm-complete__title {
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: -0.035em;
  color: var(--text);
}

.dm-complete__score {
  margin: 0;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  justify-content: center;
}

.dm-complete__score strong {
  font-size: clamp(2rem, 7vmin, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.dm-complete__score-max {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.dm-complete__meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.dm-complete__chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.32rem;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 6%, transparent);
  border: 1px solid color-mix(in srgb, var(--text) 9%, transparent);
}

.dm-complete__chip-label {
  font-size: var(--fs-3xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.dm-complete__chip-value {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Distribution panel (synthetic ranking) */
.dm-rank {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  width: min(100%, 480px);
  margin: 0.35rem 0 0.2rem;
  padding: 0.85rem 1rem 0.9rem;
  background: color-mix(in srgb, var(--text) 5%, transparent);
  border: 1px solid color-mix(in srgb, var(--text) 9%, transparent);
  border-radius: 16px;
  text-align: left;
  box-shadow: 0 6px 20px rgba(20, 24, 30, 0.05);
}

.dm-rank[hidden] {
  display: none !important;
}

.dm-rank__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: var(--fs-3xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.dm-rank__title {
  color: var(--text);
}

.dm-rank__date {
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: none;
  color: var(--text-muted);
}

.dm-rank__chart-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 600 / 210;
}

.dm-rank__chart {
  display: block;
  width: 100%;
  height: 100%;
}

.dm-rank__you {
  position: absolute;
  top: 2px;
  bottom: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  pointer-events: none;
  font-size: var(--fs-3xs);
  line-height: 1.1;
  color: var(--text);
  white-space: nowrap;
  left: var(--dm-rank-x, 50%);
}

.dm-rank__you[hidden] {
  display: none;
}

.dm-rank__you-label {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.dm-rank__you-pct {
  font-weight: 600;
  color: var(--text-muted);
  font-size: var(--fs-3xs);
}

.dm-rank__axis {
  display: flex;
  justify-content: space-between;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  color: color-mix(in srgb, var(--text-muted) 80%, transparent);
  font-variant-numeric: tabular-nums;
  padding: 0 1px;
}

.dm-rank__foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.15rem;
  padding-top: 0.55rem;
  border-top: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
  font-size: var(--fs-2xs);
}

.dm-rank__foot-label {
  font-weight: 600;
  color: var(--text);
}

.dm-rank__foot-score {
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-size: var(--fs-sm);
}

.dm-rank__note {
  margin: 0;
  font-size: 0.65rem;
  letter-spacing: 0.03em;
  color: color-mix(in srgb, var(--text-muted) 90%, transparent);
}

.dm-complete__cta-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.dm-complete__cta-row .btn {
  min-width: 8.5rem;
}

.dm-complete__cta-row .btn--primary {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.dm-complete__cta-row .btn--primary:hover:not(:disabled) {
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.16);
}

#dm-btn-share {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.dm-btn-share__icon {
  display: inline-flex;
  line-height: 0;
}

/* --- Share modal ------------------------------------------------------- */
.dm-share-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.dm-share-modal[hidden] {
  display: none !important;
}

.dm-share-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 24, 30, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
}

.dm-share-modal__inner {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.4rem 1.1rem 1.1rem;
  background: var(--surface, #fff);
  border-radius: 22px;
  box-shadow: 0 20px 60px rgba(20, 24, 30, 0.35), 0 6px 18px rgba(20, 24, 30, 0.18);
  overflow: hidden;
  animation: dm-share-pop 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes dm-share-pop {
  from { transform: translateY(14px) scale(0.96); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.dm-share-modal__x {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: var(--text-muted, #6c7480);
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.dm-share-modal__x:hover,
.dm-share-modal__x:focus-visible {
  background: rgba(20, 24, 30, 0.06);
  color: var(--text, #111418);
  outline: none;
}

.dm-share-modal__title {
  margin: 0.1rem 1.5rem 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text, #111418);
  text-align: center;
}

.dm-share-modal__sub {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted, #6c7480);
  text-align: center;
}

.dm-share-modal__preview {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.25rem;
  padding: 0.45rem;
  background:
    repeating-conic-gradient(
      rgba(20, 24, 30, 0.04) 0% 25%, transparent 0% 50%
    ) 0 0 / 18px 18px;
  border-radius: 16px;
  max-height: min(60vh, 520px);
  overflow: hidden;
}

.dm-share-modal__img {
  display: block;
  max-width: 100%;
  max-height: min(56vh, 500px);
  width: auto;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 10px 26px rgba(20, 24, 30, 0.18);
  background: #f5efe6;
}

.dm-share-modal__actions {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 0.25rem;
}

.dm-share-modal__actions .btn {
  flex: 1 1 8rem;
  min-width: 8rem;
}

.dm-share-modal__note {
  margin: 0;
  min-height: 1.1em;
  font-size: 0.72rem;
  color: var(--text-muted, #6c7480);
  text-align: center;
}

@media (max-width: 480px) {
  .dm-share-modal__inner {
    width: 100%;
    border-radius: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dm-share-modal__inner {
    animation: none;
  }
}

/* --- Intro card -------------------------------------------------------- */
.dm-intro {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  flex-direction: column;
  min-height: 0;
  transform-origin: 50% 48%;
  padding: clamp(0.85rem, 2.8vmin, 1.35rem) clamp(1rem, 4vw, 1.85rem)
    max(0.9rem, env(safe-area-inset-bottom, 0px));
  padding-left: max(clamp(1rem, 4vw, 1.85rem), env(safe-area-inset-left, 0px));
  padding-right: max(clamp(1rem, 4vw, 1.85rem), env(safe-area-inset-right, 0px));
  box-sizing: border-box;
  text-align: center;
  color: rgba(255, 255, 255, 0.94);
  background: var(--inverse-bg);
  border-radius: var(--radius-lg);
}

.dm-intro[hidden] {
  display: none !important;
}

.dm-intro__top {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  text-align: left;
}

.dm-intro__meta {
  min-width: 0;
}

.dm-intro__top-right {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
}

.dm-intro__date {
  margin: 0 0 0.2rem;
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.96);
}

.dm-intro__next {
  margin: 0;
  font-size: var(--fs-3xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.42);
}

.dm-intro__last {
  margin: 0;
  display: inline-flex;
  align-items: baseline;
  gap: 0.32rem;
  font-size: var(--fs-3xs);
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.55);
}

.dm-intro__last[hidden] {
  display: none;
}

.dm-intro__last-label {
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.42);
}

.dm-intro__last-value {
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.96);
}

.dm-intro__last-max {
  font-size: var(--fs-3xs);
  font-weight: 500;
  color: rgba(255, 255, 255, 0.4);
}

.dm-intro__streak {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.32rem 0.65rem 0.32rem 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: var(--fs-3xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
}

.dm-intro__streak[hidden] {
  display: none;
}

.dm-intro__streak-icon {
  font-size: 0.95rem;
  line-height: 1;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.25));
}

.dm-intro__streak-count {
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.dm-intro__streak-label {
  opacity: 0.7;
}

.dm-intro__main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0 0.75rem;
}

.dm-intro__title {
  margin: 0;
  font-size: clamp(1.85rem, 8.2vmin, 2.65rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.12;
  text-align: center;
  padding-bottom: 0.05em;
  background: linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0.78) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.dm-intro__stats {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: clamp(0.85rem, 4vmin, 1.5rem);
  margin: 0.95rem 0 0;
  padding: 0;
  list-style: none;
}

.dm-intro__stats li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0 clamp(0.45rem, 2.4vmin, 0.85rem);
  position: relative;
}

.dm-intro__stats li + li::before {
  content: "";
  position: absolute;
  left: calc(clamp(0.85rem, 4vmin, 1.5rem) / -2);
  top: 18%;
  bottom: 18%;
  width: 1px;
  background: rgba(255, 255, 255, 0.14);
}

.dm-intro__stats strong {
  font-size: clamp(1.35rem, 6vmin, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.dm-intro__stats span {
  font-size: var(--fs-3xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}

/* Mini preview grid (decorative) */
.dm-intro__preview {
  position: relative;
  width: 100%;
  max-width: min(100%, 220px);
  margin: 0.95rem 0 0;
  padding: 0;
}

.dm-intro__preview-grid {
  --dm-pn: 5;
  display: grid;
  grid-template-columns: repeat(var(--dm-pn), 1fr);
  gap: 0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.35),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.dm-intro__preview-cell {
  aspect-ratio: 1;
  position: relative;
  background: var(--dm-pcell, var(--dm-cover));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--dm-pcolor, #14181f);
}

.dm-intro__preview-cell svg {
  width: 60%;
  height: 60%;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.15));
  opacity: 0;
  transform: scale(0.6);
  animation: dm-preview-pop 480ms cubic-bezier(0.2, 0.9, 0.3, 1.4) forwards;
  animation-delay: calc(180ms + var(--dm-pi, 0) * 90ms);
}

.dm-intro__preview-cell .dm-intro__preview-num {
  opacity: 0;
  transform: scale(0.6);
  display: inline-block;
  animation: dm-preview-pop 480ms cubic-bezier(0.2, 0.9, 0.3, 1.4) forwards;
  animation-delay: calc(180ms + var(--dm-pi, 0) * 90ms);
}

@keyframes dm-preview-pop {
  to { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .dm-intro__preview-cell svg,
  .dm-intro__preview-cell .dm-intro__preview-num { animation: none; opacity: 1; transform: none; }
}

.dm-intro__steps {
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  width: 100%;
  max-width: min(100%, 320px);
}

.dm-intro__steps li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.86);
  text-align: left;
}

.dm-intro__step-num {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: var(--fs-3xs);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
  font-variant-numeric: tabular-nums;
}

.dm-intro__cta {
  flex-shrink: 0;
  margin-top: auto;
  width: 100%;
  align-self: stretch;
  padding: 0.72rem 1.35rem;
  font-size: var(--fs-base);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  background: var(--bg);
  border: none;
  border-radius: 999px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.dm-intro__cta:hover:not(:disabled) {
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.3);
  background: #fff;
}

@media (max-height: 560px) {
  .dm-intro__title { font-size: clamp(1.55rem, 7vmin, 2rem); }
  .dm-intro__stats { margin-top: 0.6rem; }
  .dm-intro__steps { margin-top: 0.65rem; gap: 0.4rem; }
  .dm-intro__preview { margin-top: 0.6rem; max-width: 160px; }
}

/* --- Mobile (≤600px) --------------------------------------------------- */
@media (max-width: 600px) {
  body.dm-page main.game-shell.game-shell--wide {
    padding: 0.55rem 0.55rem;
    padding-left: max(0.55rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.55rem, env(safe-area-inset-right, 0px));
    padding-bottom: max(0.55rem, env(safe-area-inset-bottom, 0px));
    row-gap: 0.4rem;
  }

  body.dm-page .game-shell--wide h1 {
    font-size: var(--fs-xl);
    margin-bottom: 0.1rem;
  }

  body.dm-page .game-shell--wide .lede {
    display: none;
  }

  .dm-shell-head {
    align-items: center;
    gap: 0.4rem;
    padding-right: var(--play-sounds-toggle-reserve, 3rem);
  }

  .dm-top-stats {
    margin-bottom: 0;
    text-align: left;
  }

  .dm-top-stats__date {
    margin-bottom: 0.1rem;
  }

  body.dm-page .game-stage.dm-stage {
    height: auto;
    max-height: none;
    flex: 1 1 auto;
    min-height: 0;
    justify-content: center;
  }

  .dm-card.dm-card--intro {
    flex: 1 1 auto;
    align-self: stretch;
    width: 100%;
  }

  .dm-card:not(.dm-card--intro) {
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
    flex: 1 1 auto;
  }

  .dm-card:not(.dm-card--intro) .dm-card__viewport {
    padding: 0.5rem 0;
    gap: 0.7rem;
    justify-content: center;
  }

  .dm-board {
    width: min(100cqw, 100cqh, 640px);
    height: min(100cqw, 100cqh, 640px);
  }

  @supports not (width: 100cqh) {
    .dm-board {
      width: min(calc(100dvw - 1.1rem), calc(82dvh - 8rem), 640px);
      height: auto;
    }
  }

  .dm-toolbar {
    margin-top: 0.15rem;
  }
}

/* Mood blobs · subtle accent */
body:has(.dm-stage) .blob__inner--tan {
  background: color-mix(in srgb, #f3d9a4 32%, var(--blob-tan));
}

body:has(.dm-stage) .blob__inner--grey {
  background: color-mix(in srgb, #cfd5dd 38%, var(--blob-grey));
}
