* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: #101418;
  color: #e8e4d8;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  overflow: hidden;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
#stage { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
.scr { display: none; width: 100%; height: 100%; max-width: 560px; margin: 0 auto; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); flex-direction: column; overflow-y: auto; }
.scr.show { display: flex; }

button { font-family: inherit; }
.mbtn {
  display: block; width: 100%; padding: 13px 16px; margin: 7px 0;
  background: #1c242c; color: #e8e4d8; border: 2px solid #38444e; border-radius: 6px;
  font-size: 16px; letter-spacing: 2px; cursor: pointer;
  box-shadow: 0 3px 0 #0a0e12;
}
.mbtn:active { transform: translateY(2px); box-shadow: 0 1px 0 #0a0e12; }
.mbtn.primary { background: #7a5a10; border-color: #c89828; color: #ffe9b0; }
.mbtn.big { font-size: 18px; padding: 15px; }
.mbtn[disabled] { opacity: .45; }
a.mbtn { text-align: center; text-decoration: none; line-height: 1.4; }
.ibtn { background: #1c242c; border: 2px solid #38444e; color: #c8c4b8; border-radius: 5px; padding: 4px 9px; font-size: 14px; cursor: pointer; }
.back { background: none; border: none; color: #c89828; font-size: 26px; line-height: 1; cursor: pointer; padding: 0 6px; }

.scr-head { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.scr-head h2 { flex: 1; font-size: 19px; letter-spacing: 3px; color: #f0d070; }
.hint { color: #7c8890; font-size: 12px; margin: 8px 2px; line-height: 1.7; }
.small { font-size: 12px; color: #98a4ac; }
.mono { font-family: ui-monospace, Consolas, monospace; letter-spacing: 1px; }
.coinbox { color: #f0d070; font-size: 14px; }

/* menu */
#scr-menu { justify-content: center; overflow: hidden; }
.logo { text-align: center; margin-bottom: 12px; }
.logo-t1 { font-size: min(44px, 6.5vh); font-weight: 900; letter-spacing: 10px; color: #f0d070; text-shadow: 0 4px 0 #7a5a10, 0 8px 18px rgba(0,0,0,.6); }
.logo-t2 { font-size: 13px; letter-spacing: 9px; color: #98a4ac; margin-top: 4px; }
.logo-t3 { font-size: 11px; letter-spacing: 4px; color: #6c7880; margin-top: 6px; }
.menu-btns .mbtn { padding: 10px 16px; margin: 5px 0; font-size: 15px; }
.menu-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; color: #98a4ac; font-size: 13px; }
@media (max-height: 620px) {
  #scr-menu { padding: 8px 14px; }
  .logo { margin-bottom: 6px; }
  .logo-t3 { display: none; }
  .menu-btns .mbtn { padding: 8px 14px; margin: 3px 0; font-size: 14px; }
  .menu-foot { margin-top: 6px; }
}
.ver { color: #55606a; font-size: 11px; }

/* tabs / list */
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { flex: 1; padding: 9px 4px; background: #1c242c; border: 2px solid #38444e; color: #98a4ac; border-radius: 6px; font-size: 14px; cursor: pointer; }
.tabs button.on { background: #7a5a10; border-color: #c89828; color: #ffe9b0; }
.joinrow { display: flex; gap: 8px; margin-bottom: 10px; }
.joinrow input { flex: 1; min-width: 0; background: #0c1218; border: 2px solid #38444e; border-radius: 6px; color: #f0d070; font-size: 17px; letter-spacing: 4px; padding: 10px; text-transform: uppercase; text-align: center; }
.joinrow .mbtn { width: auto; margin: 0; padding: 10px 14px; font-size: 14px; }
.list { flex: 1; overflow-y: auto; }
.roomitem { display: flex; align-items: center; gap: 10px; background: #161e26; border: 2px solid #2c3840; border-radius: 6px; padding: 11px 12px; margin-bottom: 8px; }
.roomitem .code { color: #f0d070; font-size: 17px; letter-spacing: 2px; font-family: ui-monospace, monospace; }
.roomitem .info { flex: 1; font-size: 13px; color: #98a4ac; }
.roomitem .mbtn { width: auto; margin: 0; padding: 8px 14px; font-size: 13px; }
.empty { text-align: center; color: #55606a; padding: 30px 0; font-size: 13px; }

/* room */
.roomcode { color: #f0d070; font-size: 22px; letter-spacing: 4px; font-family: ui-monospace, monospace; }
.slots { margin: 14px 0; }
.slot { display: flex; align-items: center; gap: 10px; background: #161e26; border: 2px solid #2c3840; border-radius: 6px; padding: 13px; margin-bottom: 8px; }
.slot .dot { width: 14px; height: 14px; border-radius: 3px; background: #3c4850; }
.slot.on .dot { background: #7cc840; }
.slot .nick { flex: 1; font-size: 15px; }
.slot .tag { font-size: 12px; color: #c89828; }

/* game */
#scr-game { padding: 0; max-width: 100%; }
#game-top { display: flex; justify-content: space-between; align-items: center; padding: 5px 10px; background: #0a0e12; }
.hud-l { display: flex; gap: 8px; font-size: 12px; color: #c8c4b8; flex-wrap: wrap; }
.hud-l span b, .hud-r b { color: #f0d070; }
.hud-r { display: flex; gap: 8px; align-items: center; }
#game-mid { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px; padding-top: 4px; position: relative; background: #000; min-height: 0; overflow: hidden; }
#cv { image-rendering: pixelated; image-rendering: crisp-edges; background: #0c0c0c; border: 2px solid #2c3840; }
#touch { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 0 12%; gap: 0; }
#stick { width: 92px; height: 92px; border-radius: 50%; background: #161e26; border: 2px solid #38444e; position: relative; touch-action: none; }
#stick-knob { position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px; border-radius: 50%; background: #3c4c58; border: 2px solid #586878; }
#btn-fire { width: 80px; height: 80px; border-radius: 50%; background: #6e2018; border: 3px solid #c85038; color: #ffd8c8; display: flex; align-items: center; justify-content: center; font-size: 17px; letter-spacing: 3px; touch-action: none; }
#btn-fire:active, #btn-fire.on { background: #a03020; }
#quickbar { display: flex; flex-direction: row; gap: 10px; justify-content: center; }
#quickbar button { position: relative; width: 44px; height: 44px; border-radius: 8px; background: rgba(22,30,38,.88); border: 2px solid #38444e; padding: 5px; cursor: pointer; }
#quickbar button canvas { width: 100%; height: 100%; image-rendering: pixelated; }
#quickbar button .cnt { position: absolute; right: -4px; top: -6px; background: #c89828; color: #201808; font-size: 10px; font-weight: 700; border-radius: 8px; padding: 1px 4px; }
#quickbar button.empty { opacity: .35; }
@media (orientation: landscape) and (max-height: 500px) {
  #scr-game { flex-direction: row; }
  #game-top { position: absolute; top: 0; left: 0; right: 0; z-index: 5; background: rgba(10,14,18,.82); }
  #game-mid { position: absolute; inset: 0; justify-content: center; }
  #touch { position: absolute; left: 50%; transform: translateX(-50%); bottom: 56px; pointer-events: auto; width: 76%; }
  #quickbar { position: absolute; left: 50%; transform: translateX(-50%); bottom: 8px; pointer-events: auto; }
  #stick { width: 84px; height: 84px; } #btn-fire { width: 72px; height: 72px; }
}

/* overlays */
.ovl { position: absolute; inset: 0; background: rgba(6,8,10,.78); display: flex; align-items: center; justify-content: center; z-index: 20; }
.ovl.hidden { display: none; }
.ovl-box { background: #141c24; border: 3px solid #38444e; border-radius: 8px; padding: 22px; width: min(320px, 86vw); text-align: center; }
.ovl-box.wide { width: min(380px, 90vw); }
.ovl-box h3 { color: #f0d070; font-size: 21px; letter-spacing: 4px; margin-bottom: 14px; }
.rs-body { text-align: left; font-size: 14px; line-height: 2; margin-bottom: 12px; max-height: 40vh; overflow-y: auto; }
.rs-body .win { color: #7cc840; } .rs-body .lose { color: #c85038; }
.rs-btns { display: flex; gap: 8px; } .rs-btns .mbtn { margin: 0; }

/* shop */
.shopgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.skinitem { background: #161e26; border: 2px solid #2c3840; border-radius: 6px; padding: 12px; text-align: center; }
.skinitem canvas { image-rendering: pixelated; width: 64px; height: 64px; }
.skinitem .nm { font-size: 14px; margin: 6px 0; }
.skinitem .mbtn { padding: 7px; font-size: 13px; margin: 4px 0 0; letter-spacing: 1px; }
.skinitem.eq { border-color: #c89828; }

/* pay */
.pkgs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.pkg { position: relative; background: #161e26; border: 2px solid #2c3840; border-radius: 6px; padding: 14px 10px; text-align: center; cursor: pointer; }
.pkg.on { border-color: #c89828; background: #241c0c; }
.pkg .y { font-size: 22px; color: #f0d070; font-weight: 700; }
.pkg .c { font-size: 13px; color: #98a4ac; margin-top: 4px; }
.pkg .tag { position: absolute; top: -1px; right: -1px; background: #a03020; color: #ffd8c8; font-size: 10px; padding: 2px 6px; border-radius: 0 4px 0 6px; }
.qrwrap { display: flex; justify-content: center; background: #fff; border-radius: 8px; padding: 10px; margin: 10px 0; }
.qrwrap img { width: min(220px, 58vw); height: auto; image-rendering: pixelated; }
.payinfo { font-size: 14px; line-height: 2; }
.payinfo b { color: #f0d070; }
.orders { margin-top: 12px; font-size: 13px; }
.order { display: flex; justify-content: space-between; padding: 8px 10px; background: #161e26; border-radius: 5px; margin-bottom: 6px; color: #98a4ac; }
.order .st-created { color: #c89828; } .order .st-pending { color: #68a8e0; } .order .st-paid { color: #7cc840; } .order .st-rejected { color: #c85038; }

/* rank */
.rank { width: 100%; border-collapse: collapse; font-size: 14px; }
.rank th { color: #7c8890; font-weight: 400; text-align: left; padding: 8px 6px; border-bottom: 2px solid #2c3840; }
.rank td { padding: 9px 6px; border-bottom: 1px solid #1c242c; }
.rank tr:nth-child(1) td { color: #f0d070; }
.rank tr:nth-child(2) td { color: #d8d4c8; }
.rank tr:nth-child(3) td { color: #c8925a; }

/* settings */
.setbox label { display: block; margin: 12px 0; font-size: 15px; }
.setbox input[type=text], .setbox input:not([type]) { background: #0c1218; border: 2px solid #38444e; border-radius: 6px; color: #e8e4d8; padding: 10px; font-size: 15px; margin-left: 8px; width: 160px; }
.setbox .row { display: flex; align-items: center; gap: 8px; }

#toast { position: fixed; left: 50%; bottom: 18%; transform: translateX(-50%); background: rgba(20,28,36,.94); border: 2px solid #c89828; color: #ffe9b0; padding: 10px 18px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 99; max-width: 82vw; text-align: center; }
#toast.show { opacity: 1; }
