/* Trickshot Almanac — flat candy-vector UI chrome over the rendered world,
   adapted from Corner Pocket's chip/cta/panel system. Menu is now the
   scrollable Trick Book (chapters grid + modes); overlay hosts chapter shot
   lists, cosmetics, and solved/daily cards. */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: #1b2a3a; font-family: 'Segoe UI', system-ui, sans-serif; overflow: hidden; }

#stage { position: relative; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 8px 0; }
canvas { max-width: 100vw; max-height: calc(100vh - 16px); aspect-ratio: 520 / 900; touch-action: none; border-radius: 14px; min-height: 0; flex: 0 1 auto; }
#hud:not(.hide) ~ * canvas, #stage:has(#hud:not(.hide)) canvas { max-height: calc(100vh - 90px); }

.hide { display: none !important; }

/* HUD — in flow above the canvas so chips never cover the table */
#hud { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; width: min(96vw, 640px); }
.chip { background: #fff; border-radius: 999px; padding: 10px 14px; font-weight: 700; font-size: 15px; color: #23445c; box-shadow: 0 3px 0 rgba(0,0,0,.25); border: none; text-decoration: none; min-height: 48px; display: inline-flex; align-items: center; }
.chip.btn { cursor: pointer; }
.chip.home { background: #ffd166; }
.chip.hint { background: #ffe27a; }
.chip.wide { max-width: 40vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Menu (Trick Book) */
#menu { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 14px;
  background: linear-gradient(180deg, #ff6fa5 0%, #ffd166 55%, #3fc463 130%); text-align: center; padding: 24px 20px; overflow-y: auto; }
#menu h1 { font-size: clamp(30px, 6vw, 46px); color: #fff; text-shadow: 0 4px 0 rgba(0,0,0,.2); margin-top: 8px; }
.tag { color: #3a2a1a; font-weight: 700; }
.banner { background: #fff; border-radius: 12px; padding: 10px 16px; font-weight: 800; color: #23445c; box-shadow: 0 4px 0 rgba(0,0,0,.2); }
.modes { display: flex; flex-direction: column; gap: 12px; width: min(86vw, 340px); }

/* Trick Book chapter grid */
.chapters { display: flex; flex-direction: column; gap: 10px; width: min(90vw, 380px); margin: 6px 0; }
.chapter-row { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; background: #fff; border: none; border-radius: 14px;
  padding: 12px 16px; cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,.2); text-align: left; }
.chapter-row:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.2); }
.chapter-row.locked { opacity: .6; cursor: not-allowed; }
.chapter-name { font-weight: 800; color: #23445c; font-size: 16px; }
.chapter-sub { font-weight: 600; color: #5d7891; font-size: 13px; }

/* Chapter shot list (inside #overlay .panel) */
.shot-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; max-height: 50vh; overflow-y: auto; }
.shot-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; background: #f2f6fa; border: none;
  border-radius: 12px; padding: 10px 12px; cursor: pointer; text-align: left; }
.shot-row:active { background: #e2ecf5; }
.shot-name { font-weight: 700; color: #23445c; font-size: 14px; }
.shot-stars { color: #ffb703; font-size: 14px; }
.shot-best { color: #5d7891; font-size: 12px; font-weight: 600; }

/* Cosmetics picker */
.cosmetic-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 8px 0 14px; }
.cosmetic-chip { background: #f2f6fa; border: 2px solid transparent; border-radius: 10px; padding: 8px 12px; font-weight: 700;
  font-size: 12px; color: #23445c; cursor: pointer; }
.cosmetic-chip:disabled { opacity: .55; cursor: not-allowed; }
.cosmetic-chip.equipped { border-color: #3fc463; background: #e5f9ea; }
.panel h3 { color: #23445c; margin-top: 12px; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; }
.cta { background: #3fc463; color: #fff; font-size: 20px; font-weight: 800; border: none; border-radius: 16px; padding: 16px; cursor: pointer;
  box-shadow: 0 5px 0 #1f8f43; min-height: 56px; }
.cta:active { transform: translateY(3px); box-shadow: 0 2px 0 #1f8f43; }
.cta.alt { background: #a077ff; box-shadow: 0 5px 0 #7a50d6; }
.cta small { display: block; font-size: 12px; font-weight: 600; opacity: .9; }
.ghost { background: transparent; border: 2px solid rgba(255,255,255,.8); color: #fff; border-radius: 12px; padding: 10px 18px; font-weight: 700; cursor: pointer; text-decoration: none; }
.hint { color: rgba(0,0,0,.55); font-size: 13px; line-height: 1.5; }

/* Overlays */
#overlay { position: absolute; inset: 0; background: rgba(20, 35, 50, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.panel { background: #fff; border-radius: 20px; padding: 24px; width: min(92vw, 420px); text-align: center; box-shadow: 0 8px 0 rgba(0,0,0,.25); max-height: 88vh; overflow-y: auto; }
.panel h2 { color: #23445c; margin-bottom: 6px; }
.panel p { color: #23445c; margin: 4px 0; }
.panel .big { font-size: 22px; font-weight: 800; color: #23445c; margin: 6px 0; }
.panel .stars { font-size: 34px; }
.panel .rec { color: #d94a80; font-weight: 800; }
.panel .cta { width: 100%; margin-top: 10px; font-size: 18px; }
.panel .ghost { display: inline-block; margin-top: 10px; border-color: #23445c; color: #23445c; }
table.card { margin: 10px auto; border-collapse: collapse; font-size: 12px; }
table.card td, table.card th { border: 1px solid #dde5ee; padding: 3px 6px; color: #23445c; }
table.card .dim { color: #8aa0b4; }
