
  :root {
    --cream:      #FFF7E8;
    --paper:      #FFFCF2;
    --off:        #F4EEDB;
    --ink:        #15132B;
    --ink-soft:   #2A2748;
    --muted:      #6A6588;
    --brand:      #6C63FF;
    --brand-deep: #4A41D4;
    --sun:        #FFC233;
    --mustard:    #FFC233;
    --hot:        #FF4F8B;
    --teal:       #1FC8A9;
    --mint:       #6EE7CF;
    --coral:      #FF8966;
    --good:       #2ECC71;
    --bad:        #E74C3C;
    --water:      #D6E6EE;
  }
  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  html, body {
    margin: 0; padding: 0;
    min-height: 100vh;
    background: var(--cream);
    color: var(--ink);
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    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;
  }
  body {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 22px 16px 60px;
  }
  .wrap {
    width: 100%;
    max-width: 640px;
    text-align: center;
    position: relative;
    z-index: 1;
  }

  .topnav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    gap: 12px;
    text-align: left;
  }
  .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;
    flex-shrink: 0;
  }
  .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); }

  h1 {
    font-family: 'Fredoka', sans-serif;
    font-size: clamp(40px, 8vw, 64px);
    font-weight: 900;
    margin: 12px 0 4px;
    letter-spacing: 0.02em;
    line-height: 0.95;
    color: var(--ink);
    text-shadow: 4px 4px 0 var(--teal), 8px 8px 0 var(--hot);
    transform: rotate(-1.5deg);
    display: inline-block;
  }
  h1 .dot { color: var(--mustard); display: inline-block; transform: scale(1.3) translateY(2px); }
  .sub {
    margin-top: 18px;
    font-size: 13px; font-weight: 700;
    color: var(--brand);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 18px;
  }

  .panel {
    background: var(--paper);
    border: 3px solid var(--ink);
    border-radius: 22px;
    padding: 26px 24px 28px;
    box-shadow: 12px 12px 0 var(--ink);
    position: relative;
    text-align: left;
  }
  .panel::after {
    content: "";
    position: absolute;
    top: -12px; right: -12px;
    width: 52px; height: 52px;
    background: var(--mustard);
    transform: rotate(15deg);
    border: 3px solid var(--ink);
    border-radius: 12px;
    z-index: 0;
  }
  .panel::before {
    content: "DAILY";
    position: absolute;
    top: 10px; right: 0;
    z-index: 1;
    transform: rotate(15deg);
    font-family: 'Fredoka', sans-serif;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.1em;
    color: var(--ink);
  }

  .status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-family: 'Fredoka', sans-serif;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--brand);
    position: relative;
    z-index: 2;
    padding-right: 44px;
  }
  .status strong { color: var(--ink); font-weight: 800; }
  .attempt-pips { display: inline-flex; gap: 6px; }
  .pip {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--paper);
    border: 2px solid var(--ink);
  }
  .pip.used.bullseye { background: var(--good); }
  .pip.used.close    { background: var(--mustard); }
  .pip.used.warm     { background: var(--coral); }
  .pip.used.cold     { background: var(--bad); }
  .pip.current { background: var(--brand); animation: pipPulse 1.2s infinite; }
  @keyframes pipPulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.3)} }

  .prompt {
    font-family: 'Fredoka', sans-serif;
    font-size: 17px;
    font-weight: 600;
    margin: 12px 0 18px;
    min-height: 24px;
    color: var(--ink);
    text-align: center;
    line-height: 1.4;
  }
  .prompt .accent { color: var(--hot); font-weight: 800; }
  .prompt em { font-style: normal; font-weight: 800; color: var(--brand); }

  /* Target card */
  .target-card {
    margin: 0 auto 14px;
    max-width: 460px;
    background: var(--ink);
    color: var(--cream);
    border: 3px solid var(--ink);
    border-radius: 16px;
    padding: 12px 18px;
    box-shadow: 5px 5px 0 var(--mustard);
    text-align: center;
    transform: rotate(-0.6deg);
  }
  .target-card .tc-label {
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--mustard);
    margin-bottom: 4px;
  }
  .target-card .tc-name {
    font-family: 'Fredoka', sans-serif;
    font-weight: 900;
    font-size: 22px;
    color: var(--cream);
    line-height: 1.15;
  }
  .target-card .tc-cat {
    font-family: 'Fredoka', sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--teal);
    margin-top: 4px;
  }

  /* World map canvas */
  .map-wrap {
    max-width: 600px;
    margin: 0 auto 12px;
    position: relative;
  }
  .world-map {
    width: 100%;
    aspect-ratio: 2 / 1;
    border: 3px solid var(--ink);
    border-radius: 12px;
    box-shadow: 4px 4px 0 var(--ink);
    background: var(--water);
    cursor: grab;
    user-select: none;
    touch-action: none;
    display: block;
    overflow: hidden;
  }
  .world-map.locked { cursor: default; }
  .world-map.panning { cursor: grabbing; }

  /* Zoom controls overlay */
  .zoom-ctrls {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    /* A row along the bottom edge only covers Antarctica; a column here hid
       eastern Australia and New Zealand at full zoom-out. */
    flex-direction: row;
    gap: 4px;
    z-index: 5;
  }
  .zoom-btn {
    width: 34px;
    height: 34px;
    background: var(--paper);
    border: 2.5px solid var(--ink);
    border-radius: 8px;
    font-family: 'Fredoka', sans-serif;
    font-weight: 900;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 2px 2px 0 var(--ink);
    color: var(--ink);
    display: grid;
    place-items: center;
    padding: 0;
    transition: transform 0.06s ease, box-shadow 0.06s ease;
  }
  .zoom-btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
  .zoom-btn:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
  .zoom-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: 2px 2px 0 var(--ink); }
  .zoom-btn svg { width: 16px; height: 16px; pointer-events: none; }
  .continent {
    fill: var(--cream);
    stroke: var(--ink);
    stroke-width: 0.9;
    stroke-linejoin: round;
    stroke-linecap: round;
    pointer-events: none;
  }
  .grat-line {
    stroke: rgba(21, 19, 43, 0.10);
    stroke-width: 0.5;
    fill: none;
    pointer-events: none;
  }
  .player-pin {
    fill: white;
    stroke: var(--ink);
    stroke-width: 2.4;
    pointer-events: none;
    filter: drop-shadow(1.5px 1.5px 0 rgba(21, 19, 43, 0.5));
  }
  .truth-pin {
    fill: var(--hot);
    stroke: var(--ink);
    stroke-width: 2.4;
    pointer-events: none;
    filter: drop-shadow(1.5px 1.5px 0 rgba(21, 19, 43, 0.5));
    animation: truthPulse 1.2s ease-out infinite;
  }
  @keyframes truthPulse {
    0%,100% { transform-origin: center; r: 5; }
    50%     { r: 7; }
  }
  .connect-line {
    stroke: var(--ink);
    stroke-width: 1.6;
    stroke-dasharray: 4 3;
    fill: none;
    pointer-events: none;
  }

  /* Tier feedback after a tap */
  .tier-feedback {
    margin: 8px auto 12px;
    max-width: 460px;
    text-align: center;
    animation: tierPop 0.45s cubic-bezier(.34,1.56,.64,1);
  }
  @keyframes tierPop {
    from { opacity: 0; transform: scale(0.7); }
    to   { opacity: 1; transform: scale(1); }
  }
  .tier-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--ink);
    color: white;
    padding: 11px 22px;
    border-radius: 999px;
    font-family: 'Fredoka', sans-serif;
    font-weight: 800;
    font-size: 16px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    box-shadow: 4px 4px 0 var(--ink);
  }
  .tier-badge.bullseye { background: var(--good); color: white; }
  .tier-badge.close    { background: var(--mustard); color: var(--ink); }
  .tier-badge.warm     { background: var(--coral); color: white; }
  .tier-badge.cold     { background: var(--bad); color: white; }
  .tier-badge .emoji { font-size: 22px; }
  .tier-badge .dist {
    margin-left: 8px;
    padding-left: 10px;
    border-left: 2px solid rgba(255,255,255,0.4);
    font-variant-numeric: tabular-nums;
  }
  .tier-badge.close .dist { border-left-color: rgba(21,19,43,0.3); }

  /* Buttons */
  .btn {
    appearance: none;
    border: 3px solid var(--ink);
    background: var(--mustard);
    color: var(--ink);
    font-family: 'Fredoka', sans-serif;
    font-weight: 800;
    font-size: 16px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 13px 28px;
    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: 4px;
  }
  .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.45;
    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.next    { background: var(--brand); color: white; }
  .btn.share   { background: var(--teal); color: white; }
  .btn.ghost   { background: var(--paper); color: var(--ink); }
  .btn-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
  }

  .scoreline {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 22px 0 8px;
    flex-wrap: wrap;
  }
  .scoreline > div {
    background: var(--cream);
    border: 2.5px solid var(--ink);
    border-radius: 14px;
    padding: 12px 16px;
    text-align: center;
    min-width: 90px;
    box-shadow: 3px 3px 0 var(--ink);
  }
  .scoreline .num {
    font-family: 'Fredoka', sans-serif;
    color: var(--ink);
    font-weight: 800;
    font-size: 22px;
    line-height: 1;
    display: block;
    margin-bottom: 4px;
  }
  .scoreline > div > div:last-child {
    font-size: 11px;
    font-weight: 700;
    color: var(--brand);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-family: 'Fredoka', sans-serif;
  }

  /* Final */
  .final { padding: 8px 0; text-align: center; }
  .final .label {
    color: var(--brand);
    font-size: 12px;
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
  }
  .final .bigscore-card {
    margin: 14px auto 8px;
    background: var(--ink);
    color: var(--cream);
    padding: 22px 28px 18px;
    border-radius: 22px;
    text-align: center;
    box-shadow: 6px 6px 0 var(--brand);
    transform: rotate(-1deg);
    border: 3px solid var(--ink);
    font-family: 'Fredoka', sans-serif;
    display: inline-block;
    min-width: 260px;
  }
  .final .bigscore {
    font-family: 'Fredoka', sans-serif;
    font-size: 46px;
    font-weight: 900;
    color: var(--mustard);
    line-height: 1;
    margin: 4px 0 6px;
    letter-spacing: 0.18em;
  }
  .final .flavor {
    color: var(--cream);
    font-size: 18px;
    font-weight: 800;
    margin-top: 6px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
  .final .flavor-sub {
    color: var(--cream);
    font-size: 13px;
    font-weight: 600;
    margin-top: 4px;
    letter-spacing: 0.04em;
    opacity: 0.85;
  }
  .final .rounds-detail {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 18px auto 12px;
    max-width: 480px;
  }
  .final .rd-tile {
    background: var(--cream);
    border: 2.5px solid var(--ink);
    border-radius: 10px;
    box-shadow: 3px 3px 0 var(--ink);
    padding: 10px 6px;
    text-align: center;
  }
  .final .rd-tile .rd-emoji { font-size: 22px; line-height: 1; }
  .final .rd-tile .rd-name {
    font-family: 'Fredoka', sans-serif;
    font-weight: 800;
    font-size: 11px;
    color: var(--ink);
    margin-top: 6px;
    line-height: 1.15;
  }
  .final .rd-tile .rd-dist {
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    font-size: 12px;
    color: var(--brand);
    margin-top: 3px;
    font-variant-numeric: tabular-nums;
  }

  /* Countdown (locked) */
  .countdown {
    margin: 10px auto;
    font-family: 'Fredoka', sans-serif;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--brand);
    text-align: center;
  }
  .countdown .time {
    display: inline-block;
    background: var(--ink);
    color: var(--mustard);
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 15px;
    letter-spacing: 0.1em;
    margin-left: 6px;
    font-variant-numeric: tabular-nums;
  }

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

  .toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: var(--cream);
    padding: 10px 18px;
    border-radius: 999px;
    font-weight: 700;
    font-family: 'Fredoka', sans-serif;
    font-size: 14px;
    letter-spacing: 0.04em;
    box-shadow: 3px 3px 0 var(--brand);
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 1500;
  }
  .toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  @media (max-width: 540px) {
    .panel { padding: 22px 14px 24px; }
    .target-card .tc-name { font-size: 18px; }
    .final .bigscore { font-size: 36px; }
    .final .rd-tile .rd-name { font-size: 10px; }
    /* On a narrow map any overlay covers real places, so sit below it. */
    .zoom-ctrls { position: static; justify-content: flex-end; margin-top: 8px; }
  }
