/* 烽火浮島錄 — 復古 RPG 視窗風(深藍底、米白雙框、像素數字) */
:root {
  --win: #141c4a;
  --win-2: #1d2862;
  --edge: #f3ecd8;
  --ink: #f3ecd8;
  --dim: #aab0d0;
  --gold: #ffd34d;
  --red: #e8503a;
  --green: #7fd36a;
  --pix: 'Press Start 2P', ui-monospace, monospace;
  --cjk: 'PingFang TC', 'Heiti TC', 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
  --serif: 'Songti TC', 'Noto Serif TC', 'PMingLiU', serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: var(--cjk);
  color: var(--ink);
  background: linear-gradient(180deg, #9fb7cc 0%, #e8c9a0 38%, #f0c497 60%, #2f7d8f 100%);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#floaters { position: fixed; inset: 0; pointer-events: none; }
[hidden] { display: none !important; }

/* 經典 RPG 視窗:深藍底 + 米白框 + 外圈深色 */
.win {
  background: var(--win);
  border: 3px solid var(--edge);
  border-radius: 6px;
  box-shadow: 0 0 0 3px var(--win), 0 6px 18px rgba(20, 16, 40, .35);
  color: var(--ink);
}
button { font: inherit; color: inherit; cursor: pointer; }
button.win { padding: 6px 12px; }
button.win:hover:not(:disabled) { background: var(--win-2); }
button:disabled { cursor: default; opacity: .7; }
.num { font-family: var(--pix); font-size: 13px; letter-spacing: 1px; }

/* 上方戰況 */
#hud {
  position: fixed; top: max(12px, env(safe-area-inset-top)); left: 16px;
  display: flex; gap: 18px; padding: 8px 14px; align-items: center;
}
.stat { display: flex; align-items: baseline; gap: 8px; }
.stat .lbl { font-size: 13px; color: var(--dim); }
.stat .gold { color: var(--gold); }
.stat.danger .num { color: var(--red); animation: blink .6s steps(2) infinite; }

#ctrl { position: fixed; top: max(12px, env(safe-area-inset-top)); right: 16px; display: flex; gap: 10px; }
button.small { width: 40px; height: 36px; padding: 0; font-size: 14px; font-family: var(--pix); }
#btn-pause { font-family: var(--cjk); }

/* 對話框 */
#dialog {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  width: min(560px, calc(100% - 32px)); padding: 10px 16px 12px; cursor: pointer;
}
#dialog-who { font-size: 13px; color: var(--gold); margin-bottom: 4px; }
#dialog-who::before { content: '◆ '; }
#dialog-text { font-size: 16px; line-height: 1.6; min-height: 1.6em; }

#toast {
  position: fixed; left: 50%; bottom: 150px; transform: translateX(-50%);
  background: rgba(20, 28, 74, .92); border: 2px solid var(--edge); border-radius: 4px;
  padding: 6px 14px; font-size: 14px; pointer-events: none; white-space: nowrap;
}
#paused {
  position: fixed; top: 45%; left: 50%; transform: translate(-50%, -50%);
  font-family: var(--serif); font-size: 40px; font-weight: 700; color: #fff;
  text-shadow: 0 3px 0 var(--win), 0 0 18px rgba(0, 0, 0, .4); pointer-events: none;
}

/* 下方:武將名冊 / 塔資訊 / 出征鈕 */
#dock {
  position: fixed; left: 16px; right: 16px; bottom: max(14px, env(safe-area-inset-bottom));
  display: flex; gap: 14px; align-items: flex-end; justify-content: center; pointer-events: none;
}
#dock > * { pointer-events: auto; }
#roster { display: flex; gap: 4px; padding: 6px; overflow-x: auto; scrollbar-width: none; }
.card {
  position: relative; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto;
  column-gap: 8px; align-items: center; min-width: 118px; padding: 6px 10px 6px 8px;
  background: transparent; border: 2px solid transparent; border-radius: 4px; text-align: left;
}
.card:hover { background: var(--win-2); }
.card:hover::before, .card.armed::before {
  content: '▶'; position: absolute; left: -2px; top: 50%; transform: translateY(-50%);
  font-size: 10px; color: var(--gold); animation: blink .8s steps(2) infinite;
}
.card.armed { border-color: var(--gold); background: var(--win-2); }
.card.poor { opacity: .45; }
.card .seal { grid-row: span 2; }
.card .who b { display: block; font-size: 15px; }
.card .who small { font-size: 11px; color: var(--dim); }
.card .cost { font-family: var(--pix); font-size: 10px; color: var(--gold); }
.card .cost::before { content: '◎'; font-family: var(--cjk); margin-right: 3px; font-size: 11px; }
.card kbd {
  position: absolute; top: 4px; right: 6px; font-family: var(--pix); font-size: 8px; color: var(--dim);
}
.seal {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  background: var(--c); color: #fffaf0; border: 2px solid #0b0f2a; border-radius: 3px;
  font-family: var(--serif); font-weight: 900; font-size: 20px; text-shadow: 0 1px 0 rgba(0, 0, 0, .4);
}
.card[data-type="cav"] .seal, .info-head .seal[style*="#d8d4c8"] { color: #1d1a16; text-shadow: none; }

#info { width: min(420px, 100%); padding: 10px 14px 12px; }
.info-head { display: flex; gap: 10px; align-items: center; }
.info-head b { font-size: 16px; display: block; }
.info-head small { font-size: 12px; color: var(--dim); }
.info-head small { letter-spacing: 1px; }
.info-head .x { margin-left: auto; background: none; border: 0; font-size: 16px; padding: 4px 6px; }
.desc { margin: 8px 0; font-size: 13px; color: var(--dim); line-height: 1.5; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 16px; margin: 0 0 10px; font-size: 13px; }
.stats div { display: flex; justify-content: space-between; }
.stats dt { color: var(--dim); }
.stats dd { margin: 0; }
.stats em { font-style: normal; color: var(--green); }
.acts { display: flex; gap: 10px; }
.acts button {
  flex: 1; padding: 8px 10px; background: var(--win-2); border: 2px solid var(--edge); border-radius: 4px; font-size: 14px;
}
.acts button:hover:not(:disabled) { background: #2a3784; }
.acts button.poor { opacity: .5; }
.acts .num { font-size: 10px; color: var(--gold); }

#btn-wave {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 132px; height: 64px; font-size: 17px; font-weight: 700; background: #6e1f18;
}
#btn-wave:hover:not(:disabled) { background: #8a2a20; }
#btn-wave:disabled { background: var(--win); }
#btn-wave small { font-size: 11px; font-weight: 400; color: var(--dim); margin-top: 2px; }

/* 飄字 */
.floater {
  position: absolute; left: 0; top: 0; font-family: var(--pix); font-size: 11px;
  text-shadow: 0 2px 0 #1a1410, 0 0 4px #1a1410; white-space: nowrap;
}
.floater.gold { color: var(--gold); }
.floater.hurt { color: var(--red); font-size: 14px; }

/* 標題 / 結算 */
.overlay {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: rgba(12, 14, 36, .45);
}
.scroll { width: min(520px, 100%); padding: 22px 26px 24px; line-height: 1.7; }
.scroll p { margin: 0 0 10px; font-size: 15px; }
.kicker { color: var(--gold); font-size: 13px !important; letter-spacing: 4px; margin: 0 !important; }
h1, h2 { font-family: var(--serif); font-weight: 900; margin: 4px 0 12px; letter-spacing: 6px; }
h1 { font-size: 44px; color: #fff3d6; text-shadow: 0 3px 0 #6e1f18; }
h2 { font-size: 34px; }
h2.won { color: var(--gold); }
h2.lost { color: var(--red); }
.howto { margin: 12px 0 18px; padding: 10px 14px 10px 30px; background: var(--win-2); border-radius: 4px; font-size: 13px; color: var(--dim); }
.cta { display: block; margin: 0 auto; padding: 10px 28px !important; font-size: 18px; font-weight: 700; background: #6e1f18; }
.cta:hover { background: #8a2a20 !important; }

@keyframes blink { 50% { opacity: 0; } }

/* 手機 */
@media (max-width: 720px) {
  #hud { left: 10px; gap: 12px; padding: 6px 10px; }
  .stat .lbl { font-size: 11px; }
  .num { font-size: 11px; }
  #ctrl { right: 10px; top: 64px; flex-direction: column; gap: 8px; }
  button.small { width: 36px; height: 32px; }
  #dialog { top: 62px; left: 10px; transform: none; width: calc(100% - 66px); padding: 8px 12px 10px; }
  #dialog-text { font-size: 14px; }
  #dock { left: 8px; right: 8px; flex-direction: column; align-items: stretch; gap: 10px; }
  #btn-wave { order: -1; align-self: flex-end; height: 50px; min-width: 120px; font-size: 15px; }
  /* 名冊改五欄直排,一眼看到五位武將 */
  #roster { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; padding: 4px; }
  .card { min-width: 0; grid-template-columns: 1fr; justify-items: center; row-gap: 2px; padding: 6px 2px; text-align: center; }
  .card .seal { grid-row: auto; }
  .card .who small, .card kbd { display: none; }
  .card .who b { font-size: 13px; }
  .card:hover::before, .card.armed::before { display: none; }
  .seal { width: 32px; height: 32px; font-size: 18px; }
  #info { width: 100%; }
  #toast { bottom: 230px; }
  h1 { font-size: 34px; }
  .scroll { padding: 18px; }
}
