/* End Game: Caveman Circus "Paper and sun" look */
.dm-root {
  --dm-accent: #2F6B4F;
  --dm-ink: #1C1B19;
  --dm-muted: #5E5A52;
  --dm-bg: #F6F4EF;
  --dm-card: #FFFFFF;
  --dm-line: #E3DED2;
  --dm-light: #EAE7D6;
  --dm-dark: #7A9A7E;
  --dm-last-light: #F3E7A0;
  --dm-last-dark: #CDBE62;
  --dm-hint-light: #F7D2AE;
  --dm-hint-dark: #E3A774;
  --dm-sel: #F2C94C;
  --dm-check: #E57361;
  box-sizing: border-box;
  max-width: 440px;
  margin: 0 auto;
  padding: 16px;
  border-radius: 20px;
  background: var(--dm-bg);
  color: var(--dm-ink);
  font-family: inherit;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.dm-root *, .dm-root *::before, .dm-root *::after { box-sizing: border-box; }
.dm-root button { font-family: inherit; }

.dm-head { display: flex; align-items: center; gap: 10px; }
.dm-banner { padding: 10px 14px; border-radius: 12px; background: #E6ECF7; border: 1px solid #C5D2EA; color: #22324F; font-size: 13px; }
.dm-btn.dm-btn-again { width: 100%; flex: none; }
.dm-logo {
  width: 40px; height: 40px; border-radius: 11px; flex: none;
  background: var(--dm-accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; line-height: 1;
}
.dm-titles { flex: 1; min-width: 0; }
.dm-title { font-weight: 800; font-size: 20px; line-height: 1.1; }
.dm-sub { font-size: 12px; color: var(--dm-muted); }
.dm-streak {
  display: flex; align-items: center; gap: 4px; height: 32px; padding: 0 11px;
  border-radius: 999px; background: #FBE9D7; color: #8A3D0E; font-weight: 700; font-size: 14px;
}
.dm-flame, .dm-bulb { display: inline-block; width: 16px; height: 16px; background: currentColor; flex: none; }
.dm-flame {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22c4 0 7-3 7-7 0-4-3-6-4-9-1 2-2 3-4 4 0-2-1-4-2-5-1 4-4 6-4 10 0 4 3 7 7 7z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22c4 0 7-3 7-7 0-4-3-6-4-9-1 2-2 3-4 4 0-2-1-4-2-5-1 4-4 6-4 10 0 4 3 7 7 7z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.dm-bulb {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18h6M10 22h4M12 2a7 7 0 0 0-4 12.7V16h8v-1.3A7 7 0 0 0 12 2z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18h6M10 22h4M12 2a7 7 0 0 0-4 12.7V16h8v-1.3A7 7 0 0 0 12 2z'/%3E%3C/svg%3E") center / contain no-repeat;
  width: 18px; height: 18px;
}

.dm-prompt {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-radius: 16px; background: var(--dm-card); border: 1px solid var(--dm-line);
}
.dm-tomove { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--dm-muted); font-weight: 500; }
.dm-dot { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--dm-ink); }
.dm-dot-w { background: #fff; }
.dm-dot-b { background: var(--dm-ink); }
.dm-goal { font-weight: 800; font-size: 26px; line-height: 1.1; }
.dm-chip {
  height: 28px; padding: 0 12px; border-radius: 999px; background: #E3EEE7; color: #1F4A36;
  font-size: 13px; font-weight: 600; display: flex; align-items: center; white-space: nowrap;
}

.dm-board-wrap { position: relative; width: 100%; aspect-ratio: 1; touch-action: none; user-select: none; -webkit-user-select: none; }
.dm-board {
  position: absolute; inset: 0;
  display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr));
  border-radius: 8px; overflow: hidden; box-shadow: 0 2px 0 #D5CFC1;
  container-type: inline-size;
}
.dm-board.dm-shake { animation: dm-shake .32s; }
@keyframes dm-shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.dm-sq {
  position: relative; border: 0; margin: 0; padding: 0; border-radius: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: inherit; min-width: 0; min-height: 0;
}
.dm-sq:focus-visible { outline: 3px solid var(--dm-accent); outline-offset: -3px; z-index: 1; }
.dm-light { background: var(--dm-light); }
.dm-dark { background: var(--dm-dark); }
.dm-light.dm-last { background: var(--dm-last-light); }
.dm-dark.dm-last { background: var(--dm-last-dark); }
.dm-light.dm-hinted { background: var(--dm-hint-light); }
.dm-dark.dm-hinted { background: var(--dm-hint-dark); }
.dm-sq.dm-sel { background: var(--dm-sel); }
.dm-sq.dm-check { background: radial-gradient(circle, var(--dm-check) 30%, rgba(229,115,97,.55) 60%, transparent 85%), var(--dm-light); }
.dm-dark.dm-check { background: radial-gradient(circle, var(--dm-check) 30%, rgba(229,115,97,.55) 60%, transparent 85%), var(--dm-dark); }
.dm-sq.dm-wrong { background: var(--dm-check); }

.dm-piece {
  display: block; width: 100%; height: 100%; pointer-events: none;
  position: relative; z-index: 1;
}
.dm-piece svg { display: block; width: 100%; height: 100%; overflow: visible; stroke-width: 1.5; stroke-linejoin: round; }
.dm-w svg { fill: #FBFAF6; stroke: #1C1B19; color: #1C1B19; }
.dm-b svg { fill: #23221F; stroke: #1C1B19; color: #EDEAE2; }
.dm-logo svg { fill: #FFFFFF; stroke: var(--dm-accent); color: var(--dm-accent); }
.dm-logo .dm-piece { width: 34px; height: 34px; }
.dm-piece .dm-detail { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.dm-piece .dm-thin { stroke-width: 1.3; }
.dm-piece .dm-eye { fill: currentColor; stroke: none; }
.dm-pop { animation: dm-pop .18s ease-out; }
@keyframes dm-pop { from { transform: scale(.82); opacity: .4; } to { transform: none; opacity: 1; } }
.dm-ghost { position: fixed; z-index: 99999; transform: translate(-50%, -55%); pointer-events: none; }

.dm-target { width: 28%; height: 28%; border-radius: 50%; background: rgba(28,27,25,.28); pointer-events: none; }
.dm-ring { position: absolute; inset: 4%; border-radius: 50%; border: 4px solid rgba(28,27,25,.28); pointer-events: none; }
.dm-coord { position: absolute; font-size: 10px; font-weight: 700; pointer-events: none; opacity: .9; }
.dm-light .dm-coord { color: var(--dm-dark); }
.dm-dark .dm-coord { color: var(--dm-light); }
.dm-rank { top: 2px; left: 3px; }
.dm-file { bottom: 1px; right: 3px; }

.dm-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.dm-arrow-line { stroke: #E8833A; stroke-width: .22; stroke-linecap: round; opacity: .88; }
.dm-arrow-head { fill: #E8833A; opacity: .88; }
.dm-mark { opacity: .8; }
.dm-mark-preview { opacity: .5; }
.dm-hint-arrow { opacity: .88; }

.dm-status { display: flex; align-items: center; justify-content: space-between; }
.dm-prog-label { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.dm-prog-bar { display: flex; gap: 4px; }
.dm-seg { width: 44px; height: 6px; border-radius: 3px; background: #DCD7CB; }
.dm-seg-on { background: var(--dm-accent); }
.dm-score { display: flex; align-items: baseline; gap: 5px; }
.dm-score-num { font-weight: 800; font-size: 32px; line-height: 1; font-variant-numeric: tabular-nums; }
.dm-score-unit { font-size: 13px; font-weight: 600; color: var(--dm-muted); }
.dm-delta { font-size: 14px; font-weight: 700; color: #A8432E; opacity: 0; }
.dm-delta-show { animation: dm-delta 1.6s ease-out; }
@keyframes dm-delta { 0% { opacity: 0; transform: translateY(6px); } 15% { opacity: 1; transform: none; } 70% { opacity: 1; } 100% { opacity: 0; } }

.dm-msg { min-height: 48px; padding: 10px 14px; border-radius: 14px; background: var(--dm-card); border: 1px solid var(--dm-line); }
.dm-msg-main { font-weight: 600; font-size: 15px; }
.dm-msg-sub { font-size: 13px; color: var(--dm-muted); }
.dm-msg-hint { background: #FDF0E4; border-color: #F3D3B5; }
.dm-msg-bad { background: #FBE8E4; border-color: #F1C4BA; }
.dm-msg-good { background: #E3EEE7; border-color: #C3DBCB; }

.dm-controls { display: flex; }
.dm-btn {
  flex: 1; height: 52px; border-radius: 14px; border: 1px solid #D5CFC1; background: var(--dm-card); color: var(--dm-ink);
  font-size: 16px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
}
.dm-btn:disabled { cursor: default; background: transparent; border-style: dashed; color: #6E6A61; }
.dm-btn:focus-visible, .dm-link:focus-visible { outline: 3px solid var(--dm-accent); outline-offset: 2px; }
.dm-cost { font-weight: 500; color: var(--dm-muted); }
.dm-btn-primary { background: var(--dm-accent); border-color: var(--dm-accent); color: #fff; width: 100%; flex: none; }
.dm-rules { margin: 0; text-align: center; font-size: 12px; color: var(--dm-muted); }

.dm-result { display: flex; flex-direction: column; gap: 12px; }
.dm-res-head { font-weight: 800; font-size: 34px; line-height: 1.05; color: var(--dm-accent); }
.dm-res-sub { font-size: 15px; margin-top: -8px; }
.dm-res-line { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; font-weight: 600; }
.dm-res-theme { font-size: 13px; color: var(--dm-muted); margin-top: -6px; }
.dm-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.dm-stat { text-align: center; padding: 10px 0; border-radius: 14px; background: var(--dm-card); border: 1px solid var(--dm-line); }
.dm-stat-num { font-weight: 800; font-size: 24px; line-height: 1.2; }
.dm-stat-label { font-size: 12px; color: var(--dm-muted); }
.dm-accent { color: var(--dm-accent); }
.dm-share-text { white-space: pre-line; padding: 10px 14px; border-radius: 12px; background: #EDEAE2; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; color: #3F3C36; word-break: break-all; }
.dm-res-row { display: flex; justify-content: space-between; gap: 12px; }
.dm-link { background: none; border: 0; padding: 6px 0; color: var(--dm-accent); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.dm-countdown { text-align: center; font-size: 14px; color: var(--dm-muted); font-variant-numeric: tabular-nums; }
.dm-today { text-align: center; }
.dm-root [hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .dm-shake, .dm-pop, .dm-delta-show { animation: none; }
  .dm-delta-show { opacity: 1; }
}

/* ---------- Caveman Circus look: cream paper, black outlines, walnut board, caveman header ---------- */
.dm-root{font-family:Rubik,system-ui,sans-serif}
.dm-root{--dm-accent:#8B5A2B;--dm-ink:#1A1814;--dm-muted:#5C554B;--dm-bg:#F3EBD8;--dm-card:#FFFFFF;--dm-line:#1A1814;--dm-light:#F3E3C3;--dm-dark:#B98552;--dm-last-light:#F5E04A;--dm-last-dark:#D9BF3A;--dm-sel:#F5E04A;border-radius:0;border:1px solid #1A1814;box-shadow:4px 4px 0 #1A1814;padding:0 16px 16px}
.dm-art{display:block;margin:0 -16px;border-bottom:1px solid #1A1814}
.dm-logo{border-radius:0;border:1px solid #1A1814;background:#8B5A2B}
.dm-streak{border-radius:0;border:1px solid #1A1814;background:#FFFFFF;color:#1A1814}
.dm-prompt,.dm-msg{border-radius:0}
.dm-chip{border-radius:0;border:1px solid #1A1814;background:#F5E04A;color:#1A1814}
.dm-board{border-radius:0;border:2px solid #1A1814;box-shadow:4px 4px 0 #1A1814}
.dm-seg{border-radius:0;background:#E3D6BC}
.dm-btn{border-radius:0;border:1px solid #1A1814;box-shadow:3px 3px 0 #1A1814}
.dm-msg-good{background:#FFF6C2}
.dm-seg-on{background:var(--dm-accent)}
.dm-head{position:relative;margin:0 -16px;padding:0 16px;min-height:62px;gap:10px;border-bottom:1px solid #1A1814;background:#F3EBD8;overflow:hidden}
.dm-head-artwrap{position:absolute;top:0;right:0;bottom:0;display:block;pointer-events:none}
.dm-head-art{display:block;height:100%;width:auto}
.dm-head .dm-logo,.dm-art{display:none}
.dm-titles{flex:none;white-space:nowrap;position:relative;z-index:1}
.dm-streak{position:relative;z-index:1}
.dm-head + *{margin-top:2px}
.dm-res-head{color:#1A1814}
.dm-stat{border-radius:0;border-color:#1A1814}
.dm-share-text{border-radius:0;border:1px solid #1A1814;background:#FFFFFF}
.dm-banner{border-radius:0;border-color:#1A1814}
.dm-link{color:#1A1814}
.dm-btn-primary{background:#F5E04A;border-color:#1A1814;color:#1A1814}

/* Points */
.dm-circus { border: 1px solid #1A1814; background: #FFFFFF; padding: 10px 12px; }
.dm-circus-label { font-weight: 800; font-size: 14px; margin-bottom: 6px; }
.dm-circus-label::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #E2531B; border: 1px solid #1A1814; margin-right: 6px; vertical-align: 0; }
.dm-circus-row { display: flex; gap: 8px; }
.dm-root .dm-circus-input { flex: 1; min-width: 0; height: 40px; padding: 0 10px; margin: 0; font: inherit; font-weight: 800; font-size: 17px; letter-spacing: .12em; text-transform: uppercase; background: #F3EBD8; color: #1A1814; border: 1px solid #1A1814; border-radius: 0; box-shadow: none; }
.dm-root .dm-circus-btn { flex: none; width: auto; height: 40px; padding: 0 14px; background: #F5E04A; color: #1A1814; border: 1px solid #1A1814; box-shadow: 3px 3px 0 #1A1814; font-weight: 800; }
.dm-circus-msg { font-size: 13px; font-weight: 700; margin-top: 6px; }
.dm-circus-msg:empty { display: none; }
.dm-circus-done { font-weight: 800; font-size: 14px; color: #1A1814; }
.dm-circus-done::before { content: "\2713 "; color: #E2531B; }

/* ---------- Wide screens: big board on the left, everything you act on beside it ---------- */
.dm-wrap { container-type: inline-size; }
@container (min-width: 760px) {
  .dm-root {
    max-width: 980px;
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr);
    grid-template-areas: "head head" "board prompt" "board status" "board msg" "board controls" "board rules" "board result";
    grid-template-rows: auto auto auto auto auto auto 1fr;
    column-gap: 26px;
    row-gap: 12px;
    align-items: start;
    padding: 0 24px 24px;
  }
  .dm-loading { grid-column: 1 / -1; }
  .dm-head { grid-area: head; margin: 0 -24px; padding: 0 24px; min-height: 78px; }
  .dm-title { font-size: 26px; }
  .dm-sub { font-size: 14px; }
  .dm-board-wrap { grid-area: board; margin-top: 12px; }
  .dm-prompt { grid-area: prompt; margin-top: 12px; }
  .dm-goal { font-size: 26px; white-space: nowrap; }
  .dm-prompt { gap: 10px; }
  .dm-status { grid-area: status; background: #FFFFFF; border: 1px solid #1A1814; padding: 12px 14px; }
  .dm-score-num { font-size: 40px; }
  .dm-msg { grid-area: msg; min-height: 72px; font-size: 16px; }
  .dm-controls { grid-area: controls; }
  .dm-btn-hint { height: 52px; font-size: 16px; }
  .dm-rules { grid-area: rules; text-align: left; font-size: 13px; }
  .dm-result { grid-area: result; gap: 10px; }
  /* The Share button copies the same text, so the preview box is left out to keep the result beside the board. */
  .dm-share-text { display: none; }
}
