/* Doodle Duel — "the school notebook": cream graph paper with a red margin line, ink #23272f, chunky
   2px ink borders with offset shadows, sticky-note word cards, Patrick Hand for the hand-written bits,
   Fraunces for the title and Nunito for everything else. Matches the approved mockup (pick, draw,
   guess, got it). Layout basics come from cb-arcade.css. */
.dd-page, .dd-dlg {
  --ink: #23272f; --ink-2: #4a4e57; --muted: #5b5f69; --line: #c9ccd3;
  --paper: #fbf6ea; --red: #e5484d; --blue: #3b6fe0; --blue-d: #1d3f9a; --green-d: #1f8a52;
  --hand: 'Patrick Hand', 'Comic Sans MS', cursive;
}
body.cbx.dd-page {
  color: var(--ink);
  background:
    linear-gradient(90deg, transparent 38px, rgba(229, 72, 77, .35) 38px, rgba(229, 72, 77, .35) 40px, transparent 40px),
    repeating-linear-gradient(0deg, rgba(59, 111, 224, .10) 0 1px, transparent 1px 26px),
    var(--paper);
}
.dd-page [hidden], .dd-dlg [hidden] { display: none !important; }
.dd-wrap { max-width: 480px; padding-top: 10px; }
.dd-hand { font-family: var(--hand); font-weight: 400; }
.dd-hand.big { margin: 4px 0 0; font-size: 30px; line-height: 1.1; text-align: center; }
.dd-sub { margin: 6px 0 0; font-size: 15px; font-weight: 700; line-height: 1.45; color: var(--muted); text-align: center; }
.dd-screen { display: flex; flex-direction: column; gap: 14px; }

/* ---------- top row: games, the title, how to play ---------- */
.cbx-hero.dd-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin: 0 0 12px; }
.dd-back { justify-self: start; display: flex; align-items: center; min-height: 44px; font-weight: 800; font-size: 14px; color: var(--muted) !important; text-decoration: none; }
.dd-title { margin: 0; font: 900 27px/1 var(--cbx-display); letter-spacing: -.01em; color: var(--ink); white-space: nowrap; }
.dd-help { justify-self: end; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--ink); background: #fff;
  font: 900 17px var(--cbx-body); color: var(--ink) !important; text-decoration: none; box-shadow: 2px 3px 0 var(--ink); }
.dd-help:active { transform: translate(1px, 2px); box-shadow: 1px 1px 0 var(--ink); }

.dd-banner { margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; background: #fff7b8; border: 2px solid var(--ink); font-weight: 800; font-size: 15px; line-height: 1.4; }
.dd-chiprow { display: flex; justify-content: center; }
.dd-streak { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; background: #fff; border: 2px solid var(--ink);
  box-shadow: 3px 4px 0 var(--ink); font-weight: 900; font-size: 14px; }

/* ---------- buttons ---------- */
.dd-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 18px; border-radius: 14px; cursor: pointer;
  background: #fff; color: var(--ink); border: 2px solid var(--ink); box-shadow: 3px 4px 0 var(--ink); font: 900 17px var(--cbx-body); text-decoration: none; }
.dd-btn:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.dd-btn.red { background: var(--red); color: #fff; min-height: 56px; font-size: 18px; }
.dd-btn.alt { box-shadow: none; font-weight: 800; font-size: 16px; min-height: 46px; }
.dd-btn.alt:active { transform: translateY(1px); }
.dd-btn.block { display: flex; width: 100%; }
.dd-btn:disabled { opacity: .45; cursor: default; transform: none; }
.dd-btn.pulse { animation: dd-pulse 1.1s ease-in-out infinite; }
@keyframes dd-pulse { 50% { transform: scale(1.03); box-shadow: 4px 6px 0 var(--ink); } }
.dd-link { align-self: center; min-height: 44px; padding: 0 18px; border: 0; background: transparent; cursor: pointer; font: 800 15px var(--cbx-body); color: var(--blue);
  text-decoration: underline; text-underline-offset: 3px; }
.dd-link.muted { color: var(--muted); }
.dd-link:disabled { color: var(--muted); text-decoration: none; cursor: default; }

/* ---------- start ---------- */
.dd-notes { display: flex; justify-content: center; gap: 12px; margin: 6px 0 2px; }
.dd-notes span { display: grid; place-items: center; width: 92px; height: 84px; border: 2px solid var(--ink); border-radius: 6px; box-shadow: 3px 4px 0 var(--ink);
  font: 900 11px var(--cbx-body); letter-spacing: .12em; text-transform: uppercase; }
.dd-notes b { display: block; font: 400 26px/1 var(--hand); letter-spacing: 0; text-transform: none; }
.dd-notes .n1 { background: #fff7b8; color: #8a6d00; transform: rotate(-4deg); }
.dd-notes .n2 { background: #ffd9c2; color: #a8501a; transform: rotate(2deg) translateY(6px); }
.dd-notes .n3 { background: #cfe0ff; color: var(--blue-d); transform: rotate(-1.5deg); }
.dd-notes b { color: var(--ink); }
.dd-mine h3 { margin: 6px 0 6px; font: 900 15px var(--cbx-body); }
.dd-mine ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dd-mine button { width: 100%; min-height: 46px; padding: 8px 14px; text-align: left; border-radius: 12px; border: 2px solid var(--ink); background: #fff; cursor: pointer; font: 800 15px var(--cbx-body); color: var(--ink); }

/* ---------- pick a word: sticky notes ---------- */
.dd-pickhead { text-align: center; }
.dd-cards { display: flex; flex-direction: column; gap: 14px; padding: 6px 8px; }
.dd-card { display: flex; align-items: center; justify-content: space-between; min-height: 84px; padding: 0 20px; border: 2px solid var(--ink); border-radius: 6px; cursor: pointer;
  box-shadow: 3px 4px 0 var(--ink); font-family: var(--cbx-body); color: var(--ink); text-align: left; transition: transform .12s, box-shadow .12s; }
.dd-card .tier { display: block; font-size: 12px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.dd-card .word { display: block; font: 400 34px/1 var(--hand); overflow-wrap: anywhere; }
.dd-card .pt { font-weight: 900; font-size: 16px; white-space: nowrap; padding-left: 10px; }
.dd-card.easy { background: #fff7b8; transform: rotate(-1.2deg); } .dd-card.easy .tier { color: #8a6d00; }
.dd-card.medium { background: #ffd9c2; transform: rotate(.8deg); } .dd-card.medium .tier { color: #a8501a; }
.dd-card.hard { background: #cfe0ff; transform: rotate(-.6deg); } .dd-card.hard .tier { color: var(--blue-d); }
.dd-card:hover, .dd-card:focus-visible { outline: none; box-shadow: 5px 6px 0 var(--ink); border-width: 3px; padding: 0 19px; }
.dd-card:active { box-shadow: 1px 1px 0 var(--ink); translate: 2px 3px; }
.dd-note { margin-top: 4px; padding: 12px 14px; border-radius: 12px; background: rgba(255, 255, 255, .75); border: 1.5px dashed #9aa0a6; font-size: 14px; font-weight: 700; line-height: 1.45; color: var(--ink-2); }
.dd-note p { margin: 0 0 8px; }
.dd-switch { display: inline-flex; align-items: center; gap: 10px; min-height: 36px; cursor: pointer; font-weight: 900; color: var(--ink); }
.dd-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.dd-switch .tr { position: relative; width: 44px; height: 26px; border-radius: 13px; background: #fff; border: 2px solid var(--ink); flex: none; transition: background .15s; }
.dd-switch .tr::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink); transition: transform .15s; }
.dd-switch input:checked + .tr { background: #2fae6a; }
.dd-switch input:checked + .tr::after { transform: translateX(18px); background: #fff; }
.dd-switch input:focus-visible + .tr { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---------- the paper ---------- */
.dd-paper { --pw: min(100%, max(240px, calc(100svh - 400px))); position: relative; width: var(--pw); aspect-ratio: 1; margin: 0 auto; container-type: inline-size;
  background: #fff; border: 2px solid var(--ink); border-radius: 8px; box-shadow: 3px 4px 0 var(--ink); }
.dd-paper canvas { display: block; width: 100%; height: 100%; border-radius: 6px; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#drawCanvas { cursor: crosshair; }
.dd-paper.erasing #drawCanvas { cursor: cell; }
.dd-paper.guess { --pw: min(100%, max(220px, calc(100svh - 440px))); }
.dd-paper.small { --pw: min(72%, 280px); }
.dd-paper.tilt { transform: rotate(-2deg); box-shadow: 4px 5px 0 var(--ink); }
.dd-paper.result { --pw: min(78%, 300px); margin-top: 6px; }
.dd-paper-msg { position: absolute; left: 50%; bottom: 14px; translate: -50% 0; margin: 0; padding: 8px 14px; border-radius: 999px; background: var(--ink); color: #fff;
  font-weight: 900; font-size: 14px; white-space: nowrap; pointer-events: none; }

/* ---------- drawing ---------- */
.dd-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 14px; border-radius: 12px; background: var(--ink); color: #fbf6ea; }
.dd-bar-word { font-weight: 800; font-size: 14px; color: #c9ccd3; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-bar-word b { font: 400 26px var(--hand); color: #fff; margin-left: 4px; }
.dd-timer { display: inline-flex; align-items: center; gap: 6px; font-weight: 900; font-size: 18px; font-variant-numeric: tabular-nums; }
.dd-timer.low { color: #ff8a8e; animation: dd-tick 1s steps(2) infinite; }
@keyframes dd-tick { 50% { opacity: .55; } }
.dd-ink { display: flex; align-items: center; gap: 10px; margin: -4px 4px 0; font-size: 13px; font-weight: 900; color: var(--muted); }
.dd-ink .bar { flex: 1; height: 10px; border-radius: 5px; border: 2px solid var(--ink); background: #fff; overflow: hidden; }
.dd-ink .bar i { display: block; height: 100%; background: var(--blue); transition: width .2s; }
.dd-ink.low { color: var(--red); }
.dd-ink.low .bar i { background: var(--red); }
.dd-colors { display: flex; align-items: center; justify-content: space-between; gap: 2px; }
.dd-color { position: relative; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; cursor: pointer; }
.dd-color::before { content: ''; position: absolute; inset: 4px; border-radius: 50%; background: var(--c); border: 3px solid #fff; box-shadow: 0 0 0 2px var(--line); }
.dd-color[aria-checked="true"]::before { box-shadow: 0 0 0 4px var(--ink); }
.dd-tools { display: flex; gap: 8px; }
.dd-sizes { flex: 1; display: flex; align-items: center; justify-content: space-around; min-height: 46px; border-radius: 12px; background: #fff; border: 2px solid var(--ink); }
.dd-size { display: grid; place-items: center; width: 44px; height: 42px; padding: 0; border: 0; background: transparent; cursor: pointer; }
.dd-size i { display: block; border-radius: 50%; background: var(--ink); }
.dd-size.s0 i { width: 8px; height: 8px; } .dd-size.s1 i { width: 16px; height: 16px; } .dd-size.s2 i { width: 24px; height: 24px; }
.dd-size[aria-checked="true"] i { box-shadow: 0 0 0 4px #ffe68a; }
.dd-tool { display: grid; place-items: center; width: 52px; min-height: 46px; padding: 0; border-radius: 12px; background: #fff; border: 2px solid var(--ink); color: var(--ink); cursor: pointer; }
.dd-tool.txt { width: auto; padding: 0 12px; background: transparent; font: 800 14px var(--cbx-body); }
.dd-tool[aria-pressed="true"] { background: #ffe68a; box-shadow: inset 0 0 0 2px var(--ink); }
.dd-tool:active { transform: translateY(1px); }
.dd-hint { margin: 0; text-align: center; font-size: 13px; font-weight: 700; line-height: 1.4; color: var(--muted); }
.dd-hint.nudge { color: var(--red); animation: dd-nudge .3s; }
@keyframes dd-nudge { 30% { transform: translateX(-4px); } 60% { transform: translateX(4px); } }

/* ---------- guessing ---------- */
.dd-guesshead { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dd-guesshead .dd-hand { font-size: 24px; line-height: 1.1; min-width: 0; }
.dd-chip.ink { flex: none; padding: 6px 12px; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 900; font-size: 14px; }
.dd-progress { position: absolute; left: 12px; right: 12px; bottom: 10px; height: 6px; border-radius: 3px; background: #eceef2; overflow: hidden; pointer-events: none; }
.dd-progress i { display: block; width: 0; height: 100%; border-radius: 3px; background: var(--blue); }
.dd-pencil { position: absolute; left: 0; top: 0; margin: -46px 0 0 -26px; pointer-events: none; will-change: transform; }
.dd-ready { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px; text-align: center;
  border-radius: 6px; background: rgba(251, 246, 234, .94); }
.dd-ready p { margin: 0; font: 400 28px/1.15 var(--hand); }
.dd-ready small { font-size: 13px; font-weight: 700; color: var(--muted); }
.dd-blanks { --n: 7; display: flex; justify-content: center; gap: 6px; }
.dd-blank { width: min(38px, calc((100% - (var(--n) - 1) * 6px) / var(--n))); height: 46px; padding: 0; border: 0; border-bottom: 4px solid var(--ink); background: transparent;
  display: grid; place-items: center; font: 900 26px var(--cbx-body); color: var(--ink); cursor: pointer; }
.dd-blank.hint { color: var(--blue); cursor: default; }
.dd-blanks.shake { animation: dd-shake .45s; }
.dd-blanks.shake .dd-blank { color: var(--red); border-color: var(--red); }
@keyframes dd-shake { 15%, 55% { transform: translateX(-9px); } 35%, 75% { transform: translateX(9px); } 90% { transform: translateX(-3px); } }
.dd-tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.dd-tile { min-width: 0; height: 46px; padding: 0; border: 2px solid var(--ink); border-radius: 8px; background: #fff; box-shadow: 2px 3px 0 var(--ink); cursor: pointer;
  font: 900 20px var(--cbx-body); color: var(--ink); }
.dd-tile:active { transform: translate(1px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.dd-tile.used { opacity: .18; box-shadow: none; cursor: default; }
.dd-guessbtns { display: flex; gap: 10px; }
.dd-guessbtns .dd-btn { flex: 1; min-height: 48px; font-size: 15px; }

/* ---------- the hand-over (pass and play) ---------- */
.dd-handcard { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 18px; padding: 28px 20px 22px; border-radius: 22px; background: #fff;
  border: 2px solid var(--ink); box-shadow: 4px 5px 0 var(--ink); text-align: center; }

/* ---------- the result ---------- */
.dd-result { gap: 18px; }
.dd-sheet { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 22px 20px 16px; border-radius: 24px; background: #fff; border: 2px solid var(--ink); text-align: center; }
.dd-kick { margin: 0; font-size: 13px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; color: var(--green-d); }
.dd-kick.miss { color: #a8501a; }
.dd-word { margin: 0; font: 400 48px/1 var(--hand); color: var(--ink); overflow-wrap: anywhere; }
.dd-line { margin: 0; font-size: 15px; font-weight: 700; line-height: 1.45; color: var(--ink-2); }
.dd-scores { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; width: 100%; }
.dd-score { padding: 10px 6px; border-radius: 12px; border: 2px solid transparent; text-align: center; min-width: 0; }
.dd-score .lb { font-size: 12px; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-score .n { font: 900 28px var(--cbx-display); }
.dd-score .n small { font: 800 12px var(--cbx-body); }
.dd-score.me { background: #eef3ff; } .dd-score.me .lb { color: var(--blue-d); }
.dd-score.them { background: #f4f1ea; } .dd-score.them .lb { color: var(--muted); }
.dd-score.both { background: #fff3e3; } .dd-score.both .lb { color: #a8501a; }
.dd-score.hot { border-color: var(--blue); }
.dd-sheet .dd-btn { width: 100%; }
.dd-more { display: flex; align-items: center; justify-content: center; min-height: 38px; font-weight: 800; color: var(--muted) !important; text-decoration: none; }
.dd-wait .dd-scores { margin-top: 2px; }

/* ---------- mode row, how to play, dialog ---------- */
.dd-modes { margin: 18px 0 0; text-align: center; font-size: 14px; font-weight: 700; line-height: 2; color: var(--muted); }
.dd-modes button { min-height: 32px; padding: 0 4px; border: 0; background: none; cursor: pointer; font: 800 14px var(--cbx-body); color: var(--blue); text-decoration: underline; text-underline-offset: 3px; }
.cbx-card.dd-read { margin-top: 22px; border: 2px solid var(--ink); box-shadow: 3px 4px 0 var(--ink); border-radius: 16px; }
.dd-dlg { width: min(400px, calc(100vw - 32px)); padding: 0; border: 2px solid var(--ink); border-radius: 18px; background: #fffdf6; color: var(--ink); box-shadow: 4px 6px 0 var(--ink); }
.dd-dlg::backdrop { background: rgba(35, 39, 47, .5); }
.dd-dlg-card { display: flex; flex-direction: column; gap: 12px; padding: 22px 20px 18px; font-family: var(--cbx-body); }
.dd-dlg h2 { margin: 0; font: 900 22px/1.15 var(--cbx-display); }
.dd-dlg p { margin: 0; font-weight: 700; color: var(--ink-2); line-height: 1.45; }
.dd-field { display: flex; flex-direction: column; gap: 5px; font-weight: 900; font-size: 14px; }
.dd-field input { min-height: 46px; padding: 0 12px; border-radius: 10px; border: 2px solid var(--ink); background: #fff; font: 800 17px var(--cbx-body); color: var(--ink); }
.dd-dlg-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.dd-dlg-actions .dd-btn { min-height: 48px; }

@media (prefers-reduced-motion: reduce) {
  .dd-btn.pulse, .dd-timer.low, .dd-blanks.shake, .dd-hint.nudge { animation: none; }
  .dd-card { transition: none; }
}
