/* 城塞守卫队 — M2 temporary UI: wooden planks with brass rims and bold dark outlines (DESIGN §5.4). */
:root {
  --ink: #2a1a0e;
  --wood: #7a4f2a;
  --wood-hi: #9a6a3a;
  --wood-lo: #5a3519;
  --brass: #e2b24f;
  --brass-lo: #a8741f;
  --cream: #fbefd2;
  --red: #d8452f;
  --blue: #3f74c8;
  --grass: #86bf45;
  --font: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --top-h: 56px;
  --bottom-h: 132px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #5e8f2e; overflow: hidden; overscroll-behavior: none; }
body { font-family: var(--font); color: var(--cream); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
::-webkit-scrollbar { display: none; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
.hidden { display: none !important; }
#app { position: fixed; inset: 0; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }

/* text with a dark outline, the house style for every label */
.outlined, .pill, .round, .token b, .spell em, .big, #banner, .lvl h3, .res h2 {
  text-shadow: 0 2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink), 1.5px 1.5px 0 var(--ink), -1.5px 1.5px 0 var(--ink), 1.5px -1.5px 0 var(--ink), -1.5px -1.5px 0 var(--ink);
}

/* ------------------------------------------------ top row */
#top { position: absolute; left: 0; right: 0; top: env(safe-area-inset-top, 0px); height: var(--top-h); display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; pointer-events: none; z-index: 5; }
#top .left, #top .right { display: flex; gap: 8px; pointer-events: auto; }
.pill, .round {
  height: 40px; border-radius: 20px; padding: 0 16px; font-weight: 900; font-size: 17px;
  background: linear-gradient(#a06c3c, #7a4f2a 55%, #643d1e); border: 3px solid var(--ink);
  box-shadow: inset 0 0 0 2px var(--brass), 0 3px 0 rgba(0,0,0,.35);
}
.round { width: 40px; padding: 0; display: grid; place-items: center; }
.pill:active, .round:active, .spell:active, .big:active { transform: translateY(2px); }
#btn-speed.fast { background: linear-gradient(#f0c35c, #d79a2c 55%, #b07418); }

/* ------------------------------------------------ bottom bar */
#bottom { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--bottom-h) + var(--safe-b)); padding-bottom: var(--safe-b); z-index: 5;
  background: linear-gradient(#7c5129, #5c3a1c); border-top: 3px solid var(--ink); box-shadow: inset 0 3px 0 var(--brass), 0 -4px 10px rgba(0,0,0,.25); }
#bottom::before { content: ""; position: absolute; inset: 3px 0 0; background: repeating-linear-gradient(90deg, transparent 0 79px, rgba(0,0,0,.18) 79px 81px); pointer-events: none; }
#status { position: relative; display: flex; gap: 8px; padding: 7px 10px 0; justify-content: center; }
.token { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px 0 6px; border-radius: 15px; background: rgba(30,16,6,.75); border: 2px solid #b8873a; }
.token b { font-size: 16px; font-weight: 900; }
.token.flash { animation: flash .5s; }
@keyframes flash { 30% { background: var(--red); transform: scale(1.12); } }
#st-gold.gain b { animation: gain .35s; }
@keyframes gain { 40% { color: #ffe27a; } }
.ico { width: 22px; height: 22px; display: inline-block; background-size: contain; background-repeat: no-repeat; background-position: center; flex: none; }
#actions { position: relative; display: flex; align-items: center; gap: 12px; padding: 8px 12px; height: 92px; max-width: 560px; margin: 0 auto; }

.hero { position: relative; width: 72px; height: 72px; border-radius: 50%; flex: none; background: radial-gradient(circle at 50% 40%, #f3dcb6, #c99a63); border: 3px solid var(--ink); box-shadow: inset 0 0 0 3px var(--brass), 0 3px 0 rgba(0,0,0,.35); }
.hero.sel { box-shadow: inset 0 0 0 3px #fff6a8, 0 0 0 4px #ffe066, 0 3px 0 rgba(0,0,0,.35); }
.hero .face { position: absolute; inset: 10px; border-radius: 50%; background-size: cover; }
.hero .lv { position: absolute; right: -4px; top: -4px; width: 24px; height: 24px; border-radius: 50%; background: var(--blue); border: 2px solid #fff; font-size: 13px; font-weight: 900; display: grid; place-items: center; }
.hero .hp { position: absolute; left: 6px; right: 6px; bottom: -8px; height: 8px; border-radius: 4px; background: #2a1a0e; border: 1.5px solid var(--ink); overflow: hidden; }
.hero .hp i { display: block; height: 100%; background: #6ac04a; width: 100%; }
.hero .down { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(rgba(20,10,4,.72) var(--p, 0%), transparent 0); display: none; }
.hero.dead .down { display: block; }
.hero.dead .face { filter: grayscale(1) brightness(.6); }

.spell { position: relative; width: 64px; height: 64px; border-radius: 50%; flex: none; background: radial-gradient(circle at 50% 35%, #a77443, #6a4220); border: 3px solid var(--ink); box-shadow: inset 0 0 0 3px var(--brass), 0 3px 0 rgba(0,0,0,.35); }
.spell .ico { position: absolute; left: 50%; top: 45%; width: 38px; height: 38px; transform: translate(-50%, -50%); }
.spell em { position: absolute; left: 50%; bottom: -12px; transform: translateX(-50%); font-style: normal; font-size: 13px; font-weight: 900; white-space: nowrap; }
.spell .cd { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(rgba(20,10,4,.72) var(--p, 0%), transparent 0); pointer-events: none; }
.spell.aim { box-shadow: inset 0 0 0 3px #fff6a8, 0 0 0 4px #ffe066, 0 0 18px #ffe066; }
.spell.ready::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid rgba(255, 230, 120, .7); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); opacity: .3; } }
.spell.locked { filter: grayscale(1) brightness(.6); }

.card { margin-left: auto; width: 104px; height: 70px; border-radius: 10px; background: var(--cream); border: 3px solid var(--ink); box-shadow: inset 0 0 0 2px var(--brass), 0 3px 0 rgba(0,0,0,.3); position: relative; color: #4a2f16; animation: pop .4s; }
.card em { position: absolute; top: -12px; left: 8px; font-style: normal; font-size: 13px; font-weight: 900; color: #ffe27a; text-shadow: 0 0 3px var(--ink), 0 0 3px var(--ink), 0 0 3px var(--ink); }
.card .pic { position: absolute; left: 6px; top: 10px; width: 46px; height: 50px; }
.card b { position: absolute; left: 54px; right: 4px; top: 22px; font-size: 14px; font-weight: 900; text-align: center; line-height: 1.15; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } 60% { transform: scale(1.08); } }

/* ------------------------------------------------ ring menu */
#ring { position: absolute; z-index: 6; width: 0; height: 0; }
#ring .opt { position: absolute; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 14px; background: linear-gradient(#8a5c30, #5e3a1a); border: 3px solid var(--ink); box-shadow: inset 0 0 0 2px var(--brass), 0 3px 0 rgba(0,0,0,.4); display: grid; place-items: center; animation: ringIn .18s both; }
#ring .opt .ico { width: 44px; height: 44px; margin-top: -6px; }
#ring .opt .price { position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%); min-width: 40px; height: 20px; padding: 0 6px; border-radius: 10px; background: #2a1a0e; border: 2px solid var(--brass-lo); font-size: 13px; font-weight: 900; color: #ffd35a; display: grid; place-items: center; }
#ring .opt.poor { filter: grayscale(.9) brightness(.7); }
#ring .opt.poor .price { color: #d06a5a; }
#ring .opt.sel { background: linear-gradient(#f0c35c, #c98b25); box-shadow: inset 0 0 0 2px #fff6a8, 0 0 0 4px #ffe066, 0 3px 0 rgba(0,0,0,.4); }
#ring .opt.sel::after { content: "✓"; position: absolute; right: -8px; top: -8px; width: 24px; height: 24px; border-radius: 50%; background: #3fa34d; border: 2px solid #fff; display: grid; place-items: center; font-size: 15px; font-weight: 900; color: #fff; }
#ring .opt.max { filter: grayscale(.6); }
#ring .opt.spec { width: 64px; height: 64px; margin: -32px 0 0 -32px; background: linear-gradient(#5a7fc0, #34508a); }
#ring .opt.spec .ico { width: 54px; height: 54px; margin-top: -8px; }
#ring .opt.skill .pips { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; }
#ring .opt.skill .pip { width: 9px; height: 9px; transform: rotate(45deg); background: #3a2410; border: 1.5px solid var(--ink); }
#ring .opt.skill .pip.on { background: #ffd34a; }
#tip .other { color: #c9b89a; font-size: 12px; margin-top: 4px; }
#ring .opt .lbl { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -60%); font-size: 15px; font-weight: 900; }
#ring .halo { position: absolute; width: 150px; height: 150px; margin: -75px 0 0 -75px; border-radius: 50%; border: 3px solid rgba(255, 240, 200, .8); background: rgba(255, 255, 255, .08); animation: ringIn .18s both; pointer-events: none; }
@keyframes ringIn { from { transform: scale(.5); opacity: 0; } }

#tip { position: absolute; z-index: 7; max-width: 230px; padding: 8px 12px; border-radius: 10px; background: rgba(30, 16, 6, .92); border: 2px solid var(--brass-lo); font-size: 13px; line-height: 1.45; pointer-events: none; }
#tip h4 { margin: 0 0 2px; font-size: 15px; color: #ffe27a; }
#tip .stats { color: #f3d9a8; }

#toast { position: absolute; left: 50%; top: 66px; transform: translateX(-50%); z-index: 8; padding: 6px 14px; border-radius: 16px; background: rgba(30,16,6,.9); border: 2px solid var(--brass-lo); font-size: 14px; font-weight: 700; white-space: nowrap; pointer-events: none; }
#banner { position: absolute; left: 0; right: 0; top: 30%; z-index: 8; text-align: center; font-size: 40px; font-weight: 900; color: #ffe27a; pointer-events: none; animation: banner 1.6s both; }
#banner small { display: block; font-size: 18px; color: var(--cream); }
@keyframes banner { 0% { transform: scale(.6); opacity: 0; } 15% { transform: scale(1.06); opacity: 1; } 25% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }

/* ------------------------------------------------ screens */
.screen { position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; }
.screen.dim { background: rgba(20, 10, 4, .55); }
#boot { background: radial-gradient(circle at 50% 35%, #9bd257, #5e8f2e); }
.boot-card { text-align: center; }
.boot-card h1 { font-size: 44px; margin: 0 0 12px; color: #ffe27a; text-shadow: 0 4px 0 var(--ink), 3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 -3px 0 var(--ink); }
.big { min-width: 160px; height: 54px; padding: 0 24px; border-radius: 27px; font-size: 21px; font-weight: 900; background: linear-gradient(#f0c35c, #d79a2c 55%, #b07418); border: 3px solid var(--ink); box-shadow: inset 0 0 0 2px #fff0b0, 0 4px 0 rgba(0,0,0,.35); }
.big.wood { background: linear-gradient(#a06c3c, #7a4f2a 55%, #643d1e); box-shadow: inset 0 0 0 2px var(--brass), 0 4px 0 rgba(0,0,0,.35); }
.panel { width: min(92vw, 380px); max-height: 86vh; display: flex; flex-direction: column; border-radius: 18px; background: linear-gradient(#8a5c30, #6a4220); border: 4px solid var(--ink); box-shadow: inset 0 0 0 3px var(--brass), 0 8px 0 rgba(0,0,0,.35); overflow: hidden; }
.panel > header { flex: none; display: flex; align-items: center; justify-content: center; position: relative; padding: 14px 48px 8px; font-size: 24px; font-weight: 900; }
.panel > header .x { position: absolute; right: 10px; top: 10px; width: 36px; height: 36px; border-radius: 50%; background: var(--wood-lo); border: 2px solid var(--ink); font-size: 18px; }
.panel .body { flex: 1; overflow-y: auto; padding: 4px 18px 16px; scrollbar-width: none; }
.panel .row { display: flex; gap: 10px; justify-content: center; padding: 14px 16px 18px; flex: none; }
.panel p { margin: 6px 0; line-height: 1.55; font-size: 15px; }

/* level select (temporary, until the painted world map of M4) */
#levels { flex-direction: column; justify-content: flex-start; background: radial-gradient(circle at 50% 20%, #9bd257, #5e8f2e 70%); overflow-y: auto; scrollbar-width: none; }
#levels .head { width: 100%; max-width: 520px; padding: 18px 16px 6px; display: flex; align-items: center; justify-content: space-between; }
#levels .head h1 { margin: 0; font-size: 30px; color: #ffe27a; }
#levels .head { gap: 10px; flex-wrap: wrap; }
#levels .head .hero-tag { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 900; padding: 4px 12px 4px 4px; border-radius: 20px; background: rgba(30,16,6,.6); border: 2px solid var(--brass); }
#levels .head .hero-tag .face { width: 32px; height: 32px; border-radius: 50%; background: #f3dcb6 center/cover; border: 2px solid var(--ink); }
#levels .head .hero-tag small { font-size: 11px; color: #ffe27a; margin-left: 4px; }
#levels .head .star-tag { font-size: 14px; font-weight: 900; padding: 6px 12px; border-radius: 14px; background: rgba(30,16,6,.6); color: #ffd34a; }
.lvl-wrap { display: grid; gap: 6px; }
.lvl-wrap .lvl { width: 100%; }
.lvl-wrap .modes { display: flex; gap: 8px; padding-left: 64px; }
.lvl-wrap .modes b { cursor: pointer; padding: 4px 12px; border-radius: 12px; font-size: 13px; background: linear-gradient(#5a7fc0, #34508a); border: 2px solid var(--ink); box-shadow: inset 0 0 0 1.5px #9cc0ff; }
.lvl-wrap .modes b.done { background: linear-gradient(#f0c35c, #c98b25); box-shadow: inset 0 0 0 1.5px #fff6a8; }
.lvl-wrap .modes.hint { font-size: 12px; color: #f3d9a8; }
.hero-list { display: grid; gap: 10px; }
.hero-card { display: grid; grid-template-columns: 56px 1fr; gap: 4px 10px; text-align: left; padding: 10px; border-radius: 14px; background: rgba(30,16,6,.35); border: 2px solid rgba(0,0,0,.4); }
.hero-card .face { grid-row: span 2; width: 56px; height: 56px; border-radius: 50%; background: #f3dcb6 center/cover; border: 3px solid var(--ink); }
.hero-card .who b { font-size: 17px; } .hero-card .who small { display: block; font-size: 12px; color: #f3d9a8; }
.hero-card .what { font-size: 13px; line-height: 1.45; }
.hero-card ul { grid-column: 1 / -1; margin: 4px 0 0; padding-left: 18px; font-size: 12px; line-height: 1.5; color: #ffe9b8; }
.hero-card li.off { color: #b89a78; }
.hero-card.sel { background: rgba(255,210,90,.22); border-color: #ffe066; box-shadow: 0 0 0 2px #ffe066; }
.hero-card.locked { filter: grayscale(.85) brightness(.75); }
#levels .region { width: 100%; max-width: 520px; padding: 6px 16px 2px; font-size: 16px; font-weight: 900; color: var(--cream); }
#levels .list { width: 100%; max-width: 520px; padding: 6px 16px 24px; display: grid; gap: 12px; }
.lvl { position: relative; display: flex; gap: 12px; align-items: center; text-align: left; padding: 12px 14px; border-radius: 16px; background: linear-gradient(#8a5c30, #6a4220); border: 3px solid var(--ink); box-shadow: inset 0 0 0 2px var(--brass), 0 4px 0 rgba(0,0,0,.3); }
.lvl .num { flex: none; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; font-weight: 900; background: var(--blue); border: 3px solid var(--ink); box-shadow: inset 0 0 0 2px #9cc0ff; }
.lvl h3 { margin: 0; font-size: 19px; }
.lvl p { margin: 3px 0 0; font-size: 13px; color: #f3d9a8; }
.lvl .stars { margin-left: auto; font-size: 22px; letter-spacing: 1px; color: #6b4a2a; white-space: nowrap; }
.lvl .stars .on { color: #ffd34a; text-shadow: 0 0 2px var(--ink), 0 0 2px var(--ink); }
.lvl.locked { filter: grayscale(.8) brightness(.75); }
.lvl .resume { position: absolute; right: 10px; top: -10px; padding: 2px 10px; border-radius: 10px; background: #3fa34d; border: 2px solid var(--ink); font-size: 12px; font-weight: 900; }

/* results */
.res { text-align: center; }
.res h2 { font-size: 34px; margin: 6px 0; color: #ffe27a; }
.res .stars { font-size: 50px; letter-spacing: 6px; }
.res .stars span { display: inline-block; color: #5a3a1e; animation: starIn .45s both; }
.res .stars span.on { color: #ffd34a; text-shadow: 0 0 3px var(--ink), 0 0 3px var(--ink), 0 0 3px var(--ink); }
@keyframes starIn { from { transform: scale(2.2) rotate(-30deg); opacity: 0; } }
.res .facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 10px 0; font-size: 15px; }
.res .facts div { padding: 6px 8px; border-radius: 10px; background: rgba(30,16,6,.35); }
.res .lvup { color: #ffe27a; font-weight: 900; }
.res .wk-tip { margin: 10px auto 0; max-width: 340px; padding: 8px 12px; border-radius: 12px; border: 2px dashed #ffe066; background: rgba(30,16,6,.45); color: #f3e3bd; font-size: 14px; line-height: 1.55; }
.res .wk-tip b { color: #ffe27a; }

.tap-hint { position: absolute; inset: 0; z-index: 9; display: grid; place-items: center; background: rgba(20,10,4,.45); }
.tap-hint div { font-size: 30px; font-weight: 900; padding: 18px 30px; border-radius: 20px; background: rgba(30,16,6,.75); border: 3px solid var(--brass); }

/* wide screens (desktop, tablet landscape): the portrait map stands in the middle at full height and the
   status and actions move into a panel at its left (DESIGN §5.2) */
@media (min-aspect-ratio: 5/4) and (min-width: 560px) {
  #bottom { left: 18px; right: auto; top: 50%; bottom: auto; transform: translateY(-50%); width: 236px; height: auto; padding: 10px 0 14px;
    border: 3px solid var(--ink); border-radius: 18px; box-shadow: inset 0 0 0 3px var(--brass), 0 6px 0 rgba(0,0,0,.3); }
  #bottom::before { display: none; }
  #status { flex-direction: column; align-items: stretch; padding: 6px 16px; }
  #actions { flex-wrap: wrap; justify-content: center; height: auto; gap: 22px 14px; padding: 12px 12px 4px; }
  .hero { width: 84px; height: 84px; }
  .card { margin: 4px auto 0; }
}

/* landscape maps on computers and tablets held sideways: the battlefield fills the screen and the interface sits in
   the corners — function buttons and status at the top left, hero and spells at the bottom left, the new-enemy
   card at the bottom right (DESIGN §5.2). The level layouts keep these corners free of plots and roads. */
body.land #bottom { inset: 0; width: auto; height: auto; transform: none; padding: 0; background: none; border: 0; box-shadow: none; pointer-events: none; }
body.land #bottom::before { display: none; }
body.land #status { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 13px); left: 152px; padding: 0; flex-direction: row; pointer-events: auto; }
body.land #actions { position: absolute; left: 16px; bottom: 16px; height: auto; max-width: none; margin: 0; padding: 0; gap: 14px; flex-wrap: nowrap; pointer-events: auto; }
body.land .card { position: fixed; right: 16px; bottom: 16px; margin: 0; }
body.land .token { background: rgba(30,16,6,.82); }
/* short sideways screens (phones turned sideways, about 330–500 px tall): the same corners, drawn smaller so the
   whole map stays readable (DESIGN §22) */
@media (max-height: 500px) {
  body.land #top .left, body.land #top .right { transform: scale(.74); transform-origin: left top; }
  body.land #top .right { transform-origin: right top; }
  body.land #status { left: 108px; top: calc(env(safe-area-inset-top, 0px) + 8px); transform: scale(.74); transform-origin: left top; }
  /* zoom, not transform: a transform on #actions would trap the fixed new-enemy card inside it */
  body.land #actions { left: 8px; bottom: 8px; gap: 9px; }
  body.land #actions > :not(.card) { zoom: .66; }
  body.land .card { right: 8px; bottom: 8px; zoom: .74; }
}

/* keyboard hints for mouse-and-keyboard players */
.kbd { display: none; position: absolute; top: -6px; left: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 6px; background: #f3e3bd; color: #4a2f16; border: 2px solid var(--ink); font-size: 12px; font-weight: 900; line-height: 16px; text-align: center; }
@media (hover: hover) and (pointer: fine) { .kbd { display: block; } }
#stage.point { cursor: pointer; }

/* scroll areas: no scroll bar; the bottom edge fades and a 下滑查看 chip bounces while more lies below */
.more-below { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 64px), rgba(0,0,0,.12)); mask-image: linear-gradient(to bottom, #000 calc(100% - 64px), rgba(0,0,0,.12)); }
.more-above { -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,.12), #000 36px); mask-image: linear-gradient(to bottom, rgba(0,0,0,.12), #000 36px); }
.more-above.more-below { -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,.12), #000 36px, #000 calc(100% - 64px), rgba(0,0,0,.12)); mask-image: linear-gradient(to bottom, rgba(0,0,0,.12), #000 36px, #000 calc(100% - 64px), rgba(0,0,0,.12)); }
.scroll-more { position: absolute; left: 50%; bottom: 76px; z-index: 12; display: flex; align-items: center; gap: 6px; padding: 6px 14px 6px 11px; border-radius: 16px;
  background: rgba(40,22,10,.92); color: #ffe27a; font-weight: 900; font-size: 13px; border: 2px solid var(--brass); box-shadow: 0 4px 10px rgba(0,0,0,.35);
  transform: translate(-50%, 0); opacity: 0; pointer-events: none; transition: opacity .25s; animation: nudge 1.6s ease-in-out infinite; cursor: pointer; }
.scroll-more.on { opacity: 1; pointer-events: auto; }
.scroll-more.fixed { position: fixed; bottom: calc(16px + env(safe-area-inset-bottom)); }
.scroll-more i { width: 8px; height: 8px; margin-top: -4px; border: solid currentColor; border-width: 0 3px 3px 0; border-radius: 1px; transform: rotate(45deg); }
@keyframes nudge { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, 5px); } }
@media (prefers-reduced-motion: reduce) { .scroll-more { animation: none; } }


/* phones: the hub's capsule floats over the top-right corner (top 14 px, 88 × 44 px), so the level list header keeps
   its buttons to the left of it */
@media (max-width: 699px) { #levels .head { padding-right: 112px; row-gap: 8px; } }

/* ------------------------------------------------ M4: the world map (home) */
#home { position: absolute; inset: 0; z-index: 4; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: manipulation; }
#world.point { cursor: pointer; }
#home-top { position: absolute; left: 12px; top: calc(env(safe-area-inset-top, 0px) + 10px); right: 112px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; pointer-events: none; }
#home-top > * { pointer-events: auto; }
#home-top h1 { margin: 0 6px 0 0; font-size: 26px; color: #ffe27a; }
#home-top .star-tag, .page .star-tag { font-size: 15px; font-weight: 900; padding: 6px 12px; border-radius: 14px; background: rgba(30,16,6,.72); color: #ffd34a; border: 2px solid var(--brass); }
#home-top .star-tag small, .page .star-tag small { color: #f3d9a8; font-size: 12px; }
#home-top .hero-tag { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 900; padding: 4px 12px 4px 4px; border-radius: 20px; background: rgba(30,16,6,.72); border: 2px solid var(--brass); }
#home-top .hero-tag .face, .pick-hero .face { width: 32px; height: 32px; border-radius: 50%; background: #f3dcb6 center/cover; border: 2px solid var(--ink); flex: none; }
#home-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; gap: 4px; padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(#7c5129, #5c3a1c); border-top: 3px solid var(--ink); box-shadow: inset 0 3px 0 var(--brass); }
.home-btn { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 52px; padding: 4px 2px; font-size: 12px; font-weight: 900; }
.home-btn .ico { width: 40px; height: 40px; filter: drop-shadow(0 2px 0 rgba(0,0,0,.35)); }
.home-btn .badge { position: absolute; top: 0; right: 4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: #d8452f; border: 2px solid #fff; font-size: 12px; display: grid; place-items: center; }
.home-btn:active { transform: translateY(2px); }
/* computers and sideways tablets: the buttons sit in the bottom-right corner over the map */
#home.wide #home-top { right: 12px; }
#home.wide #home-bar { left: auto; right: 16px; bottom: 16px; border: 3px solid var(--ink); border-radius: 18px; padding: 8px 10px; gap: 6px; box-shadow: inset 0 0 0 3px var(--brass), 0 6px 0 rgba(0,0,0,.3); }
#home.wide .home-btn { min-width: 72px; font-size: 13px; padding: 4px 6px; border-radius: 12px; }
#home.wide .home-btn:hover { background: rgba(255,226,122,.18); }
#home.wide .home-btn .ico { width: 46px; height: 46px; }

/* ------------------------------------------------ M4: full-screen pages */
.page { flex-direction: column; justify-content: flex-start; align-items: stretch; background: radial-gradient(circle at 50% 0%, #8a5c30, #4a2c14 75%); z-index: 11; }
.page > header { flex: none; position: relative; display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px; border-bottom: 3px solid var(--ink); box-shadow: inset 0 -3px 0 var(--brass); background: linear-gradient(#7c5129, #5c3a1c); }
.page > header h2 { margin: 0; font-size: 22px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page > header .back { width: 44px; height: 44px; border-radius: 50%; font-size: 30px; line-height: 1; font-weight: 900; background: var(--wood-lo); border: 2px solid var(--ink); box-shadow: inset 0 0 0 2px var(--brass); }
.page > header .extra { display: flex; gap: 8px; align-items: center; flex: none; }
/* phones: the hub's capsule floats over the top-right corner of the header */
@media (max-width: 699px) { .page > header { padding-right: 108px; } .page > header .extra .pill { height: 34px; padding: 0 12px; font-size: 14px; } }
.foe { position: relative; }
.page > .body { flex: 1; overflow-y: auto; scrollbar-width: none; padding: 14px 16px calc(24px + env(safe-area-inset-bottom, 0px)); max-width: 1100px; width: 100%; margin: 0 auto; }
.page p { line-height: 1.6; margin: 6px 0; }
.page h4 { margin: 14px 0 6px; color: #ffe27a; font-size: 16px; }
.page .hint, .level-page .hint { color: #e6caa0; font-size: 13px; }
.page .quip { color: #ffe9b8; font-style: italic; }
.page table { width: 100%; border-collapse: collapse; font-size: 14px; }
.page th, .page td { text-align: left; padding: 6px 8px; border-bottom: 1px solid rgba(255,226,122,.2); }
.page th { color: #ffe27a; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tab { padding: 8px 14px; border-radius: 14px; font-weight: 900; font-size: 14px; background: rgba(30,16,6,.45); border: 2px solid rgba(0,0,0,.5); }
.tab.on { background: linear-gradient(#f0c35c, #c98b25); border-color: var(--ink); color: #2a1a0e; }
.tab.locked { opacity: .5; }
.skills { margin: 4px 0; padding-left: 0; list-style: none; display: grid; gap: 6px; }
.skills li { padding: 8px 10px; border-radius: 10px; background: rgba(30,16,6,.35); font-size: 14px; line-height: 1.5; }
.skills li b { color: #ffe27a; margin-right: 8px; }
.skills li.off { opacity: .55; }

/* hero room */
.hero-room { display: grid; gap: 12px; }
.hero-room.two { grid-template-columns: 220px 1fr; grid-template-areas: "roster roster" "stage info"; align-items: start; }
.hero-room .roster { display: flex; gap: 8px; flex-wrap: wrap; }
.hero-room.two .roster { grid-area: roster; } .hero-room.two .stage { grid-area: stage; } .hero-room.two .info { grid-area: info; }
.hero-room .who { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 22px; background: rgba(30,16,6,.45); border: 2px solid rgba(0,0,0,.5); font-weight: 900; position: relative; }
.hero-room .who .face { width: 36px; height: 36px; border-radius: 50%; background: #f3dcb6 center/cover; border: 2px solid var(--ink); }
.hero-room .who.on { border-color: #ffe066; box-shadow: 0 0 0 2px #ffe066; }
.hero-room .who.locked { filter: grayscale(.9) brightness(.7); }
.hero-room .who em { font-style: normal; font-size: 11px; color: #bff09a; }
.hero-room .stage { display: grid; place-items: center; padding: 10px; border-radius: 18px; background: radial-gradient(circle at 50% 70%, rgba(255,226,122,.25), transparent 70%); }
.hero-room h3 { margin: 0; font-size: 24px; } .hero-room h3 small { font-size: 14px; color: #f3d9a8; margin-left: 8px; }
.bar, .xp { display: grid; grid-template-columns: 48px 1fr auto; gap: 8px; align-items: center; margin: 6px 0; font-size: 14px; }
.bar i, .xp i { height: 10px; border-radius: 5px; background: rgba(0,0,0,.45); border: 1.5px solid var(--ink); overflow: hidden; }
.bar b, .xp b { display: block; height: 100%; background: linear-gradient(#ffe27a, #e2a83a); }
.xp b { background: linear-gradient(#9ff49a, #3fa34d); }
.bar em, .xp em { font-style: normal; color: #f3d9a8; font-size: 13px; }
.hero-room .info .big { margin-top: 12px; }

/* workshop */
.workshop { display: grid; gap: 10px; }
.workshop.grid { grid-template-columns: repeat(3, 1fr); }
.workshop .line { padding: 10px; border-radius: 14px; background: rgba(30,16,6,.35); border: 2px solid rgba(0,0,0,.45); }
.workshop .head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.workshop .head .ico { width: 34px; height: 34px; }
.workshop .head small { margin-left: auto; color: #f3d9a8; }
.workshop .nodes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.node { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 10px; background: rgba(0,0,0,.35); border: 2px solid rgba(0,0,0,.5); font-size: 12px; min-height: 74px; }
.node b { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: #5a3a1e; border: 2px solid var(--ink); font-size: 12px; }
.node span { font-weight: 900; text-align: center; line-height: 1.2; }
.node em { font-style: normal; color: #ffd34a; font-weight: 900; }
.node.got { background: linear-gradient(#f0c35c, #c98b25); color: #2a1a0e; border-color: var(--ink); }
.node.got b { background: #3fa34d; color: #fff; } .node.got em { color: #2a1a0e; }
.node.next { border-color: #ffe066; box-shadow: 0 0 0 2px rgba(255,224,102,.5); }
.node.poor { opacity: .75; } .node.locked { opacity: .45; }
.node.sel { box-shadow: 0 0 0 3px #fff6a8, 0 0 14px #ffe066; }
.workshop-page .detail, .hint + .workshop { margin-top: 6px; }
.workshop-page .detail { padding: 10px 12px; border-radius: 12px; background: rgba(30,16,6,.5); border: 2px solid var(--brass); margin-bottom: 10px; }
.workshop-page .detail em { font-style: normal; font-weight: 900; color: #ffb36a; }
.workshop-page .detail em.ok { color: #bff09a; }

/* codex */
.codex { display: grid; gap: 12px; }
.codex.two { grid-template-columns: 1fr 380px; align-items: start; }
.codex .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.entry { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 4px; border-radius: 12px; background: rgba(30,16,6,.35); border: 2px solid rgba(0,0,0,.45); font-size: 12px; font-weight: 900; }
.entry.on { border-color: #ffe066; box-shadow: 0 0 0 2px #ffe066; }
.entry.unseen span { color: #b89a78; }
.codex .detail { padding: 12px; border-radius: 16px; background: rgba(30,16,6,.45); border: 2px solid var(--brass); }
.codex.two .detail { position: sticky; top: 0; }
.codex .big-pic { display: grid; place-items: center; min-height: 120px; }
.codex h3 { margin: 4px 0; font-size: 22px; } .codex h3 small { font-size: 13px; color: #f3d9a8; margin-left: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chips span { padding: 4px 10px; border-radius: 12px; background: rgba(0,0,0,.35); font-size: 13px; }
.codex .tip { color: #bff09a; }

/* statistics */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.tile { padding: 12px; border-radius: 14px; background: rgba(30,16,6,.4); border: 2px solid rgba(0,0,0,.45); display: flex; flex-direction: column; gap: 2px; }
.tile b { font-size: 24px; color: #ffe27a; } .tile b small { font-size: 13px; color: #f3d9a8; } .tile span { font-size: 13px; color: #f3d9a8; }
.bosses { display: flex; gap: 12px; flex-wrap: wrap; }
.boss { display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 900; font-size: 13px; }
.boss.no span { color: #b89a78; }

/* settings */
.setting { padding: 12px; border-radius: 14px; background: rgba(30,16,6,.35); margin-bottom: 10px; display: grid; gap: 8px; }
.setting > b { font-size: 17px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { padding: 10px 18px; border-radius: 14px; font-weight: 900; background: rgba(0,0,0,.35); border: 2px solid rgba(0,0,0,.5); }
.seg button.on { background: linear-gradient(#f0c35c, #c98b25); color: #2a1a0e; border-color: var(--ink); }
.help-page .note { color: #ffe27a; }

/* ------------------------------------------------ M4: level page (关前页) */
.panel.level-page { width: min(94vw, 420px); }
.panel.level-page.two { width: min(92vw, 760px); }
.level-page .body { display: grid; gap: 4px 18px; position: relative; }
.level-page.two .body { grid-template-columns: 1fr 1fr; }
.level-page h4 { margin: 10px 0 6px; color: #ffe27a; font-size: 15px; }
.level-page .theme { color: #f3e3bd; }
.stars-line { font-size: 26px; color: #5a3a1e; display: flex; align-items: center; gap: 2px; }
.stars-line .on { color: #ffd34a; text-shadow: 0 0 2px var(--ink), 0 0 2px var(--ink); }
.stars-line small { font-size: 13px; color: #f3d9a8; margin-left: 10px; }
.foes { display: flex; flex-wrap: wrap; gap: 6px; }
.foe { display: flex; flex-direction: column; align-items: center; width: 64px; font-size: 11px; font-weight: 900; text-align: center; }
.foe.new::before { content: "新"; position: absolute; top: -4px; right: 2px; z-index: 1; background: #d8452f; border: 2px solid #fff; border-radius: 8px; padding: 0 4px; font-size: 10px; }
.foe.unseen span { color: #b89a78; }
.pick-hero { display: grid; grid-template-columns: 40px 1fr auto; grid-template-rows: auto auto; align-items: center; gap: 0 10px; width: 100%; padding: 8px 12px 8px 8px; border-radius: 14px; background: rgba(30,16,6,.45); border: 2px solid var(--brass); text-align: left; }
.pick-hero .face { grid-row: span 2; width: 40px; height: 40px; }
.pick-hero b { font-size: 16px; } .pick-hero small { color: #f3d9a8; font-size: 12px; grid-column: 2; }
.pick-hero em { grid-row: 1 / span 2; grid-column: 3; font-style: normal; font-size: 13px; color: #ffe27a; }
.level-page .rule { font-size: 14px; color: #f3e3bd; }
.wk-hint { display: flex; align-items: center; gap: 8px; width: 100%; margin: 4px 0; padding: 8px 10px 8px 12px; border-radius: 14px; background: rgba(30,16,6,.45); border: 2px dashed #ffe066; color: #ffe27a; font-weight: 900; font-size: 14px; text-align: left; }
.wk-hint em { margin-left: auto; flex: none; font-style: normal; font-size: 13px; padding: 4px 10px; border-radius: 12px; background: linear-gradient(#f0c35c, #c98b25); color: #2a1a0e; border: 2px solid var(--ink); }
@media (hover: hover) { .wk-hint:hover { background: rgba(60,34,12,.6); } }
.level-page .row { flex-wrap: wrap; }

/* ------------------------------------------------ M4: story dialogue */
#story { position: absolute; inset: 0; z-index: 12; background: rgba(20,10,4,.35); display: flex; align-items: flex-end; justify-content: center; padding: 0 12px calc(16px + env(safe-area-inset-bottom, 0px)); }
#story .dialog { position: relative; display: flex; align-items: flex-end; gap: 8px; width: min(100%, 720px); animation: pop .3s; }
#story .portrait { flex: none; display: grid; place-items: end center; }
#story .dialog.foe { flex-direction: row-reverse; }
#story .bubble { flex: 1; position: relative; padding: 12px 16px 26px; border-radius: 18px; background: var(--cream); color: #3a2410; border: 3px solid var(--ink); box-shadow: 0 4px 0 rgba(0,0,0,.35); margin-bottom: 16px; min-height: 92px; }
#story .bubble b { display: block; font-size: 15px; color: #8a3a2a; margin-bottom: 2px; }
#story .bubble p { margin: 0; font-size: 17px; line-height: 1.55; font-weight: 700; }
#story .bubble .more { position: absolute; right: 14px; bottom: 6px; font-size: 12px; color: #8a5a30; animation: pulse 1.6s infinite; }
#story .skip { position: absolute; right: 6px; top: -40px; padding: 6px 14px; border-radius: 14px; font-weight: 900; font-size: 13px; background: rgba(30,16,6,.8); border: 2px solid var(--brass); color: var(--cream); }
#story .dialog.foe .bubble { background: #e8d8f0; }

.page .toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }

/* ------------------------------------------------ M5: the painted wood-and-brass interface (DESIGN §23)
   Switched on by body.art-ui once the art list has loaded; without it the drawn CSS look above stays. */
body.art-ui .token, body.art-ui .pill, body.art-ui .big.wood, body.art-ui #home-top .star-tag, body.art-ui #home-top .hero-tag, body.art-ui .page .star-tag {
  background: none; box-shadow: none; border-style: solid; border-color: transparent; border-radius: 0;
  border-image: url(../assets/art/ui/plank.webp) 0 160 fill / 0 var(--cap) stretch;
}
body.art-ui .token { --cap: 23px; border-width: 0; padding: 0 20px 0 12px; height: 32px; }
body.art-ui .pill { --cap: 30px; border-width: 0; padding: 0 26px 0 22px; height: 42px; }
body.art-ui .big.wood { --cap: 40px; border-width: 0; padding: 0 40px; }
body.art-ui #home-top .star-tag, body.art-ui .page .star-tag { --cap: 24px; border-width: 0; padding: 7px 22px; }
body.art-ui #home-top .hero-tag { --cap: 28px; border-width: 0; padding: 4px 26px 4px 18px; }
body.art-ui .round, body.art-ui .spell, body.art-ui .hero, body.art-ui #ring .opt, body.art-ui .back {
  background: url(../assets/art/ui/btn-round.webp) center / 100% 100% no-repeat; border: 0; border-radius: 50%;
  box-shadow: 0 3px 0 rgba(0,0,0,.28);
}
body.art-ui .round { width: 42px; height: 42px; }
body.art-ui #btn-speed.fast { background: url(../assets/art/ui/btn-round.webp) center / 100% 100% no-repeat; box-shadow: 0 0 0 3px #ffe066, 0 3px 0 rgba(0,0,0,.28); }
body.art-ui .hero .face { inset: 9px; }
body.art-ui #ring .opt { width: 62px; height: 62px; margin: -31px 0 0 -31px; }
body.art-ui #ring .opt.spec { width: 68px; height: 68px; margin: -34px 0 0 -34px; }
body.art-ui #ring .opt.sel { box-shadow: 0 0 0 4px #ffe066, 0 0 14px #ffe066, 0 3px 0 rgba(0,0,0,.35); }
body.art-ui #ring .opt .ico { width: 42px; height: 42px; margin-top: -4px; }
body.art-ui .panel, body.art-ui #tip {
  background: none; box-shadow: 0 8px 0 rgba(0,0,0,.28); border-style: solid; border-color: transparent; border-radius: 0;
  border-image: url(../assets/art/ui/panel.webp) 130 fill / 32px stretch; border-width: 16px;
}
body.art-ui #tip { border-image-width: 22px; border-width: 10px; }
body.art-ui #bottom { background: none; box-shadow: none; border-top: 0; border-style: solid; border-color: transparent; border-width: 0;
  border-image: url(../assets/art/ui/bar.webp) 50 80 30 80 fill / 18px 30px 10px 30px stretch; }
body.art-ui #bottom::before { display: none; }
body.land.art-ui #bottom { border-image: none; }
/* the painted title */
.logo-img { display: block; height: 58px; width: auto; filter: drop-shadow(0 3px 0 rgba(0,0,0,.3)); }
#home-top h1:has(.logo-img) { margin: -6px 2px -8px -4px; line-height: 0; }
@media (max-width: 699px) { .logo-img { height: 46px; } }
/* full-screen pages over a dimmed piece of the painted world map, so they belong to the same world */
body.art-ui .page { background: linear-gradient(rgba(44,26,12,.86), rgba(36,20,8,.93)), url(../assets/art/maps/world-landscape.webp) center / cover, #3a2410; }
body.art-ui .page > header { background: linear-gradient(rgba(60,36,16,.92), rgba(48,28,12,.92)); }
#boot-reset { margin: 12px auto 0; display: block; font-size: 16px; height: 44px; }
.boot-card p { max-width: 86vw; margin: 0 auto 14px; line-height: 1.6; }

/* ------------------------------------------------ review 2026-10-25: whole painted ring buttons, status bar, top buttons */
#ring .opt.art { width: 70px; height: 70px; margin: -35px 0 0 -35px; border: 0; border-radius: 50%; background: center / 100% 100% no-repeat; box-shadow: 0 3px 0 rgba(0,0,0,.3); }
body.art-ui #ring .opt.art { width: 70px; height: 70px; margin: -35px 0 0 -35px; }
#ring .opt.art .price { bottom: -12px; min-width: 44px; height: 22px; font-size: 14px; }
#ring .opt.art.sel { box-shadow: 0 0 0 4px #ffe066, 0 0 16px #ffe066, 0 3px 0 rgba(0,0,0,.35); }
/* the status row: dark wood capsules with a big painted icon over their left end and large numbers */
body.art-ui #status .token { border-image: none; border: 2px solid #d9a441; border-radius: 18px; height: 34px; padding: 0 14px 0 34px; margin-left: 14px; position: relative;
  background: linear-gradient(#6b4423, #4a2c14); box-shadow: inset 0 2px 0 rgba(255,230,160,.25), 0 3px 0 rgba(0,0,0,.35); }
body.art-ui #status .token .ico { position: absolute; left: -16px; top: 50%; width: 44px; height: 44px; transform: translateY(-50%); filter: drop-shadow(0 2px 0 rgba(0,0,0,.35)); }
body.art-ui #status .token b { font-size: 19px; font-weight: 900; color: #fff6dc; letter-spacing: .5px; }
body.art-ui #st-lives b { color: #ffd2c8; }
body.art-ui #st-gold b { color: #ffe27a; }
body.land.art-ui #status { gap: 10px; }
/* round buttons with a painted symbol (back, pause, sound) */
body.art-ui .sym { padding: 0; display: grid; place-items: center; }
body.art-ui #btn-map.sym { width: 46px; height: 46px; border-image: none; border-radius: 50%; background: url(../assets/art/ui/btn-round.webp) center / 100% 100% no-repeat; box-shadow: 0 3px 0 rgba(0,0,0,.28); }
body.art-ui .sym .ico { width: 58%; height: 58%; }
body.art-ui .page > header .back { width: 46px; height: 46px; padding: 0; display: grid; place-items: center; font-size: 0; }
body.art-ui .page > header .back .ico { width: 58%; height: 58%; }
/* phones: the status row fits in one line beside the hero and spells */
@media (max-width: 699px) {
  body.art-ui #status { gap: 4px; }
  body.art-ui #status .token { height: 30px; padding: 0 10px 0 26px; margin-left: 12px; white-space: nowrap; }
  body.art-ui #status .token .ico { width: 36px; height: 36px; left: -13px; }
  body.art-ui #status .token b { font-size: 16px; letter-spacing: 0; white-space: nowrap; }
}
/* wide screens: the title, stars and hero tag stacked in the top-left corner, so the world map can fill the screen */
#home.wide #home-top { right: auto; flex-direction: column; align-items: flex-start; gap: 6px; }
#home.wide #home-top h1 { margin: -4px 0 0 -2px; }
@media (max-height: 560px) { #home.wide .logo-img { height: 46px; } #home.wide #home-top { gap: 4px; } }
/* short wide windows (the hub on a wide monitor, phones held sideways): a compact corner bar, so the map can fill */
@media (max-height: 560px) {
  #home.wide #home-bar { right: 10px; bottom: 10px; padding: 4px 6px; gap: 2px; border-width: 2px; border-radius: 14px; }
  #home.wide .home-btn { min-width: 50px; font-size: 11px; padding: 2px 3px; }
  #home.wide .home-btn .ico { width: 32px; height: 32px; }
}
