@font-face { font-family: 'Cubic11'; src: url('/cubic11.woff2') format('woff2'); font-display: swap; }
:root {
  --ink: #2b2d42; --ink2: #5c5f7a; --paper: #fff8ec; --card: #ffffff; --line: #2b2d42;
  --coral: #ff7a59; --teal: #22a699; --sky: #4cc3e8; --sun: #ffd166; --grape: #7b6cf6; --leaf: #5cc27a; --rose: #e85d75;
  --radius: 14px;
  --px: 'Cubic11', 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
  --tx: 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--tx); color: var(--ink); background: var(--paper);
  background-image: radial-gradient(rgba(43,45,66,.07) 1.5px, transparent 1.6px); background-size: 18px 18px;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.px { font-family: var(--px); letter-spacing: .02em; }
a { color: inherit; }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--ink2); }
.small { font-size: 13px; }
.big { font-size: 18px; line-height: 1.6; }
.hidden { display: none !important; }

/* 按鈕：厚厚的、按下去會沉 */
.btn {
  font-family: var(--px); font-size: 17px; cursor: pointer; user-select: none;
  background: var(--card); border: 3px solid var(--line); border-radius: 12px; padding: 9px 16px;
  box-shadow: 0 4px 0 var(--line); transform: translateY(0); transition: transform .05s, box-shadow .05s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--coral); color: #fff; }
.btn.go { background: var(--leaf); color: #fff; }
.btn.blue { background: var(--sky); }
.btn.sun { background: var(--sun); }
.btn.danger { background: var(--rose); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; text-decoration: underline; min-height: 36px; padding: 4px 8px; }
.btn.sm { font-size: 14px; padding: 5px 10px; min-height: 36px; border-width: 2px; box-shadow: 0 3px 0 var(--line); }
.btn.icon { padding: 6px; min-width: 46px; }
.btn.on { background: var(--sun); }

.card { background: var(--card); border: 3px solid var(--line); border-radius: var(--radius); box-shadow: 0 5px 0 var(--line); }
.badge { display: inline-block; font-family: var(--px); font-size: 13px; padding: 2px 8px; border-radius: 99px; border: 2px solid var(--line); background: #fff; white-space: nowrap; }
.badge.pending { background: var(--sun); }
.badge.approved, .badge.live { background: var(--leaf); color: #fff; }
.badge.rejected { background: var(--rose); color: #fff; }
.badge.removed, .badge.withdrawn, .badge.retired { background: #ddd; }
.badge.new { background: var(--coral); color: #fff; }

input[type=text], input:not([type]), textarea, select {
  font: inherit; font-size: 18px; color: var(--ink); background: #fff; border: 3px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 100%;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, textarea:focus, select:focus { outline: 3px solid var(--sky); outline-offset: 1px; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-size: 17px; line-height: 1.5; cursor: pointer; padding: 6px 0; }
label.check input { width: 24px; height: 24px; flex: none; margin-top: 2px; accent-color: var(--teal); }
.field { display: grid; gap: 6px; margin: 12px 0; }
.field > span { font-family: var(--px); font-size: 15px; }
.hint { font-size: 13px; color: var(--ink2); }

/* 提示、對話框 */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; pointer-events: none; }
.toast { font-family: var(--px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 12px; font-size: 16px; box-shadow: 0 4px 0 rgba(0,0,0,.25); transition: opacity .4s, transform .4s; text-align: center; }
.toast.ok { background: var(--teal); }
.toast.bad { background: var(--rose); }
.toast.out { opacity: 0; transform: translateY(8px); }
.modal-back { position: fixed; inset: 0; background: rgba(43,45,66,.5); display: grid; place-items: center; z-index: 90; padding: 16px; }
.modal { background: var(--paper); border: 3px solid var(--line); border-radius: 18px; box-shadow: 0 6px 0 var(--line); padding: 20px 22px; width: min(480px, 100%); max-height: calc(100vh - 32px); overflow: auto; }
.modal.wide { width: min(760px, 100%); }
.modal h2 { font-size: 22px; margin-bottom: 10px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }

/* 頂部列 */
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--card); border-bottom: 3px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar .title { font-family: var(--px); font-size: 20px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.logo canvas { width: 32px; height: 32px; image-rendering: pixelated; }

.page { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.section-h { display: flex; align-items: baseline; gap: 12px; margin: 26px 0 12px; }
.section-h h2 { font-family: var(--px); font-size: 22px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }

/* 作品卡 */
.gcard { overflow: hidden; display: flex; flex-direction: column; text-decoration: none; transition: transform .1s; cursor: pointer; }
.gcard:hover { transform: translateY(-3px); }
.gcard .thumb { width: 100%; aspect-ratio: 24 / 15; image-rendering: pixelated; display: block; border-bottom: 3px solid var(--line); background: #bde3f7; }
.gcard .info { padding: 10px 12px 12px; display: grid; gap: 4px; }
.gcard .name { font-family: var(--px); font-size: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gcard .by { font-size: 14px; color: var(--ink2); }
.gcard .stats { display: flex; gap: 12px; font-size: 14px; color: var(--ink2); align-items: center; }
.empty { text-align: center; padding: 50px 20px; font-size: 18px; color: var(--ink2); }
.empty .px { font-size: 22px; color: var(--ink); display: block; margin-bottom: 8px; }

/* 遊戲畫面 */
.gm-wrap { position: relative; width: 100%; height: 100%; display: block; background: #1a1c2c; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.gm-cv { image-rendering: pixelated; image-rendering: crisp-edges; display: block; position: absolute; }
.gm-wrap.pad-below .gm-arrow { background: rgba(255,255,255,.12); }
.gm-wrap.pad-below .gm-dpad { bottom: 22px; left: 18px; }
.gm-wrap.pad-below .gm-jump { bottom: 24px; right: 22px; }
.gm-hud { position: absolute; top: 8px; left: 8px; display: flex; gap: 8px; pointer-events: none; }
.gm-hud span { font-family: var(--px); background: rgba(26,28,44,.72); color: #fff; padding: 4px 10px; border-radius: 10px; font-size: 16px; }
.gm-hud .gm-lv { background: rgba(255,122,89,.9); }
.gm-banner { position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%) scale(.8); opacity: 0; pointer-events: none; font-family: var(--px); font-size: clamp(22px, 4vw, 40px); color: #fff; background: rgba(26,28,44,.78); padding: 10px 26px; border-radius: 16px; transition: opacity .2s, transform .2s; white-space: nowrap; }
.gm-banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.gm-banner.ok { background: rgba(34,166,153,.92); }
.gm-banner.bad { background: rgba(232,93,117,.92); }
.gm-pad { position: absolute; inset: auto 0 0 0; height: 0; pointer-events: none; }
.gm-dpad { position: absolute; left: 14px; bottom: 14px; width: 190px; height: 96px; display: flex; pointer-events: auto; touch-action: none; }
.gm-arrow { flex: 1; display: grid; place-items: center; font-size: 34px; color: #fff; background: rgba(255,255,255,.18); border: 3px solid rgba(255,255,255,.5); border-radius: 18px; margin: 0 4px; }
.gm-jump { position: absolute; right: 18px; bottom: 16px; width: 104px; height: 104px; border-radius: 50%; display: grid; place-items: center; font-family: var(--px); font-size: 26px; color: #fff; background: rgba(255,122,89,.55); border: 3px solid rgba(255,255,255,.6); pointer-events: auto; touch-action: none; }
.gm-jump.on { background: rgba(255,122,89,.85); }

/* 全畫面遊戲層（試玩、遊玩頁） */
.stage-layer { position: fixed; inset: 0; z-index: 50; background: #1a1c2c; display: flex; flex-direction: column; }
.stage-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--ink); color: #fff; }
.stage-bar .title { font-family: var(--px); font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-bar .btn { min-height: 40px; font-size: 15px; padding: 5px 12px; color: var(--ink); }
.stage { flex: 1; min-height: 0; position: relative; }
.over-card { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(26,28,44,.6); z-index: 5; padding: 16px; }
.over-card .card { padding: 22px 26px; max-width: 460px; width: 100%; text-align: center; background: var(--paper); }
.over-card h2 { font-family: var(--px); font-size: 28px; margin-bottom: 6px; }
.over-card .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.keys-help { font-size: 14px; color: var(--ink2); margin-top: 10px; line-height: 1.6; }

@media (max-width: 640px) {
  .topbar .title { font-size: 17px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .gcard .name { font-size: 16px; }
  .gm-dpad { width: 150px; height: 80px; }
  .gm-jump { width: 86px; height: 86px; }
}

/* 編輯器 */
.ed { position: fixed; inset: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: var(--paper); }
.ed-top, .ed-bot { display: flex; gap: 8px; align-items: center; padding: 8px 10px; background: var(--card); }
.ed-top { border-bottom: 3px solid var(--line); overflow-x: auto; }
.ed-bot { border-top: 3px solid var(--line); flex-wrap: wrap; }
.ed-top > *, .ed-bot > * { flex: none; }
.ed-top .btn.sm, .ed-bot .btn.sm { min-height: 42px; font-size: 15px; }
.ed-tabs { display: flex; gap: 5px; }
.ed-tabs .btn.sm { min-width: 40px; }
.ed-body { display: grid; grid-template-columns: 156px minmax(0, 1fr); min-height: 0; }
.ed-pal { border-right: 3px solid var(--line); background: #fffdf6; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.ed-cats { display: flex; flex-wrap: wrap; gap: 4px; }
.ed-cats .btn.sm { font-size: 13px; padding: 3px 7px; min-height: 32px; box-shadow: 0 2px 0 var(--line); }
.ed-items { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ed-tile { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border: 2px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font-size: 12px; line-height: 1.2; }
.ed-tile.on { background: var(--sun); box-shadow: inset 0 0 0 3px var(--coral); }
.ed-view { position: relative; min-width: 0; min-height: 0; background: #1a1c2c; touch-action: none; overflow: hidden; }
.ed-cv { display: block; touch-action: none; position: absolute; left: 0; top: 0; }
.ed-toolset { display: flex; gap: 4px; }
.ed-status { flex: 1 1 220px !important; min-width: 0; font-size: 15px; line-height: 1.4; }
.ed-status .warn { color: #b8442e; font-weight: 700; }
.ed-status .good { color: var(--teal); font-weight: 700; }
@media (max-width: 1060px) { .ed-top .lbl { display: none; } }
@media (max-width: 900px) { .ed-bot .lbl { display: none; } }
@media (orientation: portrait) and (max-width: 900px) {
  .ed-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .ed-pal { order: 2; border-right: 0; border-top: 3px solid var(--line); max-height: 178px; }
  .ed-items { display: flex; overflow-x: auto; padding-bottom: 4px; }
  .ed-tile { min-width: 72px; }
}

/* 審核台 */
.boss-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.qrow { padding: 14px 16px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; cursor: pointer; }
.qrow .px { font-size: 19px; }
.review { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 16px; }
.review .gamebox { height: min(62vh, 560px); border: 3px solid var(--line); border-radius: var(--radius); overflow: hidden; position: relative; background: #1a1c2c; }
.review .side { padding: 16px; display: grid; gap: 10px; align-content: start; }
.texts { display: grid; gap: 4px; background: #fff; border: 2px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 16px; }
.flag { background: #ffe3e3; border: 2px solid var(--rose); border-radius: 10px; padding: 8px 10px; font-size: 15px; }
table.list { width: 100%; border-collapse: collapse; background: #fff; border: 3px solid var(--line); border-radius: 12px; overflow: hidden; }
table.list th, table.list td { padding: 9px 10px; border-bottom: 1px solid #e5e0d4; text-align: left; font-size: 15px; vertical-align: middle; }
table.list th { background: #fff3d6; font-family: var(--px); font-weight: normal; }
.codebox { font-family: var(--px); font-size: 34px; letter-spacing: .18em; text-align: center; background: #fff; border: 3px dashed var(--line); border-radius: 12px; padding: 14px; user-select: all; }
@media (max-width: 860px) { .review { grid-template-columns: 1fr; } .review .gamebox { height: 52vh; } }
