/* Nuts HUD (W3, look R2-P3): DOM over the canvas. Everything is OPAQUE so it reads over any stage (bright day, dark cellar, night forge):
   cream tiles with a navy-brown outline and a bottom lip, on oak plates with a brass rim.
   Rules: every button has hover, focus and pressed states; hover eases and never swaps fill and text colour; text >= 12 px; taps >= 44 px. */
@font-face { font-family: 'Baloo 2'; font-weight: 700; font-display: swap; src: url('fonts/baloo2-700.woff2') format('woff2'); }
.nh, .nh * { box-sizing: border-box; }
.nh {
  --ink: #2a1d16; --ink2: #5b4636; --cream: #fff3dc; --paper: #fffaf0; --paper2: #f6e2b6; --lip: #dcc08a; --brass: #e2a93b; --gold: #f6cf6b; --brass-d: #b9801f;
  --oak: #6a4630; --oak2: #4a3022; --deep: #1a100a; --tom: #d85a3c; --teal: #3f9d8f; --sun: #f6cf6b;
  --disp: 'Baloo 2', 'Trebuchet MS', ui-rounded, system-ui, sans-serif; --body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --top-h: 52px; --bot-h: 96px; --ease: cubic-bezier(.3, .7, .3, 1);
  position: fixed; inset: 0; z-index: 10; pointer-events: none; color: var(--ink);
  font: 600 14px/1.25 var(--body); -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
@media (max-height: 520px) { .nh { --top-h: 46px; --bot-h: 66px; } }
.nh [hidden] { display: none !important; }
:where(.nh) button { font: inherit; color: inherit; border: 0; background: none; margin: 0; padding: 0; cursor: pointer; touch-action: manipulation; pointer-events: auto; }
.nh svg, .nh .ic-img { display: block; flex: none; }
.ic-img { display: block; flex: none; object-fit: contain; pointer-events: none; -webkit-user-drag: none; }
.nm-bagi > .ic-img { width: 34px; height: 34px; }
.nm-bagi.locked > .ic-img { opacity: .45; filter: grayscale(1); }
.nm-btn.locked .ic-img, .nm-btn[aria-disabled=true] .ic-img { opacity: .6; }
.nm-dayc.past > .ic-img { opacity: .55; }
.nm-bigico .ic-img { margin-top: -4px; }
.bic:not(.pk) > .ic-img { width: 38px; height: 38px; }

/* ---- card buttons (win / stuck cards of the stand-alone HUD) ---- */
.nh-btn { position: relative; min-height: 48px; min-width: 44px; padding: 6px 18px 9px; border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 18px/1 var(--disp); color: var(--ink); background: var(--paper); border: 2.5px solid var(--ink);
  box-shadow: inset 0 -5px 0 var(--lip), 0 3px 0 rgba(26, 16, 10, .45);
  transition: transform .16s var(--ease), box-shadow .16s var(--ease), filter .16s var(--ease); }
@media (hover: hover) { .nh-btn:hover { transform: translateY(-2px); filter: brightness(1.05); } }
.nh-btn:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 var(--lip), 0 1px 0 rgba(26, 16, 10, .45); transition-duration: .06s; }
.nh-btn:focus-visible, .nh-icon:focus-visible, .nh-boost:focus-visible { outline: 3px solid #16a5e0; outline-offset: 2px; }
.nh-btn.primary { background: linear-gradient(#fbdc86, #f0bb48); --lip: #c98f22; }
.nh-btn.sky { background: linear-gradient(#8fdace, #55b3a5); --lip: #2f7e72; }
.nh-btn.big { min-height: 58px; font-size: 22px; border-radius: 18px; padding: 8px 26px 12px; }
.nh-btn small { font: 700 13px/1 var(--body); opacity: .85; }
.nh-btn:disabled { background: #e4d6b8; color: #8a7a62; --lip: #c9b78f; cursor: default; transform: none; }

/* ---- top bar: level plaque, coin pill, two tile buttons ---- */
.nh-top { position: absolute; left: max(10px, env(safe-area-inset-left, 0px)); right: max(10px, env(safe-area-inset-right, 0px)); top: calc(env(safe-area-inset-top, 0px) + 8px); height: var(--top-h);
  display: flex; align-items: flex-start; gap: 8px; }
.nh-pill { height: 44px; padding: 0 16px 3px; border-radius: 14px; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  font: 700 20px/1 var(--disp); border: 2.5px solid var(--ink); }
.nh-level { color: var(--cream); letter-spacing: .01em; text-shadow: 0 2px 0 rgba(26, 16, 10, .6);
  background: repeating-linear-gradient(90deg, rgba(0, 0, 0, .08) 0 1px, transparent 1px 9px), linear-gradient(var(--oak), var(--oak2));
  box-shadow: inset 0 0 0 2px var(--brass), inset 0 -5px 0 rgba(26, 16, 10, .35), 0 3px 0 rgba(26, 16, 10, .5); }
.nh-coins { padding: 0 14px 3px 8px; color: var(--ink); background: var(--paper); box-shadow: inset 0 -4px 0 var(--lip), 0 3px 0 rgba(26, 16, 10, .5); }
.nh-coins b { font-weight: 700; min-width: 2ch; text-align: right; font-variant-numeric: tabular-nums; }
.nh-coins.bump { animation: nhBump .35s cubic-bezier(.2, .9, .3, 1.5); }
.nh-spacer { flex: 1; }
.nh-icon { width: 44px; height: 44px; padding: 0 0 3px; border-radius: 14px; background: var(--paper); border: 2.5px solid var(--ink); display: grid; place-items: center;
  box-shadow: inset 0 -4px 0 var(--lip), 0 3px 0 rgba(26, 16, 10, .5); transition: transform .16s var(--ease), filter .16s var(--ease), box-shadow .16s var(--ease); }
.nh-icon.off { background: #eadcc0; }
@media (hover: hover) { .nh-icon:hover { transform: translateY(-2px); filter: brightness(1.05); } }
.nh-icon:active { transform: translateY(2px); padding-bottom: 1px; box-shadow: inset 0 -2px 0 var(--lip), 0 1px 0 rgba(26, 16, 10, .5); transition-duration: .06s; }

/* ---- torque gauge: an oak plate, one bar that fills over several levels, the Magnet it pays waits at the end ---- */
.nh-torque { position: absolute; right: max(10px, env(safe-area-inset-right, 0px)); top: calc(env(safe-area-inset-top, 0px) + 8px + var(--top-h) + 2px); display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 5px 2px 12px; border-radius: 17px; border: 2.5px solid var(--ink); color: var(--cream);
  background: linear-gradient(var(--oak), var(--oak2)); box-shadow: inset 0 0 0 1.5px var(--brass), 0 3px 0 rgba(26, 16, 10, .5);
  font: 700 13px/1 var(--disp); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.nh-tbar { position: relative; width: 104px; height: 14px; border-radius: 7px; background: #2a1d16; overflow: hidden; box-shadow: inset 0 2px 0 rgba(0, 0, 0, .5), 0 1px 0 rgba(255, 235, 190, .25); }
.nh-tfill { position: absolute; inset: 0; border-radius: 7px; background: linear-gradient(#fff0b8, #f0bb48 55%, #d99a2a); transform-origin: 0 50%; transform: scaleX(0); transition: transform .45s cubic-bezier(.2, .8, .3, 1); }
.nh-tbar::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 24px, rgba(42, 29, 22, .35) 24px 26px); }
.nh-torque.near .nh-tmag, .nh-torque.full .nh-tmag { background: #ffe08a; }
@media (max-width: 380px) { .nh-tbar { width: 84px; } }
.nh-tmag { width: 24px; height: 24px; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink); display: grid; place-items: center; }
.nh-tmag svg, .nh-tmag img { width: 18px; height: 18px; }
.nh-torque.full { animation: nhBumpC .5s cubic-bezier(.2, .9, .3, 1.5); }
@media (max-height: 520px) { .nh-torque { top: calc(env(safe-area-inset-top, 0px) + 13px); } }
@media (max-height: 520px) and (max-width: 760px) { .nh-torque > span:first-child { display: none; } .nh-torque { padding-left: 8px; } }

/* ---- bottom booster tray: one oak plate, three cream cards ---- */
.nh-bar { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--bot-h) + env(safe-area-inset-bottom, 0px)); padding: 0 max(10px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 12px) max(10px, env(safe-area-inset-left, 0px));
  display: flex; align-items: flex-end; justify-content: center; }
.nh-tray { pointer-events: auto; display: flex; gap: 8px; width: min(100%, 372px); padding: 8px 8px 9px; border-radius: 22px; border: 3px solid var(--ink);
  background: repeating-linear-gradient(90deg, rgba(0, 0, 0, .08) 0 1px, transparent 1px 11px), linear-gradient(var(--oak), var(--oak2));
  box-shadow: inset 0 0 0 2px var(--brass), inset 0 -6px 0 rgba(26, 16, 10, .3), 0 5px 0 var(--deep), 0 12px 18px rgba(0, 0, 0, .35); }
.nh-boost { position: relative; flex: 1 1 0; min-width: 0; height: 62px; padding: 0 2px 4px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  background: linear-gradient(var(--paper), #fbecc8); color: var(--ink); border: 2.5px solid var(--ink); box-shadow: inset 0 -5px 0 var(--lip), 0 3px 0 var(--deep);
  font: 700 13px/1 var(--disp); transition: transform .16s var(--ease), filter .16s var(--ease), box-shadow .16s var(--ease); }
@media (hover: hover) { .nh-boost:hover { transform: translateY(-2px); filter: brightness(1.05); } }
.nh-boost:active { transform: translateY(3px); padding-bottom: 1px; box-shadow: inset 0 -2px 0 var(--lip), 0 0 0 var(--deep); transition-duration: .06s; }
.nh-bic svg, .nh-bic img { width: 38px; height: 38px; margin-top: -2px; }
.nh-bl { max-width: 100%; padding: 0 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nh-boost.locked { background: #d9ccb2; color: #6f6252; --lip: #bfae8d; }
.nh-boost.locked .nh-bic { opacity: .45; filter: grayscale(1); }
.nh-badge { position: absolute; top: -9px; right: -7px; min-width: 26px; height: 26px; padding: 0 6px 1px; border-radius: 13px; display: grid; place-items: center; font: 700 15px/1 var(--disp); font-style: normal;
  background: var(--gold); color: var(--ink); border: 2.5px solid var(--ink); box-shadow: inset 0 -3px 0 #d89e2c; }
.nh-badge.zero { background: var(--teal); color: #fff; box-shadow: inset 0 -3px 0 #2f7e72; font-size: 18px; }
.nh-badge.lock { background: var(--paper); box-shadow: inset 0 -3px 0 var(--lip); padding: 0 3px 1px; }
.nh-badge.pop { animation: nhBump .35s cubic-bezier(.2, .9, .3, 1.5); }
.nh-boost.ready { animation: nhReady 1.3s ease-in-out infinite; }
@media (max-height: 520px) {
  .nh-bar { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px); }
  .nh-tray { width: min(100%, 520px); padding: 6px 6px 7px; border-radius: 18px; }
  .nh-boost { flex-direction: row; gap: 6px; height: 44px; padding: 0 8px 3px; } .nh-bic svg, .nh-bic img { width: 30px; height: 30px; margin-top: 0; } .nh-bl { font-size: 14px; }
}

/* ---- toast ---- */
.nh-toast { position: absolute; left: 50%; top: calc(env(safe-area-inset-top, 0px) + var(--top-h) + 58px); transform: translate(-50%, -10px); width: max-content; max-width: min(88vw, 420px); padding: 9px 18px 11px; border-radius: 16px; text-align: center;
  background: var(--paper); color: var(--ink); border: 2.5px solid var(--ink); font: 700 17px/1.2 var(--disp); box-shadow: inset 0 -4px 0 var(--lip), 0 4px 0 rgba(26, 16, 10, .45); opacity: 0; transition: opacity .25s ease, transform .3s cubic-bezier(.2, .9, .3, 1.4); pointer-events: none; }
.nh-toast.show { opacity: 1; transform: translate(-50%, 0); }
.nh-toast:empty { display: none; }
@media (max-height: 520px) { .nh-toast { top: calc(env(safe-area-inset-top, 0px) + var(--top-h) + 14px); } }

/* ---- cards (win, stuck) ---- */
.nh-scrim { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(20, 12, 6, .6); pointer-events: auto; animation: nhFade .25s ease; }
.nh-card { width: min(88vw, 360px); max-height: 92vh; overflow: auto; padding: 24px 20px 20px; border-radius: 26px; text-align: center; color: var(--ink);
  background: linear-gradient(#fff8e8, #fbeacb); border: 3px solid var(--ink); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .7), 0 8px 0 rgba(20, 12, 8, .5), 0 24px 40px rgba(0, 0, 0, .4); animation: nhPop .45s cubic-bezier(.2, .9, .3, 1.35); }
.nh-card h2 { margin: 0 0 8px; font: 700 30px/1.05 var(--disp); color: var(--ink); }
.nh-card p { margin: 0 0 16px; font: 600 15px/1.35 var(--body); color: var(--ink2); }
.nh-stars { display: flex; justify-content: center; gap: 6px; margin: 6px 0 12px; }
.nh-stars svg { width: 56px; height: 56px; transform: scale(0); }
.nh-stars svg.on { animation: nhStar .55s cubic-bezier(.2, .9, .3, 1.6) forwards; animation-delay: calc(var(--i) * .22s + .2s); }
.nh-stars svg.off { transform: scale(.85); }
.nh-reward { display: inline-flex; align-items: center; gap: 8px; padding: 4px 18px 6px 10px; border-radius: 999px; background: #fbe3a4; border: 2.5px solid var(--ink); font: 700 26px/1 var(--disp); margin-bottom: 16px; }
.nh-actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.nh-actions .nh-btn { width: 100%; }
.nh-row { display: flex; gap: 10px; } .nh-row .nh-btn { flex: 1; }
.nh-ad { display: inline-grid; place-items: center; min-width: 30px; height: 20px; padding: 0 5px; border-radius: 6px; font: 700 12px/1 var(--body); background: var(--ink); color: var(--cream); }

@keyframes nhBump { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes nhBumpC { 0% { transform: translateX(-50%) scale(1); } 40% { transform: translateX(-50%) scale(1.14); } 100% { transform: translateX(-50%) scale(1); } }
@keyframes nhReady { 0%, 100% { box-shadow: inset 0 -5px 0 var(--lip), 0 3px 0 var(--deep), 0 0 0 0 rgba(246, 207, 107, 0); } 50% { box-shadow: inset 0 -5px 0 var(--lip), 0 3px 0 var(--deep), 0 0 0 5px rgba(246, 207, 107, .9); } }
@keyframes nhFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes nhPop { from { transform: scale(.7) translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes nhStar { 0% { transform: scale(0) rotate(-40deg); } 70% { transform: scale(1.25) rotate(8deg); } 100% { transform: scale(1) rotate(0); } }
@media (prefers-reduced-motion: reduce) { .nh *, .nh *::before { animation-duration: .01s !important; animation-delay: 0s !important; transition-duration: .01s !important; } .nh-stars svg { transform: scale(1); } }

/* ---- R2-P6 armed Magnet: lit, pressed-in button + a ring on every bolt it can pull ---- */
.nh-boost.armed { background: linear-gradient(#8fdace, #55b3a5); box-shadow: inset 0 3px 0 #2f7e72, 0 0 0 3px #fff3dc, 0 0 0 6px #2f7e72; transform: translateY(2px); animation: none; }
.nh-boost.armed .nh-bic { animation: nhArm .7s ease-in-out infinite alternate; }
@keyframes nhArm { to { transform: translateY(-3px) rotate(-8deg); } }
.nh-rings { position: absolute; inset: 0; pointer-events: none; }
.nh-ring { position: absolute; width: 60px; height: 60px; margin: -30px 0 0 -30px; box-sizing: border-box; border-radius: 50%; border: 4px solid #f6cf6b; box-shadow: 0 0 0 2.5px #2a1d16, inset 0 0 0 2.5px #2a1d16, 0 0 18px 4px rgba(246, 207, 107, .55);
  animation: nhRing 1s ease-in-out infinite alternate; }
@keyframes nhRing { from { opacity: .55; transform: scale(.96); } to { opacity: 1; transform: scale(1.03); } }
@media (max-height: 520px) { .nh-ring { width: 48px; height: 48px; margin: -24px 0 0 -24px; } }
@media (prefers-reduced-motion: reduce) { .nh-ring, .nh-boost.armed .nh-bic { animation: none; } }

.nh-torque.off{visibility:hidden} /* 20 Nov: hidden until the Magnet it pays is unlocked (layout kept) */

/* 20 Nov: house button added to the top bar; round buttons keep 44 px, narrow phones tighten gaps and pills instead */
.nh-icon { flex: none; }
@media (max-width: 400px) { .nh-top { gap: 5px; } .nh-pill { padding: 0 10px 3px; font-size: 18px; } .nh-coins { padding: 0 10px 3px 6px; gap: 5px; } }

/* ---- Brolly Barges: berth meter (left, same row as the bell gauge) ---- */
.nh-berths { position: absolute; left: max(10px, env(safe-area-inset-left, 0px)); top: calc(env(safe-area-inset-top, 0px) + 8px + var(--top-h) + 2px); display: flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px 2px 8px; border-radius: 17px; border: 2.5px solid var(--ink); color: var(--cream); white-space: nowrap;
  background: linear-gradient(var(--oak), var(--oak2)); box-shadow: inset 0 0 0 1.5px var(--brass), 0 3px 0 rgba(26, 16, 10, .5);
  font: 700 14px/1 var(--disp); letter-spacing: .04em; transition: background .25s, transform .2s; }
.nh-berths b { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 3ch; text-align: center; padding: 3px 6px 4px; border-radius: 9px; background: rgba(26, 16, 10, .45); }
.nh-berths.warn { background: linear-gradient(#e0a02a, #b9741a); color: #2a1d16; }
.nh-berths.warn b { background: rgba(255, 243, 220, .55); }
.nh-berths.full { background: linear-gradient(#e2573b, #a63220); }
.nh-berths.full b { background: rgba(60, 10, 4, .5); }
.nh-berths.shake { animation: nhShake .45s cubic-bezier(.3, .6, .4, 1); }
@keyframes nhShake { 0%, 100% { transform: none; } 15% { transform: translateX(-6px) rotate(-2deg); } 35% { transform: translateX(6px) rotate(2deg) scale(1.06); } 55% { transform: translateX(-4px) rotate(-1deg) scale(1.06); } 75% { transform: translateX(3px); } }
@media (prefers-reduced-motion: reduce) { .nh-berths.shake { animation: none; } }
@media (max-width: 380px) { .nh-berths { padding: 0 9px 2px 6px; font-size: 13px; } .nh-bl2 { max-width: 7ch; overflow: hidden; text-overflow: ellipsis; } }
@media (max-height: 520px) { .nh-berths { top: calc(env(safe-area-inset-top, 0px) + 13px); left: calc(50% - 150px); } .nh-torque { right: auto; left: calc(50% + 10px); } }
.nh-card.fail .nh-failrow { display: flex; flex-direction: column; gap: 10px; align-items: stretch; margin-top: 8px; }

/* Hoist tug picker: sits just above the booster bar, thumb height */
.nh-pick { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--bot-h) + env(safe-area-inset-bottom, 0px) + 10px); display: flex; align-items: center; gap: 8px; pointer-events: auto;
  max-width: calc(100vw - 20px); padding: 8px 8px 9px 10px; border-radius: 20px; border: 3px solid var(--ink); background: linear-gradient(var(--oak), var(--oak2)); box-shadow: inset 0 0 0 2px var(--brass), 0 4px 0 rgba(26, 16, 10, .5);
  animation: nhPick .22s cubic-bezier(.2, .9, .3, 1.3); }
@keyframes nhPick { from { opacity: 0; transform: translate(-50%, 14px); } }
.nh-pickrow { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.nh-pickbtn { position: relative; flex: 0 0 auto; width: 56px; height: 56px; border-radius: 15px; border: 2.5px solid var(--ink); background: var(--paper); box-shadow: inset 0 -4px 0 var(--lip), 0 3px 0 rgba(26, 16, 10, .5); display: grid; place-items: center; padding: 0 0 3px; cursor: pointer; }
.nh-pickbtn:active { transform: translateY(2px); }
.nh-pickbtn i { position: absolute; right: -4px; top: -6px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--ink); color: var(--cream); font: 800 12px/20px var(--disp); text-align: center; font-style: normal; }
.nh-pickx { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 14px; border: 2.5px solid var(--ink); background: #c8553a; display: grid; place-items: center; padding: 0 0 3px; cursor: pointer; }
@media (max-height: 520px) { .nh-pick { bottom: calc(var(--bot-h) + 4px); } }

/* Crane confirm bar: two big buttons above the booster bar */
.nh-confirm { gap: 10px; padding: 8px 10px 9px; }
.nh-cbtn { min-width: 112px; height: 52px; padding: 0 16px; border-radius: 16px; border: 2.5px solid var(--ink); font: 800 17px/1 var(--disp); color: var(--ink); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--paper); box-shadow: inset 0 -4px 0 var(--lip), 0 3px 0 rgba(26, 16, 10, .5); }
.nh-cbtn.ok { background: linear-gradient(#ffd45c, #f0a626); }
.nh-cbtn:active { transform: translateY(2px); }

/* booster explainer chip: a small '?' on the corner of each booster (hit area 44 px); the sheet is in meta-ui.js / booster-info.js */
.nh-q { position: absolute; top: -7px; left: -7px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: #3b86a8; color: #fff; border: 2px solid #fff3dc;
  font: 800 12px/1 var(--disp); box-shadow: 0 2px 0 rgba(40,20,10,.3); }
.nh-q::after { content: ""; position: absolute; inset: -12px; border-radius: 50%; }
.nh-boost.locked .nh-q { background: #8a7a62; }
@media (max-height: 440px) { .nh-q { top: -6px; left: -6px; } }
