/* ================= 主画面（开局页）=================
   设计稿坐标 1672×941（和 menu-bg 一样大）。背景 cover 铺满、底边对齐；
   .menu-stage 按设计坐标摆放，由 app.js 的 fitMenu() 等比缩放并让桌沿和背景里的桌沿对齐。
   展柜里的藏品按展柜原图（1000×1100）的搁板坐标摆，用百分比，跟着展柜缩放。 */
.setup.menu { position: fixed; inset: 0; overflow: hidden; padding: 0; background: #2A1A0E; color: var(--ink); }
.menu-bg { position: absolute; inset: 0; background: url(../assets/menu/menu-bg.webp?v=1a934bea54) center bottom / cover no-repeat; }
.menu-form { display: contents; }
.menu-stage { position: absolute; left: 0; top: 0; width: 1672px; height: 941px; transform-origin: 0 0; }

/* 展柜：原图 1000×1100，显示宽 640（s = 0.64）；底座落在桌面上 */
.menu-cabinet { position: absolute; left: 954px; top: 191px; width: 640px; height: 704px;
  background: url(../assets/menu/menu-cabinet.webp?v=f1392a928a) center / 100% 100% no-repeat;
  filter: drop-shadow(-18px 14px 18px rgba(60,25,5,.45)); }
/* 藏品：left = 格子中心，bottom = 搁板面（原图 y 428 / 610 / 785）；宽高上限按格子算，等比不拉伸 */
.menu-item { position: absolute; width: auto; height: auto; translate: -50% 0; transform: rotate(var(--r, 0deg));
  filter: drop-shadow(0 3px 2px rgba(0,0,0,.45)) drop-shadow(0 0 6px rgba(255,200,120,.18)); pointer-events: none; }
.menu-item::after { content: none; }
.it-bottle  { left: 25.5%; bottom: 61.3%; max-height: 13.6%; }
.it-tin     { left: 50%;   bottom: 61.3%; max-width: 19.5%; }
.it-tv      { left: 74.6%; bottom: 61.3%; max-width: 20.5%; max-height: 13.2%; }
.it-sewing  { left: 25%;   bottom: 44.9%; max-width: 21%; }
.it-camera  { left: 50.5%; bottom: 44.9%; max-width: 18.5%; }
.it-thermos { left: 74%;   bottom: 44.9%; max-height: 12.6%; }
.it-radio   { left: 25.8%; bottom: 29%;   max-width: 20%; }
.it-truck   { left: 50%;   bottom: 29%;   max-width: 20.5%; --r: -1deg; }
.it-bicycle { left: 74.5%; bottom: 29%;   max-width: 21.5%; }

/* 明信片：桌面右下角，斜放压在展柜底座前面 */
.menu-postcard { position: absolute; left: 1278px; top: 780px; width: 230px; transform: rotate(-9deg); transform-origin: 50% 50%;
  filter: drop-shadow(4px 6px 5px rgba(40,15,0,.5)); pointer-events: none; }

/* 左侧：徽章、标题、按钮 */
.menu-left { position: absolute; left: 330px; top: 96px; width: 640px; display: grid; justify-items: center; text-align: center; }
.menu-emblem { width: 270px; height: auto; filter: drop-shadow(0 2px 2px rgba(80,30,0,.35)); }
.setup.menu .menu-title { margin: 6px 0 0; display: flex; align-items: center; gap: 10px; color: #8E1B16;
  font: 900 78px/1.1 "Songti SC", "STSong", "SimSun", "Noto Serif SC", var(--serif); letter-spacing: .06em; white-space: nowrap;
  text-shadow: 0 1px 0 #F6DFB0, 0 2px 0 #5A0F0B, 0 6px 10px rgba(90,30,0,.25); }
.menu-title span { padding-left: .08em; }
.laurel { display: block; width: 52px; height: 92px; flex: none; background: url(../assets/menu/logo-laurel.webp?v=d2c27b0258) 0 50% / auto 100% no-repeat;
  filter: drop-shadow(0 1px 1px rgba(80,30,0,.4)); }
.laurel.r { background-position: 100% 50%; }
.menu-sub { margin: 4px 0 0; font: 700 17px var(--serif); letter-spacing: .32em; color: #6B3A1A; }
.setup.menu .lede { margin: 12px 0 0; max-width: 30em; font: 500 15px/1.6 var(--sans); color: #5A3A1E; }
.menu-actions { margin-top: 22px; display: grid; justify-items: center; gap: 14px; }
/* 按钮：底图九宫格只横向拉伸中段，高度固定，不按原像素放大 */
.setup.menu .menu-btn { box-sizing: border-box; display: grid; place-items: center; width: 380px; height: 92px; min-width: 0; min-height: 0; padding: 0 0 6px .3em; white-space: nowrap; justify-self: center;
  border: solid transparent; border-width: 0 46px; border-image: url(../assets/menu/btn-primary.webp?v=3352ef6f63) 0 92 fill / 0 46px stretch;
  background: none; box-shadow: none; border-radius: 0; text-decoration: none; cursor: pointer;
  font: 900 32px/1 "Songti SC", "STSong", var(--serif); letter-spacing: .3em; color: #FBE6B0;
  text-shadow: 0 2px 0 #5A0F0B, 0 0 8px rgba(0,0,0,.25); filter: drop-shadow(0 6px 6px rgba(70,25,0,.4)); transition: filter .15s, transform .15s; }
.setup.menu .menu-btn.secondary { width: 340px; height: 82px; border-radius: 0; gap: 0; font-size: 27px; border-image-source: url(../assets/menu/btn-secondary.webp?v=aea1cd151b); color: #5A2A12; text-shadow: 0 1px 0 #FFF4D8; }
.setup.menu .menu-btn:hover, .setup.menu .menu-btn:focus-visible { filter: drop-shadow(0 8px 8px rgba(70,25,0,.45)) brightness(1.06); }
.menu-btn:active { transform: translateY(2px); }
.menu-btn:focus-visible { outline: 3px solid #E9C76A; outline-offset: 4px; }
.setup.menu .menu-link { background: none; box-shadow: none; padding: 0; min-height: 0; border: 0; font: inherit; color: #8E1B16; text-decoration: underline; cursor: pointer; }

/* 右上角齿轮：设置与声音 */
.setup.menu .menu-gear { position: absolute; right: 22px; top: 18px; z-index: 5; width: clamp(40px, 6.5vh, 62px); height: clamp(40px, 6.5vh, 62px); min-height: 0; padding: 0; border: 0; border-radius: 50%;
  background: url(../assets/menu/icon-gear.webp?v=4cb09db3a8) center / contain no-repeat; box-shadow: none; filter: drop-shadow(0 4px 4px rgba(60,20,0,.45)); cursor: pointer; }
.menu-gear:hover, .menu-gear:focus-visible { filter: drop-shadow(0 4px 6px rgba(60,20,0,.55)) brightness(1.08); }
@media (prefers-reduced-motion: no-preference) { .menu-gear:hover { transform: rotate(30deg); transition: transform .3s; } }

/* 设置面板：不跟舞台缩放，字号保持可读 */
.menu-settings { position: absolute; right: 22px; top: 92px; z-index: 6; width: min(440px, calc(100vw - 44px)); max-height: calc(100vh - 110px); overflow: auto;
  box-sizing: border-box; padding: 16px 20px 18px; display: grid; gap: 12px; background: var(--paper-2); color: var(--ink); border-radius: 12px;
  box-shadow: 0 0 0 4px #4A2A16, 0 0 0 6px var(--brass), 0 24px 50px rgba(0,0,0,.55); }
.menu-settings[hidden] { display: none; }
.menu-settings .ms-head { display: flex; justify-content: space-between; align-items: center; font: 800 18px var(--serif); }
.menu-settings label { display: grid; gap: 4px; font-weight: 600; }
.menu-settings select { box-shadow: inset 0 0 0 1px #CDBF9F; }
.ms-sound { display: flex; gap: 6px; align-items: center; font-weight: 600; }
.ms-sound span { margin-right: 6px; white-space: nowrap; }
.ms-sound button { flex: 1; }
.ms-sound button { min-height: 32px; padding: 2px 14px; background: #EFE4C8; }
.ms-sound button[aria-pressed="true"] { background: #8E1B16; color: #FBE6B0; }

/* 盖过 style.css 里旧开局卡片的 #setup-form button */
#setup-form .menu-btn.primary { font-size: 34px; min-width: 0; justify-self: center; }
/* 「怎么玩」：两个大按钮下方的次级入口，文字链样式，不抢主按钮 */
.setup.menu .menu-howto { margin-top: 2px; min-height: 0; padding: 4px 14px; background: none; border: 0; box-shadow: none; border-radius: 16px; cursor: pointer;
  font: 700 19px var(--serif); letter-spacing: .2em; color: #7A3A1E; text-decoration: underline; text-decoration-color: rgba(122,58,30,.35); text-underline-offset: 5px; }
.setup.menu .menu-howto:hover, .setup.menu .menu-howto:focus-visible { color: #8E1B16; background: rgba(255,240,205,.5); text-decoration-color: currentColor; }
#setup-form .menu-howto { justify-self: center; min-width: 0; font-size: 19px; }
/* 进度备份 */
.ms-save { display: grid; gap: 6px; border-top: 1px solid #D6C9AA; padding-top: 10px; }
.ms-save > b { font: 800 15px var(--serif); }
.ms-note { margin: 0; font-size: 12.5px; color: #6b5d48; line-height: 1.5; }
.ms-note.bad { color: #A0281E; font-weight: 600; }
.ms-save-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.ms-save-btns button, .ms-file { min-height: 32px; padding: 4px 12px; background: #EFE4C8; border-radius: 6px; font: 600 13px var(--sans); cursor: pointer; display: inline-flex; align-items: center; }
.ms-file input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.ms-file:focus-within { outline: 3px solid var(--amber); outline-offset: 2px; }
#save-text { width: 100%; box-sizing: border-box; font: 11px/1.4 ui-monospace, Menlo, monospace; resize: vertical; border-radius: 6px; border: 1px solid #CDBF9F; padding: 6px; background: #FFFCF4; }

/* 语言切换：齿轮左边一枚小圆角牌子（EN / 中文），和齿轮同高、对齐 */
.setup.menu .menu-lang { position: absolute; top: 18px; right: calc(22px + clamp(40px, 6.5vh, 62px) + 12px); z-index: 5;
  height: clamp(40px, 6.5vh, 62px); min-width: clamp(52px, 8vh, 72px); padding: 0 14px; border-radius: 999px; cursor: pointer;
  font: 700 clamp(15px, 2.2vh, 19px)/1 var(--serif, serif); letter-spacing: .04em; color: #7A1E12;
  background: rgba(255,246,224,.88); border: 2px solid #C9A86A; box-shadow: 0 3px 8px rgba(60,20,0,.25); }
.setup.menu .menu-lang:hover, .setup.menu .menu-lang:focus-visible { background: #FFF3D2; outline: 3px solid #E0B04A; outline-offset: 2px; }
.ms-lang { display: flex; gap: 6px; align-items: center; font-weight: 600; }
.ms-lang span { margin-right: 6px; white-space: nowrap; }
.ms-lang button { flex: 1; min-height: 32px; padding: 2px 14px; background: #EFE4C8; }
.ms-lang button[aria-pressed="true"] { background: #8E1B16; color: #FBE6B0; }
/* 旧的 #setup-form button 规则会给按钮加最小宽度：齿轮和语言按钮按自身尺寸 */
#setup-form .menu-gear { min-width: 0; width: clamp(40px, 6.5vh, 62px); }
#setup-form .menu-lang { min-width: clamp(52px, 8vh, 72px); width: auto; }

/* 英文界面：中文排版用的大字距在英文里会把单词拆散；标题收小一号放进桂冠之间 */
html[data-lang="en"] .setup.menu .menu-title { font-size: 64px; letter-spacing: .01em; }
html[data-lang="en"] .menu-sub { letter-spacing: .08em; font-size: 15px; max-width: 34em; }
html[data-lang="en"] .setup.menu .menu-btn { letter-spacing: .06em; }
html[data-lang="en"] .setup.menu .menu-howto { letter-spacing: .03em; }
html[data-lang="en"] .setup.menu .menu-btn.secondary { font-size: 24px; }
/* 设置面板里的小按钮不吃旧的 #setup-form button 最小宽度（英文标签更长时会把面板撑出右边） */
#setup-form .menu-settings :is(.ms-sound, .ms-lang, .ms-save-btns) button, #setup-form .menu-settings .menu-link { min-width: 0; }
.menu-settings > * { min-width: 0; }

/* ===== 触屏（手机 / 平板）：可点区域 ≥ 44px ===== */
@media (pointer: coarse) {
  /* 主画面舞台是整体缩放的：命中框用 ::after 按设计坐标扩，--hit-* 写设计坐标下的扩展量（测试按缩放比换算） */
  .setup.menu .menu-howto { position: relative; --hit-y: 34; --hit-x: 20; }
  .setup.menu .menu-howto::after { content: ""; position: absolute; inset: -34px -20px; }
  .setup.menu .menu-actions { gap: 26px; }
  .setup.menu .menu-btn { position: relative; --hit-y: 8; }
  .setup.menu .menu-btn::after { content: ""; position: absolute; inset: -8px -46px; }
  .setup.menu :is(.menu-gear, .menu-lang) { --hit-y: 3; --hit-x: 3; }
  .setup.menu :is(.menu-gear, .menu-lang)::after { content: ""; position: absolute; inset: -3px; }
  .setup.menu .menu-gear, .setup.menu .menu-lang { top: max(18px, var(--sai-t, 0px)); }
  .setup.menu .menu-gear { right: max(22px, var(--sai-r, 0px)); }
  /* 设置面板：每一行按钮、下拉、选项都给足 44 */
  .menu-settings :is(button, select, summary, .ms-file) { min-height: 44px; }
  .menu-settings label.radio { min-height: 44px; display: flex; align-items: center; }
  .menu-settings .menu-link { min-height: 44px; padding: 0 8px; }
}
@media (pointer: coarse) { .setup.menu .menu-settings .menu-link { min-height: 44px; padding: 0 8px; } }
@media (pointer: coarse) {
  .setup.menu .menu-howto { --hit-y: 40; --hit-x: 18; }
  .setup.menu .menu-howto::after { inset: -40px -18px; }
  .setup.menu .menu-btn { --hit-y: 14; }
  .setup.menu .menu-btn::after { inset: -14px -46px; }
}

/* 「联机对战」：和「品牌档案馆」同款的次级大按钮（只在有联机后端时出现）；三个大按钮时整体收紧一点，桌面和短横屏都放得下 */
.setup.menu .menu-btn[hidden] { display: none; }
#setup-form .menu-online { justify-self: center; min-width: 0; }
.setup.menu .menu-actions:has(#setup-online:not([hidden])) { gap: 10px; margin-top: 16px; }
.setup.menu .menu-actions:has(#setup-online:not([hidden])) .menu-btn.primary { height: 84px; }
.setup.menu .menu-actions:has(#setup-online:not([hidden])) .menu-btn.secondary { height: 72px; font-size: 25px; }
html[data-lang="en"] .setup.menu .menu-actions:has(#setup-online:not([hidden])) .menu-btn.secondary { font-size: 22px; }
@media (pointer: coarse) {
  /* 触屏：667×375 上舞台缩到约 0.4，次级按钮加高到 76、命中框上下各扩 17（设计坐标）才够 44 */
  .setup.menu .menu-actions:has(#setup-online:not([hidden])) { gap: 22px; }
  .setup.menu .menu-actions:has(#setup-online:not([hidden])) .menu-btn.secondary { height: 76px; --hit-y: 17; }
  .setup.menu .menu-actions:has(#setup-online:not([hidden])) .menu-btn.secondary::after { inset: -17px -46px; }
}
