/* 零日生存戰 R8：樂高積木風遊戲介面 */
:root {
  --ink: #1d2433; --paper: #fffaf0; --roc: #2e7df6; --roc-dk: #1b56b8; --prc: #e8392f; --prc-dk: #a8231b;
  --yellow: #ffd23f; --yellow-dk: #d9a400; --green: #4cc26e; --green-dk: #2e8a4a; --sky: #9fdcff; --grey: #e9edf2;
  --brick-shadow: 0 5px 0 var(--ink);
  font-family: Huninn, "jf open 粉圓", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--sky); color: var(--ink); user-select: none; -webkit-user-select: none; }
#gl, #ov { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#ov { pointer-events: none; }
button { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- bricks ---------- */
.brick { position: relative; background: var(--paper); border: 3px solid var(--ink); border-radius: 16px; box-shadow: var(--brick-shadow); }
.brick.studs::before { content: ""; position: absolute; left: 16px; right: 16px; top: -11px; height: 11px;
  background: radial-gradient(circle at 50% 70%, var(--stud, #ffd23f) 0 6px, var(--ink) 6.5px 8.5px, transparent 9px) 0 0 / 26px 22px repeat-x; }
.btn { --c: var(--yellow); --d: var(--yellow-dk); cursor: pointer; border: 3px solid var(--ink); background: var(--c); border-radius: 12px; padding: 8px 14px;
  font-weight: 900; font-size: 15px; box-shadow: 0 4px 0 var(--ink), inset 0 -4px 0 var(--d); transition: transform .06s, box-shadow .06s, filter .1s; white-space: nowrap; }
.btn:hover { filter: brightness(1.08) saturate(1.1); transform: translateY(-1px); }
.btn:active, .btn.on { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink), inset 0 -2px 0 var(--d); }
.btn:disabled { filter: grayscale(.8) brightness(.95); cursor: not-allowed; opacity: .6; transform: none; }
.btn.blue { --c: #5aa2ff; --d: #2e6fd0; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.btn.red { --c: #ff5d52; --d: #c73a31; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.btn.green { --c: #5ad37f; --d: #2f9a54; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.btn.white { --c: #fff; --d: #d9dee6; }
.btn.big { font-size: 22px; padding: 12px 26px; border-radius: 16px; }
.btn.icon { padding: 6px 9px; min-width: 40px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border: 2px solid var(--ink); border-radius: 999px; font-size: 12px; font-weight: 800; background: #fff; }

/* ---------- title / screens ---------- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 18px; z-index: 20; pointer-events: none; }
.screen > * { pointer-events: auto; }
#title { background: radial-gradient(ellipse at 50% 40%, rgba(255,255,255,.0) 30%, rgba(30,60,110,.35)); }
.logo { text-align: center; filter: drop-shadow(0 8px 0 var(--ink)); }
.logo .l1 { display: flex; gap: 6px; justify-content: center; }
.logo .tile { width: 92px; height: 92px; display: grid; place-items: center; font-size: 62px; font-weight: 900; color: #fff; border: 4px solid var(--ink); border-radius: 14px; position: relative;
  text-shadow: 0 4px 0 rgba(0,0,0,.25); animation: bob 2.6s ease-in-out infinite; }
.logo .tile::before { content: ""; position: absolute; top: -14px; left: 10px; right: 10px; height: 14px; background: radial-gradient(circle at 50% 70%, var(--sc) 0 9px, var(--ink) 9.5px 12px, transparent 12.5px) 0 0/36px 26px repeat-x; }
.logo .tile:nth-child(1) { background: var(--roc); --sc: var(--roc); animation-delay: 0s; } .logo .tile:nth-child(2) { background: var(--yellow); color: var(--ink); --sc: var(--yellow); animation-delay: .15s; }
.logo .tile:nth-child(3) { background: var(--green); --sc: var(--green); animation-delay: .3s; } .logo .tile:nth-child(4) { background: var(--prc); --sc: var(--prc); animation-delay: .45s; }
.logo .tile:nth-child(5) { background: #ff9f1c; --sc: #ff9f1c; animation-delay: .6s; }
.logo .sub { margin-top: 18px; display: inline-block; background: var(--ink); color: #fff; font-weight: 900; padding: 6px 16px; border-radius: 10px; font-size: 18px; letter-spacing: 2px; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-8px) rotate(1deg); } }
.title-btns { display: flex; gap: 14px; }
.disclaimer { font-size: 12px; background: rgba(255,255,255,.85); border: 2px solid var(--ink); border-radius: 10px; padding: 4px 10px; max-width: 640px; text-align: center; }

#pick .cards { display: flex; gap: 26px; }
.fcard { width: 330px; padding: 18px 18px 16px; cursor: pointer; text-align: center; transition: transform .15s; }
.fcard:hover { transform: translateY(-6px) rotate(-.5deg); }
.fcard.sel { outline: 5px solid var(--yellow); outline-offset: 4px; }
.fcard h2 { margin: 6px 0 2px; font-size: 26px; }
.fcard.roc { --stud: var(--roc); } .fcard.prc { --stud: var(--prc); }
.fcard .flag { height: 10px; border-radius: 6px; margin: 0 30px 10px; }
.fcard.roc .flag { background: var(--roc); } .fcard.prc .flag { background: var(--prc); }
.fcard .thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0; }
.fcard .thumbs img { width: 100%; aspect-ratio: 4/3; background: linear-gradient(#bfe8ff, #e9f7ff); border: 2px solid var(--ink); border-radius: 10px; }
.fcard p { margin: 4px 0; font-size: 14px; }
.diff { display: flex; gap: 10px; align-items: center; padding: 10px 16px; font-weight: 900; }

/* ---------- story bubble ---------- */
#story { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); display: flex; align-items: flex-end; gap: 14px; z-index: 22; }
#story .face { width: 96px; height: 110px; flex: none; }
#story .bubble { width: min(640px, 70vw); padding: 18px 20px 14px; font-size: 20px; font-weight: 800; line-height: 1.5; min-height: 96px; }
#story .bubble small { display: block; font-size: 13px; font-weight: 600; opacity: .75; margin-top: 8px; }
#story .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; position: absolute; }
#clock { left: 14px; top: 14px; display: flex; gap: 8px; align-items: center; padding: 8px 10px; }
#clock .time { font-size: 22px; font-weight: 900; min-width: 74px; text-align: center; font-variant-numeric: tabular-nums; }
#clock .phase { font-size: 12px; font-weight: 900; background: var(--ink); color: #fff; border-radius: 8px; padding: 2px 8px; }
#tools { right: 14px; top: 14px; display: flex; gap: 6px; padding: 8px; }
#objbar { left: 50%; top: 24px; transform: translateX(-50%); display: flex; gap: 10px; align-items: stretch; padding: 8px 12px; }
.objgrp { display: flex; gap: 6px; align-items: center; }
.objgrp { position: relative; }
.objgrp .lbl { position: absolute; top: -21px; left: 6px; font-size: 12.5px; font-weight: 900; letter-spacing: 2px; color: #fff; padding: 2px 10px 3px; border: 2.5px solid var(--ink); border-radius: 9px; box-shadow: 0 2px 0 var(--ink); white-space: nowrap; z-index: 1; }
.obj { width: 46px; text-align: center; border: 2.5px solid var(--ink); border-radius: 10px; background: #fff; padding: 3px 2px 4px; position: relative; }
.obj .ic { font-size: 20px; line-height: 1.1; }
.obj .hp { height: 6px; border: 1.5px solid var(--ink); border-radius: 4px; background: #39404d; overflow: hidden; margin: 2px 3px 0; }
.obj .hp i { display: block; height: 100%; background: #6fe46f; transition: width .3s; }
.obj.dead { background: #565d6b; color: #fff; } .obj.dead .ic { filter: grayscale(1); }
.obj.dead::after { content: "✖"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 30px; color: #ff5d52; text-shadow: 0 2px 0 var(--ink); }
.obj.enemy.dead::after { content: "✔"; color: #7dff6b; }
.obj.flash { animation: shake .4s; }
@keyframes shake { 20% { transform: translateX(-4px) rotate(-3deg); } 40% { transform: translateX(4px) rotate(3deg); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.capbox { display: flex; flex-direction: column; justify-content: center; width: 92px; font-size: 11px; font-weight: 900; text-align: center; }
.capbox .hp { height: 10px; border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; background: #39404d; margin-top: 3px; }
.capbox .hp i { display: block; height: 100%; background: var(--yellow); }
.vsdot { align-self: center; font-weight: 900; font-size: 18px; }

#feed { right: 14px; top: 84px; width: 300px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; padding: 8px 12px; font-size: 14px; font-weight: 800; border: 3px solid var(--ink); border-radius: 12px; background: #fff; box-shadow: 0 4px 0 var(--ink);
  animation: tin .35s cubic-bezier(.3,1.6,.6,1); display: flex; gap: 8px; align-items: center; cursor: pointer; }
.toast.good { background: #e6ffd9; } .toast.bad { background: #ffe1dd; } .toast.big { font-size: 16px; padding: 10px 14px; }
.toast.out { animation: tout .4s forwards; }
@keyframes tin { from { transform: translateX(120%) scale(.6); } to { transform: none; } }
@keyframes tout { to { transform: translateX(120%); opacity: 0; } }

#mini { right: 14px; bottom: 14px; padding: 6px; }
#mini canvas { display: block; width: 216px; height: 216px; touch-action: none; border-radius: 10px; border: 2px solid var(--ink); cursor: pointer; background: #2a7fd4; }
#mini .mtitle { position: absolute; left: 12px; top: -12px; font-size: 12px; font-weight: 900; background: var(--ink); color: #fff; padding: 1px 8px; border-radius: 8px; }

#unitpanel { left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; gap: 12px; padding: 10px 12px 10px 10px; align-items: stretch; max-width: calc(100vw - 520px); }
#unitpanel .thumb { width: 116px; height: 88px; border: 2.5px solid var(--ink); border-radius: 12px; background: linear-gradient(#bfe8ff, #f2fbff); flex: none; object-fit: contain; }
#unitpanel .info { min-width: 200px; display: flex; flex-direction: column; gap: 3px; }
#unitpanel .nm { font-size: 18px; font-weight: 900; line-height: 1.1; }
#unitpanel .grp { font-size: 12px; font-weight: 700; opacity: .75; }
.meters { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 6px; align-items: center; font-size: 11px; font-weight: 800; }
.meter { height: 9px; border: 2px solid var(--ink); border-radius: 6px; background: #39404d; overflow: hidden; min-width: 110px; }
.meter i { display: block; height: 100%; }
.cmds { display: grid; grid-template-columns: repeat(4, 64px); gap: 7px; align-content: center; }
.cmd { position: relative; height: 58px; padding: 4px 2px 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; line-height: 1.05; border-radius: 12px; }
.cmd .e { font-size: 22px; line-height: 1; margin-bottom: 2px; }
.cmd kbd { position: absolute; top: 2px; right: 4px; font-size: 9px; opacity: .7; font-family: inherit; }
.cmd .cnt { position: absolute; top: -9px; left: -7px; background: var(--prc); color: #fff; border: 2px solid var(--ink); border-radius: 999px; font-size: 11px; padding: 0 5px; }
.cmd .cool { position: absolute; inset: 0; border-radius: 9px; background: rgba(29,36,51,.45); clip-path: inset(var(--k, 0%) 0 0 0); }
.multi { display: flex; flex-wrap: wrap; gap: 6px; max-width: 360px; align-content: flex-start; }
.multi .chip { cursor: pointer; }

#deploy { left: 14px; top: 84px; bottom: 14px; width: 340px; display: flex; flex-direction: column; padding: 12px 10px 10px; --stud: var(--yellow); }
#deploy h3 { margin: 2px 4px 6px; font-size: 20px; display: flex; align-items: center; gap: 8px; }
#deploy .tot { display: flex; gap: 6px; margin: 0 4px 8px; }
#deploy .tot .chip { font-size: 12px; }
#deploy .tabs { display: flex; gap: 5px; margin: 0 2px 8px; flex-wrap: wrap; }
#deploy .tabs .btn { padding: 5px 9px; font-size: 13px; }
#deploy .list { flex: 1; overflow-y: auto; padding: 2px 4px 6px; }
#deploy .list::-webkit-scrollbar { width: 10px; } #deploy .list::-webkit-scrollbar-thumb { background: #b7c0cc; border-radius: 8px; border: 2px solid var(--paper); }
.grp-h { font-size: 13px; font-weight: 900; margin: 10px 2px 5px; display: flex; align-items: center; gap: 6px; }
.grp-h::after { content: ""; flex: 1; height: 3px; background: var(--ink); opacity: .15; border-radius: 2px; }
.urow { display: flex; align-items: center; gap: 8px; padding: 5px 7px 5px 5px; margin-bottom: 6px; border: 2.5px solid var(--ink); border-radius: 12px; background: #fff; cursor: pointer; box-shadow: 0 3px 0 var(--ink); transition: transform .08s; }
.urow:hover { transform: translateX(3px); background: #fffbe0; }
.urow.on { background: var(--yellow); transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.urow.empty { opacity: .45; }
.urow img { width: 54px; height: 41px; border-radius: 8px; border: 2px solid var(--ink); background: linear-gradient(#bfe8ff, #f2fbff); flex: none; }
.urow .nm { flex: 1; font-size: 13px; font-weight: 800; line-height: 1.15; }
.urow .nm small { display: block; font-size: 11px; opacity: .65; font-weight: 700; }
.urow .ct { text-align: right; font-size: 11px; font-weight: 800; line-height: 1.25; }
.urow .ct b { font-size: 17px; }
#deploy .foot { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
#deploy .foot .btn { flex: 1; }
#deploy .note { font-size: 11px; opacity: .7; margin: 6px 4px 0; }

#hint { left: 50%; top: 92px; transform: translateX(-50%); padding: 7px 14px; font-weight: 900; font-size: 15px; pointer-events: none; white-space: nowrap; }
#hint.bad { background: #ffe1dd; } #hint.good { background: #e6ffd9; }
#selbox { position: fixed; border: 2px dashed #fff; background: rgba(255,225,77,.18); pointer-events: none; z-index: 9; box-shadow: 0 0 0 1px var(--ink); }
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.lbl { position: absolute; transform: translate(-50%, -50%); font-weight: 900; white-space: nowrap; color: #fff; text-shadow: 0 2px 0 var(--ink), 0 0 6px rgba(0,0,0,.35); }
.lbl.province { font-size: 26px; letter-spacing: 8px; color: rgba(255,255,255,.85); }
.lbl.sea { font-size: 22px; letter-spacing: 10px; color: rgba(255,255,255,.75); }
.lbl.island { font-size: 13px; background: rgba(29,36,51,.6); padding: 1px 7px; border-radius: 8px; text-shadow: none; }
.lbl.taiwan { font-size: 28px; letter-spacing: 8px; }

.modal { position: fixed; inset: 0; background: rgba(20,30,50,.45); display: grid; place-items: center; z-index: 40; }
.modal .box { width: min(520px, 92vw); padding: 20px 22px 18px; }
.modal h2 { margin: 0 0 12px; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0; font-weight: 800; }
.seg { display: flex; gap: 6px; }
.seg .btn { padding: 5px 12px; font-size: 14px; }
.help-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 14px; }
.help-grid kbd { background: var(--ink); color: #fff; border-radius: 6px; padding: 1px 7px; font-family: inherit; font-weight: 900; font-size: 12px; white-space: nowrap; }

#result .box { width: min(560px, 92vw); padding: 22px 26px 20px; text-align: center; }
#result .big { font-size: 64px; line-height: 1; animation: bob 2s infinite; }
#result h1 { margin: 6px 0 2px; font-size: 40px; }
#result .kind { display: inline-block; background: var(--ink); color: #fff; border-radius: 10px; padding: 3px 12px; font-weight: 900; }
#result table { margin: 14px auto 6px; border-collapse: separate; border-spacing: 10px 4px; font-weight: 800; }
#result td:first-child { text-align: left; } #result td { text-align: right; }
#result .row { display: flex; gap: 10px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }

#loading { position: fixed; inset: 0; display: grid; place-items: center; background: var(--sky); z-index: 60; font-weight: 900; font-size: 20px; }
#loading .spin { width: 64px; height: 44px; margin: 0 auto 14px; background: var(--prc); border: 4px solid var(--ink); border-radius: 8px; position: relative; animation: flip 1s infinite; }
#loading .spin::before { content: ""; position: absolute; top: -14px; left: 4px; right: 4px; height: 14px; background: radial-gradient(circle at 50% 70%, var(--prc) 0 7px, var(--ink) 7.5px 10px, transparent 10.5px) 0 0/26px 24px repeat-x; }
@keyframes flip { 0% { transform: rotate(0); background: var(--prc); } 33% { background: var(--yellow); } 66% { background: var(--roc); } 100% { transform: rotate(360deg); background: var(--prc); } }

@media (max-width: 1420px) { #objbar { left: auto; right: 180px; transform: none; } }
@media (max-width: 1250px) { #unitpanel { max-width: calc(100vw - 260px); left: calc(50% - 110px); } .cmds { grid-template-columns: repeat(4, 58px); } }
@media (max-height: 760px) { #deploy { top: 74px; } .fcard .thumbs { display: none; } }

/* ---------- R9：戰法卡、發動橫幅、勝利演出 ---------- */
#tacbar { left: 14px; top: 84px; width: 178px; padding: 14px 8px 8px; display: flex; flex-direction: column; gap: 6px; max-height: calc(100vh - 110px); overflow-y: auto; --stud: #ff8a1f; }
#tacbar .tt { font-weight: 900; font-size: 14px; margin: 0 4px 2px; }
.tcard { position: relative; overflow: hidden; display: grid; grid-template-columns: 30px 1fr; grid-template-rows: auto auto; align-items: center; text-align: left; gap: 0 6px; padding: 5px 7px; border: 2.5px solid var(--ink); border-radius: 11px; background: #fff; cursor: pointer; box-shadow: 0 3px 0 var(--ink); font: inherit; transition: transform .08s; }
.tcard:hover { transform: translateX(3px); background: #fffbe0; }
.tcard.on { background: var(--yellow); transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.tcard .ti { grid-row: span 2; font-size: 22px; text-align: center; }
.tcard .tn { font-size: 12.5px; font-weight: 900; line-height: 1.1; }
.tcard .tx { font-size: 11px; font-weight: 800; opacity: .7; }
.tcard .tcd { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(29,36,51,.32); pointer-events: none; transition: height .2s linear; }
.tcard.cool { filter: grayscale(.4); }
#tacBanner { position: fixed; left: 50%; top: 30%; z-index: 30; display: flex; gap: 14px; align-items: center; padding: 14px 22px 14px 16px; border: 4px solid var(--ink); border-radius: 18px; box-shadow: 0 7px 0 var(--ink); background: #fff; pointer-events: none; max-width: min(620px, 92vw); }
#tacBanner.hide { opacity: 0; transform: translate(-50%, -40px) scale(.7); transition: opacity .35s, transform .35s; }
#tacBanner.show { opacity: 1; transform: translate(-50%, 0) scale(1); animation: bannerIn .45s cubic-bezier(.3,1.7,.5,1); }
#tacBanner.mine { background: #fff7cf; } #tacBanner.foe { background: #ffe1dd; }
#tacBanner .bi { font-size: 54px; filter: drop-shadow(0 3px 0 rgba(0,0,0,.2)); }
#tacBanner .bt { display: flex; flex-direction: column; gap: 2px; }
#tacBanner small { font-weight: 900; font-size: 13px; opacity: .75; } #tacBanner b { font-size: 28px; line-height: 1.1; } #tacBanner span { font-size: 14px; font-weight: 700; }
@keyframes bannerIn { from { transform: translate(-50%, 0) scale(.3) rotate(-8deg); opacity: 0; } to { transform: translate(-50%, 0) scale(1); opacity: 1; } }
#victory { position: fixed; inset: 0; z-index: 35; pointer-events: none; display: flex; justify-content: center; align-items: flex-start; padding-top: 88px; }
#victory.hidden { display: none; }
#victory .vbox { pointer-events: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
#victory .stamp { font-size: 58px; font-weight: 900; color: #fff; padding: 4px 34px; border: 6px solid var(--ink); border-radius: 22px; box-shadow: 0 9px 0 var(--ink); transform: rotate(-6deg); animation: stamp .6s cubic-bezier(.2,1.8,.5,1) both; }
#victory .ROC .stamp { background: var(--roc); } #victory .PRC .stamp { background: var(--prc); }
@keyframes stamp { from { transform: scale(3) rotate(-20deg); opacity: 0; } to { transform: rotate(-6deg); opacity: 1; } }
#victory .vname { font-size: 24px; font-weight: 900; color: #fff; text-shadow: 0 3px 0 var(--ink), 0 0 10px rgba(0,0,0,.4); }
#victory .vsong, #victory .vkind { background: rgba(255,255,255,.92); border: 3px solid var(--ink); border-radius: 12px; padding: 4px 12px; font-weight: 800; }
#victory .vsong { animation: bob 2.4s infinite; }

/* R10 主動還擊開關＋防空攔截計數 */
.tcard.auto { background: #eef3ff; }
.tcard.auto .lamp { position: absolute; right: 7px; top: 7px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--ink); background: #9aa3b5; }
.tcard.auto.armed { background: #d9ffe3; }
.tcard.auto.armed .lamp { background: #3cd66a; box-shadow: 0 0 6px #3cd66a; }
.tcard.auto.fight { background: #ffd9cf; animation: retPulse .7s ease-in-out infinite alternate; }
.tcard.auto.fight .lamp { background: #ff4b2b; box-shadow: 0 0 8px #ff4b2b; }
@keyframes retPulse { from { transform: translateX(0); } to { transform: translateX(3px) rotate(-1deg); } }
.adef { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 3px 6px; padding: 6px 8px; margin: 2px 0 4px; border: 2.5px solid var(--ink); border-radius: 11px; background: #e3f8ff; box-shadow: 0 3px 0 var(--ink); font-size: 12px; font-weight: 900; }
.adef b { font-size: 13px; }
.adef i { grid-column: span 2; height: 8px; border: 2px solid var(--ink); border-radius: 6px; background: #fff; overflow: hidden; }
.adef u { display: block; height: 100%; width: 0; background: #29b6f6; transition: width .3s; }

/* R11 開戰特寫：官員搭機落跑 */
#fleeTag { position: fixed; left: 0; top: 0; z-index: 31; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 14px 10px; border: 4px solid var(--ink); border-radius: 16px; background: #ffe14d; box-shadow: 0 6px 0 var(--ink); font-weight: 900; text-align: center; animation: fleeWobble .5s ease-in-out infinite alternate; }
#fleeTag b { font-size: 13px; color: #e8392f; letter-spacing: 2px; }
#fleeTag span { font-size: 20px; }
#fleeTag small { font-size: 11px; opacity: .75; }
#fleeTag::after { content: ''; position: absolute; left: 50%; bottom: -14px; margin-left: -10px; border: 10px solid transparent; border-top-color: var(--ink); }
@keyframes fleeWobble { from { rotate: -2deg; } to { rotate: 2deg; } }
#fleeBar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-between; align-items: center; padding: 14px 22px; background: #1d2433; color: #fff; font-weight: 900; font-size: 18px; }
#fleeBar::before { content: ''; position: fixed; left: 0; right: 0; top: 0; height: 64px; background: #1d2433; }
#fleeBar .btn { color: var(--ink); }

/* ---------- R14 手機版：觸控、直式版面（桌面版不受影響） ---------- */
#gl { touch-action: none; }
html, body { overscroll-behavior: none; -webkit-touch-callout: none; }
#mdock, #depFold { display: none; }
#mini.fold canvas { display: none; }
#mini.fold { padding: 4px; }
#mini.fold .mtitle { position: static; display: block; padding: 6px 10px; font-size: 13px; }
body.mobile .btn:hover, body.mobile .tcard:hover, body.mobile .urow:hover, body.mobile .fcard:hover { transform: none; filter: none; }

@media (orientation: portrait) and (max-width: 820px) {
  /* 標題／選陣營 */
  .logo .tile { width: 58px; height: 58px; font-size: 38px; border-radius: 10px; }
  .logo .tile::before { top: -10px; left: 6px; right: 6px; height: 10px; background-size: 22px 18px; }
  .logo .sub { font-size: 14px; }
  .title-btns { flex-direction: column; align-items: stretch; width: min(320px, 86vw); }
  .disclaimer { max-width: 90vw; }
  #pick { justify-content: flex-start; overflow-y: auto; padding: 26px 0 30px; gap: 14px; }
  #pick .cards { flex-direction: column; gap: 22px; }
  .fcard { width: min(340px, 88vw); padding: 12px 14px; }
  .fcard .thumbs { grid-template-columns: repeat(6, 1fr); margin: 6px 0; }
  .fcard h2 { font-size: 22px; }
  .diff { flex-direction: column; width: min(340px, 88vw); }
  .diff .seg { flex-direction: column; width: 100%; } .diff .seg .btn { white-space: normal; }
  #pick .title-btns { flex-direction: row; justify-content: center; }
  #story { left: 8px; right: 8px; bottom: 16px; transform: none; gap: 6px; }
  #story .face { width: 56px; height: 64px; }
  #story .bubble { width: auto; flex: 1; font-size: 16px; padding: 14px 14px 10px; }
  .lbl.province { font-size: 18px; letter-spacing: 4px; } .lbl.sea { font-size: 16px; letter-spacing: 6px; } .lbl.taiwan { font-size: 20px; letter-spacing: 5px; }

  /* 頂端列：時間＋工具，下面一排雙方目標 */
  #clock { left: 8px; top: 8px; padding: 5px 6px; gap: 5px; }
  #clock .time { font-size: 17px; min-width: 54px; }
  #clock .phase { display: none; }
  #clock .seg { gap: 3px; } #clock .seg .btn.icon { min-width: 32px; }
  #clock .btn.icon, #tools .btn.icon { min-width: 36px; padding: 5px 6px; font-size: 13px; }
  #tools { right: 8px; top: 8px; padding: 5px; gap: 4px; }
  #objbar { left: 8px; right: 8px; top: 82px; transform: none; justify-content: center; gap: 4px; padding: 6px 4px; }
  .objgrp { gap: 3px; }
  .objgrp .lbl { font-size: 11px; letter-spacing: 1px; top: -19px; padding: 1px 7px 2px; }
  .obj { width: 34px; padding: 2px 1px 3px; } .obj .ic { font-size: 16px; }
  .capbox { width: 54px; font-size: 9px; line-height: 1.1; }
  .vsdot { font-size: 13px; }
  #hint { top: auto; bottom: 214px; max-width: 92vw; white-space: normal; text-align: center; font-size: 13px; padding: 6px 10px; }
  #feed { left: 8px; right: auto; top: 158px; width: min(250px, 64vw); gap: 6px; }
  .toast { font-size: 12px; padding: 6px 9px; } .toast.big { font-size: 13px; padding: 7px 10px; }
  #feed .toast:nth-child(n+4) { display: none; }
  @keyframes tin { from { transform: translateX(-120%) scale(.6); } to { transform: none; } }
  @keyframes tout { to { transform: translateX(-120%); opacity: 0; } }
  #mini { right: 8px; bottom: auto; top: 158px; padding: 4px; }
  #mini canvas { width: 118px; height: 118px; }
  #mini .mtitle { font-size: 11px; left: 8px; top: -11px; }

  /* 底部按鈕列 */
  #mdock { display: flex; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); padding: 6px; gap: 6px; }
  #mdock .btn { flex: 1; min-height: 46px; padding: 6px 4px; font-size: 14px; }
  #mdock[data-mode="deploy"] #mTac, #mdock[data-mode="deploy"] #mCancel { display: none; }
  #hud:has(#deploy:not(.hidden)) #mdock { display: none; }

  /* 戰法抽屜：從底部升起，兩欄大卡 */
  #tacbar { left: 8px; right: 8px; top: auto; bottom: calc(76px + env(safe-area-inset-bottom)); width: auto; max-height: 52vh; padding: 16px 8px 10px; display: none; grid-template-columns: 1fr 1fr; gap: 7px; z-index: 3; }
  #tacbar.open { display: grid; animation: sheetUp .28s cubic-bezier(.3,1.5,.6,1); }
  #tacbar .tt, #tacbar .adef { grid-column: 1 / -1; }
  .tcard { min-height: 50px; padding: 6px 8px; } .tcard .tn { font-size: 13px; }
  @keyframes sheetUp { from { transform: translateY(40px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }

  /* 部隊面板：底部按鈕列上方，指令按鈕排滿一列 */
  #unitpanel { left: 8px; right: 8px; bottom: calc(76px + env(safe-area-inset-bottom)); transform: none; max-width: none; flex-wrap: wrap; gap: 6px 8px; padding: 8px; }
  #unitpanel .thumb { width: 64px; height: 48px; }
  #unitpanel .info { min-width: 0; flex: 1; }
  #unitpanel .nm { font-size: 15px; } .meter { min-width: 60px; } .meters { font-size: 10px; }
  .multi { max-width: none; max-height: 64px; overflow-y: auto; }
  .cmds { grid-template-columns: repeat(6, 1fr); width: 100%; gap: 5px; }
  .cmd { height: 50px; font-size: 10.5px; } .cmd .e { font-size: 19px; } .cmd kbd { display: none; }

  /* 部署抽屜：底部卡片橫向捲動，可收起 */
  #deploy { left: 8px; right: 8px; top: auto; bottom: calc(8px + env(safe-area-inset-bottom)); width: auto; height: min(330px, 44vh); padding: 14px 8px 8px; }
  #deploy h3 { font-size: 16px; margin: 0 4px 4px; }
  #depFold { display: inline-block; margin-left: auto; font-size: 13px; }
  #deploy .tot { margin-bottom: 5px; }
  #deploy .tabs { flex-wrap: nowrap; overflow-x: auto; margin-bottom: 6px; padding-bottom: 4px; }
  #deploy .tabs .btn { padding: 6px 10px; }
  #deploy .list { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; align-items: stretch; padding: 4px 2px 8px; }
  #deploy .grp-h { writing-mode: vertical-rl; margin: 0; font-size: 11px; flex: none; }
  #deploy .grp-h::after { display: none; }
  #deploy .urow { flex: none; width: 112px; flex-direction: column; align-items: stretch; gap: 3px; margin: 0; padding: 5px; text-align: center; }
  #deploy .urow img { width: 100%; height: 56px; }
  #deploy .urow .nm { font-size: 12px; } #deploy .urow .nm small { font-size: 10px; }
  #deploy .urow .ct { text-align: center; } #deploy .urow .ct b { font-size: 15px; }
  #deploy .urow.on { transform: translateY(-4px); }
  #deploy .foot { gap: 5px; margin-top: 4px; }
  #deploy .foot .btn { padding: 7px 6px; font-size: 13px; }
  #deploy .foot #bFight { font-size: 18px; padding: 8px; }
  #deploy .note { display: none; }
  #deploy.fold { height: auto; }
  #deploy.fold .tot, #deploy.fold .tabs, #deploy.fold .list, #deploy.fold .foot .btn:not(#bFight) { display: none; }
  #hud:has(#deploy:not(.hidden):not(.fold)) #hint { bottom: calc(min(330px, 44vh) + 18px); }
  #hud:has(#deploy:not(.hidden)) #unitpanel { bottom: calc(min(330px, 44vh) + 18px); }
  #hud:has(#deploy.fold:not(.hidden)) #unitpanel { bottom: 120px; }

  /* 演出 */
  #tacBanner { padding: 10px 14px 10px 10px; gap: 8px; top: 24%; }
  #tacBanner .bi { font-size: 38px; } #tacBanner b { font-size: 20px; } #tacBanner span { font-size: 12px; }
  #victory { padding-top: 140px; } #victory .stamp { font-size: 40px; padding: 4px 20px; } #victory .vname { font-size: 19px; }
  #victory .vsong, #victory .vkind { font-size: 13px; max-width: 90vw; }
  #result h1 { font-size: 30px; } #result .big { font-size: 46px; }
  #fleeBar { font-size: 14px; padding: 10px 12px; gap: 8px; }
  .help-grid { font-size: 13px; } .modal .box { max-height: 88vh; overflow-y: auto; }
  .opt { flex-wrap: wrap; } .opt .seg { flex-wrap: wrap; }
}

/* 橫式手機：沿用桌面版但整體縮小 */
@media (orientation: landscape) and (max-height: 500px) {
  #hud > *:not(#mdock) { zoom: .62; }
  #tacbar { max-height: calc((100vh - 70px) / .62); }
  #deploy { bottom: 8px; }
  .logo .tile { width: 56px; height: 56px; font-size: 36px; }
  #story .bubble { font-size: 15px; min-height: 0; }
}
