/* Dragonle – retro pixel style. No rounded corners: every frame is a notched pixel border. */
:root {
  --night1: #1c1240;
  --night2: #2d1b63;
  --paper: #f4e6c0;
  --paper2: #e8d39c;
  --paper3: #d9bd78;
  --ink: #1b1024;
  --ink2: #4a3a5e;
  --mute: #7d6f8c;
  --red: #e04434;
  --yellow: #ffd23f;
  --orange: #f08a2a;
  --teal: #2ea89c;
  --blue: #3a76e0;
  --purple: #7b4fd0;
  --pink: #e8609e;
  --green: #3fa356;
  --font: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  --head: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  --display: 'Silkscreen', 'Courier New', monospace; /* blocky pixel font, only for big titles */
  --navh: 68px;
  /* pixel border (notched corners) and hard pixel drop shadow */
  --pb: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink);
  --pb2: 0 -2px 0 0 var(--ink), 0 2px 0 0 var(--ink), -2px 0 0 0 var(--ink), 2px 0 0 0 var(--ink);
  --drop: 3px 6px 0 0 rgba(0,0,0,.55), 6px 3px 0 0 rgba(0,0,0,.55);
  --drop-s: 3px 3px 0 0 rgba(0,0,0,.5);
  /* 2×2 pixel dither dots */
  --dither: conic-gradient(from 90deg at 2px 2px, rgba(27,16,36,.09) 90deg, transparent 0) 0 0 / 6px 6px;
  --dither-light: conic-gradient(from 90deg at 2px 2px, rgba(255,255,255,.06) 90deg, transparent 0) 0 0 / 6px 6px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--dither-light), linear-gradient(180deg, var(--night2), var(--night1) 640px);
  background-color: var(--night1);
  color: var(--ink);
  font: 17px/1.35 var(--font);
  min-height: 100vh;
  padding-bottom: calc(var(--navh) + env(safe-area-inset-bottom));
  font-variant-ligatures: none;
}
img, canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
.ico { display: inline-block; vertical-align: middle; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2 { font-family: var(--display); font-weight: 700; margin: 0; letter-spacing: 0; }
h3 { font-family: var(--head); font-weight: 800; margin: 0; letter-spacing: .2px; }
h2 { font-size: 24px; line-height: 1.1; }
h3 { font-size: 15px; line-height: 1.2; }
p { margin: .35em 0; }
a { color: var(--blue); font-weight: 700; }
small, .dim { color: var(--ink2); }
.mute { color: var(--mute); }
.good { color: #1f7a34; }
.bad { color: #b8261a; }
.epic { color: #5e2bb8; }
.goldt { color: #a06a00; }
b { font-weight: 700; }

/* ---------------------------------------------------------------- frames & buttons */
.panel { background: var(--paper); box-shadow: var(--pb), var(--drop); padding: 12px; margin: 3px; }
.panel.alt { background: var(--dither), var(--paper2); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 4px 12px; margin: 3px;
  background: var(--yellow); color: var(--ink); border: 0;
  box-shadow: var(--pb), inset 0 -4px 0 0 rgba(0,0,0,.22), inset 0 3px 0 0 rgba(255,255,255,.45), var(--drop-s);
  font-weight: 700; font-size: 16px; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translate(3px, 3px); box-shadow: var(--pb), inset 0 4px 0 0 rgba(0,0,0,.2); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: grayscale(.6); transform: none; }
.btn.ember { background: var(--orange); }
.btn.go { background: var(--teal); color: #fff; text-shadow: 2px 2px 0 rgba(0,0,0,.4); }
.btn.ghost { background: #fbf4e0; }
.btn.small { min-height: 28px; padding: 1px 9px; font-size: 15px; }
.btn.danger { background: var(--red); color: #fff; text-shadow: 2px 2px 0 rgba(0,0,0,.4); }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; background: var(--ink); border-bottom: 3px solid #000;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 24px; line-height: 1; color: var(--yellow); text-shadow: 3px 0 0 var(--red), 0 3px 0 var(--red), 3px 3px 0 var(--red), 6px 6px 0 #000; }
.brand .ico { animation: hop 1.2s steps(1) infinite; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px 1px 5px; margin: 3px; background: var(--paper); box-shadow: var(--pb2), 0 0 0 0 transparent; font-size: 16px; white-space: nowrap; color: var(--ink); }
.chip.gold { background: var(--yellow); }
.tools { display: flex; gap: 8px; }
.tool { width: 38px; height: 38px; border: 0; margin: 2px; background: var(--paper); box-shadow: var(--pb2); display: grid; place-items: center; padding: 0; }
.tool small { font-family: var(--head); font-weight: 800; font-size: 8px; color: var(--ink); line-height: 1; }

/* ---------------------------------------------------------------- sky */
.sky-wrap { position: relative; height: 162px; border-bottom: 3px solid #000; overflow: hidden; background: #0d0a24; }
.sky { width: 100%; height: 100%; display: block; }
.sky-info { position: absolute; left: 12px; bottom: 16px; font-size: 14px; font-weight: 700; color: var(--ink); background: var(--paper); box-shadow: var(--pb2); padding: 0 8px; pointer-events: none; }
.tension { position: absolute; right: 12px; top: 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.tension[hidden] { display: none; }
.tension-label { font-family: var(--head); font-weight: 800; font-size: 13px; color: var(--yellow); text-shadow: 2px 2px 0 #000; }
.tension-bar { width: 180px; height: 12px; background: #2a0a10; box-shadow: var(--pb2); }
.tension-bar i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(90deg, var(--red) 0 6px, var(--orange) 6px 9px); }

/* ---------------------------------------------------------------- view */
.view { max-width: 1140px; margin: 0 auto; padding: 16px 14px 28px; outline: none; }
.screen-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.screen-head h2 { color: var(--yellow); text-shadow: 3px 3px 0 #000; }
.screen-head .sub { color: #e2d6ff; flex: 1; font-size: 16px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.cols-4 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.section { margin: 24px 0 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.section h3 { color: #fff; background: var(--purple); box-shadow: var(--pb2), 3px 3px 0 0 #000; padding: 3px 10px; margin: 2px; text-shadow: 2px 2px 0 #000; }
.section small { color: #e2d6ff; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs .btn { background: var(--paper); }
.tabs .btn.on { background: var(--pink); color: #fff; text-shadow: 2px 2px 0 rgba(0,0,0,.4); }
.empty { padding: 18px; text-align: center; color: var(--ink2); }
.sw { display: inline-block; width: 12px; height: 12px; vertical-align: -1px; box-shadow: 0 -2px 0 0 var(--ink), 0 2px 0 0 var(--ink), -2px 0 0 0 var(--ink), 2px 0 0 0 var(--ink); margin: 0 3px; }
.tag { display: inline-block; padding: 0 6px; font-size: 13px; font-weight: 700; background: #fbf4e0; box-shadow: var(--pb2); margin: 2px 5px 2px 2px; }
.tag.pure { background: var(--yellow); }
.tag.deep { background: var(--ink); color: #c9b8ff; }
.tag.imp { background: var(--pink); color: #fff; }
.tag.mat { background: repeating-linear-gradient(90deg, #fff6b0 0 4px, #ffd23f 4px 8px); }
.tag.war { background: var(--red); color: #fff; }
.tag.role { background: var(--yellow); }
.tag.restless { background: var(--orange); animation: blink 1s steps(1) infinite; }

/* bars: segmented pixel bars */
.bar { height: 12px; background: #fbf4e0; box-shadow: var(--pb2); position: relative; overflow: hidden; margin: 2px; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: repeating-linear-gradient(90deg, var(--green) 0 5px, #2f8a44 5px 6px); }
.bar.gold > i { background: repeating-linear-gradient(90deg, var(--yellow) 0 5px, #d9a514 5px 6px); }
.bar.ember > i { background: repeating-linear-gradient(90deg, var(--orange) 0 5px, #b8601a 5px 6px); }
.vec { display: flex; height: 12px; box-shadow: var(--pb2); margin: 2px; background: #fbf4e0; }
.vec span { height: 100%; }
.vecrows { display: grid; gap: 7px; }
.vecrow { display: grid; grid-template-columns: 116px 1fr 48px; gap: 8px; align-items: center; font-size: 15px; }
.vecrow .bar { height: 16px; }
.vecrow .bar > i { transition: width .45s steps(8); }

/* ---------------------------------------------------------------- world / portals */
.hub { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 18px; }
.portal { position: relative; padding: 12px 10px; margin: 3px; text-align: center; background: var(--paper); box-shadow: var(--pb), var(--drop); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.portal[data-act] { cursor: pointer; }
.portal[data-act]:hover { transform: translateY(-3px); }
.portal .art { position: relative; width: 104px; height: 120px; }
.portal .art img { position: absolute; inset: 0; }
.portal .art img.f1 { animation: swap .9s steps(1) infinite; }
.portal.closed .art::after { content: 'CLOSED'; position: absolute; left: -8px; right: -8px; top: 50px; background: var(--red); color: #fff; font-family: var(--display); font-weight: 700; font-size: 15px; box-shadow: var(--pb2); text-shadow: 2px 2px 0 #000; }
.portal .pname { font-family: var(--head); font-weight: 800; font-size: 15px; line-height: 1.1; }
.portal .pinfo { font-size: 14px; color: var(--ink2); display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.portal .pinfo b { color: var(--ink); }
.portal .badge { position: absolute; top: -10px; right: -8px; background: var(--red); color: #fff; font-weight: 700; font-size: 14px; padding: 0 7px; box-shadow: var(--pb2); animation: hop 1s steps(1) infinite; z-index: 2; }

/* ---------------------------------------------------------------- zone */
.zone-head { --zc: #888; display: flex; gap: 12px; align-items: center; padding: 10px 14px; margin: 3px 3px 8px; background: var(--dither), var(--zc); box-shadow: var(--pb), var(--drop); flex-wrap: wrap; }
.zone-head h2 { flex: 1; color: #fff; text-shadow: 3px 3px 0 #000, -2px 0 0 #000, 0 -2px 0 #000; }
.zone-head .info { background: var(--paper); box-shadow: var(--pb2); padding: 0 8px; font-size: 15px; margin: 2px; }
.incs { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.inc { position: relative; height: 190px; margin: 3px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 8px; gap: 6px; background: var(--dither), var(--paper); box-shadow: var(--pb), var(--drop); }
.inc .hatch { position: absolute; left: 50%; bottom: 44px; transform: translateX(-50%); }
.inc .hatch img { display: block; }
.inc .hatch img.f1 { position: absolute; inset: 0; animation: swap 0.8s steps(1) infinite; }
.inc .eggimg { position: absolute; left: 50%; bottom: 68px; transform: translateX(-50%); z-index: 1; cursor: pointer; }
.inc.oven .eggimg { bottom: 50px; }
.inc .eggimg img { display: block; }
.inc .eggimg.ready img { animation: shake .2s steps(1) infinite; }
.inc .eggimg.crack1 img { animation: shake 1.2s steps(1) infinite; }
.inc .eggimg.crack2 img { animation: shake .6s steps(1) infinite; }
.inc .eggimg.ready::before { content: 'CLICK!'; position: absolute; top: -22px; left: 50%; transform: translateX(-50%); font-family: var(--display); font-weight: 700; font-size: 13px; color: var(--yellow); text-shadow: 2px 2px 0 #000, -2px 0 0 #000; animation: hop .5s steps(1) infinite; white-space: nowrap; }
.inc .inc-label { font-size: 14px; color: var(--ink); position: relative; z-index: 1; text-align: center; }
.inc .bar { width: 100%; position: relative; z-index: 1; }
.inc.free { justify-content: center; }
.inc .placeholder-note { position: absolute; top: 6px; left: 8px; font-size: 12px; color: var(--mute); }
.ground { position: relative; height: 230px; margin: 3px; background: var(--dither), linear-gradient(transparent 70%, rgba(0,0,0,.2)), color-mix(in srgb, var(--zc) 40%, #3a2a50); box-shadow: var(--pb), var(--drop); overflow: hidden; touch-action: manipulation; }
.ground .empty { color: #fff; text-shadow: 2px 2px 0 #000; }
.scale { position: absolute; transform: translate(-50%, -50%); padding: 6px; cursor: pointer; border: 0; background: transparent; }
.scale.new { animation: fall .5s steps(5) both; }
.scale img { display: block; }
.scale:hover img { transform: translateY(-3px); }
.scale.glint img { animation: glint 1.2s steps(1) infinite; }
.scale.locked { opacity: .45; filter: grayscale(.7); cursor: not-allowed; }
.pop { position: absolute; transform: translate(-50%, -100%); pointer-events: none; font-family: var(--display); font-weight: 700; font-size: 16px; color: var(--yellow); text-shadow: 2px 2px 0 #000, -2px 0 0 #000; animation: rise .8s steps(6) forwards; white-space: nowrap; z-index: 3; }
.combo { position: absolute; right: 12px; top: 10px; font-family: var(--display); font-weight: 700; font-size: 18px; color: #fff; background: var(--red); padding: 2px 10px; box-shadow: var(--pb2), 3px 3px 0 0 #000; z-index: 3; text-shadow: 2px 2px 0 #000; }

/* ---------------------------------------------------------------- cards */
.card { display: flex; gap: 12px; align-items: center; padding: 10px; margin: 3px; background: var(--paper); box-shadow: var(--pb), var(--drop); }
.card.click { cursor: pointer; }
.card.click:hover { transform: translateY(-2px); }
.card .pic { flex: 0 0 auto; width: 104px; height: 72px; display: grid; place-items: center; background: var(--dither), #fbf4e0; box-shadow: var(--pb2); margin: 2px; cursor: pointer; }
.card .meta { flex: 1; min-width: 0; display: grid; gap: 4px; }
.card .meta .nm { font-weight: 700; font-size: 17px; }
.card .acts { display: flex; gap: 4px; flex-wrap: wrap; }
.mature { color: #b05000; font-weight: 700; }

/* ---------------------------------------------------------------- nesting ground */
select { font: inherit; color: var(--ink); background: #fbf4e0; border: 0; padding: 5px 8px; margin: 3px; max-width: 100%; width: calc(100% - 6px); box-shadow: var(--pb2); }
.rngbar { height: 10px; background: var(--paper2); box-shadow: var(--pb2); position: relative; margin: 2px; }
.rngbar i { position: absolute; top: 0; bottom: 0; }

/* clutch animation – pixel nest */
.clutch { display: grid; gap: 12px; justify-items: center; text-align: center; }
.pxnest { position: relative; }
.pxnest > img { display: block; }
.pxnest .slots { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); display: grid; grid-template-columns: repeat(6, 30px); gap: 4px 6px; justify-items: center; }
.pxnest .slot { width: 30px; height: 36px; position: relative; }
.pxnest .slot img { position: absolute; inset: 0; }
.pxnest .slot.off img { visibility: hidden; }
.pxnest .slot.real img.sh { visibility: hidden; }
.pxnest .slot img.egg { visibility: hidden; }
.pxnest .slot.real img.egg { visibility: visible; animation: pop .3s steps(3); }
.pxnest.flicker > img { animation: flicker .25s steps(1) infinite; }
.pxnest .smoke { position: absolute; left: 0; right: 0; top: -10px; font-family: var(--head); font-weight: 800; color: #ddd; text-shadow: 2px 2px 0 #000; animation: rise 1.6s steps(8) forwards; }
.counter { font-family: var(--display); font-weight: 700; font-size: 38px; line-height: 1; color: var(--yellow); text-shadow: 3px 3px 0 var(--red), 6px 6px 0 #000; min-height: 44px; }
.counter.spin { color: #fff; }
.rolls { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; font-size: 15px; }
.rolls span { padding: 0 8px; background: #fbf4e0; box-shadow: var(--pb2); margin: 2px; font-weight: 700; }
.beam { position: fixed; left: 50%; top: 0; bottom: 0; width: 84px; transform: translateX(-50%); background: repeating-linear-gradient(90deg, rgba(255,240,170,.85) 0 12px, rgba(255,255,255,.95) 12px 24px); pointer-events: none; animation: beam 1.6s steps(8) forwards; z-index: 80; }

/* ---------------------------------------------------------------- market */
.offer { display: grid; gap: 6px; justify-items: center; text-align: center; padding: 14px 12px; }
.offer .oname { font-family: var(--head); font-weight: 800; font-size: 15px; }
.offer .price { font-family: var(--head); font-weight: 800; font-size: 17px; background: var(--yellow); padding: 1px 10px; box-shadow: var(--pb2); margin: 2px; }
.offer .timer { width: 100%; }
.offer.wonder { background: var(--dither), var(--pink); color: #fff; }
.offer.wonder small, .offer.wonder .dim { color: #fff; }
.offer.wonder .oname { text-shadow: 2px 2px 0 #000; }

/* ---------------------------------------------------------------- factions */
.fac { display: grid; gap: 8px; }
.fac-head { display: flex; gap: 8px; align-items: center; margin: -12px -12px 2px; padding: 8px 12px; border-bottom: 3px solid var(--ink); }
.fac-head h3 { flex: 1; font-size: 17px; color: #fff; text-shadow: 2px 2px 0 #000, -2px 0 0 #000, 0 -2px 0 #000; }
.fac .needs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; font-size: 13px; font-weight: 700; }
.fac .needs.alarm .bar { animation: alarm .6s steps(1) infinite; }
.fac .acts { display: grid; gap: 8px; }
.act { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; padding: 6px 8px; margin: 2px; background: #fbf4e0; box-shadow: var(--pb2); font-size: 14px; }
.act .grp { font-family: var(--head); font-weight: 800; font-size: 10px; font-weight: 700; text-transform: uppercase; padding: 0 5px; box-shadow: var(--pb2); margin: 0 3px 0 2px; color: #fff; }
.act .grp.neutral { background: var(--green); } .act .grp.war { background: var(--red); } .act .grp.counter { background: var(--orange); } .act .grp.group { background: var(--purple); }
.act.done { opacity: .5; }
.repbar { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; font-size: 14px; }
.matrix { border-collapse: collapse; font-size: 12px; margin: 0 auto; }
.matrix th, .matrix td { width: 32px; height: 28px; text-align: center; padding: 0; }
.matrix td { border: 2px solid var(--ink); font-weight: 700; }
.matrix-wrap { overflow-x: auto; }
.net { width: 100%; max-width: 580px; display: block; margin: 6px auto; background: var(--dither), #fbf4e0; box-shadow: var(--pb2); shape-rendering: crispEdges; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 14px; justify-content: center; margin-top: 8px; }
.kingbox { display: flex; gap: 10px; align-items: center; }
.kingbox .pic { width: 104px; height: 72px; display: grid; place-items: center; background: var(--dither), var(--yellow); box-shadow: var(--pb2); margin: 2px; cursor: pointer; }

/* ---------------------------------------------------------------- bag & collection */
table.list { width: 100%; border-collapse: collapse; font-size: 15px; }
table.list th { text-align: left; font-family: var(--head); font-weight: 800; font-size: 12px; padding: 6px; border-bottom: 3px solid var(--ink); }
table.list td { padding: 5px 6px; border-bottom: 2px dashed rgba(27,16,36,.2); vertical-align: middle; }
.table-wrap { overflow-x: auto; }
.coll { display: grid; grid-template-columns: 110px repeat(20, 24px); gap: 4px; font-size: 12px; align-items: center; font-weight: 700; }
.coll .cell { width: 22px; height: 22px; background: var(--dither), #fbf4e0; box-shadow: var(--pb2); margin: 2px; }
.coll .cell.have { outline: 2px solid #fff; outline-offset: -4px; }

/* ---------------------------------------------------------------- log */
.log { display: grid; gap: 8px; font-size: 15px; }
.log .li { display: grid; grid-template-columns: 74px 1fr; gap: 8px; padding: 6px 8px; margin: 2px; background: var(--paper); box-shadow: var(--pb2); }
.log .li .t { color: var(--mute); font-weight: 700; }
.log .li.good { border-left: 6px solid var(--green); } .log .li.bad { border-left: 6px solid var(--red); } .log .li.epic { border-left: 6px solid var(--purple); } .log .li.war { border-left: 6px solid var(--orange); }
.hist { display: grid; grid-template-columns: repeat(13, 1fr); gap: 4px; align-items: end; height: 130px; }
.hist .col { display: grid; align-items: end; height: 100%; position: relative; }
.hist .col i { display: block; background: repeating-linear-gradient(0deg, var(--yellow) 0 5px, #d9a514 5px 6px); box-shadow: 0 -2px 0 0 var(--ink), -2px 0 0 0 var(--ink), 2px 0 0 0 var(--ink); }
.hist .col b { display: block; position: absolute; left: -2px; right: -2px; border-top: 3px dashed var(--purple); }
.hist-x { display: grid; grid-template-columns: repeat(13, 1fr); gap: 4px; font-size: 13px; text-align: center; font-weight: 700; border-top: 3px solid var(--ink); }

/* ---------------------------------------------------------------- modal, toasts, bursts */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 14px; background: var(--dither-light), rgba(12,6,28,.78); }
.modal[hidden] { display: none; }
.modal-box { position: relative; width: min(100%, 600px); max-height: calc(100vh - 28px); overflow: auto; background: var(--paper); box-shadow: 0 -4px 0 0 var(--ink), 0 4px 0 0 var(--ink), -4px 0 0 0 var(--ink), 4px 0 0 0 var(--ink), inset 0 0 0 3px var(--paper2), 8px 8px 0 0 #000; padding: 20px 18px 18px; animation: pop .18s steps(3); }
.modal-box.wide { width: min(100%, 860px); }
.modal-x { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border: 0; background: var(--red); color: #fff; font-weight: 700; box-shadow: var(--pb2); }
.modal h2 { margin-bottom: 12px; padding-right: 36px; color: var(--ink); font-size: 22px; text-shadow: 2px 2px 0 var(--paper3); }
.modal h3 { margin: 12px 0 6px; }
.center { text-align: center; }
.reveal { display: grid; gap: 10px; justify-items: center; text-align: center; }
.hero { position: relative; display: grid; place-items: center; min-width: 176px; min-height: 150px; }
.hero > .bst { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.hero > .bst.f1 { animation: swap .5s steps(1) infinite; }
.hero > .fg { position: relative; z-index: 1; animation: pop .3s steps(3); }
.hero.mat > .fg { animation: pop .3s steps(3), glint 1s steps(1) infinite; }
.reveal .big { font-family: var(--display); font-weight: 700; font-size: 20px; }
.labels { display: grid; gap: 6px; }
.labels .btn { background: #fbf4e0; }
.labels .btn.on { background: var(--teal); color: #fff; }
/* pixel speech bubble: notched border + stair-step tail */
.bubble { --bb: #fffaf0; position: relative; background: var(--bb); box-shadow: var(--pb); margin: 3px 3px 16px; padding: 10px 12px; }
.bubble::after { content: ''; position: absolute; left: 24px; bottom: -3px; width: 3px; height: 3px; background: transparent;
  box-shadow: 0 0 0 0 var(--ink), 3px 0 0 0 var(--bb), 6px 0 0 0 var(--bb), 9px 0 0 0 var(--ink),
              3px 3px 0 0 var(--ink), 6px 3px 0 0 var(--bb), 9px 3px 0 0 var(--ink),
              6px 6px 0 0 var(--ink), 9px 6px 0 0 var(--ink),
              9px 9px 0 0 var(--ink); }
.riddle { display: grid; gap: 4px; font-size: 17px; }
.riddle i { font-style: normal; }
.toasts { position: fixed; right: 14px; bottom: calc(var(--navh) + 16px); z-index: 70; display: grid; gap: 4px; justify-items: end; pointer-events: none; }
.toast { max-width: 340px; font-size: 15px; font-weight: 600; animation: slide .2s steps(3), fade .4s steps(3) 3.6s forwards; }
.toast::after { left: auto; right: 24px; }
.toast.good { --bb: #d6f5d0; } .toast.bad { --bb: #f8d4cc; } .toast.epic { --bb: #e4d6ff; } .toast.war { --bb: #fbdcba; }
.flash { position: fixed; inset: 0; pointer-events: none; z-index: 90; background: #fff; opacity: 0; }
.flash.on { animation: flash .5s steps(4); }
.fanfare { font-family: var(--display); font-weight: 700; font-size: 22px; color: var(--yellow); text-shadow: 3px 3px 0 var(--red), 6px 6px 0 #000; animation: hop .6s steps(1) infinite; display: inline-block; }
.burstbox { position: relative; display: grid; place-items: center; min-height: 140px; min-width: 240px; }
.burstbox > img { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.burstbox > img.f1 { animation: swap .5s steps(1) infinite; }
.burstbox > span { position: relative; }
.burstbox > .fanfare.long { font-size: 15px; max-width: 130px; text-align: center; line-height: 1.25; }

/* ---------------------------------------------------------------- handbook */
.book { display: grid; grid-template-columns: 190px 1fr; gap: 16px; }
.book .toc { display: grid; gap: 4px; align-content: start; }
.book .toc .btn { justify-content: flex-start; background: #fbf4e0; font-size: 14px; white-space: normal; text-align: left; }
.book .toc .btn.on { background: var(--yellow); }
.book .page { min-height: 380px; }
.book .page h3 { font-size: 16px; margin: 14px 0 6px; }
.book .page p { line-height: 1.45; }
.book .fig { display: flex; gap: 10px; align-items: flex-end; justify-content: center; flex-wrap: wrap; padding: 10px; margin: 8px 3px; background: var(--dither), #fbf4e0; box-shadow: var(--pb2); }
.book .fig figcaption { width: 100%; text-align: center; font-size: 13px; color: var(--ink2); }
.book .tip { background: var(--dither), #fff1b8; box-shadow: var(--pb2); margin: 10px 3px; padding: 8px 10px; font-size: 15px; }
.book .tip b:first-child { font-family: var(--head); font-weight: 800; font-size: 12px; }
.book table { border-collapse: collapse; margin: 6px 0; font-size: 14px; }
.book td, .book th { padding: 2px 8px; border-bottom: 2px dashed rgba(27,16,36,.2); text-align: left; }
.book .pager { display: flex; justify-content: space-between; margin-top: 14px; }
.book .chapno { font-family: var(--head); font-weight: 800; font-size: 11px; color: var(--mute); }

/* ---------------------------------------------------------------- navigation */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(8, 1fr);
  height: calc(var(--navh) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--paper); border-top: 3px solid var(--ink); box-shadow: 0 -3px 0 0 #000;
}
.nav button { border: 0; border-right: 3px solid var(--paper2); background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-family: var(--head); font-weight: 800; font-size: 10px; font-weight: 700; color: var(--ink); position: relative; }
.nav button:hover .ico { transform: translateY(-3px); }
.nav button.on { background: var(--dither), var(--yellow); }
.nav button .dot { position: absolute; top: 6px; right: calc(50% - 26px); width: 9px; height: 9px; background: var(--red); box-shadow: var(--pb2); animation: hop 1s steps(1) infinite; }

/* ---------------------------------------------------------------- animations (all stepped) */
@keyframes hop { 50% { transform: translateY(-3px); } }
@keyframes swap { 0% { opacity: 1; } 50% { opacity: 0; } }
@keyframes flicker { 50% { filter: brightness(1.2); } }
@keyframes shake { 0% { transform: translateX(-3px); } 50% { transform: translateX(3px); } }
@keyframes blink { 50% { opacity: .45; } }
@keyframes beat { 50% { transform: scale(1.25); } }
@keyframes alarm { 50% { background: #f8c8bc; } }
@keyframes fall { 0% { transform: translate(-50%, -260%); opacity: 0; } 70% { transform: translate(-50%, -40%); opacity: 1; } 100% { transform: translate(-50%, -50%); } }
@keyframes glint { 50% { filter: brightness(1.45); } }
@keyframes rise { to { transform: translate(-50%, -280%); opacity: 0; } }
@keyframes pop { 0% { transform: scale(.5); } 60% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes slide { from { transform: translateX(36px); opacity: 0; } }
@keyframes fade { to { opacity: 0; transform: translateY(6px); } }
@keyframes flash { 0% { opacity: .7; } 100% { opacity: 0; } }
@keyframes beam { 0% { opacity: 0; width: 12px; } 30% { opacity: 1; width: 120px; } 100% { opacity: 0; width: 48px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; }
}
@media (max-width: 700px) {
  body { font-size: 16px; }
  .brand-name { font-size: 18px; }
  .sky-wrap { height: 132px; }
  .nav button { font-size: 8px; }
  .chip.time { display: none; }
  .cols-2 { grid-template-columns: 1fr; }
  .vecrow { grid-template-columns: 92px 1fr 42px; }
  .coll { grid-template-columns: 74px repeat(20, 14px); }
  .coll .cell { width: 12px; height: 12px; }
  h2 { font-size: 20px; }
  .book { grid-template-columns: 1fr; }
  .book .toc { grid-template-columns: repeat(2, 1fr); }
}

/* clutch info box (side, small, quiet) */
.clutches { position: fixed; left: 14px; bottom: calc(var(--navh) + 16px); z-index: 65; display: grid; gap: 10px; width: 236px; }
.cbox { background: var(--paper); box-shadow: var(--pb), var(--drop); padding: 8px 10px; font-size: 14px; cursor: pointer; display: grid; gap: 6px; animation: slide .2s steps(3); transition: opacity .4s steps(3); }
.cbox:hover { background: #fff6dc; }
.cbox.gone { opacity: 0; }
.cbox.big { box-shadow: 0 -3px 0 0 var(--yellow), 0 3px 0 0 var(--yellow), -3px 0 0 0 var(--yellow), 3px 0 0 0 var(--yellow), var(--drop); }
.cbox .chead { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-weight: 700; }
.cbox .chead small { font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cbox .crolls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.cbox .crolls span { background: #fff; box-shadow: var(--pb2); text-align: center; padding: 1px 0; font-size: 13px; color: var(--mute); }
.cbox .crolls span.on { color: var(--ink); }
.cbox .crolls span.off { opacity: .35; }
.cbox .crolls b { color: var(--ink); }
.cbox .ceggs { display: flex; flex-wrap: wrap; gap: 2px; min-height: 0; }
.cbox .ceggs:empty { display: none; }
.cbox .ceggs img { animation: pop .25s steps(3); }
@media (max-width: 640px) { .clutches { width: 200px; left: 8px; } }

/* all-dragons list */
.dlist .drow { cursor: pointer; }
.dlist .drow:hover td { background: #fff6dc; }
.dlist .dpic { display: grid; place-items: center; width: 74px; height: 48px; background: var(--dither), #fbf4e0; box-shadow: var(--pb2); margin: 2px; }
.dlist .dvec { min-width: 110px; }
.dlist td small { color: var(--ink2); }
@media (max-width: 640px) { .dlist .dvec, .dlist th:nth-child(4) { display: none; } .nav button { font-size: 10px; } }

/* nesting ground */
.nests { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; align-items: stretch; }
.nest-card { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 0 0 12px; overflow: hidden; }
.nest-card > *:not(.nhead):not(.nscene) { margin-left: 12px; margin-right: 12px; }
.nhead { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: var(--dither), var(--paper2); box-shadow: inset 0 -3px 0 0 var(--ink); font-family: var(--head); font-weight: 800; font-size: 15px; }
.nstate { font-family: var(--font); font-size: 13px; font-weight: 700; padding: 0 8px; background: #fbf4e0; box-shadow: var(--pb2); margin: 2px; }
.nstate.idle { color: var(--mute); }
.nest-card.restless .nstate { background: var(--orange); color: #fff; animation: blink 1s steps(1) infinite; }
.nscene { position: relative; height: 164px; display: flex; justify-content: center; align-items: flex-end; background: linear-gradient(transparent 60%, rgba(27,16,36,.08)); }
.nscene .nbowl { display: block; margin-bottom: 4px; }
.nscene .nd { position: absolute; bottom: 76px; cursor: pointer; z-index: 1; }
.nscene .nd img { display: block; }
.nscene .nd.l { left: calc(50% - 104px); }
.nscene .nd.r { right: calc(50% - 104px); }
.nscene .nd:hover img { transform: translateY(-3px); }
.nscene .nd.ghost { opacity: .5; filter: grayscale(1) brightness(2.4); cursor: default; }
.nscene .nheart { position: absolute; left: 50%; bottom: 118px; transform: translateX(-50%); z-index: 2; }
.nscene .nheart img { animation: beat .8s steps(1) infinite; }
.nest-card.restless .nscene .nheart img { animation-duration: .35s; }
.nscene .nheart.dim { opacity: .35; } .nscene .nheart.dim img { animation: none; }
.nnames { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.nnames span { display: grid; min-width: 0; }
.nnames span.r { text-align: right; }
.nnames b, .nnames small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nest-card select { width: auto; margin-top: 2px; margin-bottom: 2px; }
.nwarn { background: #f8d4cc; box-shadow: var(--pb2); padding: 6px 8px; font-size: 14px; font-weight: 700; }
.nfoot { margin-top: auto; display: flex; align-items: center; gap: 8px; justify-content: space-between; padding-top: 4px; }
.nfoot small { flex: 1; min-width: 0; }
.btn.wide { width: 100%; }
.preview { font-size: 14px; display: grid; gap: 3px; background: #fbf4e0; box-shadow: var(--pb2); padding: 7px 8px; min-width: 0; }
.preview .rng { display: grid; grid-template-columns: minmax(0, 92px) minmax(0, 1fr) 58px; gap: 6px; align-items: center; }
.preview .rl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview .rv { text-align: right; font-weight: 700; }

/* activity board */
.board-top { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.board-timer { display: grid; text-align: center; background: var(--dither), var(--yellow); box-shadow: var(--pb2); padding: 4px 12px; margin: 2px; }
.board-timer b { font-family: var(--head); font-weight: 800; font-size: 20px; }
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; padding: 14px; background: var(--dither), #8a6438; box-shadow: var(--pb), var(--drop); margin: 3px; }
.note { position: relative; display: flex; flex-direction: column; gap: 5px; padding: 14px 10px 10px; background: #fbf4e0; box-shadow: var(--pb2), 3px 3px 0 0 rgba(0,0,0,.45), inset 0 4px 0 0 var(--fc); margin: 2px; min-width: 0; }
.note:nth-child(3n+1) { transform: translateY(2px); } .note:nth-child(3n+2) { transform: translateY(-2px); }
.note-pin { position: absolute; top: -5px; left: 50%; width: 8px; height: 8px; margin-left: -4px; background: var(--red); box-shadow: var(--pb2); }
.note-head { font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.note-tgt { color: var(--ink2); }
.note-title { font-family: var(--head); font-weight: 800; font-size: 14px; line-height: 1.2; }
.note small { color: var(--ink2); }
.note-meta { display: grid; gap: 2px; font-size: 13px; margin-top: auto; padding-top: 4px; border-top: 2px dotted rgba(27,16,36,.25); }
.note-eff { font-weight: 700; }
.note .btn { align-self: flex-start; }
.note.done { opacity: .55; }

/* readable body text */
body { font-size: 16px; line-height: 1.4; }
small { font-size: 13.5px; }
.tool small { font-size: 9px; }
.act .grp { font-size: 11px; }
table.list th { font-size: 13px; }
