* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #151925;
  color: #e8ecf4;
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif;
  user-select: none;
}
#app {
  position: fixed;
  left: 50%;
  top: 0;
  width: 1080px;
  transform: translateX(-50%);
  transform-origin: top center;
}
html, body { overflow: hidden; }
#topbar {
  display: flex;
  gap: 10px;
  align-items: center;
  height: 36px;
  padding: 0 8px;
  background: linear-gradient(#2a3150, #1f2433);
  border-bottom: 1px solid #343d5c;
  font-size: 15px;
  font-weight: bold;
}
#topbar .stat {
  padding: 3px 10px;
  font-size: 13px;
  font-weight: normal;
  line-height: 1.3;
  color: #e8ecf5;
  background: linear-gradient(#36405f, #2c3550);
  border-radius: 10px;
  box-shadow: 0 2px 0 #1a2033;
}
#topbar .stat #lives, #topbar .stat #gold, #topbar .stat #gold2, #topbar .stat #wave, #topbar .stat #maxWave { font-weight: bold; font-variant-numeric: tabular-nums; }
#enemiesLeft { margin-left: auto; color: #c5cde0; }
#enemiesLeft:empty { padding: 0; border: none; background: none; box-shadow: none; }
#topbar button { padding: 3px 10px; font-size: 13px; font-weight: normal; line-height: 1.3; box-shadow: 0 2px 0 #1a2033; }
#topbar button.on { background: #1e5f74; }
#topbar .tb-ico { width: 1.2em; height: 1.2em; vertical-align: -0.24em; margin-right: 4px; }
#coopBtn.linked { background: #1b7f4a; }
.stat.hidden { display: none; }
#topbar #fsBtn { font-size: 15px; line-height: 1.15; padding: 3px 9px; }
body.fullscreen { overflow: hidden; }
html, body { overscroll-behavior: none; }
#rotateHint { display: none; }
@media (orientation: portrait) and (pointer: coarse) and (max-width: 760px) {
  #rotateHint { display: flex; position: fixed; inset: 0; z-index: 9999; align-items: center; justify-content: center; text-align: center;
    background: radial-gradient(circle at 50% 40%, #2a3150, #0d1019 75%); }
  #rotateHint > div { display: flex; flex-direction: column; gap: 10px; padding: 24px; }
  #rotateHint .rotate-icon { font-size: 56px; animation: rotate-phone 2.4s ease-in-out infinite; }
  #rotateHint b { font-size: 20px; color: #ffd54f; }
  #rotateHint span { font-size: 14px; color: #c5cde0; }
}
@keyframes rotate-phone { 0%, 30% { transform: rotate(0); } 55%, 85% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }
body.phone #topbar { height: 44px; gap: 7px; font-size: 19px; }
body.phone #topbar .stat { padding: 4px 12px; font-size: 16px; }
body.phone #topbar button { padding: 4px 12px; font-size: 16px; }
body.phone #bottombar { height: 150px; padding: 8px 10px; gap: 6px; }
body.phone #towerBar { grid-template-columns: repeat(5, 96px); gap: 5px; }
body.phone .tower-btn { border-radius: 16px; gap: 3px; }
body.phone .tower-btn .icon { width: 50px; height: 50px; font-size: 37px; }
body.phone .tower-btn .name { font-size: 18px; }
body.phone .tower-btn .cost { font-size: 18px; }
body.phone .tower-btn .coin { width: 17px; height: 17px; }
body.phone #info { font-size: 16px; }
body.phone #controls { width: 196px; gap: 6px; }
body.phone #controls button { font-size: 20px; padding: 8px 10px; }
body.phone #waveBtn { font-size: 23px; }
@media (max-height: 520px) {
  #topbar { height: 32px; gap: 6px; font-size: 14px; }
  #topbar .stat { padding: 2px 8px; font-size: 12px; }
  #topbar button { padding: 2px 8px; font-size: 12px; }
}
#stage { position: relative; }
#game3d {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#game {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  cursor: default;
  touch-action: none;
}
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 20, 0.72);
}
.overlay.hidden { display: none; }
.set-body, #coopOverlay .panel, #rankOverlay .panel, #mapOverlay .panel { max-height: calc(100% - 20px); overflow-y: auto; box-sizing: border-box; }
.set-body::-webkit-scrollbar, #coopOverlay .panel::-webkit-scrollbar, #rankOverlay .panel::-webkit-scrollbar, #mapOverlay .panel::-webkit-scrollbar, .rank-table tbody::-webkit-scrollbar { width: 6px; }
.set-body::-webkit-scrollbar-track, #coopOverlay .panel::-webkit-scrollbar-track, #rankOverlay .panel::-webkit-scrollbar-track, #mapOverlay .panel::-webkit-scrollbar-track, .rank-table tbody::-webkit-scrollbar-track { background: transparent; }
.set-body::-webkit-scrollbar-thumb, #coopOverlay .panel::-webkit-scrollbar-thumb, #rankOverlay .panel::-webkit-scrollbar-thumb, #mapOverlay .panel::-webkit-scrollbar-thumb, .rank-table tbody::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.22); border-radius: 999px; }
.set-body::-webkit-scrollbar-thumb:hover, #coopOverlay .panel::-webkit-scrollbar-thumb:hover, #rankOverlay .panel::-webkit-scrollbar-thumb:hover, #mapOverlay .panel::-webkit-scrollbar-thumb:hover, .rank-table tbody::-webkit-scrollbar-thumb:hover { background: rgba(143, 211, 255, 0.6); }
.set-body::-webkit-scrollbar-button, #coopOverlay .panel::-webkit-scrollbar-button, #rankOverlay .panel::-webkit-scrollbar-button, #mapOverlay .panel::-webkit-scrollbar-button, .rank-table tbody::-webkit-scrollbar-button { display: none; height: 0; }
@supports not selector(::-webkit-scrollbar) { .set-body, #coopOverlay .panel, #rankOverlay .panel, #mapOverlay .panel, .rank-table tbody { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.22) transparent; } }
#chat { position: absolute; left: 10px; bottom: 10px; z-index: 5; font-size: 13px; }
#chat.hidden { display: none; }
.chat-panel { width: 300px; padding: 6px; border-radius: 12px; background: rgba(10, 14, 26, 0.62); border: 1px solid rgba(255, 255, 255, 0.08); }
#chat.folded .chat-panel { display: none; }
#chatPill { display: none; padding: 4px 12px; font-size: 12px; font-weight: normal; border-radius: 999px; background: rgba(43, 51, 72, 0.92); box-shadow: 0 2px 0 #161a29; }
#chat.folded #chatPill { display: inline-block; }
#chatPill.unread { background: linear-gradient(#2a7a93, #1e5f74); color: #fff; font-weight: bold; }
.chat-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; font-size: 12px; color: #c5cde0; }
.chat-head b { flex: 1; font-weight: normal; }
.chat-head button { padding: 1px 9px; font-size: 11px; font-weight: normal; border-radius: 999px; background: rgba(43, 51, 72, 0.9); box-shadow: none; }
#chatClear[hidden] { display: none; }
#chatLog { max-height: 120px; min-height: 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; padding-right: 4px; }
#chatLog::-webkit-scrollbar { width: 6px; }
#chatLog::-webkit-scrollbar-track { background: transparent; }
#chatLog::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.22); border-radius: 999px; }
#chatLog::-webkit-scrollbar-thumb:hover { background: rgba(255, 213, 79, 0.6); }
#chatLog::-webkit-scrollbar-button { display: none; height: 0; }
@supports not selector(::-webkit-scrollbar) { #chatLog { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.22) transparent; } }
.chat-line { align-self: flex-start; max-width: 100%; padding: 2px 9px; border-radius: 10px; background: rgba(255, 255, 255, 0.07); color: #e8ecf4; word-break: break-word; }
.chat-line b { margin-right: 6px; }
.chat-line.me b { color: #ffd54f; }
.chat-line.mate b { color: #4fc3f7; }
.chat-line.sys { color: #a5d6a7; font-style: italic; background: none; }
#chatForm { margin-top: 5px; }
#chatInput { width: 100%; padding: 5px 10px; border-radius: 10px; border: 1px solid #4a5678; background: rgba(15, 19, 32, 0.95); color: #fff; font: inherit; }
#chatInput:focus { outline: none; border-color: #ffd54f; }
#coopBody { margin: 10px 0 14px; text-align: left; }
#coopBody p { margin: 6px 0; }
.coop-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.coop-choice > div { padding: 12px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); }
.coop-choice p { font-size: 13px; min-height: 3.2em; }
#coopCode { width: 7em; margin-right: 6px; padding: 6px 8px; border-radius: 8px; border: 1px solid #4a5678; background: #1b2133; color: #fff; font: inherit; font-size: 16px; letter-spacing: 3px; text-transform: uppercase; }
.coop-code { display: flex; align-items: center; justify-content: center; gap: 4px; margin: 4px 0 8px; }
.coop-code span { font-size: 40px; font-weight: bold; letter-spacing: 8px; color: #8fd3ff; user-select: all; } 
.coop-copy { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 4px; border: 0; border-radius: 8px;
  background: none; box-shadow: none; color: #8d97ad; cursor: pointer; transform: none; }
.coop-copy:hover { color: #ffd54f; background: rgba(255, 255, 255, 0.06); }
.coop-copy svg { width: 100%; height: 100%; display: block; }
.coop-copy:active:not(:disabled) { transform: none; box-shadow: none; } 
.coop-copy.ok { color: #66bb6a; }
.coop-copy.fail { color: #ef5350; }
.coop-err { color: #ff8a80; }
.coop-ok { color: #a5d6a7; }
.buff-chip { background: rgba(255, 202, 40, 0.22); color: #ffe082; margin-left: 6px; }
.mate-chip { background: rgba(41, 182, 246, 0.25); color: #b3e5fc; margin-left: 6px; }
.overlay .panel {
  background: linear-gradient(#2a3150, #1f2433);
  border: 1px solid #343d5c;
  border-radius: 14px;
  box-shadow: 0 2px 0 #1a2033, 0 14px 32px rgba(0, 0, 0, 0.55);
  padding: 20px 28px;
  max-width: 460px;
  text-align: center;
  color: #e8ecf5;
}
.overlay h1 { margin: 0 0 10px; font-size: 26px; letter-spacing: 1px; color: #e8ecf5; }
.overlay .panel:not(.space-card) button { font-weight: normal; }
.overlay .panel:not(.space-card) .ov-btn {background: linear-gradient(#4b5a84, #3b476a); color: #fff; box-shadow: 0 2px 0 #1a2033; font-size: 15px; font-weight: normal; padding: 7px 30px; border-radius: 10px; }
.overlay .panel.wide { max-width: 560px; }
#mapOverlay .panel.wide { max-width: 880px; }
.overlay .panel.set-card { display: flex; flex-direction: column; max-height: calc(100% - 20px); box-sizing: border-box; padding: 18px 26px 16px; }
.overlay .set-card h1 { flex: none; margin: 0 0 4px; }
.set-body { flex: 1 1 auto; min-height: 0; margin: 8px 0 4px; padding: 0 6px; text-align: left; }
.set-body li { margin: 4px 0; }
.overlay .set-card .set-body p { margin: 0 0 6px; }
.set-page.hidden { display: none; }
.overlay .set-card .ov-btn { flex: none; align-self: center; margin-top: 10px; }
#langList { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 8px 0 2px; }
#langList button[data-lang=auto] { grid-column: 1 / -1; } 
#langList button, .rank-tabs button, .rank-me button { padding: 6px 16px; font-size: 13px; font-weight: normal; box-shadow: 0 2px 0 #1a2033; border-radius: 10px; }
#langList button.on, .rank-tabs button.on { background: linear-gradient(#2a7f99, #1e5f74); box-shadow: 0 2px 0 #123f4e; }
.about-table { border-collapse: collapse; margin: 4px auto 12px; }
.about-table th, .about-table td { padding: 5px 14px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); text-align: left; }
.about-table th { color: #9aa4ba; font-weight: normal; }
.about-table .muted { display: block; font-size: 12px; }
.set-menu {
  position: absolute; z-index: 30; display: flex; flex-direction: column; gap: 2px; min-width: 160px; padding: 6px;
  border: 1px solid #343d5c; border-radius: 12px;
  background: linear-gradient(#2a3150, #1f2433);
  box-shadow: 0 2px 0 #1a2033, 0 12px 26px rgba(0, 0, 0, 0.55);
}
.set-menu.hidden { display: none; }
.set-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px; border-radius: 10px;
  background: transparent; box-shadow: none; color: #e8ecf5; font-size: 13px; font-weight: normal; text-align: left;
}
.set-menu button:hover { background: rgba(255, 255, 255, 0.08); filter: none; }
.set-menu button:active { transform: none; box-shadow: none; }
.set-menu .menu-ico { flex: none; width: 1.25em; height: 1.25em; color: #9fb4d8; }
body.phone .set-menu button { font-size: 16px; padding: 9px 14px; }
html[lang=ja] body.phone .tower-btn .name { font-size: 14px; white-space: nowrap; }
html[lang=ja] body.phone #pauseBtn { font-size: 16px; white-space: nowrap; }
#rankOverlay .panel.wide { max-width: 640px; }
.rank-tabs { display: flex; justify-content: center; gap: 8px; margin-bottom: 10px; }
.rank-me { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-bottom: 10px; font-size: 14px; }
.rank-me input { width: 150px; padding: 5px 10px; border-radius: 8px; border: 1px solid #4a5678; background: #1b2133; color: #fff; font: inherit; }
.rank-table { width: 100%; border-collapse: collapse; margin-bottom: 4px; font-size: 14px; }
.rank-table th, .rank-table td { padding: 4px 6px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.rank-table th { color: #9aa4ba; font-weight: normal; }
.rank-table tbody { display: block; max-height: 170px; overflow-y: auto; }
.rank-table thead, .rank-table tbody tr { display: table; width: 100%; table-layout: fixed; }
.rank-table th:nth-child(1), .rank-table td:nth-child(1) { width: 44px; }
.rank-table th:nth-child(2), .rank-table td:nth-child(2) { width: 34%; text-align: left; }
.rank-table .rank-name .muted { margin-left: 4px; font-size: 12px; }
.rank-table tr.mine td { color: #8fd3ff; border-bottom: 2px solid rgba(255, 255, 255, 0.16); }
.rank-table tr.me td { background: rgba(143, 211, 255, 0.12); }
#overlay .space-card p.score-line { color: #ffe082; }
.overlay .muted { color: #9aa4ba; }
#mapList { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin: 10px 0 14px; }
.map-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px;
  background: linear-gradient(#323b58, #262d45);
  border: 2px solid #3d4868;
  border-radius: 12px;
  box-shadow: 0 3px 0 #161a29;
  font-weight: normal;
  font-size: 12px;
  line-height: 1.4;
}
.map-card b { display: flex; align-items: center; gap: 6px; font-size: 15px; color: #fff; }
.map-card { min-width: 0; }
.map-card canvas { width: 100%; max-width: 150px; height: auto; aspect-ratio: 5 / 3; border-radius: 6px; background: #0b1020; }
.map-card.current { border-color: #8fd3ff; }
.diff { font-weight: bold; }
.diff-0 { color: #81c784; }
.diff-1 { color: #ffd54f; }
.diff-2 { color: #ef5350; }
.diff-3, .diff-4 { color: #ce93d8; } 
.overlay ul { text-align: left; padding-left: 20px; line-height: 1.7; font-size: 14px; }
kbd {
  background: #39425a;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 12px;
}
#bottombar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 4px; 
  padding: 6px 10px;
  background: linear-gradient(#1f2433, #191d2b);
  border-top: 1px solid #343d5c;
  height: 104px; box-sizing: border-box; 
}
#towerBar { display: grid; grid-template-columns: repeat(5, 68px); gap: 3px; }
.tower-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 3px 2px;
  background: linear-gradient(#323b58, #262d45);
  border: 2px solid #3d4868;
  border-radius: 12px;
  box-shadow: 0 3px 0 #161a29;
  color: inherit;
  font: inherit;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  position: relative;
  transition: transform 0.08s, border-color 0.15s;
}
.tower-btn:hover:not(:disabled) { border-color: #7d8db8; transform: translateY(-2px); }
.tower-btn.active { border-color: #ffd54f; background: linear-gradient(#4a4426, #33301f); box-shadow: 0 0 0 2px rgba(255, 213, 79, 0.25), 0 3px 0 #161a29; }
.tower-btn:disabled { filter: grayscale(0.9); opacity: 0.5; cursor: not-allowed; }
.tower-btn .icon, .tower-icon {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.45), var(--c) 60%);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25);
  font-size: 17px;
}
.tower-btn .icon > i, .tower-icon > i { font-style: normal; display: block; }
.tower-btn .icon > i.glyph-svg, .tower-icon > i.glyph-svg { width: 0.96em; height: 0.96em; transform: translateY(-0.05em); }
.glyph-svg svg { display: block; width: 100%; height: 100%; }
.tower-btn .cost { color: #ffd54f; font-size: 12px; }
.tower-btn .icon { width: 34px; height: 34px; font-size: 25px; line-height: 1; } 
.tower-btn .name { font-size: 12px; }
#info {
  overflow: hidden; min-height: 0;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 5px 12px;
  font-size: 13px;
  line-height: 1.5;
  overflow: hidden;
}
#info h3 { display: flex; align-items: center; gap: 6px; margin: 0 0 2px; font-size: 15px; white-space: nowrap; }
#info .desc { font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#info .enemy-info .desc { -webkit-line-clamp: 2; line-height: 1.35; } 
#info .row button { padding: 6px 8px; font-size: 12px; white-space: nowrap; }
#info .tower-icon { width: 28px; height: 28px; font-size: 20px; line-height: 1; }
#info .muted { color: #9aa4ba; }
#info .row { display: flex; gap: 6px; margin-top: 6px; }
.info-grid { display: grid; grid-template-columns: minmax(0, max-content) minmax(200px, 1fr); gap: 16px; align-items: center; }
.info-grid > :first-child { align-self: start; } 
.info-grid.sel { grid-template-columns: auto minmax(0, 1fr); }
.chip { flex: none; padding: 1px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); font-size: 11px; font-weight: normal; color: #c5cde0; }
.stars { color: #ffd54f; letter-spacing: 1px; font-size: 14px; }
.info-grid.enemy-info { grid-template-columns: minmax(300px, 1fr) minmax(200px, 300px); }
.enemy-head { display: flex; align-items: center; gap: 10px; }
.enemy-head > div { flex: 1; min-width: 0; }
.enemy-portrait {
  width: 72px; height: 72px; flex: none; border-radius: 14px;
  background: radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--c) 35%, #2f3a58), #141826 75%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 4px 10px rgba(0, 0, 0, 0.35);
}
.enemy-hp { display: flex; align-items: center; gap: 8px; margin: 4px 0 2px; font-size: 12px; color: #e8ecf4; font-variant-numeric: tabular-nums; }
.enemy-hp .bar { flex: 1; height: 10px; }
.enemy-hp .bar b { opacity: 1; }
.slow-chip { background: rgba(79, 195, 247, 0.25); color: #b3e5fc; }
.stats.enemy-stats { grid-template-columns: minmax(64px, max-content) 1fr; column-gap: 10px; }
.enemy-stats .stat-row em { text-align: left; } 
.target-pick { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: normal; cursor: pointer; }
.target-pick select { background: #2b3348; color: #fff; border: 1px solid #4a5678; border-radius: 6px; padding: 1px 4px; font: inherit; font-size: 12px; cursor: pointer; }
.stats { display: grid; grid-template-columns: minmax(26px, max-content) minmax(24px, 1fr) max-content; gap: 5px; }
.stat-row { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: center; font-size: 11px; color: #9aa4ba; }
.stat-row > span { white-space: nowrap; }
.stat-row em { font-style: normal; text-align: right; white-space: nowrap; min-width: 34px; color: #e8ecf4; font-variant-numeric: tabular-nums; }
.bar { position: relative; height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.bar b { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 999px; background: linear-gradient(90deg, #66bb6a, #c5e1a5); transition: width 0.25s; }
.bar b.next { background: #ffd54f; opacity: 0; transition: opacity 0.15s; }
#info.preview .bar b.next { opacity: 0.55; }
.bar b.buff { background: linear-gradient(90deg, #ffa000, #ffe082); } 
.stat-row em b.buffed { color: #ffd54f; font-weight: bold; }
#controls { display: flex; flex-direction: column; gap: 4px; width: 138px; }
#controls #waveBtn { flex: 1; } 
#controls button { padding: 5px 8px; font-size: 13px; }
#controls .row { display: flex; gap: 6px; }
#controls .row button { flex: 1; }
button {
  background: linear-gradient(#4b5a84, #3b476a);
  color: #fff;
  border: none;
  border-radius: 10px;
  box-shadow: 0 3px 0 #232a40;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.06s, filter 0.15s;
}
button:hover:not(:disabled) { filter: brightness(1.15); }
button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #232a40; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
#waveBtn { background: linear-gradient(#43a047, #2e7d32); box-shadow: 0 3px 0 #1b4d1f; flex: 1; font-size: 15px; }
#waveBtn.ready { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 3px 0 #1b4d1f, 0 0 0 0 rgba(102, 187, 106, 0.6); }
  50% { box-shadow: 0 3px 0 #1b4d1f, 0 0 0 6px rgba(102, 187, 106, 0); }
}
@media (prefers-reduced-motion: reduce) { #waveBtn.ready { animation: none; } }
#info .row .act-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 5px 6px 5px 11px; border-radius: 11px; font-size: 13px; letter-spacing: 0.5px;
  border: 1px solid transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -2px 0 rgba(0, 0, 0, 0.18), 0 2px 0 rgba(0, 0, 0, 0.35), 0 6px 14px rgba(0, 0, 0, 0.25);
  transition: transform 0.08s, filter 0.15s, background 0.15s;
}
#info .row .act-btn:active:not(:disabled) { transform: translateY(1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 rgba(0, 0, 0, 0.35); }
.act-ico { font-size: 12px; opacity: 0.85; }
.act-price { padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, 0.28); font-size: 12px; font-variant-numeric: tabular-nums; }
.act-up {
  flex: 1;
  background: linear-gradient(180deg, #ffe58a 0%, #ffcb2e 48%, #f5a623 100%);
  border-color: #ffeaa6 !important;
  color: #4a3000; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}
.act-up .act-price { background: rgba(255, 250, 230, 0.78); color: #5a3a06; box-shadow: inset 0 0 0 1px rgba(120, 80, 0, 0.22), 0 1px 0 rgba(255, 255, 255, 0.5); font-weight: bold; } 
.act-up:disabled { background: linear-gradient(180deg, #5b6277, #474d61); border-color: rgba(255, 255, 255, 0.12) !important; color: #c5cde0; text-shadow: none; opacity: 0.75; }
.act-up:disabled .act-price { background: rgba(255, 255, 255, 0.14); color: #ffcdd2; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12); font-weight: bold; } 
.act-up.maxed:disabled { background: rgba(255, 213, 79, 0.08); border-color: rgba(255, 213, 79, 0.55) !important; color: #ffd54f; opacity: 1; box-shadow: none; cursor: default; }
.act-sell {
  background: linear-gradient(180deg, #3b3f55, #2b2f42);
  border-color: rgba(255, 138, 128, 0.35) !important;
  color: #ffb4a8;
}
.act-sell .act-price { background: rgba(255, 138, 128, 0.14); color: #ffd7d0; }
#info .row .act-sell:hover { background: linear-gradient(180deg, #5d3038, #4a262c); filter: none; }
.up-tip {
  position: absolute;
  z-index: 10;
  padding: 8px 12px;
  background: rgba(20, 24, 38, 0.96);
  border: 1px solid #4a5678;
  border-radius: 10px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  font-size: 13px;
  pointer-events: none;
  display: none;
}
.up-tip.show { display: block; }
.up-tip b { display: block; margin-bottom: 4px; color: #ffd54f; }
.up-tip table { border-collapse: collapse; }
.up-tip td { padding: 1px 4px; color: #c5cde0; white-space: nowrap; }
.up-tip td:first-child { color: #9aa4ba; padding-left: 0; }
.up-tip td.up { color: #a5d6a7; font-weight: bold; }
#toast {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translate(-50%, -8px);
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(198, 40, 40, 0.92);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  font-size: 14px;
  font-weight: bold;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#ovBtn, .ov-btn { background: linear-gradient(#fbc02d, #f9a825); color: #3b2a00; box-shadow: 0 4px 0 #a06b00; font-size: 18px; padding: 10px 30px; }
.overlay .panel.space-card {
  position: relative;
  min-width: 320px;
  margin-top: 40px;
  padding: 60px 36px 24px;
  border: 2px solid #4d5058;
  border-radius: 22px;
  background:
    radial-gradient(circle at 14% 24%, rgba(0, 0, 0, 0.16) 0 7px, transparent 8px),
    radial-gradient(circle at 86% 70%, rgba(0, 0, 0, 0.14) 0 11px, transparent 12px),
    radial-gradient(circle at 72% 18%, rgba(255, 255, 255, 0.05) 0 5px, transparent 6px),
    radial-gradient(circle at 24% 82%, rgba(255, 255, 255, 0.04) 0 9px, transparent 10px),
    linear-gradient(170deg, #3b3e45, #26282d);
  box-shadow: 0 6px 0 #16171a, 0 14px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.overlay .space-card h1 { margin: 2px 0 6px; font-size: 32px; letter-spacing: 2px; color: #efe4c6; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45); }
#overlay .space-card.lost h1 { color: #e3b5a2; }
.overlay .space-card p { margin: 8px 0 0; color: #c9c4bb; }
.space-kicker { font-size: 13px; letter-spacing: 3px; color: #a29d94; }
.space-kicker:empty { display: none; }
.space-planet {
  --p1: #b9b6ae; --p2: #8b8880; --p3: #4a4844;
  position: absolute; top: -48px; left: 50%; width: 92px; height: 92px; margin-left: -46px;
  animation: planet-float 5s ease-in-out infinite;
}
.space-planet > i {
  position: absolute; inset: 0; border-radius: 50%;
  background:
    radial-gradient(circle at 62% 36%, rgba(0, 0, 0, 0.22) 0 8px, rgba(255, 255, 255, 0.12) 9px, transparent 11px),
    radial-gradient(circle at 34% 64%, rgba(0, 0, 0, 0.2) 0 11px, rgba(255, 255, 255, 0.1) 12px, transparent 14px),
    radial-gradient(circle at 70% 72%, rgba(0, 0, 0, 0.18) 0 5px, transparent 7px),
    radial-gradient(circle at 30% 30%, rgba(0, 0, 0, 0.15) 0 4px, transparent 6px),
    radial-gradient(circle at 50% 88%, rgba(0, 0, 0, 0.15) 0 6px, transparent 8px),
    radial-gradient(circle at 35% 30%, var(--p1), var(--p2) 55%, var(--p3) 100%);
  box-shadow: inset -14px -14px 24px rgba(0, 0, 0, 0.5), 0 8px 16px rgba(0, 0, 0, 0.45);
}
.space-planet::before, .space-planet::after {
  content: ''; position: absolute; left: -30%; top: 38%; width: 160%; height: 26%; box-sizing: border-box;
  border-radius: 50%; border: 3px solid rgba(190, 184, 172, 0.5); transform: rotate(-14deg);
}
.space-planet::after { clip-path: inset(50% 0 0 0); }
@keyframes planet-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.space-planet.p-meadow { --p1: #8fd3ff; --p2: #3a8fd6; --p3: #18406e; --ring: rgba(150, 215, 255, 0.6); }
.space-planet.p-ice { --p1: #e2c8ff; --p2: #9a6fe0; --p3: #3f2a75; --ring: rgba(220, 195, 255, 0.65); }
.space-planet.p-lava { --p1: #ffb08a; --p2: #e0533a; --p3: #6e1c14; --ring: rgba(255, 170, 130, 0.6); }
.space-planet.p-desert { --p1: #ffd99a; --p2: #e89a3c; --p3: #7a4316; --ring: rgba(255, 210, 140, 0.65); }
.space-planet.p-swamp { --p1: #c6f28a; --p2: #5fae3a; --p3: #24501b; --ring: rgba(190, 240, 140, 0.6); }
.space-planet.p-gold { --p1: #fff1a8; --p2: #f2b72f; --p3: #8a5a0c; --ring: rgba(255, 225, 120, 0.75); }
.space-planet.p-meadow::before, .space-planet.p-meadow::after, .space-planet.p-ice::before, .space-planet.p-ice::after,
.space-planet.p-lava::before, .space-planet.p-lava::after, .space-planet.p-desert::before, .space-planet.p-desert::after,
.space-planet.p-swamp::before, .space-planet.p-swamp::after, .space-planet.p-gold::before, .space-planet.p-gold::after { border-color: var(--ring); }
.space-planet.p-lost { --p1: #8d8a85; --p2: #66635f; --p3: #33312f; animation: none; }
.space-planet.p-lost::before, .space-planet.p-lost::after { border-color: rgba(160, 155, 147, 0.25); }
.overlay .space-card #ovBtn, .overlay .space-card .ov-btn { margin-top: 18px; border-radius: 999px; padding: 11px 34px; }
#gallery { position: fixed; z-index: 60; }
.gallery-panel { max-width: 1000px !important; width: calc(100vw - 40px); text-align: left !important; }
.gallery-head { display: flex; align-items: center; justify-content: space-between; }
.gallery-head h1 { margin: 0 0 10px; }
.gallery-close { padding: 4px 12px; font-size: 18px; }
.gallery-body { display: grid; grid-template-columns: 150px 360px 1fr; gap: 14px; align-items: start; }
.gallery-list { display: grid; gap: 4px; }
.gallery-tabs { display: flex; gap: 4px; margin-bottom: 4px; }
.gallery-tabs button { flex: 1; padding: 4px 0; font-size: 12px; background: #262d45; color: #9aa4ba; border: 2px solid transparent; box-shadow: none; }
.gallery-tabs button.on { color: #ffd54f; border-color: #ffd54f; }
.gallery-live { margin-left: auto; padding: 0 6px; border-radius: 8px; background: #2e7d32; font-size: 11px; color: #fff; }
.gallery-gen { margin-left: 4px; padding: 1px 8px; border-radius: 8px; background: #3b4566; font-size: 12px; color: #c5cde0; }
.gallery-use { margin: 0 0 10px; padding: 8px 10px; border-radius: 10px; background: rgba(0, 0, 0, 0.25); font-size: 13px; display: grid; gap: 6px; }
.gallery-use div { display: flex; gap: 6px; }
.gallery-use button { padding: 4px 10px; font-size: 13px; border: 2px solid transparent; }
.gallery-use button.on { border-color: #ffd54f; }
.gallery-use b .muted { font-weight: normal; font-size: 11px; }
.gallery-assign { border-collapse: collapse; }
.gallery-assign th, .gallery-assign td { padding: 2px 2px; text-align: center; border-radius: 6px; }
.gallery-assign td:first-child { text-align: left; color: #c5cde0 !important; white-space: nowrap; padding-right: 6px; }
.gallery-assign th { cursor: pointer; }
.gallery-assign .cur { background: rgba(255, 213, 79, 0.15); }
.gallery-assign th.map-all-h { cursor: default; font-size: 11px; font-weight: normal; color: #9aa4ba; }
.gallery-assign .map-all { padding-left: 5px; border-left: 1px solid rgba(255, 255, 255, 0.1); border-radius: 0; }
.gallery-assign .map-all select { border-color: #ffd54f; }
.gallery-assign select { background: #2b3348; color: #fff; border: 1px solid #4a5678; border-radius: 6px; padding: 1px 0; font: inherit; font-size: 12px; }
.gallery-item { display: flex; align-items: center; gap: 8px; padding: 4px 8px; font-size: 13px; text-align: left; background: linear-gradient(#323b58, #262d45); border: 2px solid transparent; }
.gallery-item.on { border-color: #ffd54f; }
.gallery-view canvas { width: 360px; height: 260px; display: block; border-radius: 12px; background: radial-gradient(circle at 50% 40%, #2f3a58, #141826); }
.gallery-tip { margin-top: 2px; font-size: 12px; }
.gallery-view canvas { cursor: grab; touch-action: none; }
.gallery-slow { display: block; margin-top: 6px; font-size: 13px; color: #c5cde0; cursor: pointer; }
.gallery-info h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-size: 20px; }
.gallery-info p { margin: 0 0 8px; font-size: 13px; }
.gallery-info table { border-collapse: collapse; font-size: 13px; }
.gallery-info td { padding: 2px 8px 2px 0; vertical-align: top; }
.gallery-info td:first-child { color: #9aa4ba; white-space: nowrap; }
.gallery-stats { margin: 8px 0; padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); font-size: 13px; }
.gallery-stats > b { display: block; margin-bottom: 4px; }
.stat-edit { display: grid; grid-template-columns: 64px 76px 1fr; gap: 8px; align-items: center; padding: 2px 4px; border-radius: 6px; }
.stat-edit.changed { background: rgba(255, 183, 77, 0.14); }
.stat-edit span { color: #9aa4ba; }
.stat-edit input { width: 100%; padding: 2px 6px; border-radius: 6px; border: 1px solid #4a5678; background: #1b2133; color: #fff; font: inherit; }
.stat-edit em { font-style: normal; font-size: 11px; color: #8d97ad; }
.gallery-stats button { margin-top: 6px; padding: 3px 10px; font-size: 12px; font-weight: normal; }
.gallery-calc { margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(0, 0, 0, 0.25); font-size: 13px; display: grid; gap: 6px; }
.gallery-calc select { background: #2b3348; color: #fff; border: 1px solid #4a5678; border-radius: 6px; padding: 2px 4px; font: inherit; }
.gallery-calc .big { font-size: 16px; color: #ffd54f; }
.gallery-levels { display: flex; gap: 6px; justify-content: center; margin-top: 6px; }
.gallery-levels button { padding: 3px 12px; font-size: 13px; background: linear-gradient(#323b58, #262d45); border: 2px solid transparent; }
.gallery-levels button.on { border-color: #ffd54f; }
.gallery-info .tower-levels th { padding: 2px 8px; font-weight: normal; color: #9aa4ba; border-radius: 6px; }
.gallery-info .tower-levels td + td { text-align: right; padding: 2px 8px; border-radius: 6px; }
.gallery-info .tower-levels .cur { background: rgba(255, 213, 79, 0.15); color: #fff; }
.wave-panel { max-width: 1000px !important; }
.wave-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.wave-tabs button { padding: 4px 10px; font-size: 13px; background: linear-gradient(#323b58, #262d45); border: 2px solid transparent; }
.wave-tabs button.on { border-color: #ffd54f; }
.wave-custom { color: #ffb74d; font-size: 10px; vertical-align: middle; }
.wave-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.wave-actions button { padding: 5px 10px; font-size: 12px; }
.wave-money { margin-left: auto; margin-right: 14px; font-size: 13px; padding: 2px 6px; border-radius: 6px; }
.wave-money.set { background: rgba(255, 183, 77, 0.18); }
.wave-money input { width: 64px; margin-left: 4px; padding: 2px 4px; border-radius: 5px; border: 1px solid #3c4662; background: #1b2133; color: #fff; font: inherit; }
.wave-panel { position: relative; }
.wave-confirm { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; background: rgba(8, 10, 18, 0.6); border-radius: inherit; }
.wave-confirm-box { max-width: 380px; padding: 18px 20px 14px; border-radius: 14px; background: #262d45; border: 1px solid #4a5678; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
.wave-confirm-box p { margin: 0 0 14px; font-size: 14px; line-height: 1.6; }
.wave-confirm-btns { display: flex; justify-content: flex-end; gap: 8px; }
.wave-confirm-btns button { padding: 5px 14px; font-size: 13px; }
.wave-confirm-btns .danger { background: linear-gradient(#e57373, #c62828); color: #fff; }
.wave-preview-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 13px; }
.wave-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.wave-table th, .wave-table td { padding: 3px 5px; text-align: right; white-space: nowrap; }
.wave-table th { font-weight: normal; color: #9aa4ba; }
.wave-table th .dot { width: 9px; height: 9px; margin-right: 3px; vertical-align: -1px; }
.wave-table td:first-child, .wave-table th:first-child { text-align: center; }
.wave-table tr.final td { background: rgba(255, 82, 82, 0.12); }
.wave-table td.hp { width: 30%; text-align: left; }
.wave-table th.hp-h { text-align: left; padding-left: 8px; }
.wave-table input.hp-input { width: 84px; }
.wave-table td.hp.over input { color: #ef9a9a; border-color: #ef5350; }
.wave-table.editable td { padding: 2px 3px; }
.wave-table input { width: 54px; padding: 2px 4px; border-radius: 5px; border: 1px solid #3c4662; background: #1b2133; color: #fff; font: inherit; text-align: right; }
.wave-table input::placeholder { color: #6f7a94; }
.wave-table td.set { background: rgba(255, 183, 77, 0.18); }
.wave-table td.set input { border-color: #ffb74d; color: #ffcc80; font-weight: bold; }
.wave-table td.hp .bar { display: inline-block; width: 60%; height: 7px; margin-right: 6px; vertical-align: middle; }
.coin {
  display: inline-block; width: 1.1em; height: 1.1em; margin-right: 0.25em; vertical-align: -0.19em; flex: none;
  background: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><circle cx='10' cy='10' r='8.8' fill='%23eb9b16' stroke='%236b4300' stroke-width='1.3'/><circle cx='9.3' cy='9.2' r='7.2' fill='%23ffc93c'/><path d='M9.4 5.2l1.3 2.65 2.9.42-2.1 2.05.5 2.9-2.6-1.37-2.6 1.37.5-2.9-2.1-2.05 2.9-.42z' fill='%23fff4c7' stroke='%23e09412' stroke-width='0.7' stroke-linejoin='round'/><ellipse cx='5.9' cy='5.6' rx='1.6' ry='0.95' transform='rotate(-35 5.9 5.6)' fill='white' opacity='0.9'/></svg>") no-repeat center / contain;
}
.dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.3); }
#devPanel {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 50;
  width: min(560px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  background: rgba(10, 13, 20, 0.96);
  border: 1px solid #3a4560;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-family: Consolas, "Cascadia Mono", "Microsoft JhengHei", monospace;
  font-size: 12px;
  user-select: text;
}
#devPanel[hidden] { display: none; }
#devPanel header { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid #222838; }
#devPanel header b, #devPanel .dev-status, #devPanel .target-pick { white-space: nowrap; }
#devPanel header b { color: #ffd54f; }
#devPanel .dev-status { margin-right: auto; color: #8892aa; }
#devPanel button { padding: 3px 8px; white-space: nowrap; font-size: 12px; font-weight: normal; border-radius: 6px; box-shadow: none; }
#devPanel button.on { background: #8e3b3b; }
#devPanel .dev-log { height: 220px; overflow-y: auto; padding: 6px 8px; white-space: pre-wrap; word-break: break-all; line-height: 1.45; }
#devPanel .dev-cmd { color: #e8ecf4; }
#devPanel .dev-out { color: #9aa4ba; }
#devPanel .dev-err { color: #ef5350; }
#devPanel .dev-sys { color: #ffd54f; }
#devPanel form { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-top: 1px solid #222838; }
#devPanel form span { color: #66bb6a; font-weight: bold; }
#devPanel form input { flex: 1; background: transparent; border: none; outline: none; color: #e8ecf4; font: inherit; font-size: 13px; }
@media (max-width: 640px) {
  #bottombar { grid-template-columns: 1fr; height: auto; } 
  #towerBar { grid-template-columns: repeat(5, 1fr); }
  #controls { width: auto; flex-direction: row; }
}
