
  :root {
    /* MyDailyPuzzles unified brand palette */
    --cream:    #FFF7E8;
    --paper:    #FFFCF2;
    --off:      #F4EEDB;
    --ink:      #15132B;
    --ink-soft: #2A2748;
    --brand:    #6C63FF;
    --pink:     #FF4F8B;
    --hot:      #FF2E63;
    --teal:     #1FC8A9;
    --mint:     #4ECDC4;
    --mustard:  #FFC233;
    --sun:      #FFC233;
    --plum:     #6A2C91;
    --grape:    #6C63FF;
    --coral:    #FF8966;
    --good:     #2ECC71;
    --ok:       #F1C40F;
    --meh:      #E67E22;
    --bad:      #E74C3C;
    --awful:    #34495E;
  }

  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

  html, body {
    margin: 0; padding: 0;
    min-height: 100vh;
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--ink);
    background: var(--cream);
    background-image:
      radial-gradient(circle at 12% 8%,  rgba(255, 79, 139, 0.10) 0, transparent 38%),
      radial-gradient(circle at 88% 20%, rgba(108, 99, 255, 0.12) 0, transparent 42%),
      radial-gradient(circle at 50% 95%, rgba(31, 200, 169, 0.10) 0, transparent 45%);
    background-attachment: fixed;
    overflow-x: hidden;
    user-select: none;
    -webkit-user-select: none;
  }

  body::before {
    content: "";
    position: fixed; inset: 0;
    background-image:
      radial-gradient(rgba(31, 27, 58, 0.05) 1px, transparent 1px),
      radial-gradient(rgba(31, 27, 58, 0.025) 1px, transparent 1px);
    background-size: 24px 24px, 16px 16px;
    background-position: 0 0, 12px 12px;
    pointer-events: none;
    z-index: 0;
  }

  .app {
    position: relative;
    z-index: 1;
    max-width: 720px;
    margin: 0 auto;
    padding: 22px 22px 60px;
  }

  /* ---- Top brand nav ---- */
  .topnav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    gap: 12px;
  }
  .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--ink);
  }
  .logo-mark {
    width: 38px; height: 38px;
    background: var(--ink);
    border-radius: 10px;
    display: grid;
    place-items: center;
    color: var(--sun);
    font-family: 'Fredoka', sans-serif;
    font-weight: 900;
    font-size: 22px;
    transform: rotate(-4deg);
    box-shadow: 3px 3px 0 var(--hot);
    flex-shrink: 0;
  }
  .logo-text {
    font-family: 'Fredoka', sans-serif;
    font-weight: 800;
    font-size: 17px;
    letter-spacing: -0.01em;
    line-height: 1;
  }
  .logo-text .dot-mark { color: var(--hot); }
  .logo-text .tld { color: var(--brand); }
  .back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--paper);
    border: 2.5px solid var(--ink);
    border-radius: 999px;
    padding: 7px 14px;
    color: var(--ink);
    text-decoration: none;
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    font-size: 13px;
    box-shadow: 3px 3px 0 var(--ink);
    transition: transform 0.1s, box-shadow 0.1s;
  }
  .back-link:hover {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 var(--ink);
  }
  .back-link:active {
    transform: translate(1px, 1px);
    box-shadow: 2px 2px 0 var(--ink);
  }

  header { text-align: center; margin-bottom: 16px; }
  .title {
    font-family: 'Fredoka', sans-serif;
    font-size: clamp(44px, 9vw, 72px);
    font-weight: 900;
    letter-spacing: 0.02em;
    margin: 0;
    color: var(--ink);
    line-height: 0.9;
    text-shadow: 4px 4px 0 var(--mustard), 8px 8px 0 var(--pink);
    transform: rotate(-1.5deg);
    display: inline-block;
  }
  .title .dot { color: var(--hot); display: inline-block; transform: scale(1.3) translateY(2px); }
  .subtitle {
    margin-top: 18px;
    font-size: 13px; font-weight: 700;
    color: var(--brand);
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }
  .subtitle .pill {
    display: inline-block;
    background: var(--ink); color: var(--cream);
    padding: 4px 12px; border-radius: 999px;
    margin-left: 6px; font-size: 13px;
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    letter-spacing: 0.04em;
  }

  .stage {
    margin-top: 18px;
    background: var(--paper);
    border: 3px solid var(--ink);
    border-radius: 22px;
    box-shadow: 12px 12px 0 var(--ink);
    padding: 28px 24px 32px;
    position: relative;
    min-height: 540px;
    display: flex;
    flex-direction: column;
  }
  .stage::after {
    content: "";
    position: absolute;
    top: -12px; right: -12px;
    width: 60px; height: 60px;
    background: var(--mustard);
    transform: rotate(15deg);
    border: 3px solid var(--ink);
    border-radius: 12px;
    z-index: 0;
  }
  .stage::before {
    content: "OFFICIAL";
    position: absolute;
    top: 14px; right: -12px;
    width: 60px;
    text-align: center;
    z-index: 1;
    transform: rotate(15deg);
    transform-origin: center;
    font-family: 'Fredoka', sans-serif;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 0.04em;
    color: var(--ink);
  }

  .view {
    display: none;
    flex-direction: column;
    align-items: center;
    flex: 1;
    width: 100%;
    animation: viewIn 0.45s cubic-bezier(.34,1.56,.64,1);
  }
  .view.active { display: flex; }
  @keyframes viewIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .character {
    width: 200px; height: 200px;
    position: relative;
    margin: 4px auto 8px;
    animation: bob 3.6s ease-in-out infinite;
  }
  .character.small { width: 140px; height: 140px; }
  @keyframes bob {
    0%, 100% { transform: translateY(0) rotate(-1deg); }
    50%      { transform: translateY(-8px) rotate(1deg); }
  }
  .character svg { width: 100%; height: 100%; overflow: visible; }
  .mouth { transition: d 0.3s cubic-bezier(.34,1.56,.64,1); }

  .speech {
    background: var(--cream);
    border: 3px solid var(--ink);
    padding: 14px 20px;
    border-radius: 18px;
    font-size: 16px; font-weight: 600;
    line-height: 1.4; color: var(--ink);
    text-align: center;
    max-width: 460px;
    position: relative;
    margin: 4px auto 18px;
    box-shadow: 4px 4px 0 var(--ink);
    transform: rotate(-0.5deg);
  }
  .speech::after {
    content: "";
    position: absolute;
    top: -16px; left: 50%;
    width: 0; height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-bottom: 16px solid var(--ink);
    transform: translateX(-50%);
  }
  .speech::before {
    content: "";
    position: absolute;
    top: -11px; left: 50%;
    width: 0; height: 0;
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-bottom: 12px solid var(--cream);
    transform: translateX(-50%);
    z-index: 1;
  }
  .speech em { color: var(--hot); font-style: normal; font-weight: 800; }

  .btn {
    appearance: none;
    border: 3px solid var(--ink);
    background: var(--mustard);
    color: var(--ink);
    font-family: 'Fredoka', sans-serif;
    font-weight: 800;
    font-size: 17px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 14px 30px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 4px 5px 0 var(--ink);
    transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.2s;
    margin: 8px;
  }
  .btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 6px 0 var(--ink); }
  .btn:active { transform: translate(2px, 3px); box-shadow: 1px 2px 0 var(--ink); }
  .btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: 4px 5px 0 var(--ink) !important; }
  .btn.primary { background: var(--hot); color: white; }
  .btn.go      { background: var(--good); color: white; }
  .btn.stop    { background: var(--bad); color: white; font-size: 28px; padding: 28px 56px; }
  .btn.next    { background: var(--grape); color: white; }
  .btn.share   { background: var(--teal); color: white; }
  .btn.ghost   { background: var(--paper); }

  .round-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 14px;
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--brand);
  }
  .pip-row { display: flex; gap: 6px; }
  .pip {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--paper);
    border: 2px solid var(--ink);
  }
  .pip.done { background: var(--mint); }
  .pip.current { background: var(--mustard); animation: pipPulse 1.2s infinite; }
  @keyframes pipPulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.3)} }

  .target-display {
    background: var(--ink);
    color: var(--cream);
    padding: 14px 28px;
    border-radius: 16px;
    font-family: 'Fredoka', sans-serif;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.05em;
    margin: 6px auto 14px;
    text-align: center;
    transform: rotate(-1deg);
    box-shadow: 4px 4px 0 var(--pink);
    border: 3px solid var(--ink);
  }
  .target-display .num {
    display: block;
    font-size: 56px;
    font-weight: 900;
    line-height: 1;
    margin-top: 4px;
    color: var(--mustard);
    letter-spacing: 0.02em;
  }
  .target-display .num .unit {
    font-size: 22px;
    color: var(--cream);
    margin-left: 6px;
  }

  .round-result {
    background: var(--ink);
    color: var(--cream);
    padding: 14px 22px;
    border-radius: 16px;
    margin: 4px auto 14px;
    border: 3px solid var(--ink);
    box-shadow: 4px 4px 0 var(--teal);
    font-family: 'Fredoka', sans-serif;
    text-align: center;
    transform: rotate(1deg);
    max-width: 360px;
    width: fit-content;
    animation: rrPop 0.4s cubic-bezier(.34,1.56,.64,1);
  }
  @keyframes rrPop {
    from { opacity: 0; transform: rotate(1deg) scale(0.85); }
    to   { opacity: 1; transform: rotate(1deg) scale(1); }
  }
  .round-result .rr-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--teal);
    margin-bottom: 4px;
  }
  .round-result .rr-time {
    font-size: 30px;
    font-weight: 900;
    color: var(--mustard);
    line-height: 1;
    margin-bottom: 8px;
    font-variant-numeric: tabular-nums;
  }
  .round-result .rr-time .unit {
    font-size: 16px;
    color: var(--cream);
    margin-left: 4px;
    font-weight: 700;
  }
  .round-result .rr-error {
    font-size: 15px;
    font-weight: 700;
    color: var(--cream);
    letter-spacing: 0.04em;
  }
  .round-result .rr-error .rr-emoji {
    font-size: 18px;
    vertical-align: middle;
    margin-right: 4px;
  }
  .round-result .rr-error .rr-num {
    font-variant-numeric: tabular-nums;
    color: var(--mustard);
    font-weight: 900;
  }

  .stage-prompt {
    font-family: 'Fredoka', sans-serif;
    font-size: 22px;
    font-weight: 800;
    text-align: center;
    margin: 8px 0;
    min-height: 30px;
  }

  .button-stage {
    margin: 12px 0 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
  }

  .counting .character { animation-play-state: paused; opacity: 0.78; }
  .counting .target-display { background: #444; color: #444; box-shadow: 3px 4px 0 #999; }
  .counting .target-display .num { color: #444; }
  .counting .target-display .num .unit { color: #444; }
  .counting .target-display::after {
    content: "(no peeking)";
    display: block;
    font-size: 11px;
    color: var(--cream);
    margin-top: 4px;
    letter-spacing: 0.1em;
  }
  .counting .stage-prompt { color: var(--bad); }

  .results-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    width: 100%;
    max-width: 420px;
    margin: 8px auto 12px;
  }
  .result-row {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 10px 14px;
    background: var(--cream);
    border: 2.5px solid var(--ink);
    border-radius: 14px;
    font-weight: 700;
    box-shadow: 3px 3px 0 var(--ink);
    opacity: 0;
    transform: translateX(-20px);
  }
  .result-row.show {
    animation: rowIn 0.5s cubic-bezier(.34,1.56,.64,1) forwards;
  }
  @keyframes rowIn { to { opacity: 1; transform: translateX(0); } }
  .result-row .badge {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 2.5px solid var(--ink);
    display: flex; align-items: center; justify-content: center;
    font-weight: 900;
    font-size: 14px;
    color: white;
  }
  .result-row .label { font-size: 13px; color: var(--brand); font-family: 'Fredoka', sans-serif; letter-spacing: 0.04em; }
  .result-row .num { font-size: 16px; font-variant-numeric: tabular-nums; }
  .result-row .your-time { color: var(--ink); font-weight: 900; }
  .result-row .err {
    font-size: 18px;
    color: var(--ink);
    font-weight: 900;
    text-align: right;
    font-variant-numeric: tabular-nums;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.1;
  }
  .result-row .err .emoji { font-size: 22px; line-height: 1; margin-bottom: 2px; }
  .badge.good  { background: var(--good); }
  .badge.ok    { background: var(--ok); color: var(--ink); }
  .badge.meh   { background: var(--meh); }
  .badge.bad   { background: var(--bad); }
  .badge.awful { background: var(--awful); }

  .total-card {
    margin: 14px auto 8px;
    background: var(--ink);
    color: var(--cream);
    padding: 18px 28px;
    border-radius: 22px;
    text-align: center;
    box-shadow: 6px 6px 0 var(--pink);
    transform: rotate(-1deg);
    border: 3px solid var(--ink);
    font-family: 'Fredoka', sans-serif;
  }
  .total-card .total-num {
    font-size: 56px;
    font-weight: 900;
    color: var(--mustard);
    line-height: 1;
    letter-spacing: 0.02em;
  }
  .total-card .total-num .unit { font-size: 22px; color: var(--cream); margin-left: 4px; }
  .total-card .total-label {
    font-size: 12px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-top: 8px;
    color: var(--mint);
    font-weight: 700;
  }
  .total-card .grade {
    font-size: 28px;
    font-weight: 800;
    color: var(--cream);
    margin-top: 10px;
    letter-spacing: 0.06em;
  }
  .total-card .grade .stamp {
    display: inline-block;
    margin-left: 8px;
    transform: rotate(-8deg);
    font-size: 32px;
  }

  .share-grid {
    font-size: 30px;
    text-align: center;
    margin: 10px 0;
    letter-spacing: 6px;
    line-height: 1;
  }

  .results-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 8px;
  }

  .toast {
    position: fixed;
    bottom: 24px; left: 50%;
    transform: translateX(-50%) translateY(calc(100% + 40px));
    background: var(--ink);
    color: var(--cream);
    padding: 14px 28px;
    border-radius: 999px;
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    box-shadow: 4px 5px 0 var(--pink);
    visibility: hidden;
    transition: transform 0.4s cubic-bezier(.34,1.56,.64,1), visibility 0s linear 0.4s;
    z-index: 99;
    pointer-events: none;
  }
  .toast.show { transform: translateX(-50%) translateY(0); visibility: visible; transition: transform 0.4s cubic-bezier(.34,1.56,.64,1); }

  .countdown {
    background: var(--paper);
    border: 3px dashed var(--ink);
    border-radius: 18px;
    padding: 16px 24px;
    text-align: center;
    margin: 14px 0;
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
  }
  .countdown .time {
    font-size: 36px;
    color: var(--hot);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
    display: block;
    margin-top: 4px;
    font-weight: 800;
  }

  .footer {
    text-align: center;
    margin-top: 18px;
    font-size: 12px;
    color: var(--brand);
    opacity: 0.8;
    letter-spacing: 0.05em;
    font-weight: 600;
  }

  #confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

  .shake { animation: shake 0.5s; }
  @keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
  }

  .tip {
    background: var(--paper);
    border: 2px dashed var(--brand);
    border-radius: 14px;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--ink-soft);
    margin: 6px 0 4px;
    text-align: center;
    max-width: 460px;
    font-weight: 500;
  }
  .tip strong { color: var(--hot); }

  @keyframes wave {
    0%, 100% { transform: rotate(-8deg); }
    50% { transform: rotate(8deg); }
  }
  .arm.wave { transform-box: fill-box; transform-origin: 50% 100%; animation: wave 0.6s ease-in-out infinite; }

  @media (max-width: 480px) {
    .app { padding: 18px 12px 40px; }
    .stage { padding: 22px 16px 26px; min-height: 520px; }
    .character { width: 170px; height: 170px; }
    .btn.stop { font-size: 24px; padding: 22px 44px; }
    .target-display .num { font-size: 44px; }
    .total-card .total-num { font-size: 44px; }
    .result-row { grid-template-columns: 40px 1fr auto; gap: 10px; padding: 8px 10px; }
    .result-row .badge { width: 30px; height: 30px; font-size: 12px; }
    .result-row .label { font-size: 11px; }
  }

/* SVG pupils blink via style.transform; scale around their own centre, not the SVG origin. */
.character .pupil { transform-box: fill-box; transform-origin: center; }
/* The shared theme gives .total-card a light background; keep its secondary text legible. */
.game-page .total-card .total-label { color: var(--muted, #667069); }
.game-page .total-card .grade,
.game-page .total-card .total-num .unit { color: var(--ink); }
