/* Draw the World */
:root {
  --bg: #fdf6e9;
  --ink: #1d2b4f;
  --ink-soft: #4a5677;
  --card: #ffffff;
  --line: #e8dcc6;
  --sea: #dff1fb;
  --sea-line: #c3e2f3;
  --land: #ffd166;
  --land-ink: #b27a00;
  --you: #ef476f;
  --primary: #3a6df0;
  --primary-ink: #ffffff;
  --good: #1f9d6b;
  --ok: #e0a100;
  --meh: #f07b2c;
  --bad: #d64545;
  --radius: 18px;
  --shadow: 0 2px 0 rgba(29, 43, 79, .08), 0 10px 30px rgba(29, 43, 79, .08);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI Rounded", "Arial Rounded MT Bold", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font: 17px/1.5 var(--font);
  background-image: radial-gradient(circle at 1px 1px, rgba(29, 43, 79, .07) 1px, transparent 0);
  background-size: 22px 22px;
}
[hidden] { display: none !important; }
a { color: var(--primary); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }

.top { display: flex; justify-content: center; padding: 14px 16px 0; }
.logo {
  display: inline-flex; align-items: center; gap: 10px; font: 800 20px/1 var(--font); color: var(--ink);
  background: none; border: 0; cursor: pointer; padding: 8px 10px; border-radius: 12px;
}
.logo em, .title em { font-style: normal; color: var(--primary); }
.logo-globe, .ico {
  width: 28px; height: 28px; border-radius: 50%; display: inline-block; flex: none;
  background: var(--sea-line); border: 3px solid var(--ink); position: relative; overflow: hidden;
}
.logo-globe::after {
  content: ""; position: absolute; left: 4px; top: 5px; width: 13px; height: 11px;
  background: var(--land); border: 2px solid var(--ink); border-radius: 50% 40% 55% 45%;
}

main { max-width: 980px; margin: 0 auto; padding: 8px 16px 24px; }
.screen { animation: pop .35s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hero { text-align: center; padding: 18px 0 10px; }
.title { font-size: clamp(38px, 8vw, 64px); line-height: 1.02; margin: 0 0 10px; font-weight: 900; letter-spacing: -.02em; }
.title-sm { font-size: clamp(26px, 5vw, 38px); margin: 10px 0 4px; text-align: center; font-weight: 900; }
.lede { font-size: 18px; color: var(--ink-soft); max-width: 34em; margin: 0 auto 16px; text-align: center; }

.card {
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px;
}
.card p { margin: 0 0 12px; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.card-title { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font-size: 22px; font-weight: 850; }
.ico { width: 30px; height: 30px; border-radius: 9px; }
.ico-dice { background: #fff; }
.ico-dice::before, .ico-dice::after { content: ""; position: absolute; width: 6px; height: 6px; border-radius: 50%; background: var(--ink); }
.ico-dice::before { left: 4px; top: 4px; box-shadow: 10px 10px 0 var(--ink); }
.ico-dice::after { right: 4px; top: 4px; box-shadow: -10px 10px 0 var(--ink); }
.ico-plane { background: var(--sea-line); border-radius: 50%; }
.ico-plane::before { content: ""; position: absolute; left: 3px; top: 10px; width: 18px; height: 5px; background: var(--ink); border-radius: 3px; transform: rotate(-25deg); }
.ico-plane::after { content: ""; position: absolute; left: 9px; top: 6px; width: 5px; height: 14px; background: var(--ink); border-radius: 3px; transform: rotate(-25deg); }

.daily {
  position: relative; overflow: hidden; text-align: center; padding: 26px 22px 22px;
  background: linear-gradient(160deg, #3a6df0 0%, #5b4cdb 100%); color: #fff; border-color: #2b52c4;
}
.daily::before {
  content: ""; position: absolute; inset: -40% -10% auto auto; width: 320px; height: 320px; border-radius: 50%;
  background: rgba(255, 255, 255, .08); pointer-events: none;
}
.daily .kicker { color: #ffe08a; }
.daily-top { display: flex; justify-content: center; gap: 12px; align-items: center; flex-wrap: wrap; }
.daily-title { font-size: clamp(30px, 6vw, 44px); margin: 2px 0 6px; font-weight: 900; line-height: 1.1; }
.daily-sub { color: #e6ebff; max-width: 32em; margin-left: auto !important; margin-right: auto !important; }
.daily .small { color: #d6defc; margin: 12px 0 0; }
.streak { background: rgba(255, 255, 255, .16); border-radius: 999px; padding: 2px 12px; margin: 0 !important; font-weight: 800; font-size: 15px; }
.daily-tries { display: flex; justify-content: center; gap: 8px; margin: 4px 0 14px; flex-wrap: wrap; min-height: 0; }
.try-pill { background: rgba(255, 255, 255, .16); border-radius: 12px; padding: 6px 12px; font-weight: 800; }
.try-pill.best { background: #ffe08a; color: var(--ink); }
.daily .btn { border-color: #1b2f80; }
.daily .btn-primary { background: #ffd166; color: var(--ink); }
.daily .btn-primary:hover { background: #ffdb85; }

.kicker { text-transform: uppercase; letter-spacing: .12em; font-size: 13px; font-weight: 850; color: var(--primary); margin: 0 0 4px !important; }
.small { font-size: 14px; color: var(--ink-soft); }
.center { text-align: center; justify-content: center; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.daily .row { justify-content: center; }

.btn {
  font: 800 16px/1 var(--font); color: var(--ink); background: #fff; border: 2px solid var(--ink);
  border-radius: 14px; padding: 12px 18px; cursor: pointer; box-shadow: 0 3px 0 var(--ink);
  transition: transform .08s ease, box-shadow .08s ease, background .15s; min-height: 46px;
}
.btn:hover { background: #f4f1ea; }
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: 0 3px 0 var(--ink); }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: #2f5fd9; }
.btn-big { font-size: 18px; padding: 15px 24px; min-height: 54px; }
.btn-ghost { border-color: transparent; box-shadow: none; background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.btn-ghost:hover { background: rgba(29, 43, 79, .06); }
.btn-ghost:active { transform: none; }

.field { display: block; font-weight: 800; font-size: 14px; margin-bottom: 6px; }
.select {
  width: 100%; font: 700 16px var(--font); color: var(--ink); background: #fff; border: 2px solid var(--line);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; min-height: 46px;
}
.progress { height: 12px; background: #f1e8d6; border-radius: 99px; overflow: hidden; margin: 6px 0 8px; }
.progress span { display: block; height: 100%; width: var(--p, 0%); background: linear-gradient(90deg, #06d6a0, #3a6df0); border-radius: 99px; }

.how { margin-top: 16px; }
.how summary { cursor: pointer; font-weight: 850; }
.how p { margin-top: 10px; color: var(--ink-soft); }

/* Draw */
.prompt { text-align: center; padding: 6px 0 10px; }
.draw-title { font-size: clamp(28px, 6vw, 44px); margin: 0; font-weight: 900; line-height: 1.1; }
.draw-title:focus { outline: none; }
#draw-name { color: var(--primary); }
.hint { margin: 6px 0 0; color: var(--ink-soft); }
.hint[hidden] { display: none; }
.pad-wrap { display: flex; flex-direction: column; align-items: center; }
.pad {
  position: relative; width: min(100%, 560px, calc(100vh - 290px)); min-width: 260px; aspect-ratio: 1;
  background: var(--sea); border: 3px solid var(--ink); border-radius: 22px; box-shadow: 0 5px 0 var(--ink);
  overflow: hidden;
  background-image:
    linear-gradient(var(--sea-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--sea-line) 1px, transparent 1px);
  background-size: 10% 10%;
}
.pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.pad-result canvas { cursor: default; }
.pad-tip {
  position: absolute; inset: auto 0 44%; text-align: center; margin: 0; color: #6f97b3; font-weight: 800; font-size: 20px;
  pointer-events: none; transition: opacity .2s;
}
.pad.has-ink .pad-tip { opacity: 0; }
#draw-msg { margin: 8px 0 0; min-height: 0; }
#draw-msg:empty { margin: 0; }
#draw-msg.warn { color: var(--bad); font-weight: 800; }
.toolbar { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

/* Result */
.result-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 26px; align-items: center; padding-top: 10px; }
.result-grid .pad { width: min(100%, 520px); }
.legend { display: flex; gap: 8px; align-items: center; justify-content: center; font-size: 14px; color: var(--ink-soft); font-weight: 700; margin: 12px 0 0; flex-wrap: wrap; }
.key { width: 22px; height: 12px; border-radius: 4px; display: inline-block; margin-left: 8px; }
.key-real { background: var(--land); border: 2px solid var(--land-ink); }
.key-you { background: var(--you); height: 5px; }
.result-title { font-size: clamp(26px, 5vw, 38px); margin: 0; font-weight: 900; line-height: 1.1; }
.result-title:focus { outline: none; }
.score { font-size: clamp(64px, 14vw, 104px); font-weight: 900; line-height: 1; margin: 8px 0 6px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.score .pct { font-size: .45em; margin-left: 2px; color: var(--ink-soft); }
.score.good { color: var(--good); } .score.ok { color: var(--ok); } .score.meh { color: var(--meh); } .score.bad { color: var(--bad); }
.meter { height: 14px; background: #f1e8d6; border-radius: 99px; overflow: hidden; margin-bottom: 12px; }
.meter span { display: block; height: 100%; width: var(--p, 0%); background: linear-gradient(90deg, #ef476f, #ffd166 50%, #06d6a0); border-radius: 99px; transition: width .9s cubic-bezier(.2, .8, .2, 1); }
.verdict { font-size: 20px; font-weight: 800; margin: 0 0 6px; }
.breakdown { color: var(--ink-soft); margin: 0 0 6px; font-size: 15px; }
.best { margin: 0 0 14px; }
.stack .btn { flex: 1 1 auto; }
.share-preview {
  margin: 14px 0 0; padding: 12px 14px; background: #fff; border: 2px dashed var(--line); border-radius: 12px;
  font: 15px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; user-select: all;
}

/* Summary */
.tiles { list-style: none; padding: 0; margin: 10px auto 20px; display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.tile { background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 8px 10px; font-size: 13px; font-weight: 750; line-height: 1.25; display: flex; justify-content: space-between; gap: 6px; }
.tile b { font-variant-numeric: tabular-nums; }
.tile.good { border-color: #8fdcbc; background: #e9f9f1; } .tile.ok { border-color: #f3d27a; background: #fff6dc; }
.tile.meh { border-color: #f7b88b; background: #fff0e4; } .tile.bad { border-color: #f0a3a3; background: #fdeaea; }
.tile.skip { color: var(--ink-soft); background: #f6f3ec; } .tile.todo { color: #9aa1b5; border-style: dashed; background: transparent; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 800; transition: .25s; z-index: 20;
  max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  body { font-size: 16px; }
  .cards { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr; gap: 14px; }
  .result-side { text-align: center; }
  .result-side .row { justify-content: center; }
  .score { margin: 2px 0; }
  .pad { width: min(100%, 560px, calc(100vh - 300px)); }
  .daily { padding: 22px 16px 18px; }
}
@media (max-width: 420px) {
  .toolbar .btn { padding: 12px 14px; }
  .toolbar .btn-big { flex: 1 0 100%; order: -1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
.tiles { margin-top: 18px; }
.title-sm:focus { outline: none; }
