/* GridForge (方陣煉金) — style.css | 磷光製圖桌主題 */
:root {
  --bg: #14161A;
  --grid: #1F232A;
  --panel: #1A1D23;
  --panel-edge: #2A2F38;
  --text: #E6EAEF;
  --dim: #8A93A0;
  --warn: #FF4D5E;
  --phos: #5CE1A5;
  --c0: #E4572E; --c1: #17BEBB; --c2: #FFC914; --c3: #76B041; --c4: #B07BAC;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", "Consolas", "SFMono-Regular", "Menlo", monospace;
  --sans: "IBM Plex Sans TC", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --micro: 120ms; --panel-t: 200ms; --flip: 250ms;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow: hidden; user-select: none; -webkit-user-select: none;
  touch-action: none;
}
.num, .n { font-variant-numeric: tabular-nums; }
h1, h2, h3, .title { font-family: var(--sans); letter-spacing: .02em; }
button { font-family: var(--mono); cursor: pointer; color: var(--text); }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ===== 遊戲畫面 ===== */
#game { flex: 1; display: none; flex-direction: column; height: 100%; }
#game.on { display: flex; }

#hud { padding: 8px 12px 6px; border-bottom: 1px solid var(--panel-edge); background: var(--panel); }
.hud-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hud-row + .hud-row { margin-top: 6px; }
.stat { display: flex; flex-direction: column; line-height: 1.15; }
.stat .lab { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; }
.stat .val { font-size: 15px; font-weight: 600; }
.stat .val.big { font-size: 19px; color: var(--phos); }
.spacer { flex: 1; }
.chip { font-size: 11px; padding: 2px 7px; border: 1px solid var(--panel-edge); border-radius: 10px; color: var(--dim); }
.chip.boss { color: var(--warn); border-color: var(--warn); }
.progress { height: 6px; background: #0d0f12; border-radius: 4px; overflow: hidden; margin-top: 3px; width: 100%; }
.progress > i { display: block; height: 100%; width: 0; background: var(--phos); transition: width var(--panel-t) cubic-bezier(.2,0,0,1); }

#relicbar { display: flex; gap: 4px; flex-wrap: wrap; min-height: 22px; }
.relic-mini { font-size: 10px; padding: 2px 6px; border: 1px solid var(--panel-edge); border-radius: 4px; background: #0f1114; cursor: help; white-space: nowrap; }

#board-wrap { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; padding: 8px; min-height: 0; }
#board { touch-action: none; border-radius: 6px; }

#tray { display: flex; justify-content: center; align-items: flex-end; gap: 14px; padding: 8px 12px 6px; min-height: 92px; }
.tray-slot { width: 88px; height: 80px; display: flex; align-items: center; justify-content: center; position: relative; }
.tray-slot.used { opacity: .18; }

#actionbar { display: flex; gap: 8px; padding: 6px 12px 10px; justify-content: center; }
.btn { border: 1px solid var(--panel-edge); background: var(--panel); border-radius: 6px; padding: 8px 14px; font-size: 13px; transition: border-color var(--micro), background var(--micro); }
.btn:hover { border-color: var(--phos); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn.warn:hover { border-color: var(--warn); }
.btn.primary { background: var(--phos); color: #0c1310; border-color: var(--phos); font-weight: 600; }

/* 幽靈預估浮層 */
#preview { position: absolute; pointer-events: none; z-index: 30; background: rgba(20,24,28,.94); border: 1px solid var(--phos);
  border-radius: 6px; padding: 6px 10px; font-size: 12px; display: none; box-shadow: 0 4px 18px rgba(0,0,0,.5); }
#preview.show { display: block; }
#preview .pv-score { color: var(--phos); font-size: 16px; font-weight: 700; }
#preview .pv-line { color: var(--dim); font-size: 11px; }
#preview.illegal { border-color: var(--warn); }
#preview.illegal .pv-score { color: var(--warn); }

/* ===== 覆蓋層(選單/商店/設定/結算) ===== */
.overlay { position: fixed; inset: 0; background: rgba(10,12,15,.82); backdrop-filter: blur(3px); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 16px; }
.overlay.on { display: flex; }
.sheet { background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 12px; padding: 20px; width: 100%;
  max-width: 560px; max-height: 92vh; overflow-y: auto; animation: rise var(--panel-t) cubic-bezier(.2,0,0,1); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.sheet h2 { font-size: 20px; margin-bottom: 4px; }
.sheet .sub { color: var(--dim); font-size: 12px; margin-bottom: 14px; }
.sheet h3 { font-size: 13px; color: var(--phos); margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .06em; }

/* 選單 */
#menu .brand { font-size: 40px; font-family: var(--sans); font-weight: 700; letter-spacing: .04em; text-align: center;
  background: linear-gradient(120deg, var(--phos), #5CB8E1); -webkit-background-clip: text; background-clip: text; color: transparent; }
#menu .brand-sub { text-align: center; color: var(--dim); font-size: 13px; margin: 4px 0 22px; }
.menu-btns { display: flex; flex-direction: column; gap: 10px; }
.menu-btns .btn { width: 100%; padding: 13px; font-size: 15px; }

/* 卡片(商店) */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.card { border: 1px solid var(--panel-edge); border-radius: 8px; padding: 10px; background: #0f1114; position: relative;
  transition: transform var(--flip), border-color var(--micro); transform-style: preserve-3d; }
.card:hover { border-color: var(--phos); }
.card.bought { opacity: .4; pointer-events: none; }
.card .cname { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.card .cdesc { font-size: 11px; color: var(--dim); line-height: 1.35; min-height: 44px; }
.card .cprice { margin-top: 8px; font-size: 12px; color: var(--c2); }
.card .rarity { position: absolute; top: 8px; right: 8px; font-size: 9px; text-transform: uppercase; color: var(--dim); }
.card.flip { animation: flipin var(--flip) ease-out; }
@keyframes flipin { from { transform: rotateY(90deg); opacity: 0; } to { transform: none; opacity: 1; } }

.shop-foot { display: flex; gap: 8px; margin-top: 16px; align-items: center; }

/* 結算 */
.result-score { font-size: 34px; color: var(--phos); font-weight: 700; text-align: center; margin: 8px 0; }
.breakdown { font-size: 12px; }
.breakdown .brow { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed #22262d; }

/* 提示 toast */
#hint { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 200; max-width: 90%;
  background: var(--panel); border: 1px solid var(--phos); border-radius: 8px; padding: 10px 16px; font-size: 13px;
  display: none; box-shadow: 0 6px 24px rgba(0,0,0,.5); animation: rise var(--panel-t) ease-out; }
#hint.on { display: block; }
#hint .ht { color: var(--phos); font-weight: 600; margin-bottom: 2px; }
#hint .hbtn { margin-top: 8px; font-size: 11px; padding: 4px 10px; }

/* 教學高亮 */
.tut-mask { position: fixed; inset: 0; z-index: 150; pointer-events: none; display: none; }
.tut-mask.on { display: block; }
.tut-box { position: absolute; background: var(--panel); border: 1px solid var(--phos); border-radius: 8px; padding: 12px 16px;
  max-width: 300px; font-size: 13px; pointer-events: auto; box-shadow: 0 6px 24px rgba(0,0,0,.6); }
.tut-box .tt { color: var(--phos); font-weight: 600; margin-bottom: 4px; }
.tut-box .tbtns { margin-top: 10px; display: flex; gap: 8px; }

/* 設定 */
.setting { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #22262d; }
.setting label { font-size: 13px; }
.setting input[type=range] { width: 140px; }
.toggle { width: 44px; height: 24px; border-radius: 12px; background: #2a2f38; position: relative; cursor: pointer; transition: background var(--micro); }
.toggle.on { background: var(--phos); }
.toggle > i { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left var(--micro); }
.toggle.on > i { left: 22px; }

.list-item { border: 1px solid var(--panel-edge); border-radius: 6px; padding: 8px 10px; margin-bottom: 6px; }
.list-item .li-name { font-size: 13px; font-weight: 600; }
.list-item .li-desc { font-size: 11px; color: var(--dim); }
.list-item.locked { opacity: .4; }
.li-name .badge { font-size: 9px; padding: 1px 5px; border-radius: 4px; background: #2a2f38; margin-left: 6px; color: var(--dim); }
.li-name .badge.got { background: var(--phos); color: #0c1310; }

.close-x { position: absolute; top: 14px; right: 16px; font-size: 20px; color: var(--dim); background: none; border: none; }
.sheet { position: relative; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tab { font-size: 12px; padding: 5px 12px; border: 1px solid var(--panel-edge); border-radius: 6px; background: none; }
.tab.on { border-color: var(--phos); color: var(--phos); }

/* 每日榜(線上) */
.lb-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
.lb-table td { padding: 6px 8px; border-bottom: 1px solid #22262d; }
.lb-table .lb-rank { color: var(--dim); width: 34px; }
.lb-table .lb-score { text-align: right; color: var(--phos); font-weight: 600; }
.lb-row.lb-me { background: rgba(92,225,165,.12); }
.lb-row.lb-me .lb-name { color: var(--phos); font-weight: 700; }
.daily-upload { margin-top: 16px; border-top: 1px solid var(--panel-edge); padding-top: 12px; }
.upload-row { display: flex; gap: 8px; }
.upload-row input[type=text] { flex: 1; background: #0f1114; border: 1px solid var(--panel-edge); border-radius: 6px;
  color: var(--text); font-family: var(--mono); font-size: 13px; padding: 8px 10px; }
.upload-row input[type=text]:focus { outline: none; border-color: var(--phos); }

/* 怎麼玩 */
.howto-p { font-size: 13px; line-height: 1.55; color: var(--text); margin: 4px 0 6px; }
.howto-p.tiny { color: var(--dim); }
.howto-p b { color: var(--phos); font-weight: 600; }
.howto-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 6px 0 8px; }
.howto-table th { text-align: left; font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; padding: 4px 8px; border-bottom: 1px solid var(--panel-edge); }
.howto-table td { padding: 7px 8px; border-bottom: 1px solid #22262d; vertical-align: top; }
.howto-table td:first-child { font-weight: 600; white-space: nowrap; }
.howto-table td.num { text-align: right; color: var(--phos); font-weight: 700; white-space: nowrap; }
.ht-sub { display: block; font-size: 10px; color: var(--dim); font-weight: 400; }

.tiny { font-size: 11px; color: var(--dim); }
.center { text-align: center; }
.mt { margin-top: 12px; }
@media (max-width: 480px) {
  .stat .val.big { font-size: 17px; }
  #tray { gap: 8px; }
  .tray-slot { width: 74px; }
}
