/* ---------- HUD ---------- */
.hud {
  position: fixed; inset: 0; z-index: 10; pointer-events: none;
  display: grid; grid-template-rows: auto 1fr auto; gap: 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: calc(14px + var(--safe-t)) calc(14px + var(--safe-b));
}
.hud > * { min-width: 0; }
.panel { background: var(--hud); border: 1px solid var(--hud-line); border-radius: 12px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.logo {
  pointer-events: auto; display: grid; gap: 3px; padding: 10px 16px 11px; text-align: left; cursor: inherit;
  border: 1px solid var(--hud-line); border-radius: 12px; background: var(--hud); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.logo-name { font-family: var(--f-display); font-weight: 900; font-stretch: 125%; font-size: 21px; line-height: 1; letter-spacing: .02em; text-transform: uppercase; }
.logo-name em { font-style: normal; color: var(--hot); }
.logo-sub { font: 600 10.5px/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-dim); }
.quick { pointer-events: auto; display: flex; gap: 6px; }
.qbtn {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 13px; border-radius: 10px; cursor: inherit;
  border: 1px solid var(--hud-line); background: var(--hud); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  font: 600 11.5px/1 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink);
}
.qbtn:hover { border-color: var(--accent); color: var(--accent); }
.qbtn svg { width: 16px; height: 16px; flex: none; }
.qbtn.icon-only { padding: 0; width: 38px; justify-content: center; }
.qbtn[aria-pressed="false"] .wave { opacity: 0; }

.bottombar { display: grid; grid-template-columns: auto 1fr auto; align-items: end; gap: 12px; }
.mini { pointer-events: auto; display: grid; gap: 8px; justify-items: start; }
.mini-ring { position: relative; width: 168px; height: 168px; border-radius: 50%; padding: 6px; background: var(--hud); border: 1px solid var(--hud-line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
#minimap { width: 100%; height: 100%; display: block; border-radius: 50%; cursor: crosshair; touch-action: none; }
.mini-n { position: absolute; left: 50%; top: -9px; transform: translateX(-50%); font: 700 10px/1 var(--f-mono); padding: 4px 6px; border-radius: 5px; background: var(--hot); color: #fff; }
.mini-label { display: flex; align-items: center; gap: 10px; padding: 7px 10px; font: 600 11px/1 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; }
.mini-label b { color: var(--ink); font-weight: 600; }
.mini-label span { color: var(--ink-dim); }
.mini-label .sep { width: 1px; height: 12px; background: var(--hud-line); }
#fitBtn { pointer-events: auto; cursor: inherit; border: 0; background: transparent; padding: 0; color: var(--ink-dim); font: inherit; letter-spacing: inherit; text-transform: inherit; }
#fitBtn:hover { color: var(--accent); }

.tutorial {
  justify-self: center; align-self: end; display: flex; align-items: center; gap: 12px; padding: 10px 16px; margin-bottom: 6px;
  font-size: 14px; transition: opacity .3s ease, transform .3s ease; max-width: 100%;
}
.tutorial.gone { opacity: 0; transform: translateY(12px); }
.tutorial .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--hot); box-shadow: 0 0 0 0 var(--hot); animation: pulse 1.6s infinite; flex: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--hot) 70%, transparent); } 100% { box-shadow: 0 0 0 12px transparent; } }

.prompts { display: grid; gap: 8px; justify-items: end; }
.prompt-list { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 14px; padding: 9px 12px; font-size: 13px; color: var(--ink); max-width: min(680px, 56vw); }
.card .kc { color: var(--card-ink); border-color: color-mix(in srgb, var(--card-ink) 28%, transparent); background: color-mix(in srgb, var(--card-ink) 6%, transparent); }
.card .kc.pad { background: var(--card-ink); color: var(--card); }
.pr { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.kc { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--hud-line); border-bottom-width: 2px; font: 700 10.5px/1 var(--f-mono); color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.kc.pad { border-radius: 11px; background: var(--ink); color: var(--bg); border-color: var(--ink); }
.kc svg { width: 14px; height: 18px; }
.coords { font: 600 10.5px/1 var(--f-mono); letter-spacing: .08em; color: var(--ink-dim); padding: 0 4px; font-variant-numeric: tabular-nums; }

/* ---------- Notifications + achievements (top left, under the logo) ---------- */
.toasts {
  position: fixed; z-index: 30; top: calc(82px + var(--safe-t)); left: max(16px, env(safe-area-inset-left, 0px));
  width: min(360px, calc(100vw - 32px)); display: grid; gap: 10px; justify-items: start; pointer-events: none;
}
.toast {
  display: grid; gap: 3px; padding: 11px 16px 12px; max-width: 100%; pointer-events: none;
  opacity: 0; transform: translateX(-40px); transition: opacity .25s ease, transform .45s cubic-bezier(.2,1.3,.4,1);
}
.toast.show { opacity: 1; transform: none; }
.toast.leave { opacity: 0; transform: translateX(-30px) scale(.96); transition-duration: .3s; }
.toast small { font: 600 10px/1 var(--f-mono); letter-spacing: .18em; text-transform: uppercase; color: var(--hot); }
.toast strong { font-family: var(--f-display); font-weight: 900; font-stretch: 118%; font-size: 17px; line-height: 1.05; text-transform: uppercase; }
.toast span { font-size: 12.5px; color: var(--ink-dim); }

/* achievement: bigger, icon tile with a burst, progress bar that fills, a shine that sweeps across */
.toast.achievement {
  --glow: var(--hot);
  width: 100%; grid-template-columns: 58px 1fr; align-items: center; gap: 14px; padding: 12px 16px 12px 12px; position: relative; overflow: hidden;
  border-color: color-mix(in srgb, var(--glow) 55%, var(--hud-line));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--glow) 25%, transparent), 0 18px 40px -16px color-mix(in srgb, var(--glow) 55%, transparent);
}
.toast.achievement.gold { --glow: #f4c534; }
.toast.achievement::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, color-mix(in srgb, var(--glow) 30%, transparent) 50%, transparent 65%);
  transform: translateX(-110%);
}
.toast.achievement.show::after { animation: t-shine 1.1s .35s ease-out; }
.t-ico {
  position: relative; width: 58px; height: 58px; border-radius: 14px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--glow), color-mix(in srgb, var(--glow) 55%, var(--accent)));
  box-shadow: 0 6px 18px -6px var(--glow);
}
.t-ico svg { width: 28px; height: 28px; }
.t-ico::before { content: ""; position: absolute; inset: -4px; border-radius: 18px; border: 2px solid var(--glow); opacity: 0; }
.toast.achievement.show .t-ico { animation: t-pop .6s .1s cubic-bezier(.3,1.7,.5,1) both; }
.toast.achievement.show .t-ico::before { animation: t-ring .8s .25s ease-out; }
.t-txt { display: grid; gap: 4px; min-width: 0; }
.toast.achievement small { color: var(--glow); }
.toast.achievement strong { font-size: 21px; }
.t-bar { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; margin-top: 4px; }
.t-bar i { position: relative; height: 6px; border-radius: 3px; background: var(--hud-line); overflow: hidden; }
.t-bar i::before { content: ""; position: absolute; inset: 0; width: var(--from); border-radius: inherit; background: var(--glow); }
.toast.achievement.show .t-bar i::before { animation: t-fill .9s .45s cubic-bezier(.2,.8,.2,1) forwards; }
.t-bar b { font: 700 10.5px/1 var(--f-mono); color: var(--ink-dim); font-variant-numeric: tabular-nums; }
@keyframes t-pop { 0% { transform: scale(.4) rotate(-25deg); } 100% { transform: none; } }
@keyframes t-ring { 0% { opacity: .9; transform: scale(.8); } 100% { opacity: 0; transform: scale(1.5); } }
@keyframes t-fill { to { width: var(--to); } }
@keyframes t-shine { to { transform: translateX(110%); } }

/* ---------- Top left: logo, trophies, sound ---------- */
.topleft { pointer-events: auto; display: flex; align-items: center; gap: 6px; min-width: 0; }
.ach-btn b { font: 700 11px/1 var(--f-mono); letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.ach-btn svg { color: #f4c534; }
.ach-btn.complete { border-color: #f4c534; color: #f4c534; box-shadow: 0 0 0 1px rgba(244,197,52,.25), 0 6px 18px -8px rgba(244,197,52,.7); }

/* list of achievements, dropping from the trophy button */
.ach-panel {
  position: fixed; z-index: 32; top: calc(76px + var(--safe-t)); left: max(16px, env(safe-area-inset-left, 0px));
  width: min(380px, calc(100vw - 32px)); max-height: calc(100dvh - 120px - var(--safe-t)); overflow-y: auto; overscroll-behavior: contain;
  padding: 16px; display: grid; gap: 12px; background: var(--bg-2); box-shadow: 0 30px 60px -24px var(--shadow);
  opacity: 0; transform: translateY(-10px) scale(.98); transform-origin: top left; transition: opacity .2s ease, transform .25s cubic-bezier(.2,1.2,.4,1);
}
.ach-panel.show { opacity: 1; transform: none; }
.ap-head { display: flex; justify-content: space-between; align-items: end; }
.ap-head small { display: block; font: 600 10px/1 var(--f-mono); letter-spacing: .18em; text-transform: uppercase; color: var(--hot); margin-bottom: 6px; }
.ap-head strong { font-family: var(--f-display); font-weight: 900; font-stretch: 118%; font-size: 24px; line-height: 1; text-transform: uppercase; }
.ap-pct { font: 700 13px/1 var(--f-mono); color: var(--ink-dim); }
.ap-bar { height: 6px; border-radius: 3px; background: var(--hud-line); overflow: hidden; }
.ap-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--hot), #f4c534); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.ap-coffee { display: block; padding: 10px 12px; border-radius: 10px; background: #f4c534; color: #17181b; font-weight: 700; font-size: 14px; text-decoration: none; text-align: center; }
.ap-group { margin: 8px 0 2px; font: 600 10px/1 var(--f-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-dim); }
.ap-list { display: grid; gap: 6px; }
.ap-item { display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: center; padding: 8px; border-radius: 10px; border: 1px solid var(--hud-line); opacity: .55; transition: opacity .2s, border-color .2s, transform .2s; }
.ap-item.got { opacity: 1; border-color: color-mix(in srgb, var(--hot) 40%, var(--hud-line)); }
.ap-item.got.gold { border-color: rgba(244,197,52,.6); }
.ap-item:hover { transform: translateX(3px); opacity: 1; }
.ap-ico { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: var(--hud-line); color: var(--ink-dim); }
.ap-item.got .ap-ico { background: linear-gradient(135deg, var(--hot), color-mix(in srgb, var(--hot) 55%, var(--accent))); color: #fff; }
.ap-item.got.gold .ap-ico { background: linear-gradient(135deg, #f4c534, #e08a1e); }
.ap-ico svg { width: 18px; height: 18px; }
.ap-txt { display: grid; gap: 3px; min-width: 0; }
.ap-txt b { font-size: 14px; }
.ap-txt small { font-size: 12px; color: var(--ink-dim); }
.ap-check { font-style: normal; font-weight: 800; color: var(--hot); }
.ap-item.gold .ap-check { color: #f4c534; }
.ap-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-top: 8px; border-top: 1px dashed var(--hud-line); font-size: 12px; color: var(--ink-dim); }
.ap-reset { border: 0; background: transparent; color: var(--ink-dim); font: 600 11px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; cursor: pointer; padding: 6px; border-radius: 6px; }
.ap-reset:hover, .ap-reset.armed { color: var(--hot); }

/* ---------- The surprise ---------- */
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 60; pointer-events: none; }
.legend-wrap { position: fixed; inset: 0; z-index: 55; display: grid; place-items: center; padding: 24px; background: rgba(8,9,11,.55); opacity: 0; transition: opacity .3s ease; }
.legend-wrap.show { opacity: 1; }
.legend-card {
  position: relative; width: min(420px, 100%); padding: 44px 26px 22px; border-radius: 22px; text-align: center; display: grid; gap: 10px; justify-items: center;
  background: var(--bg-2); border: 1px solid rgba(244,197,52,.6); box-shadow: 0 40px 90px -30px rgba(244,197,52,.45);
  transform: translateY(24px) scale(.94); transition: transform .5s cubic-bezier(.2,1.4,.4,1);
}
.legend-wrap.show .legend-card { transform: none; }
.lg-crown { position: absolute; top: -40px; width: 84px; height: 70px; animation: lg-crown 2.4s ease-in-out infinite; filter: drop-shadow(0 10px 14px rgba(0,0,0,.4)); }
.lg-crown svg { width: 100%; height: 100%; display: block; }
@keyframes lg-crown { 50% { transform: translateY(-6px) rotate(-6deg); } }
.legend-card small { font: 600 10.5px/1 var(--f-mono); letter-spacing: .18em; text-transform: uppercase; color: #f4c534; }
.legend-card h2 { margin: 0; font-family: var(--f-display); font-weight: 900; font-stretch: 125%; font-size: 30px; line-height: 1; text-transform: uppercase; }
.legend-card p { margin: 4px 0 6px; font-size: 15px; line-height: 1.5; color: var(--ink); }
.lg-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.lg-coffee { background: #f4c534; color: #17181b; text-decoration: none; }
.lg-coffee:hover { background: #ffd54d; color: #17181b; }
.lg-later { border: 1px solid var(--hud-line); background: transparent; color: var(--ink); border-radius: 10px; padding: 9px 14px; font: 600 12px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
.lg-later:hover { border-color: var(--accent); color: var(--accent); }
.lg-note { font-size: 12px; color: var(--ink-dim); }
/* the lasting reward: a crown on the logo */
.legend .logo { overflow: visible; }
.legend .logo::after {
  content: ""; position: absolute; top: -12px; left: 8px; width: 26px; height: 22px; transform: rotate(-16deg);
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 40'%3E%3Cpath d='M5 13l10 9 9-17 9 17 10-9-4 22H9z' fill='%23f4c534' stroke='%2317181b' stroke-width='2.5' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.legend .logo-name em { color: #f4c534; }
